diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-23 22:50:56 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-23 22:50:56 +0400 |
commit | a42ba82f638e481d7fd3c3ed2ba05c331ef6717e (patch) | |
tree | 81a2b9221799707b49b74a5df8bb3ff964ba78bd /source | |
parent | 7afbdff1b6c348227e652e1c3071ab7ba7c91c44 (diff) | |
parent | a73dd3476e7d180d3320afc04d218ce22f2f3bfc (diff) |
Merged changes in the trunk up to revision 50829.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
Also addressed code inconsistency due to changes in the trunk revision 50628 (color
management with OCIO) and 50806 (UV project material). OCIO-related changes are marked
OCIO_TODO as in some other files modified in revision 50628.
Diffstat (limited to 'source')
728 files changed, 10524 insertions, 9223 deletions
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index cda2cf303eb..2845b2f95c9 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -734,16 +734,15 @@ AviError AVI_close(AviMovie *movie) fclose(movie->fp); - for (i = 0; movie->header && (i < movie->header->Streams); i++) { - if (movie->streams && (movie->streams[i].sf != NULL)) { + for (i = 0; i < movie->header->Streams; i++) { + if (movie->streams[i].sf != NULL) { MEM_freeN(movie->streams[i].sf); } } - if (movie->header != NULL) - MEM_freeN(movie->header); - if (movie->streams != NULL) - MEM_freeN(movie->streams); + MEM_freeN(movie->header); + MEM_freeN(movie->streams); + if (movie->entries != NULL) MEM_freeN(movie->entries); if (movie->offset_table != NULL) @@ -1082,15 +1081,15 @@ AviError AVI_close_compress(AviMovie *movie) fclose(movie->fp); - for (i = 0; movie->header && (i < movie->header->Streams); i++) { + for (i = 0; i < movie->header->Streams; i++) { if (movie->streams && (movie->streams[i].sf != NULL)) { MEM_freeN(movie->streams[i].sf); } } - if (movie->header != NULL) - MEM_freeN(movie->header); - if (movie->entries != NULL) - MEM_freeN(movie->entries); + + MEM_freeN(movie->header); + MEM_freeN(movie->entries); + if (movie->streams != NULL) MEM_freeN(movie->streams); if (movie->offset_table != NULL) diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 0732e02b5fc..ce10951d6ff 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -33,6 +33,7 @@ #define __BLF_API_H__ struct rctf; +struct ColorManagedDisplay; int BLF_init(int points, int dpi); void BLF_exit(void); @@ -151,7 +152,7 @@ void BLF_shadow_offset(int fontid, int x, int y); * * BLF_buffer(NULL, NULL, 0, 0, 0, FALSE); */ -void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management); +void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display); /* Set the color to be used for text. */ void BLF_buffer_col(int fontid, float r, float g, float b, float a); diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index ebf9ff4db39..da60710a137 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -27,6 +27,7 @@ set(INC ../blenlib ../editors/include ../makesdna + ../imbuf ../../../intern/guardedalloc ) diff --git a/source/blender/blenfont/SConscript b/source/blender/blenfont/SConscript index c46960d2311..d3c7b1c2fcc 100644 --- a/source/blender/blenfont/SConscript +++ b/source/blender/blenfont/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('intern/*.c') -incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../editors/include' +incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../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.c b/source/blender/blenfont/intern/blf.c index d4739b37f93..92fcb576e7d 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -50,7 +50,6 @@ #include "blf_internal_types.h" #include "blf_internal.h" - /* Max number of font in memory. * Take care that now every font have a glyph cache per size/dpi, * so we don't need load the same font with different size, just @@ -746,7 +745,7 @@ void BLF_shadow_offset(int fontid, int x, int y) } } -void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management) +void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display) { FontBLF *font = BLF_get(fontid); @@ -756,7 +755,7 @@ void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int font->buf_info.w = w; font->buf_info.h = h; font->buf_info.ch = nch; - font->buf_info.do_color_management = do_color_management; + font->buf_info.display = display; } } diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index ab43804db8e..1900efa2dbc 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -53,6 +53,8 @@ #include "BIF_gl.h" #include "BLF_api.h" +#include "IMB_colormanagement.h" + #include "blf_internal_types.h" #include "blf_internal.h" @@ -159,7 +161,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font) } \ } (void)0 -void blf_font_draw(FontBLF *font, const char *str, unsigned int len) +void blf_font_draw(FontBLF *font, const char *str, size_t len) { unsigned int c; GlyphBLF *g, *g_prev = NULL; @@ -172,7 +174,7 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len) blf_font_ensure_ascii_table(font); - while (str[i] && i < len) { + while ((i < len) && str[i]) { BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); if (c == BLI_UTF8_ERR) @@ -191,7 +193,7 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len) } /* faster version of blf_font_draw, ascii only for view dimensions */ -void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len) +void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len) { unsigned char c; GlyphBLF *g, *g_prev = NULL; @@ -245,11 +247,12 @@ void blf_font_buffer(FontBLF *font, const char *str) blf_font_ensure_ascii_table(font); /* another buffer specific call for color conversion */ - if (buf_info->do_color_management) { - srgb_to_linearrgb_v4(b_col_float, buf_info->col); + if (buf_info->display) { + copy_v4_v4(b_col_float, buf_info->col); + IMB_colormanagement_display_to_scene_linear_v3(b_col_float, buf_info->display); } else { - copy_v4_v4(b_col_float, buf_info->col); + srgb_to_linearrgb_v4(b_col_float, buf_info->col); } while (str[i]) { @@ -427,8 +430,8 @@ void blf_font_width_and_height(FontBLF *font, const char *str, float *width, flo } blf_font_boundbox(font, str, &box); - *width = (BLI_RCT_SIZE_X(&box) * xa); - *height = (BLI_RCT_SIZE_Y(&box) * ya); + *width = (BLI_rctf_size_x(&box) * xa); + *height = (BLI_rctf_size_y(&box) * ya); } float blf_font_width(FontBLF *font, const char *str) @@ -442,7 +445,7 @@ float blf_font_width(FontBLF *font, const char *str) xa = 1.0f; blf_font_boundbox(font, str, &box); - return BLI_RCT_SIZE_X(&box) * xa; + return BLI_rctf_size_x(&box) * xa; } float blf_font_height(FontBLF *font, const char *str) @@ -456,7 +459,7 @@ float blf_font_height(FontBLF *font, const char *str) ya = 1.0f; blf_font_boundbox(font, str, &box); - return BLI_RCT_SIZE_Y(&box) * ya; + return BLI_rctf_size_y(&box) * ya; } float blf_font_fixed_width(FontBLF *font) diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 63225651e5b..91ecded88be 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -415,7 +415,7 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) g->uv[1][1] = ((float)(g->yoff + g->height)) / ((float)gc->p2_height); /* update the x offset for the next glyph. */ - gc->x_offs += (int)(BLI_RCT_SIZE_X(&g->box) + gc->pad); + gc->x_offs += (int)(BLI_rctf_size_x(&g->box) + gc->pad); gc->rem_glyphs--; g->build_tex = 1; diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index ba66fce8374..65a54783978 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -51,8 +51,8 @@ struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size); void blf_font_size(struct FontBLF *font, int size, int dpi); -void blf_font_draw(struct FontBLF *font, const char *str, unsigned int len); -void blf_font_draw_ascii(struct FontBLF *font, const char *str, unsigned int len); +void blf_font_draw(struct FontBLF *font, const char *str, size_t len); +void blf_font_draw_ascii(struct FontBLF *font, const char *str, size_t len); void blf_font_buffer(struct FontBLF *font, const char *str); void blf_font_boundbox(struct FontBLF *font, const char *str, struct rctf *box); void blf_font_width_and_height(struct FontBLF *font, const char *str, float *width, float *height); diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 4c617da7583..1acc3dad4cf 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -145,8 +145,8 @@ typedef struct FontBufInfoBLF { /* number of channels. */ int ch; - /* is the float buffer linear */ - int do_color_management; + /* display device used for color management */ + struct ColorManagedDisplay *display; /* and the color, the alphas is get from the glyph! * color is srgb space */ diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 2b7e225d709..d0b77222114 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -129,7 +129,7 @@ void BLF_lang_init(void) } /* get LANG/LANGUAGE environment variable */ -static void get_language_variable(const char *varname, char *var, int maxlen) +static void get_language_variable(const char *varname, char *var, const size_t maxlen) { char *env = getenv(varname); @@ -149,7 +149,7 @@ static void get_language_variable(const char *varname, char *var, int maxlen) /* get language to be used based on locale(which might be empty when using default language) and * LANG environment variable */ -static void get_language(const char *locale, const char *lang, char *language, int maxlen) +static void get_language(const char *locale, const char *lang, char *language, const size_t maxlen) { if (locale[0]) { BLI_strncpy(language, locale, maxlen); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 1e67027ae8c..db1139c9c7b 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 18 +#define BLENDER_SUBVERSION 21 /* 262 was the last editmesh release but its has compatibility code for bmesh data, * so set the minversion to 2.61 */ @@ -53,7 +53,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE beta +#define BLENDER_VERSION_CYCLE rc extern char versionstr[]; /* from blender.c */ diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 9ce2de79dbf..728f88b3c16 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -31,6 +31,9 @@ * \ingroup bke */ +struct ColorManagedColorspaceSettings; +struct ColorManagedDisplaySettings; +struct ColorManagedViewSettings; struct CurveMapping; struct CurveMap; struct CurveMapPoint; @@ -39,7 +42,7 @@ struct Histogram; struct ImBuf; struct rctf; -#if defined _WIN32 +#if defined _MSC_VER # define DO_INLINE __inline #elif defined(__sun) || defined(__sun__) # define DO_INLINE @@ -58,7 +61,7 @@ void curvemapping_set_black_white(struct CurveMapping *cumap, con #define CURVEMAP_SLOPE_NEGATIVE 0 #define CURVEMAP_SLOPE_POSITIVE 1 -void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, int preset, int slope); +void curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope); void curvemap_remove(struct CurveMap *cuma, const short flag); void curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp); struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y); @@ -89,9 +92,25 @@ void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBu void curvemapping_premultiply(struct CurveMapping *cumap, int restore); -void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const short use_color_management); -void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management); +void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, + const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); +void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); void scopes_free(struct Scopes *scopes); void scopes_new(struct Scopes *scopes); +void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings); +void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings, + const struct ColorManagedDisplaySettings *settings); + +void BKE_color_managed_view_settings_init(struct ColorManagedViewSettings *settings); +void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings, + const struct ColorManagedViewSettings *settings); +void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings); + +void BKE_color_managed_colorspace_settings_init(struct ColorManagedColorspaceSettings *colorspace_settings); +void BKE_color_managed_colorspace_settings_copy(struct ColorManagedColorspaceSettings *colorspace_settings, + const struct ColorManagedColorspaceSettings *settings); + #endif diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index a845ac10c9d..e6161cebf54 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -93,6 +93,8 @@ void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float /* ** Nurbs ** */ +int BKE_nurbList_index_get_co(struct ListBase *editnurb, const int index, float r_co[3]); + int BKE_nurbList_verts_count(struct ListBase *nurb); int BKE_nurbList_verts_count_without_handles(struct ListBase *nurb); diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 19dd67b88f8..33361b9921c 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -73,6 +73,8 @@ extern const CustomDataMask CD_MASK_FACECORNERS; #define CD_TYPE_AS_MASK(_type) (CustomDataMask)((CustomDataMask)1 << (CustomDataMask)(_type)) +void customData_mask_layers__print(CustomDataMask mask); + /** * Checks if the layer at physical offset \a layer_n (in data->layers) support math * the below operations. diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index 67cdee9fa07..3e9803a908b 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -52,10 +52,6 @@ int group_is_animated(struct Object *parent, struct Group *group); void group_tag_recalc(struct Group *group); void group_handle_recalc_and_update(struct Scene *scene, struct Object *parent, struct Group *group); -#if 0 /* UNUSED */ -struct Object *group_get_member_with_action(struct Group *group, struct bAction *act); -void group_relink_nla_objects(struct Object *ob); -#endif #endif diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 67461281674..ac324b2af00 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -46,6 +46,8 @@ struct Object; struct ImageFormatData; struct Main; +#define IMA_MAX_SPACE 64 + /* call from library */ void BKE_image_free(struct Image *me); @@ -64,6 +66,7 @@ int BKE_imtype_is_movie(const char imtype); int BKE_imtype_supports_zbuf(const char imtype); int BKE_imtype_supports_compress(const char imtype); int BKE_imtype_supports_quality(const char imtype); +int BKE_imtype_supports_float(const char imtype); char BKE_imtype_valid_channels(const char imtype); char BKE_imtype_valid_depths(const char imtype); @@ -72,7 +75,7 @@ char BKE_imtype_from_arg(const char *arg); void BKE_imformat_defaults(struct ImageFormatData *im_format); void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf); -struct anim *openanim(const char *name, int flags, int streamindex); +struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]); void BKE_image_de_interlace(struct Image *ima, int odd); diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 1ad451b0937..01baf8feb2a 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -47,13 +47,13 @@ struct Mesh; extern "C" { #endif -void BKE_key_free(struct Key *sc); -void free_key_nolib(struct Key *key); -struct Key *add_key(struct ID *id); +void BKE_key_free(struct Key *sc); +void BKE_key_free_nolib(struct Key *key); +struct Key *BKE_key_add(struct ID *id); struct Key *BKE_key_copy(struct Key *key); -struct Key *copy_key_nolib(struct Key *key); -void BKE_key_make_local(struct Key *key); -void sort_keys(struct Key *key); +struct Key *BKE_key_copy_nolib(struct Key *key); +void BKE_key_make_local(struct Key *key); +void BKE_key_sort(struct Key *key); void key_curve_position_weights(float t, float data[4], int type); void key_curve_tangent_weights(float t, float data[4], int type); @@ -61,27 +61,29 @@ void key_curve_normal_weights(float t, float data[4], int type); float *do_ob_key(struct Scene *scene, struct Object *ob); -struct Key *ob_get_key(struct Object *ob); -struct KeyBlock *add_keyblock(struct Key *key, const char *name); -struct KeyBlock *add_keyblock_ctime(struct Key *key, const char *name, const short do_force); -struct KeyBlock *ob_get_keyblock(struct Object *ob); -struct KeyBlock *ob_get_reference_keyblock(struct Object *ob); -struct KeyBlock *key_get_keyblock(struct Key *key, int index); -struct KeyBlock *key_get_named_keyblock(struct Key *key, const char name[]); -char *key_get_curValue_rnaPath(struct Key *key, struct KeyBlock *kb); +struct Key *BKE_key_from_object(struct Object *ob); +struct KeyBlock *BKE_keyblock_from_object(struct Object *ob); +struct KeyBlock *BKE_keyblock_from_object_reference(struct Object *ob); + +struct KeyBlock *BKE_keyblock_add(struct Key *key, const char *name); +struct KeyBlock *BKE_keyblock_add_ctime(struct Key *key, const char *name, const short do_force); +struct KeyBlock *BKE_keyblock_from_key(struct Key *key, int index); +struct KeyBlock *BKE_keyblock_find_name(struct Key *key, const char name[]); +void BKE_keyblock_copy_settings(struct KeyBlock *kb_dst, const struct KeyBlock *kb_src); +char *BKE_keyblock_curval_rnapath_get(struct Key *key, struct KeyBlock *kb); // needed for the GE -void do_rel_key(const int start, int end, const int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb, const int mode); +void BKE_key_evaluate_relative(const int start, int end, const int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb, const int mode); /* conversion functions */ -void key_to_mesh(struct KeyBlock *kb, struct Mesh *me); -void mesh_to_key(struct Mesh *me, struct KeyBlock *kb); -void key_to_latt(struct KeyBlock *kb, struct Lattice *lt); -void latt_to_key(struct Lattice *lt, struct KeyBlock *kb); -void key_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb); -void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb); -float (*key_to_vertcos(struct Object *ob, struct KeyBlock *kb))[3]; -void vertcos_to_key(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]); -void offset_to_key(struct Object *ob, struct KeyBlock *kb, float (*ofs)[3]); +void BKE_key_convert_to_mesh(struct KeyBlock *kb, struct Mesh *me); +void BKE_key_convert_from_mesh(struct Mesh *me, struct KeyBlock *kb); +void BKE_key_convert_to_lattice(struct KeyBlock *kb, struct Lattice *lt); +void BKE_key_convert_from_lattice(struct Lattice *lt, struct KeyBlock *kb); +void BKE_key_convert_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb); +void BKE_key_convert_from_curve(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb); +float (*BKE_key_convert_to_vertcos(struct Object *ob, struct KeyBlock *kb))[3]; +void BKE_key_convert_from_vertcos(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]); +void BKE_key_convert_from_offset(struct Object *ob, struct KeyBlock *kb, float (*ofs)[3]); /* key.c */ extern int slurph_opt; diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 51e301fec80..cc15ceecbac 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -131,6 +131,7 @@ void BKE_mask_get_handle_point_adjacent(struct MaskSpline *spline, struct MaskSp void BKE_mask_layer_calc_handles(struct MaskLayer *masklay); void BKE_mask_layer_calc_handles_deform(struct MaskLayer *masklay); void BKE_mask_calc_handles(struct Mask *mask); +void BKE_mask_update_deform(struct Mask *mask); void BKE_mask_spline_ensure_deform(struct MaskSpline *spline); /* animation */ @@ -163,10 +164,10 @@ void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, i int BKE_mask_get_duration(struct Mask *mask); -#define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT) +#define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f3) & SELECT) #define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT) -#define MASKPOINT_ISSEL_HANDLE_ONLY(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) ) -#define MASKPOINT_ISSEL_HANDLE(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) ) +#define MASKPOINT_ISSEL_HANDLE_ONLY(p) ( (((p)->bezt.f1 | (p)->bezt.f3) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) ) +#define MASKPOINT_ISSEL_HANDLE(p) ( (((p)->bezt.f1 | (p)->bezt.f3) & SELECT) ) #define MASKPOINT_SEL_ALL(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f2 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0 #define MASKPOINT_DESEL_ALL(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f2 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0 diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 438d5110666..6ad2ad924e2 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -64,6 +64,8 @@ struct Tex; struct SpaceNode; struct ARegion; struct Object; +struct ColorManagedViewSettings; +struct ColorManagedDisplaySettings; /* ************** NODE TYPE DEFINITIONS ***** */ @@ -725,7 +727,8 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria struct CompBuf; struct bNodeTreeExec *ntreeCompositBeginExecTree(struct bNodeTree *ntree, int use_tree_data); void ntreeCompositEndExecTree(struct bNodeTreeExec *exec, int use_tree_data); -void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews); +void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews, + const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings); void ntreeCompositTagRender(struct Scene *sce); int ntreeCompositTagAnimated(struct bNodeTree *ntree); void ntreeCompositTagGenerators(struct bNodeTree *ntree); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 31642dad60d..269d96d5c38 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -93,6 +93,7 @@ void BKE_object_to_mat3(struct Object *ob, float mat[][3]); void BKE_object_to_mat4(struct Object *ob, float mat[][4]); void BKE_object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent); +int BKE_object_pose_context_check(struct Object *ob); struct Object *BKE_object_pose_armature_get(struct Object *ob); void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob); diff --git a/source/blender/blenkernel/BKE_property.h b/source/blender/blenkernel/BKE_property.h index a29dc0e7be4..e0eb8c04b60 100644 --- a/source/blender/blenkernel/BKE_property.h +++ b/source/blender/blenkernel/BKE_property.h @@ -35,19 +35,18 @@ struct bProperty; struct ListBase; struct Object; -void free_property(struct bProperty *prop); -void free_properties(struct ListBase *lb); -struct bProperty *copy_property(struct bProperty *prop); -void copy_properties(struct ListBase *lbn, struct ListBase *lbo); -void init_property(struct bProperty *prop); -struct bProperty *new_property(int type); -void unique_property(struct bProperty *first, struct bProperty *prop, int force); -struct bProperty *get_ob_property(struct Object *ob, const char *name); -void set_ob_property(struct Object *ob, struct bProperty *propc); -int compare_property(struct bProperty *prop, const char *str); -void set_property(struct bProperty *prop, const char *str); -void add_property(struct bProperty *prop, const char *str); -void set_property_valstr(struct bProperty *prop, char *str); -void cp_property(struct bProperty *prop1, struct bProperty *prop2); +void BKE_bproperty_free(struct bProperty *prop); +void BKE_bproperty_free_list(struct ListBase *lb); +struct bProperty *BKE_bproperty_copy(struct bProperty *prop); +void BKE_bproperty_copy_list(struct ListBase *lbn, struct ListBase *lbo); +void BKE_bproperty_init(struct bProperty *prop); +struct bProperty *BKE_bproperty_new(int type); +void BKE_bproperty_unique(struct bProperty *first, struct bProperty *prop, int force); +struct bProperty *BKE_bproperty_object_get(struct Object *ob, const char *name); +void BKE_bproperty_object_set(struct Object *ob, struct bProperty *propc); +// int BKE_bproperty_cmp(struct bProperty *prop, const char *str); +void BKE_bproperty_set(struct bProperty *prop, const char *str); +void BKE_bproperty_add(struct bProperty *prop, const char *str); +void BKE_bproperty_set_valstr(struct bProperty *prop, char *str); #endif diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h index 22b44511195..d598a26fdf9 100644 --- a/source/blender/blenkernel/BKE_sca.h +++ b/source/blender/blenkernel/BKE_sca.h @@ -74,5 +74,7 @@ void sca_move_sensor(struct bSensor *sens_to_move, struct Object *ob, int move_u void sca_move_controller(struct bController *cont_to_move, struct Object *ob, int move_up); void sca_move_actuator(struct bActuator *act_to_move, struct Object *ob, int move_up); +const char *sca_state_name_get(Object *ob, short bit); + #endif diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index bce4243190a..023b7e85c40 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -108,6 +108,8 @@ float get_render_aosss_error(struct RenderData *r, float error); int BKE_scene_use_new_shading_nodes(struct Scene *scene); +void BKE_scene_disable_color_management(struct Scene *scene); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 51a64c97ca6..0c571f62f0e 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -177,6 +177,16 @@ struct ImBuf *BKE_sequencer_give_ibuf_seqbase(SeqRenderData context, float cfra, void BKE_sequencer_give_ibuf_prefetch_request(SeqRenderData context, float cfra, int chan_shown); /* ********************************************************************** + * sequencer.c + * + * sequencer color space functions + * ********************************************************************** */ + +void BKE_sequencer_imbuf_to_sequencer_space(struct Scene *scene, struct ImBuf *ibuf, int make_float); +void BKE_sequencer_imbuf_from_sequencer_space(struct Scene *scene, struct ImBuf *ibuf); +void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4]); + +/* ********************************************************************** * sequencer scene functions * ********************************************************************** */ struct Editing *BKE_sequencer_editing_get(struct Scene *scene, int alloc); @@ -350,7 +360,7 @@ struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seq struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); /* view3d draw callback, run when not in background view */ -typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, int, char[256]); +typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, int, int, char[256]); extern SequencerDrawView sequencer_view3d_cb; /* copy/paste */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index c89d0ecb142..9a24a3ca4e0 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -45,6 +45,7 @@ set(INC ../../../intern/mikktspace ../../../intern/opennl/extern ../../../intern/raskter + ../../../intern/smoke/extern # XXX - BAD LEVEL CALL WM_api.h ../windowmanager @@ -344,9 +345,6 @@ if(WITH_MOD_FLUID) endif() if(WITH_MOD_SMOKE) - list(APPEND INC - ../../../intern/smoke/extern - ) add_definitions(-DWITH_SMOKE) endif() diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 58827e326a3..8a656c735f6 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -3,6 +3,10 @@ Import ('env') import os sources = env.Glob('intern/*.c') +sources.remove('intern' + os.sep + 'mask_rasterize.c') +sources.remove('intern' + os.sep + 'mask.c') + +sources_mask = env.Glob('intern/mask*.c') incs = '. #/intern/guardedalloc #/intern/memutil' incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager' @@ -118,7 +122,10 @@ if env['WITH_BF_INTERNATIONAL']: if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25]) #, cc_compileflags = env['CCFLAGS'].append('/WX') ) else: env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [166,25,0] ) + +env.BlenderLib ( libname = 'bf_blenkernel_mask', sources = sources_mask, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [200,25,0] ) diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 387d4775ad4..82ac0736b07 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1397,7 +1397,7 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss) return eCCGError_None; } -#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset) +#define VERT_getNo(e, lvl) _vert_getNo(v, lvl, vertDataSize, normalDataOffset) #define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset) #define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset) #define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize) @@ -1491,7 +1491,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, /* XXX can I reduce the number of normalisations here? */ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { CCGVert *v = (CCGVert *) effectedV[ptrIdx]; - float length, *no = _vert_getNo(v, lvl, vertDataSize, normalDataOffset); + float length, *no = VERT_getNo(v, lvl); NormZero(no); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 8c0aea5723f..5e13fe78a43 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -384,7 +384,7 @@ void DM_ensure_tessface(DerivedMesh *dm) } } - else if (dm->dirty && DM_DIRTY_TESS_CDLAYERS) { + else if (dm->dirty & DM_DIRTY_TESS_CDLAYERS) { BLI_assert(CustomData_has_layer(&dm->faceData, CD_POLYINDEX)); DM_update_tessface_data(dm); } @@ -808,7 +808,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, if (mti->isDisabled && mti->isDisabled(md, 0)) return NULL; if (build_shapekey_layers && me->key && (kb = BLI_findlink(&me->key->block, ob->shapenr - 1))) { - key_to_mesh(kb, me); + BKE_key_convert_to_mesh(kb, me); } if (mti->type == eModifierTypeType_OnlyDeform) { @@ -878,7 +878,7 @@ static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free * by a more flexible customdata system, but not simple */ if (!em) { ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - KeyBlock *kb = key_get_keyblock(ob_get_key(ob), clmd->sim_parms->shapekey_rest); + KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ob), clmd->sim_parms->shapekey_rest); if (kb->data) return kb->data; @@ -1276,7 +1276,7 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape } if (!kb) { - kb = add_keyblock(me->key, layer->name); + kb = BKE_keyblock_add(me->key, layer->name); kb->uid = layer->uid; } diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 06bf5211abb..925658b84f4 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1214,475 +1214,3 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c } } -/* ********** NLA with non-poses works with ipo channels ********** */ - -#if 0 // XXX OLD ANIMATION SYSTEM (TO BE REMOVED) - -/* ************************ Blending with NLA *************** */ - -static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mode) -{ - float dstweight; - - switch (mode) { - case ACTSTRIPMODE_BLEND: - dstweight = 1.0F - srcweight; - break; - case ACTSTRIPMODE_ADD: - dstweight = 1.0F; - break; - default: - dstweight = 1.0F; - } - - interp_v3_v3v3(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight); -} - - -/* - * bone matching diagram, strips A and B - * - * .------------------------. - * | A | - * '------------------------' - * . . b2 - * . .-------------v----------. - * . | B . | - * . '------------------------' - * . . . - * . . . - * offset: . 0 . A-B . A-b2+B - * . . . - * - * */ - - -static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, float srcweight, short mode) -{ - /* matching offset bones */ - /* take dst offset, and put src on on that location */ - - if (strip->offs_bone[0] == 0) - return; - - /* are we also blending with matching bones? */ - if (strip->prev && strip->start >= strip->prev->start) { - bPoseChannel *dpchan = BKE_pose_channel_find_name(dst, strip->offs_bone); - if (dpchan) { - bPoseChannel *spchan = BKE_pose_channel_find_name(src, strip->offs_bone); - if (spchan) { - float vec[3]; - - /* dst->ctime has the internal strip->prev action time */ - /* map this time to nla time */ - - float ctime = get_actionstrip_frame(strip, src->ctime, 1); - - if (ctime > strip->prev->end) { - bActionChannel *achan; - - /* add src to dest, minus the position of src on strip->prev->end */ - - ctime = get_actionstrip_frame(strip, strip->prev->end, 0); - - achan = get_action_channel(strip->act, strip->offs_bone); - if (achan && achan->ipo) { - bPoseChannel pchan; - /* Evaluates and sets the internal ipo value */ - calc_ipo(achan->ipo, ctime); - /* This call also sets the pchan flags */ - execute_action_ipo(achan, &pchan); - - /* store offset that moves src to location of pchan */ - sub_v3_v3v3(vec, dpchan->loc, pchan.loc); - - mul_mat3_m4_v3(dpchan->bone->arm_mat, vec); - } - } - else { - /* store offset that moves src to location of dst */ - - sub_v3_v3v3(vec, dpchan->loc, spchan->loc); - mul_mat3_m4_v3(dpchan->bone->arm_mat, vec); - } - - /* if blending, we only add with factor scrweight */ - mul_v3_fl(vec, srcweight); - - add_v3_v3(dst->cyclic_offset, vec); - } - } - } - - add_v3_v3(dst->cyclic_offset, src->cyclic_offset); -} - -/* added "sizecorr" here, to allow armatures to be scaled and still have striding. - * Only works for uniform scaling. In general I'd advise against scaling armatures ever though! (ton) - */ -static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip, Path *path, float pathdist, float *stride_offset) -{ - bAction *act = strip->act; - const char *name = strip->stridechannel; - bActionChannel *achan = get_action_channel(act, name); - int stride_axis = strip->stride_axis; - - if (achan && achan->ipo) { - IpoCurve *icu = NULL; - float minx = 0.0f, maxx = 0.0f, miny = 0.0f, maxy = 0.0f; - int foundvert = 0; - - if (stride_axis == 0) stride_axis = AC_LOC_X; - else if (stride_axis == 1) stride_axis = AC_LOC_Y; - else stride_axis = AC_LOC_Z; - - /* calculate the min/max */ - for (icu = achan->ipo->curve.first; icu; icu = icu->next) { - if (icu->adrcode == stride_axis) { - if (icu->totvert > 1) { - foundvert = 1; - minx = icu->bezt[0].vec[1][0]; - maxx = icu->bezt[icu->totvert - 1].vec[1][0]; - - miny = icu->bezt[0].vec[1][1]; - maxy = icu->bezt[icu->totvert - 1].vec[1][1]; - } - break; - } - } - - if (foundvert && miny != maxy) { - float stridelen = sizecorr * fabs(maxy - miny), striptime; - float actiondist, pdist, pdistNewNormalized, offs; - float vec1[4], vec2[4], dir[3]; - - /* internal cycling, actoffs is in frames */ - offs = stridelen * strip->actoffs / (maxx - minx); - - /* amount path moves object */ - pdist = (float)fmod(pathdist + offs, stridelen); - striptime = pdist / stridelen; - - /* amount stride bone moves */ - actiondist = sizecorr * eval_icu(icu, minx + striptime * (maxx - minx)) - miny; - - pdist = fabs(actiondist) - pdist; - pdistNewNormalized = (pathdist + pdist) / path->totdist; - - /* now we need to go pdist further (or less) on cu path */ - where_on_path(ob, (pathdist) / path->totdist, vec1, dir); /* vec needs size 4 */ - if (pdistNewNormalized <= 1) { - /* search for correction in positive path-direction */ - where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ - sub_v3_v3v3(stride_offset, vec2, vec1); - } - else { - /* we reached the end of the path, search backwards instead */ - where_on_path(ob, (pathdist - pdist) / path->totdist, vec2, dir); /* vec needs size 4 */ - sub_v3_v3v3(stride_offset, vec1, vec2); - } - mul_mat3_m4_v3(ob->obmat, stride_offset); - return striptime; - } - } - return 0.0f; -} - -static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float time) -{ - /* only called when strip has cyclic, so >= 1.0f works... */ - if (time >= 1.0f) { - bActionChannel *achan = get_action_channel(strip->act, strip->offs_bone); - - if (achan && achan->ipo) { - IpoCurve *icu = NULL; - Bone *bone; - float min[3] = {0.0f, 0.0f, 0.0f}, max[3] = {0.0f, 0.0f, 0.0f}; - int index = 0, foundvert = 0; - - /* calculate the min/max */ - for (icu = achan->ipo->curve.first; icu; icu = icu->next) { - if (icu->totvert > 1) { - - if (icu->adrcode == AC_LOC_X) - index = 0; - else if (icu->adrcode == AC_LOC_Y) - index = 1; - else if (icu->adrcode == AC_LOC_Z) - index = 2; - else - continue; - - foundvert = 1; - min[index] = icu->bezt[0].vec[1][1]; - max[index] = icu->bezt[icu->totvert - 1].vec[1][1]; - } - } - if (foundvert) { - /* bring it into armature space */ - sub_v3_v3v3(min, max, min); - bone = BKE_armature_find_bone_name(ob->data, strip->offs_bone); /* weak */ - if (bone) { - mul_mat3_m4_v3(bone->arm_mat, min); - - /* dominant motion, cyclic_offset was cleared in BKE_pose_rest */ - if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) { - if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0] = time * min[0]; - if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1] = time * min[1]; - if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2] = time * min[2]; - } - else { - if (fabsf(min[0]) >= fabsf(min[1]) && fabsf(min[0]) >= fabsf(min[2])) - pose->cyclic_offset[0] = time * min[0]; - else if (fabsf(min[1]) >= fabsf(min[0]) && fabsf(min[1]) >= fabsf(min[2])) - pose->cyclic_offset[1] = time * min[1]; - else - pose->cyclic_offset[2] = time * min[2]; - } - } - } - } - } -} - -/* simple case for now; only the curve path with constraint value > 0.5 */ -/* blending we might do later... */ -static Object *get_parent_path(Object *ob) -{ - bConstraint *con; - - if (ob->parent && ob->parent->type == OB_CURVE) - return ob->parent; - - for (con = ob->constraints.first; con; con = con->next) { - if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) { - if (con->enforce > 0.5f) { - bFollowPathConstraint *data = con->data; - return data->tar; - } - } - } - return NULL; -} - -/* ************** do the action ************ */ - -/* ----- nla, etc. --------- */ - -static void do_nla(Scene *scene, Object *ob, int blocktype) -{ - bPose *tpose = NULL; - Key *key = NULL; - ListBase tchanbase = {NULL, NULL}, chanbase = {NULL, NULL}; - bActionStrip *strip, *striplast = NULL, *stripfirst = NULL; - float striptime, frametime, length, actlength; - float blendfac, stripframe; - float scene_cfra = BKE_scene_frame_get(scene); - int doit, dostride; - - if (blocktype == ID_AR) { - BKE_pose_copy_data(&tpose, ob->pose, 1); - BKE_pose_rest(ob->pose); // potentially destroying current not-keyed pose - } - else { - key = ob_get_key(ob); - } - - /* check on extend to left or right, when no strip is hit by 'cfra' */ - for (strip = ob->nlastrips.first; strip; strip = strip->next) { - /* escape loop on a hit */ - if (scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f) /* note 0.1 comes back below */ - break; - if (scene_cfra < strip->start) { - if (stripfirst == NULL) - stripfirst = strip; - else if (stripfirst->start > strip->start) - stripfirst = strip; - } - else if (scene_cfra > strip->end) { - if (striplast == NULL) - striplast = strip; - else if (striplast->end < strip->end) - striplast = strip; - } - } - if (strip == NULL) { /* extend */ - if (striplast) - scene_cfra = striplast->end; - else if (stripfirst) - scene_cfra = stripfirst->start; - } - - /* and now go over all strips */ - for (strip = ob->nlastrips.first; strip; strip = strip->next) { - doit = dostride = 0; - - if (strip->act && !(strip->flag & ACTSTRIP_MUTE)) { /* so theres an action */ - - /* Determine if the current frame is within the strip's range */ - length = strip->end - strip->start; - actlength = strip->actend - strip->actstart; - striptime = (scene_cfra - strip->start) / length; - stripframe = (scene_cfra - strip->start); - - if (striptime >= 0.0) { - - if (blocktype == ID_AR) - BKE_pose_rest(tpose); - - /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */ - if (striptime < 1.0f + 0.1f / length) { - - /* Handle path */ - if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype == ID_AR) && (ob->ipoflag & OB_DISABLE_PATH) == 0) { - Object *parent = get_parent_path(ob); - - if (parent) { - Curve *cu = parent->data; - float ctime, pdist; - - if (cu->flag & CU_PATH) { - /* Ensure we have a valid path */ - if (cu->path == NULL || cu->path->data == NULL) makeDispListCurveTypes(scene, parent, 0); - if (cu->path) { - - /* Find the position on the path */ - ctime = bsystem_time(scene, ob, scene_cfra, 0.0); - - if (calc_ipo_spec(cu->ipo, CU_SPEED, &ctime) == 0) { - /* correct for actions not starting on zero */ - ctime = (ctime - strip->actstart) / cu->pathlen; - CLAMP(ctime, 0.0, 1.0); - } - pdist = ctime * cu->path->totdist; - - if (tpose && strip->stridechannel[0]) { - striptime = stridechannel_frame(parent, ob->size[0], strip, cu->path, pdist, tpose->stride_offset); - } - else { - if (strip->stridelen) { - striptime = pdist / strip->stridelen; - striptime = (float)fmod(striptime + strip->actoffs, 1.0); - } - else - striptime = 0; - } - - frametime = (striptime * actlength) + strip->actstart; - frametime = bsystem_time(scene, ob, frametime, 0.0); - - if (blocktype == ID_AR) { - extract_pose_from_action(tpose, strip->act, frametime); - } - else if (blocktype == ID_OB) { - extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); - if (key) - extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); - } - doit = dostride = 1; - } - } - } - } - /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */ - else { - - /* Mod to repeat */ - if (strip->repeat != 1.0f) { - float cycle = striptime * strip->repeat; - - striptime = (float)fmod(cycle, 1.0f + 0.1f / length); - cycle -= striptime; - - if (blocktype == ID_AR) - cyclic_offs_bone(ob, tpose, strip, cycle); - } - - frametime = (striptime * actlength) + strip->actstart; - frametime = nla_time(scene, frametime, (float)strip->repeat); - - if (blocktype == ID_AR) { - extract_pose_from_action(tpose, strip->act, frametime); - } - else if (blocktype == ID_OB) { - extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); - if (key) - extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); - } - - doit = 1; - } - } - /* Handle extend */ - else { - if (strip->flag & ACTSTRIP_HOLDLASTFRAME) { - /* we want the strip to hold on the exact fraction of the repeat value */ - - frametime = actlength * (strip->repeat - (int)strip->repeat); - if (frametime <= 0.000001f) frametime = actlength; /* rounding errors... */ - frametime = bsystem_time(scene, ob, frametime + strip->actstart, 0.0); - - if (blocktype == ID_AR) - extract_pose_from_action(tpose, strip->act, frametime); - else if (blocktype == ID_OB) { - extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); - if (key) - extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); - } - - /* handle cycle hold */ - if (strip->repeat != 1.0f) { - if (blocktype == ID_AR) - cyclic_offs_bone(ob, tpose, strip, strip->repeat - 1.0f); - } - - doit = 1; - } - } - - /* Handle blendin & blendout */ - if (doit) { - /* Handle blendin */ - - if (strip->blendin > 0.0 && stripframe <= strip->blendin && scene_cfra >= strip->start) { - blendfac = stripframe / strip->blendin; - } - else if (strip->blendout > 0.0 && stripframe >= (length - strip->blendout) && scene_cfra <= strip->end) { - blendfac = (length - stripframe) / (strip->blendout); - } - else - blendfac = 1; - - if (blocktype == ID_AR) { /* Blend this pose with the accumulated pose */ - /* offset bone, for matching cycles */ - blend_pose_offset_bone(strip, ob->pose, tpose, blendfac, strip->mode); - - blend_poses(ob->pose, tpose, blendfac, strip->mode); - if (dostride) - blend_pose_strides(ob->pose, tpose, blendfac, strip->mode); - } - else { - blend_ipochannels(&chanbase, &tchanbase, blendfac, strip->mode); - BLI_freelistN(&tchanbase); - } - } - } - } - } - - if (blocktype == ID_OB) { - execute_ipochannels(&chanbase); - } - else if (blocktype == ID_AR) { - /* apply stride offset to object */ - add_v3_v3(ob->obmat[3], ob->pose->stride_offset); - } - - /* free */ - if (tpose) - BKE_pose_free(tpose); - if (chanbase.first) - BLI_freelistN(&chanbase); -} - -#endif // XXX OLD ANIMATION SYSTEM (TO BE REMOVED) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 09519f68415..99b788e80ce 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -89,8 +89,10 @@ #include "WM_api.h" // XXXXX BAD, very BAD dependency (bad level call) - remove asap, elubie +#include "IMB_colormanagement.h" + #ifdef WITH_PYTHON -#include "BPY_extern.h" +# include "BPY_extern.h" #endif Global G; @@ -217,8 +219,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath /* no load screens? */ if (mode) { /* comes from readfile.c */ - extern void lib_link_screen_restore(Main *, bScreen *, Scene *); - SWAP(ListBase, G.main->wm, bfd->main->wm); SWAP(ListBase, G.main->screen, bfd->main->screen); SWAP(ListBase, G.main->script, bfd->main->script); @@ -232,7 +232,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath if (curscreen) curscreen->scene = curscene; /* can run in bgmode */ /* clear_global will free G.main, here we can still restore pointers */ - lib_link_screen_restore(bfd->main, curscreen, curscene); + blo_lib_link_screen_restore(bfd->main, curscreen, curscene); } /* free G.main Main database */ @@ -322,7 +322,11 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath /* baseflags, groups, make depsgraph, etc */ BKE_scene_set_background(G.main, CTX_data_scene(C)); - + + if (mode != 'u') { + IMB_colormanagement_check_file_config(G.main); + } + MEM_freeN(bfd); (void)curscene; /* quiet warning */ diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b0de7a5ea6c..4241756a109 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -50,36 +50,7 @@ #include "BKE_modifier.h" #include "BKE_pointcache.h" -#ifdef _WIN32 -void tstart( void ) -{} -void tend( void ) -{ -} -double tval( void ) -{ - return 0; -} -#else -#include <sys/time.h> -static struct timeval _tstart, _tend; -static struct timezone tz; -void tstart( void ) -{ - gettimeofday(&_tstart, &tz); -} -void tend(void) -{ - gettimeofday(&_tend, &tz); -} -double tval(void) -{ - double t1, t2; - t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 ); - t2 = ( double ) _tend.tv_sec + ( double ) _tend.tv_usec/ ( 1000*1000 ); - return t2-t1; -} -#endif +// #include "PIL_time.h" /* timing for debug prints */ /* Our available solvers. */ // 255 is the magic reserved number, so NEVER try to put 255 solvers in here! @@ -410,13 +381,13 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul cloth_apply_vgroup ( clmd, result ); cloth_update_springs( clmd ); - tstart(); + // TIMEIT_START(cloth_step) /* call the solver. */ if (solvers [clmd->sim_parms->solver_type].solver) ret = solvers[clmd->sim_parms->solver_type].solver(ob, framenr, clmd, effectors); - tend(); + // TIMEIT_END(cloth_step) pdEndEffectors(&effectors); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index af9bb971d05..6631afcddaf 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -161,8 +161,6 @@ void bvhtree_update_from_mvert(BVHTree * bvhtree, MFace *faces, int numfaces, MV /*********************************** Collision modifier code end ***********************************/ -#define mySWAP(a, b) do { double tmp = b ; b = a ; a = tmp ; } while (0) - // w3 is not perfect static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3 ) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index d65c81b4f9b..b66bd1fd32b 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -49,6 +49,7 @@ #include "BKE_fcurve.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -174,6 +175,7 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con } curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul); + cumap->changed_timestamp++; } /* ***************** operations on single curve ************* */ @@ -260,7 +262,7 @@ CurveMapPoint *curvemap_insert(CurveMap *cuma, float x, float y) return newcmp; } -void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) +void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) { if (cuma->curve) MEM_freeN(cuma->curve); @@ -479,7 +481,7 @@ static float curvemap_calc_extend(const CurveMap *cuma, float x, const float fir } /* only creates a table for a single channel in CurveMapping */ -static void curvemap_make_table(CurveMap *cuma, rctf *clipr) +static void curvemap_make_table(CurveMap *cuma, const rctf *clipr) { CurveMapPoint *cmp = cuma->curve; BezTriple *bezt; @@ -677,7 +679,7 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) CurveMap *cuma = cumap->cm + cumap->cur; CurveMapPoint *cmp = cuma->curve; rctf *clipr = &cumap->clipr; - float thresh = 0.01f * BLI_RCT_SIZE_X(clipr); + float thresh = 0.01f * BLI_rctf_size_x(clipr); float dx = 0.0f, dy = 0.0f; int a; @@ -996,7 +998,8 @@ static void save_sample_line(Scopes *scopes, const int idx, const float fx, cons } } -void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short use_color_management) +void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) { int i, x, y; float *fp; @@ -1008,6 +1011,8 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short int y1 = 0.5f + hist->co[0][1] * ibuf->y; int y2 = 0.5f + hist->co[1][1] * ibuf->y; + struct ColormanageProcessor *cm_processor = NULL; + hist->channels = 3; hist->x_resolution = 256; hist->xmax = 1.0f; @@ -1015,6 +1020,9 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; + if (ibuf->rect_float) + cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + /* persistent draw */ hist->flag |= HISTO_FLAG_SAMPLELINE; /* keep drawing the flag after */ @@ -1029,10 +1037,8 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - if (use_color_management) - linearrgb_to_srgb_v3_v3(rgb, fp); - else - copy_v3_v3(rgb, fp); + copy_v3_v3(rgb, fp); + IMB_colormanagement_processor_apply_v3(cm_processor, rgb); hist->data_luma[i] = rgb_to_luma(rgb); hist->data_r[i] = rgb[0]; @@ -1050,9 +1056,13 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short } } } + + if (cm_processor) + IMB_colormanagement_processor_free(cm_processor); } -void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) +void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) { int x, y, c; unsigned int n, nl; @@ -1065,6 +1075,8 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) int ycc_mode = -1; const short is_float = (ibuf->rect_float != NULL); + struct ColormanageProcessor *cm_processor = NULL; + if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; if (scopes->ok == 1) return; @@ -1134,6 +1146,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) else rc = (unsigned char *)ibuf->rect; + if (ibuf->rect_float) + cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + for (y = 0; y < ibuf->y; y++) { if (savedlines < scopes->sample_lines && y >= ((savedlines) * ibuf->y) / (scopes->sample_lines + 1)) { saveline = 1; @@ -1144,11 +1159,8 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) for (x = 0; x < ibuf->x; x++) { if (is_float) { - if (use_color_management) - linearrgb_to_srgb_v3_v3(rgba, rf); - else - copy_v3_v3(rgba, rf); - rgba[3] = rf[3]; + copy_v4_v4(rgba, rf); + IMB_colormanagement_processor_apply_v4(cm_processor, rgba); } else { for (c = 0; c < 4; c++) @@ -1219,6 +1231,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) MEM_freeN(bin_b); MEM_freeN(bin_a); + if (cm_processor) + IMB_colormanagement_processor_free(cm_processor); + scopes->ok = 1; } @@ -1257,3 +1272,58 @@ void scopes_new(Scopes *scopes) scopes->waveform_3 = NULL; scopes->vecscope = NULL; } + +void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settings) +{ + const char *display_name = IMB_colormanagement_display_get_default_name(); + + BLI_strncpy(settings->display_device, display_name, sizeof(settings->display_device)); +} + +void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_settings, + const ColorManagedDisplaySettings *settings) +{ + BLI_strncpy(new_settings->display_device, settings->display_device, sizeof(new_settings->display_device)); +} + +void BKE_color_managed_view_settings_init(ColorManagedViewSettings *settings) +{ + /* OCIO_TODO: use default view transform here when OCIO is completely integrated + * and proper versioning stuff is added. + * for now use NONE to be compatible with all current files + */ + BLI_strncpy(settings->view_transform, "Default", sizeof(settings->view_transform)); + + settings->gamma = 1.0f; + settings->exposure = 0.0f; +} + +void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings, + const ColorManagedViewSettings *settings) +{ + BLI_strncpy(new_settings->view_transform, settings->view_transform, sizeof(new_settings->view_transform)); + + new_settings->flag = settings->flag; + new_settings->exposure = settings->exposure; + new_settings->gamma = settings->gamma; + + if (settings->curve_mapping) + new_settings->curve_mapping = curvemapping_copy(settings->curve_mapping); +} + +void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings) +{ + if (settings->curve_mapping) + curvemapping_free(settings->curve_mapping); +} + +void BKE_color_managed_colorspace_settings_init(ColorManagedColorspaceSettings *colorspace_settings) +{ + BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name)); +} + +void BKE_color_managed_colorspace_settings_copy(ColorManagedColorspaceSettings *colorspace_settings, + const ColorManagedColorspaceSettings *settings) +{ + BLI_strncpy(colorspace_settings->name, settings->name, sizeof(colorspace_settings->name)); +} diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 6b9e0921c3b..e3f7ae1b1c7 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1030,7 +1030,6 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar if (VALID_CONS_TARGET(ct)) { float size[3], vec[3]; float totmat[3][3]; - float tmat[4][4]; /* Get size property, since ob->size is only the object's own relative size, not its global one */ mat4_to_size(size, cob->matrix); @@ -1053,9 +1052,8 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar vectomat(vec, ct->matrix[2], (short)data->reserved1, (short)data->reserved2, data->flags, totmat); - - copy_m4_m4(tmat, cob->matrix); - mul_m4_m3m4(cob->matrix, totmat, tmat); + + mul_m4_m3m4(cob->matrix, totmat, cob->matrix); } } @@ -2281,7 +2279,6 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t float totmat[3][3]; float tmpmat[3][3]; float invmat[3][3]; - float tmat[4][4]; float mdet; /* Vector object -> target */ @@ -2509,8 +2506,6 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t totmat[1][0] = tmpmat[1][0]; totmat[1][1] = tmpmat[1][1]; totmat[1][2] = tmpmat[1][2]; totmat[2][0] = tmpmat[2][0]; totmat[2][1] = tmpmat[2][1]; totmat[2][2] = tmpmat[2][2]; - copy_m4_m4(tmat, cob->matrix); - mdet = determinant_m3(totmat[0][0], totmat[0][1], totmat[0][2], totmat[1][0], totmat[1][1], totmat[1][2], totmat[2][0], totmat[2][1], totmat[2][2]); @@ -2519,7 +2514,7 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t } /* apply out transformaton to the object */ - mul_m4_m3m4(cob->matrix, totmat, tmat); + mul_m4_m3m4(cob->matrix, totmat, cob->matrix); } } @@ -2717,7 +2712,6 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t if (VALID_CONS_TARGET(ct)) { float size[3], scale[3], vec[3], xx[3], zz[3], orth[3]; float totmat[3][3]; - float tmat[4][4]; float dist; /* store scaling before destroying obmat */ @@ -2815,9 +2809,8 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t normalize_v3_v3(totmat[2], zz); break; } /* switch (data->plane) */ - - copy_m4_m4(tmat, cob->matrix); - mul_m4_m3m4(cob->matrix, totmat, tmat); + + mul_m4_m3m4(cob->matrix, totmat, cob->matrix); } } @@ -4061,32 +4054,36 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase copy_v3_v3(cob->matrix[3], disp); } - if (data->depth_ob && data->depth_ob->derivedFinal) { + if (data->depth_ob) { Object *depth_ob = data->depth_ob; - BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; - BVHTreeRayHit hit; - float ray_start[3], ray_end[3], ray_nor[3], imat[4][4]; - int result; + DerivedMesh *target = object_get_derived_final(depth_ob); + if (target) { + BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; + BVHTreeRayHit hit; + float ray_start[3], ray_end[3], ray_nor[3], imat[4][4]; + int result; - invert_m4_m4(imat, depth_ob->obmat); + invert_m4_m4(imat, depth_ob->obmat); - mul_v3_m4v3(ray_start, imat, camob->obmat[3]); - mul_v3_m4v3(ray_end, imat, cob->matrix[3]); + mul_v3_m4v3(ray_start, imat, camob->obmat[3]); + mul_v3_m4v3(ray_end, imat, cob->matrix[3]); - sub_v3_v3v3(ray_nor, ray_end, ray_start); + sub_v3_v3v3(ray_nor, ray_end, ray_start); - bvhtree_from_mesh_faces(&treeData, depth_ob->derivedFinal, 0.0f, 4, 6); + bvhtree_from_mesh_faces(&treeData, target, 0.0f, 4, 6); - hit.dist = FLT_MAX; - hit.index = -1; + hit.dist = FLT_MAX; + hit.index = -1; - result = BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData); + result = BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData); - if (result != -1) { - mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co); - } + if (result != -1) { + mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co); + } - free_bvhtree_from_mesh(&treeData); + free_bvhtree_from_mesh(&treeData); + target->release(target); + } } } } diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index a2f88781cbb..09ca0df0680 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -429,6 +429,33 @@ void BKE_curve_texspace_calc(Curve *cu) } } +int BKE_nurbList_index_get_co(ListBase *nurb, const int index, float r_co[3]) +{ + Nurb *nu; + int tot = 0; + + for (nu = nurb->first; nu; nu = nu->next) { + int tot_nu; + if (nu->type == CU_BEZIER) { + tot_nu = nu->pntsu; + if (index - tot < tot_nu) { + copy_v3_v3(r_co, nu->bezt[index - tot].vec[1]); + return TRUE; + } + } + else { + tot_nu = nu->pntsu * nu->pntsv; + if (index - tot < tot_nu) { + copy_v3_v3(r_co, nu->bp[index - tot].vec); + return TRUE; + } + } + tot += tot_nu; + } + + return FALSE; +} + int BKE_nurbList_verts_count(ListBase *nurb) { Nurb *nu; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 342ee5bba41..ba859cadf92 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -271,28 +271,6 @@ static void layerInterp_mdeformvert(void **sources, const float *weights, BLI_linklist_free(dest_dw, linklist_free_simple); } - -static void layerInterp_msticky(void **sources, const float *weights, - const float *UNUSED(sub_weights), int count, void *dest) -{ - float co[2], w; - MSticky *mst; - int i; - - co[0] = co[1] = 0.0f; - for (i = 0; i < count; i++) { - w = weights ? weights[i] : 1.0f; - mst = (MSticky *)sources[i]; - - madd_v2_v2fl(co, mst->co, w); - } - - /* delay writing to the destination incase dest is in sources */ - mst = (MSticky *)dest; - copy_v2_v2(mst->co, co); -} - - static void layerCopy_tface(const void *source, void *dest, int count) { const MTFace *source_tf = (const MTFace *)source; @@ -1055,8 +1033,8 @@ static void layerInterp_mvert_skin(void **sources, const float *weights, static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 0: CD_MVERT */ {sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL}, - /* 1: CD_MSTICKY */ - {sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL, + /* 1: CD_MSTICKY */ /* DEPRECATED */ + {sizeof(float) * 2, "", 1, NULL, NULL, NULL, NULL, NULL, NULL}, /* 2: CD_MDEFORMVERT */ {sizeof(MDeformVert), "MDeformVert", 1, NULL, layerCopy_mdeformvert, @@ -1155,7 +1133,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(GridPaintMask), "GridPaintMask", 1, NULL, layerCopy_grid_paint_mask, layerFree_grid_paint_mask, NULL, NULL, NULL}, /* 36: CD_SKIN_NODE */ - {sizeof(MVertSkin), "MVertSkin", 1, "Skin", NULL, NULL, + {sizeof(MVertSkin), "MVertSkin", 1, NULL, NULL, NULL, layerInterp_mvert_skin, NULL, layerDefault_mvert_skin} }; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index b8d5294eabc..31a6f768f89 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -501,7 +501,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ob->adt) dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation - key = ob_get_key(ob); + key = BKE_key_from_object(ob); if (key && key->adt) dag_add_driver_relation(key->adt, dag, node, 1); @@ -2650,7 +2650,7 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on ShapeKey */ if (idtype == ID_KE) { for (obt = bmain->object.first; obt; obt = obt->id.next) { - Key *key = ob_get_key(obt); + Key *key = BKE_key_from_object(obt); if (!(ob && obt == ob) && ((ID *)key == id)) { obt->flag |= (OB_RECALC_OB | OB_RECALC_DATA); lib_id_recalc_tag(bmain, &obt->id); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index f47ac641cf9..1cb29b90133 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -669,7 +669,7 @@ static void boundInsert(Bounds3D *b, float point[3]) } } -float getSurfaceDimension(PaintSurfaceData *sData) +static float getSurfaceDimension(PaintSurfaceData *sData) { Bounds3D *mb = &sData->bData->mesh_bounds; return MAX3((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2])); @@ -910,7 +910,7 @@ static void free_bakeData(PaintSurfaceData *data) } /* free surface data if it's not used anymore */ -void surface_freeUnusedData(DynamicPaintSurface *surface) +static void surface_freeUnusedData(DynamicPaintSurface *surface) { if (!surface->data) return; @@ -1368,7 +1368,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for MEM_freeN(temp_data); } -void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) +static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) { PaintSurfaceData *sData = surface->data; PaintPoint *pPoint = (PaintPoint *)sData->type_data; @@ -1605,7 +1605,7 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Deri /* * Apply canvas data to the object derived mesh */ -struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, +static DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *ob, DerivedMesh *dm) { @@ -1830,9 +1830,12 @@ void dynamicPaint_cacheUpdateFrames(DynamicPaintSurface *surface) } } -void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMesh *dm) +static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMesh *dm) { - if (canvas->dm) canvas->dm->release(canvas->dm); + if (canvas->dm) { + canvas->dm->release(canvas->dm); + } + canvas->dm = CDDM_copy(dm); } @@ -2748,7 +2751,7 @@ static void dynamicPaint_freeBrushMaterials(BrushMaterials *bMats) /* * Get material diffuse color and alpha (including linked textures) in given coordinates */ -void dynamicPaint_doMaterialTex(BrushMaterials *bMats, float color[3], float *alpha, Object *brushOb, const float volume_co[3], const float surface_co[3], int faceIndex, short isQuad, DerivedMesh *orcoDm) +static void dynamicPaint_doMaterialTex(BrushMaterials *bMats, float color[3], float *alpha, Object *brushOb, const float volume_co[3], const float surface_co[3], int faceIndex, short isQuad, DerivedMesh *orcoDm) { Material *mat = bMats->mat; MFace *mface = orcoDm->getTessFaceArray(orcoDm); @@ -3953,7 +3956,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int } /* find two adjacency points (closest_id) and influence (closest_d) to move paint towards when affected by a force */ -void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, float force[3], float closest_d[2], int closest_id[2]) +static void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, float force[3], float closest_d[2], int closest_id[2]) { BakeAdjPoint *bNeighs = sData->bData->bNeighs; int numOfNeighs = sData->adj_data->n_num[index]; @@ -4342,7 +4345,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force } } -void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) +static void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) { PaintSurfaceData *sData = surface->data; BakeAdjPoint *bNeighs = sData->bData->bNeighs; diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index befec1907da..8d430eb58b5 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -152,7 +152,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { /* don't consider two-edged faces */ - if (efa->len < 3) { + if (UNLIKELY(efa->len < 3)) { /* do nothing */ } diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 538d2469a93..68321076398 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -48,10 +48,6 @@ #include "BKE_fcurve.h" #include "BKE_idprop.h" - -#define SMALL -1.0e-10 -#define SELECT 1 - /* ******************************** F-Modifiers ********************************* */ /* Info ------------------------------- */ diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 0d9a69008ee..3392f6f109b 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -116,16 +116,6 @@ void BKE_group_unlink(Group *group) if (ob->dup_group == group) { ob->dup_group = NULL; -#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ - { - bActionStrip *strip; - /* duplicator strips use a group object, we remove it */ - for (strip = ob->nlastrips.first; strip; strip = strip->next) { - if (strip->object) - strip->object = NULL; - } - } -#endif } for (psys = ob->particlesystem.first; psys; psys = psys->next) { @@ -389,57 +379,3 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group } } } - -#if 0 -Object *group_get_member_with_action(Group *group, bAction *act) -{ - GroupObject *go; - - if (group == NULL || act == NULL) return NULL; - - for (go = group->gobject.first; go; go = go->next) { - if (go->ob) { - if (go->ob->action == act) - return go->ob; - if (go->ob->nlastrips.first) { - bActionStrip *strip; - - for (strip = go->ob->nlastrips.first; strip; strip = strip->next) { - if (strip->act == act) - return go->ob; - } - } - } - } - return NULL; -} - -/* if group has NLA, we try to map the used objects in NLA to group members */ -/* this assuming that object has received a new group link */ -void group_relink_nla_objects(Object *ob) -{ - Group *group; - GroupObject *go; - bActionStrip *strip; - - if (ob == NULL || ob->dup_group == NULL) return; - group = ob->dup_group; - - for (strip = ob->nlastrips.first; strip; strip = strip->next) { - if (strip->object) { - for (go = group->gobject.first; go; go = go->next) { - if (go->ob) { - if (strcmp(go->ob->id.name, strip->object->id.name) == 0) - break; - } - } - if (go) - strip->object = go->ob; - else - strip->object = NULL; - } - - } -} - -#endif diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 8a49cba7649..d8c3e260399 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -65,7 +65,7 @@ static void icon_free(void *val) Icon *icon = val; if (icon) { - if (icon->drawinfo_free) { + if (icon->drawinfo_free) { icon->drawinfo_free(icon->drawinfo); } else if (icon->drawinfo) { @@ -255,7 +255,7 @@ void BKE_icon_changed(int id) prv->changed_timestamp[i]++; } } - } + } } int BKE_icon_getid(struct ID *id) diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 8229df28ab8..8ceaab56f83 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -484,7 +484,7 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) BLI_remlink(&group->data.group, loop); IDP_FreeProperty(loop); - MEM_freeN(loop); + MEM_freeN(loop); } else { group->len++; @@ -679,7 +679,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n case IDP_DOUBLE: prop = MEM_callocN(sizeof(IDProperty), "IDProperty float"); *(double *)&prop->data.val = val->d; - break; + break; case IDP_ARRAY: { /* for now, we only support float and int and double arrays */ diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 3f756e74b26..d620fc50e86 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -47,6 +47,7 @@ #include "MEM_guardedalloc.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -70,6 +71,7 @@ #include "BLI_bpath.h" #include "BKE_bmfont.h" +#include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_icons.h" #include "BKE_image.h" @@ -243,6 +245,11 @@ static Image *image_alloc(const char *name, short source, short type) ima->source = source; ima->type = type; + + if (source == IMA_SRC_VIEWER) + ima->flag |= IMA_VIEW_AS_RENDER; + + BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings); } return ima; } @@ -325,6 +332,8 @@ Image *BKE_image_copy(Image *ima) nima->aspx = ima->aspx; nima->aspy = ima->aspy; + BKE_color_managed_colorspace_settings_copy(&nima->colorspace_settings, &ima->colorspace_settings); + return nima; } @@ -594,7 +603,8 @@ Image *BKE_image_load_exists(const char *filepath) return BKE_image_load(filepath); } -static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4]) +static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, + float color[4], ColorManagedColorspaceSettings *colorspace_settings) { ImBuf *ibuf; unsigned char *rect = NULL; @@ -603,12 +613,24 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char if (floatbuf) { ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat); rect_float = ibuf->rect_float; - ibuf->profile = IB_PROFILE_LINEAR_RGB; + + if (colorspace_settings->name[0] == '\0') { + const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_FLOAT); + + BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name)); + } } else { ibuf = IMB_allocImBuf(width, height, depth, IB_rect); rect = (unsigned char *)ibuf->rect; - ibuf->profile = IB_PROFILE_SRGB; + + if (colorspace_settings->name[0] == '\0') { + const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE); + + BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name)); + } + + IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace_settings->name); } BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); @@ -643,7 +665,7 @@ Image *BKE_image_add_generated(unsigned int width, unsigned int height, const ch ima->gen_type = gen_type; ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); - ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color); + ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok = IMA_OK_LOADED; @@ -1009,6 +1031,19 @@ int BKE_imtype_supports_quality(const char imtype) return 0; } +int BKE_imtype_supports_float(const char imtype) +{ + switch (imtype) { + case R_IMF_IMTYPE_CINEON: + case R_IMF_IMTYPE_DPX: + case R_IMF_IMTYPE_RADHDR: + case R_IMF_IMTYPE_OPENEXR: + case R_IMF_IMTYPE_MULTILAYER: + return TRUE; + } + return 0; +} + char BKE_imtype_valid_channels(const char imtype) { char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */ @@ -1207,6 +1242,9 @@ void BKE_imformat_defaults(ImageFormatData *im_format) im_format->imtype = R_IMF_IMTYPE_PNG; im_format->quality = 90; im_format->compress = 90; + + BKE_color_managed_display_settings_init(&im_format->display_settings); + BKE_color_managed_view_settings_init(&im_format->view_settings); } void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf) @@ -1477,10 +1515,11 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec int x, y, y_ofs; float h_fixed; const int mono = blf_mono_font_render; // XXX + struct ColorManagedDisplay *display; + const char *display_device; /* this could be an argument if we want to operate on non linear float imbuf's * for now though this is only used for renders which use scene settings */ - const int do_color_management = (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0; #define BUFF_MARGIN_X 2 #define BUFF_MARGIN_Y 1 @@ -1488,6 +1527,9 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec if (!rect && !rectf) return; + display_device = scene->display_settings.display_device; + display = IMB_colormanagement_display_get_named(display_device); + stampdata(scene, camera, &stamp_data, 1); /* TODO, do_versions */ @@ -1497,7 +1539,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* set before return */ BLF_size(mono, scene->r.stamp_font_id, 72); - BLF_buffer(mono, rectf, rect, width, height, channels, do_color_management); + BLF_buffer(mono, rectf, rect, width, height, channels, display); BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); pad = BLF_width_max(mono); @@ -1514,7 +1556,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y -= h; /* also a little of space to the background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and draw the text. */ @@ -1531,7 +1573,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); @@ -1547,7 +1589,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); @@ -1563,7 +1605,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); @@ -1578,7 +1620,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.marker, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ @@ -1594,7 +1636,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed; /* extra space for background */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ @@ -1609,7 +1651,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ @@ -1624,7 +1666,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.camera, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.camera); @@ -1637,7 +1679,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.cameralens); @@ -1650,7 +1692,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec x = width - w - 2; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ @@ -1666,7 +1708,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y = height - h; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); @@ -1878,12 +1920,12 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int } /* used by sequencer too */ -struct anim *openanim(const char *name, int flags, int streamindex) +struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]) { struct anim *anim; struct ImBuf *ibuf; - anim = IMB_open_anim(name, flags, streamindex); + anim = IMB_open_anim(name, flags, streamindex, colorspace); if (anim == NULL) return NULL; ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); @@ -2177,8 +2219,10 @@ void BKE_image_backup_render(Scene *scene, Image *ima) /* in that case we have to build a render-result */ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr) { + const char *colorspace = ima->colorspace_settings.name; + int predivide = ima->flag & IMA_CM_PREDIVIDE; - ima->rr = RE_MultilayerConvert(ibuf->userdata, ibuf->x, ibuf->y); + ima->rr = RE_MultilayerConvert(ibuf->userdata, colorspace, predivide, ibuf->x, ibuf->y); #ifdef WITH_OPENEXR IMB_exr_close(ibuf->userdata); @@ -2226,7 +2270,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) flag |= IB_premul; /* read ibuf */ - ibuf = IMB_loadiffname(name, flag); + ibuf = IMB_loadiffname(name, flag, ima->colorspace_settings.name); #if 0 if (ibuf) { @@ -2304,7 +2348,6 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f ibuf->flags |= IB_rectfloat; ibuf->mall = IB_rectfloat; ibuf->channels = rpass->channels; - ibuf->profile = IB_PROFILE_LINEAR_RGB; image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame); @@ -2334,7 +2377,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) BKE_image_user_file_path(iuser, ima, str); /* FIXME: make several stream accessible in image editor, too*/ - ima->anim = openanim(str, IB_rect, 0); + ima->anim = openanim(str, IB_rect, 0, ima->colorspace_settings.name); /* let's initialize this user */ if (ima->anim && iuser && iuser->frames == 0) @@ -2385,8 +2428,8 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, - ima->packedfile->size, flag, "<packed data>"); + ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, ima->packedfile->size, flag, + ima->colorspace_settings.name, "<packed data>"); } else { flag = IB_rect | IB_multilayer | IB_metadata; @@ -2398,7 +2441,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) BKE_image_user_file_path(iuser, ima, str); /* read ibuf */ - ibuf = IMB_loadiffname(str, flag); + ibuf = IMB_loadiffname(str, flag, ima->colorspace_settings.name); } if (ibuf) { @@ -2455,7 +2498,6 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) ibuf->rect_float = rpass->rect; ibuf->flags |= IB_rectfloat; ibuf->channels = rpass->channels; - ibuf->profile = IB_PROFILE_LINEAR_RGB; image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0); } @@ -2561,6 +2603,13 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); } + /* invalidate color managed buffers if render result changed */ + BLI_lock_thread(LOCK_COLORMANAGE); + if (ibuf->x != rres.rectx || ibuf->y != rres.recty || ibuf->rect_float != rectf) + { + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + } + ibuf->x = rres.rectx; ibuf->y = rres.recty; @@ -2592,8 +2641,8 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf->flags &= ~IB_zbuffloat; } - /* since its possible to access the buffer from the image directly, set the profile [#25073] */ - ibuf->profile = (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE; + BLI_unlock_thread(LOCK_COLORMANAGE); + ibuf->dither = dither; if (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) { @@ -2750,7 +2799,8 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) /* UV testgrid or black or solid etc */ if (ima->gen_x == 0) ima->gen_x = 1024; if (ima->gen_y == 0) ima->gen_y = 1024; - ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color); + ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, + color, &ima->colorspace_settings); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok = IMA_OK_LOADED; } @@ -2966,5 +3016,8 @@ void BKE_image_get_aspect(Image *image, float *aspx, float *aspy) *aspx = 1.0; /* x is always 1 */ - *aspy = image->aspy / image->aspx; + if (image) + *aspy = image->aspy / image->aspx; + else + *aspy = 1.0f; } diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 4d7013b9f73..37572eebed6 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -289,7 +289,11 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width BLF_size(mono, 54, 72); /* hard coded size! */ - BLF_buffer(mono, rect_float, rect, width, height, 4, TRUE); + /* OCIO_TODO: using NULL as display will assume using sRGB display + * this is correct since currently generated images are assumed to be in sRGB space, + * but this would probably needed to be fixed in some way + */ + BLF_buffer(mono, rect_float, rect, width, height, 4, NULL); for (y = 0; y < height; y += step) { text[1] = '1'; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 1c6974b2615..ebb95a6561e 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -48,8 +48,11 @@ #include "BKE_global.h" -#define CLOTH_OPENMP_LIMIT 512 +#ifdef _OPENMP +# define CLOTH_OPENMP_LIMIT 512 +#endif +#if 0 /* debug timing */ #ifdef _WIN32 #include <windows.h> static LARGE_INTEGER _itstart, _itend; @@ -81,7 +84,7 @@ double itval(void) static struct timeval _itstart, _itend; static struct timezone itz; -void itstart(void) +static void itstart(void) { gettimeofday(&_itstart, &itz); } @@ -89,7 +92,7 @@ static void itend(void) { gettimeofday(&_itend, &itz); } -double itval(void) +static double itval(void) { double t1, t2; t1 = (double)_itstart.tv_sec + (double)_itstart.tv_usec/(1000*1000); @@ -97,6 +100,7 @@ double itval(void) return t2-t1; } #endif +#endif /* debug timing */ static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; static float ZERO[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; @@ -1691,13 +1695,13 @@ static void simulate_implicit_euler(lfVector *Vnew, lfVector *UNUSED(lX), lfVect mul_bfmatrix_lfvector(dFdXmV, dFdX, lV); add_lfvectorS_lfvectorS(B, lF, dt, dFdXmV, (dt*dt), numverts); - - itstart(); - + + // itstart(); + cg_filtered(dV, A, B, z, S); /* conjugate gradient algorithm to solve Ax=b */ // cg_filtered_pre(dV, A, B, z, S, P, Pinv, bigI); - - itend(); + + // itend(); // printf("cg_filtered calc time: %f\n", (float)itval()); cp_lfvector(olddV, dV, numverts); @@ -1713,7 +1717,7 @@ static void simulate_implicit_euler(lfVector *Vnew, lfVector *UNUSED(lX), lfVect * (edge distance constraints) in a lagrangian solver. then add forces to help * guide the implicit solver to that state. this function is called after * collisions*/ -int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float (*initial_cos)[3], float UNUSED(step), float dt) +static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothModifierData * clmd, float (*initial_cos)[3], float UNUSED(step), float dt) { Cloth *cloth= clmd->clothObject; float (*cos)[3] = MEM_callocN(sizeof(float)*3*cloth->numverts, "cos cloth_calc_helper_forces"); diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index b79608342dd..5b05ce02104 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -94,7 +94,7 @@ void BKE_key_free(Key *key) } -void free_key_nolib(Key *key) +void BKE_key_free_nolib(Key *key) { KeyBlock *kb; @@ -121,7 +121,7 @@ void free_key_nolib(Key *key) /* from misc_util: flip the bytes from x */ /* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */ -Key *add_key(ID *id) /* common function */ +Key *BKE_key_add(ID *id) /* common function */ { Key *key; char *el; @@ -196,7 +196,7 @@ Key *BKE_key_copy(Key *key) } -Key *copy_key_nolib(Key *key) +Key *BKE_key_copy_nolib(Key *key) { Key *keyn; KeyBlock *kbn, *kb; @@ -241,7 +241,7 @@ void BKE_key_make_local(Key *key) * currently being called. */ -void sort_keys(Key *key) +void BKE_key_sort(Key *key) { KeyBlock *kb; KeyBlock *kb2; @@ -711,7 +711,7 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const } } -void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb, const int mode) +void BKE_key_evaluate_relative(const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb, const int mode) { KeyBlock *kb; int *ofsp, ofs[3], elemsize, b; @@ -1071,7 +1071,7 @@ static float *get_weights_array(Object *ob, char *vgroup) static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { - KeyBlock *k[4], *actkb = ob_get_keyblock(ob); + KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob); float t[4]; int flag = 0; @@ -1106,7 +1106,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int kb->weights = get_weights_array(ob, kb->vgroup); } - do_rel_key(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY); + BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY); for (kb = key->block.first; kb; kb = kb->next) { if (kb->weights) MEM_freeN(kb->weights); @@ -1154,11 +1154,11 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, char *out, const for (a = 0, nu = cu->nurb.first; nu; nu = nu->next, a += step) { if (nu->bp) { step = nu->pntsu * nu->pntsv; - do_rel_key(a, a + step, tot, out, key, actkb, KEY_MODE_BPOINT); + BKE_key_evaluate_relative(a, a + step, tot, out, key, actkb, KEY_MODE_BPOINT); } else if (nu->bezt) { step = 3 * nu->pntsu; - do_rel_key(a, a + step, tot, out, key, actkb, KEY_MODE_BEZTRIPLE); + BKE_key_evaluate_relative(a, a + step, tot, out, key, actkb, KEY_MODE_BEZTRIPLE); } else { step = 0; @@ -1169,7 +1169,7 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, char *out, const static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { Curve *cu = ob->data; - KeyBlock *k[4], *actkb = ob_get_keyblock(ob); + KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob); float t[4]; int flag = 0; @@ -1251,7 +1251,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { Lattice *lt = ob->data; - KeyBlock *k[4], *actkb = ob_get_keyblock(ob); + KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob); float t[4]; int flag; @@ -1277,7 +1277,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int for (kb = key->block.first; kb; kb = kb->next) kb->weights = get_weights_array(ob, kb->vgroup); - do_rel_key(0, tot, tot, out, key, actkb, KEY_MODE_DUMMY); + BKE_key_evaluate_relative(0, tot, tot, out, key, actkb, KEY_MODE_DUMMY); for (kb = key->block.first; kb; kb = kb->next) { if (kb->weights) MEM_freeN(kb->weights); @@ -1302,8 +1302,8 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int /* returns key coordinates (+ tilt) when key applied, NULL otherwise */ float *do_ob_key(Scene *scene, Object *ob) { - Key *key = ob_get_key(ob); - KeyBlock *actkb = ob_get_keyblock(ob); + Key *key = BKE_key_from_object(ob); + KeyBlock *actkb = BKE_keyblock_from_object(ob); char *out; int tot = 0, size = 0; @@ -1386,7 +1386,7 @@ float *do_ob_key(Scene *scene, Object *ob) return (float *)out; } -Key *ob_get_key(Object *ob) +Key *BKE_key_from_object(Object *ob) { if (ob == NULL) return NULL; @@ -1405,7 +1405,7 @@ Key *ob_get_key(Object *ob) return NULL; } -KeyBlock *add_keyblock(Key *key, const char *name) +KeyBlock *BKE_keyblock_add(Key *key, const char *name) { KeyBlock *kb; float curpos = -0.1; @@ -1439,7 +1439,7 @@ KeyBlock *add_keyblock(Key *key, const char *name) /** * \note caller may want to set this to current time, but don't do it here since we need to sort - * which could cause problems in some cases, see #add_keyblock_ctime */ + * which could cause problems in some cases, see #BKE_keyblock_add_ctime */ kb->pos = curpos + 0.1f; /* only used for absolute shape keys */ return kb; @@ -1453,22 +1453,22 @@ KeyBlock *add_keyblock(Key *key, const char *name) * \param name Optional name for the new keyblock. * \param do_force always use ctime even for relative keys. */ -KeyBlock *add_keyblock_ctime(Key *key, const char *name, const short do_force) +KeyBlock *BKE_keyblock_add_ctime(Key *key, const char *name, const short do_force) { - KeyBlock *kb = add_keyblock(key, name); + KeyBlock *kb = BKE_keyblock_add(key, name); if (do_force || (key->type != KEY_RELATIVE)) { kb->pos = key->ctime / 100.0f; - sort_keys(key); + BKE_key_sort(key); } return kb; } /* only the active keyblock */ -KeyBlock *ob_get_keyblock(Object *ob) +KeyBlock *BKE_keyblock_from_object(Object *ob) { - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); if (key) { KeyBlock *kb = BLI_findlink(&key->block, ob->shapenr - 1); @@ -1478,9 +1478,9 @@ KeyBlock *ob_get_keyblock(Object *ob) return NULL; } -KeyBlock *ob_get_reference_keyblock(Object *ob) +KeyBlock *BKE_keyblock_from_object_reference(Object *ob) { - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); if (key) return key->refkey; @@ -1489,7 +1489,7 @@ KeyBlock *ob_get_reference_keyblock(Object *ob) } /* get the appropriate KeyBlock given an index */ -KeyBlock *key_get_keyblock(Key *key, int index) +KeyBlock *BKE_keyblock_from_key(Key *key, int index) { KeyBlock *kb; int i; @@ -1509,18 +1509,29 @@ KeyBlock *key_get_keyblock(Key *key, int index) } /* get the appropriate KeyBlock given a name to search for */ -KeyBlock *key_get_named_keyblock(Key *key, const char name[]) +KeyBlock *BKE_keyblock_find_name(Key *key, const char name[]) { - if (key && name) - return BLI_findstring(&key->block, name, offsetof(KeyBlock, name)); - - return NULL; + return BLI_findstring(&key->block, name, offsetof(KeyBlock, name)); +} + +/** + * \brief copy shape-key attributes, but not key data.or name/uid + */ +void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src) +{ + kb_dst->pos = kb_src->pos; + kb_dst->curval = kb_src->curval; + kb_dst->type = kb_src->type; + kb_dst->relative = kb_src->relative; + BLI_strncpy(kb_dst->vgroup, kb_src->vgroup, sizeof(kb_dst->vgroup)); + kb_dst->slidermin = kb_src->slidermin; + kb_dst->slidermax = kb_src->slidermax; } /* Get RNA-Path for 'value' setting of the given ShapeKey * NOTE: the user needs to free the returned string once they're finish with it */ -char *key_get_curValue_rnaPath(Key *key, KeyBlock *kb) +char *BKE_keyblock_curval_rnapath_get(Key *key, KeyBlock *kb) { PointerRNA ptr; PropertyRNA *prop; @@ -1542,7 +1553,7 @@ char *key_get_curValue_rnaPath(Key *key, KeyBlock *kb) /* conversion functions */ /************************* Lattice ************************/ -void latt_to_key(Lattice *lt, KeyBlock *kb) +void BKE_key_convert_from_lattice(Lattice *lt, KeyBlock *kb) { BPoint *bp; float *fp; @@ -1563,7 +1574,7 @@ void latt_to_key(Lattice *lt, KeyBlock *kb) } } -void key_to_latt(KeyBlock *kb, Lattice *lt) +void BKE_key_convert_to_lattice(KeyBlock *kb, Lattice *lt) { BPoint *bp; float *fp; @@ -1581,7 +1592,7 @@ void key_to_latt(KeyBlock *kb, Lattice *lt) } /************************* Curve ************************/ -void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb) +void BKE_key_convert_from_curve(Curve *cu, KeyBlock *kb, ListBase *nurb) { Nurb *nu; BezTriple *bezt; @@ -1632,7 +1643,7 @@ void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb) } } -void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb) +void BKE_key_convert_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb) { Nurb *nu; BezTriple *bezt; @@ -1683,7 +1694,7 @@ void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb) } /************************* Mesh ************************/ -void mesh_to_key(Mesh *me, KeyBlock *kb) +void BKE_key_convert_from_mesh(Mesh *me, KeyBlock *kb) { MVert *mvert; float *fp; @@ -1704,7 +1715,7 @@ void mesh_to_key(Mesh *me, KeyBlock *kb) } } -void key_to_mesh(KeyBlock *kb, Mesh *me) +void BKE_key_convert_to_mesh(KeyBlock *kb, Mesh *me) { MVert *mvert; float *fp; @@ -1721,7 +1732,7 @@ void key_to_mesh(KeyBlock *kb, Mesh *me) } /************************* vert coords ************************/ -float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3] +float (*BKE_key_convert_to_vertcos(Object * ob, KeyBlock * kb))[3] { float (*vertCos)[3], *co; float *fp = kb->data; @@ -1743,7 +1754,7 @@ float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3] if (tot == 0) return NULL; - vertCos = MEM_callocN(tot * sizeof(*vertCos), "key_to_vertcos vertCos"); + vertCos = MEM_callocN(tot * sizeof(*vertCos), "BKE_key_convert_to_vertcos vertCos"); /* Copy coords to array */ co = (float *)vertCos; @@ -1797,7 +1808,7 @@ float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3] return vertCos; } -void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) +void BKE_key_convert_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos)[3]) { float *co = (float *)vertCos, *fp; int tot = 0, a, elemsize; @@ -1826,7 +1837,7 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) return; } - fp = kb->data = MEM_callocN(tot * elemsize, "key_to_vertcos vertCos"); + fp = kb->data = MEM_callocN(tot * elemsize, "BKE_key_convert_to_vertcos vertCos"); /* Copy coords to keyblock */ @@ -1877,7 +1888,7 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) } } -void offset_to_key(Object *ob, KeyBlock *kb, float (*ofs)[3]) +void BKE_key_convert_from_offset(Object *ob, KeyBlock *kb, float (*ofs)[3]) { int a; float *co = (float *)ofs, *fp = kb->data; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 97b46d4829d..3564071334c 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1112,7 +1112,8 @@ static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[ return FALSE; } -int BKE_mask_evaluate_parent_delta(MaskParent *parent, float ctime, float r_delta[2]) +/* could make external but for now its only used internally */ +static int mask_evaluate_parent_delta(MaskParent *parent, float ctime, float r_delta[2]) { float parent_co[2]; @@ -1452,7 +1453,7 @@ void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const int do *point_deform = *point; point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL; - if (BKE_mask_evaluate_parent_delta(&point->parent, ctime, delta)) { + if (mask_evaluate_parent_delta(&point->parent, ctime, delta)) { add_v2_v2(point_deform->bezt.vec[0], delta); add_v2_v2(point_deform->bezt.vec[1], delta); add_v2_v2(point_deform->bezt.vec[2], delta); diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 18617f0ef2e..1a9ac9dc0af 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -253,9 +253,9 @@ void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle) } -void maskrasterize_spline_differentiate_point_outset(float (*diff_feather_points)[2], float (*diff_points)[2], - const unsigned int tot_diff_point, const float ofs, - const short do_test) +static void maskrasterize_spline_differentiate_point_outset(float (*diff_feather_points)[2], float (*diff_points)[2], + const unsigned int tot_diff_point, const float ofs, + const short do_test) { unsigned int k_prev = tot_diff_point - 2; unsigned int k_curr = tot_diff_point - 1; @@ -410,8 +410,8 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) { MemArena *arena = BLI_memarena_new(1 << 16, __func__); - const float bucket_dim_x = BLI_RCT_SIZE_X(&layer->bounds); - const float bucket_dim_y = BLI_RCT_SIZE_Y(&layer->bounds); + const float bucket_dim_x = BLI_rctf_size_x(&layer->bounds); + const float bucket_dim_y = BLI_rctf_size_y(&layer->bounds); layer->buckets_x = (bucket_dim_x / pixel_size) / (float)BUCKET_PIXELS_PER_CELL; layer->buckets_y = (bucket_dim_y / pixel_size) / (float)BUCKET_PIXELS_PER_CELL; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index fc1c5e43cbf..3408e2393c9 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -942,7 +942,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) if (ma->texco & (TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM | TEXCO_STRAND | TEXCO_STRESS)) needuv = 1; else if (ma->texco & (TEXCO_GLOB | TEXCO_UV | TEXCO_OBJECT | TEXCO_SPEED)) needuv = 1; - else if (ma->texco & (TEXCO_LAVECTOR | TEXCO_VIEW | TEXCO_STICKY)) needuv = 1; + else if (ma->texco & (TEXCO_LAVECTOR | TEXCO_VIEW)) needuv = 1; if ((ma->mapto & MAP_NORM) && (mtex->normapspace == MTEX_NSPACE_TANGENT)) needtang = 1; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 3925c3cc858..2030ab0f552 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -186,7 +186,7 @@ void BKE_mball_unlink(MetaBall *mb) /* do not free mball itself */ void BKE_mball_free(MetaBall *mb) { - BKE_mball_unlink(mb); + BKE_mball_unlink(mb); if (mb->adt) { BKE_free_animdata((ID *)mb); @@ -562,7 +562,7 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis) basis = ob; basisnr = obnr; } - } + } } } @@ -691,7 +691,7 @@ static float densfunc(MetaElem *ball, float x, float y, float z) /* *** end deprecated *** */ } - dist2 = 1.0f - (len_v3(dvec) / ball->rad2); + dist2 = 1.0f - (len_squared_v3(dvec) / ball->rad2); if ((ball->flag & MB_NEGATIVE) == 0) { return (dist2 < 0.0f) ? -0.5f : (ball->s * dist2 * dist2 * dist2) - 0.5f; @@ -732,7 +732,7 @@ static octal_node *find_metaball_octal_node(octal_node *node, float x, float y, return find_metaball_octal_node(node->nodes[2], x, y, z, depth--); else return node; - } + } } } else { @@ -762,7 +762,7 @@ static octal_node *find_metaball_octal_node(octal_node *node, float x, float y, return find_metaball_octal_node(node->nodes[6], x, y, z, depth--); else return node; - } + } } } @@ -861,7 +861,7 @@ static void *new_pgn_element(int size) } BLI_freelistN(&lb); - return NULL; + return NULL; } size = 4 * ( (size + 3) / 4); @@ -1628,7 +1628,7 @@ static void polygonize(PROCESS *mbproc, MetaBall *mb) for (a = 0; a < G_mb.totelem; a++) { /* try to find 8 points on the surface for each MetaElem */ - find_first_points(mbproc, mb, a); + find_first_points(mbproc, mb, a); } /* polygonize all MetaElems of current MetaBall */ @@ -2038,7 +2038,7 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float } - /* ml belongs to the (4)5th node too */ + /* ml belongs to the (4)5th node too */ if (ml->bb->vec[6][2] >= z) { fill_metaball_octal_node(node, ml, 4); } @@ -2226,7 +2226,7 @@ static void init_metaball_octal_tree(int depth) } } - /* size of first node */ + /* size of first node */ size[0] = node->x_max - node->x_min; size[1] = node->y_max - node->y_min; size[2] = node->z_max - node->z_min; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 8c3ec7e2e40..206d80a6ff0 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -367,7 +367,6 @@ void mesh_update_customdata_pointers(Mesh *me, const short do_ensure_tess_cd) me->mvert = CustomData_get_layer(&me->vdata, CD_MVERT); me->dvert = CustomData_get_layer(&me->vdata, CD_MDEFORMVERT); - me->msticky = CustomData_get_layer(&me->vdata, CD_MSTICKY); me->medge = CustomData_get_layer(&me->edata, CD_MEDGE); @@ -1944,8 +1943,9 @@ void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpo MVert *mv = &mverts[i]; float *no = tnorms[i]; - if (normalize_v3(no) == 0.0f) + if (UNLIKELY(normalize_v3(no) == 0.0f)) { normalize_v3_v3(no, mv->co); + } normal_float_to_short_v3(mv->no, no); } @@ -1981,8 +1981,9 @@ void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, MVert *mv = &mverts[i]; float *no = tnorms[i]; - if (normalize_v3(no) == 0.0f) + if (UNLIKELY(normalize_v3(no) == 0.0f)) { normalize_v3_v3(no, mv->co); + } normal_float_to_short_v3(mv->no, no); } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 65538e5bea2..28de80a7157 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -482,7 +482,7 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) } /* shape key modifier, not yet for curves */ - if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) { + if (ELEM(ob->type, OB_MESH, OB_LATTICE) && BKE_key_from_object(ob)) { if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE)) smd.modifier.mode |= eModifierMode_Editmode | eModifierMode_OnCage; else diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 268234c7e73..97d4c150b84 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -66,6 +66,7 @@ #include "BKE_animsys.h" #include "BKE_constraint.h" +#include "BKE_colortools.h" #include "BKE_library.h" #include "BKE_global.h" #include "BKE_main.h" @@ -73,6 +74,7 @@ #include "BKE_image.h" /* openanim */ #include "BKE_tracking.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_moviecache.h" @@ -197,19 +199,25 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user, struct ImBuf *ibuf; char name[FILE_MAX]; int loadflag, use_proxy = FALSE; + char *colorspace; use_proxy = (flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL; if (use_proxy) { int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT; get_proxy_fname(clip, user->render_size, undistort, framenr, name); + + /* proxies were built using default color space settings */ + colorspace = NULL; } - else + else { get_sequence_fname(clip, framenr, name); + colorspace = clip->colorspace_settings.name; + } loadflag = IB_rect | IB_multilayer; /* read ibuf */ - ibuf = IMB_loadiffname(name, loadflag); + ibuf = IMB_loadiffname(name, loadflag, colorspace); return ibuf; } @@ -223,7 +231,7 @@ static void movieclip_open_anim_file(MovieClip *clip) BLI_path_abs(str, ID_BLEND_PATH(G.main, &clip->id)); /* FIXME: make several stream accessible in image editor, too */ - clip->anim = openanim(str, IB_rect, 0); + clip->anim = openanim(str, IB_rect, 0, clip->colorspace_settings.name); if (clip->anim) { if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) { @@ -383,7 +391,7 @@ static int moviecache_hashcmp(const void *av, const void *bv) return 0; } -void *moviecache_getprioritydata(void *key_v) +static void *moviecache_getprioritydata(void *key_v) { MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *) key_v; MovieClipCachePriorityData *priority_data; @@ -394,7 +402,7 @@ void *moviecache_getprioritydata(void *key_v) return priority_data; } -int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v) +static int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v) { MovieClipImBufCacheKey *last_userkey = (MovieClipImBufCacheKey *) last_userkey_v; MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *) priority_data_v; @@ -402,7 +410,7 @@ int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v) return -abs(last_userkey->framenr - priority_data->framenr); } -void moviecache_prioritydeleter(void *priority_data_v) +static void moviecache_prioritydeleter(void *priority_data_v) { MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *) priority_data_v; @@ -478,6 +486,7 @@ static MovieClip *movieclip_alloc(const char *name) clip->aspx = clip->aspy = 1.0f; BKE_tracking_settings_init(&clip->tracking); + BKE_color_managed_colorspace_settings_init(&clip->colorspace_settings); clip->proxy.build_size_flag = IMB_PROXY_25; clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN | diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f8f2ae86f1d..6fd7a55dd0a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -307,17 +307,27 @@ void BKE_object_free(Object *ob) ID *id = ob->data; id->us--; if (id->us == 0) { - if (ob->type == OB_MESH) BKE_mesh_unlink(ob->data); - else if (ob->type == OB_CURVE) BKE_curve_unlink(ob->data); - else if (ob->type == OB_MBALL) BKE_mball_unlink(ob->data); + switch (ob->type) { + case OB_MESH: + BKE_mesh_unlink((Mesh *)id); + break; + case OB_CURVE: + BKE_curve_unlink((Curve *)id); + break; + case OB_MBALL: + BKE_mball_unlink((MetaBall *)id); + break; + } } ob->data = NULL; } - - for (a = 0; a < ob->totcol; a++) { - if (ob->mat[a]) ob->mat[a]->id.us--; + + if (ob->mat) { + for (a = 0; a < ob->totcol; a++) { + if (ob->mat[a]) ob->mat[a]->id.us--; + } + MEM_freeN(ob->mat); } - if (ob->mat) MEM_freeN(ob->mat); if (ob->matbits) MEM_freeN(ob->matbits); ob->mat = NULL; ob->matbits = NULL; @@ -332,7 +342,7 @@ void BKE_object_free(Object *ob) BKE_pose_free(ob->pose); if (ob->mpath) animviz_free_motionpath(ob->mpath); - free_properties(&ob->prop); + BKE_bproperty_free_list(&ob->prop); BKE_object_free_modifiers(ob); free_sensors(&ob->sensors); @@ -1079,12 +1089,12 @@ static void copy_object_pose(Object *obn, Object *ob) } } -static int object_pose_context(Object *ob) +int BKE_object_pose_context_check(Object *ob) { - if ( (ob) && - (ob->type == OB_ARMATURE) && - (ob->pose) && - (ob->mode & OB_MODE_POSE)) + if ((ob) && + (ob->type == OB_ARMATURE) && + (ob->pose) && + (ob->mode & OB_MODE_POSE)) { return 1; } @@ -1098,12 +1108,12 @@ Object *BKE_object_pose_armature_get(Object *ob) if (ob == NULL) return NULL; - if (object_pose_context(ob)) + if (BKE_object_pose_context_check(ob)) return ob; ob = modifiers_isDeformedByArmature(ob); - if (object_pose_context(ob)) + if (BKE_object_pose_context_check(ob)) return ob; return NULL; @@ -1147,7 +1157,7 @@ Object *BKE_object_copy(Object *ob) } obn->prop.first = obn->prop.last = NULL; - copy_properties(&obn->prop, &ob->prop); + BKE_bproperty_copy_list(&obn->prop, &ob->prop); copy_sensors(&obn->sensors, &ob->sensors); copy_controllers(&obn->controllers, &ob->controllers); @@ -1766,9 +1776,8 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) static void give_parvert(Object *par, int nr, float vec[3]) { BMEditMesh *em; - int a, count; - - vec[0] = vec[1] = vec[2] = 0.0f; + + zero_v3(vec); if (par->type == OB_MESH) { Mesh *me = par->data; @@ -1795,18 +1804,28 @@ static void give_parvert(Object *par, int nr, float vec[3]) dm = (em) ? em->derivedFinal : par->derivedFinal; if (dm) { - MVert *mvert = dm->getVertArray(dm); - int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); - int i, vindex, numVerts = dm->getNumVerts(dm); - - /* get the average of all verts with (original index == nr) */ - count = 0; - for (i = 0; i < numVerts; i++) { - vindex = (index) ? index[i] : i; - - if (vindex == nr) { - add_v3_v3(vec, mvert[i].co); - count++; + int count = 0; + int numVerts = dm->getNumVerts(dm); + + if (nr < numVerts) { + MVert *mvert = dm->getVertArray(dm); + int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); + int i; + + /* get the average of all verts with (original index == nr) */ + if (index) { + for (i = 0; i < numVerts; i++) { + if (index[i] == nr) { + add_v3_v3(vec, mvert[i].co); + count++; + } + } + } + else { + if (nr < numVerts) { + add_v3_v3(vec, mvert[nr].co); + count++; + } } } @@ -1828,71 +1847,31 @@ static void give_parvert(Object *par, int nr, float vec[3]) } } else if (ELEM(par->type, OB_CURVE, OB_SURF)) { - Nurb *nu; - Curve *cu; - BPoint *bp; - BezTriple *bezt; - int found = 0; - ListBase *nurbs; - - cu = par->data; - nurbs = BKE_curve_nurbs_get(cu); - nu = nurbs->first; - - count = 0; - while (nu && !found) { - if (nu->type == CU_BEZIER) { - bezt = nu->bezt; - a = nu->pntsu; - while (a--) { - if (count == nr) { - found = 1; - copy_v3_v3(vec, bezt->vec[1]); - break; - } - count++; - bezt++; - } - } - else { - bp = nu->bp; - a = nu->pntsu * nu->pntsv; - while (a--) { - if (count == nr) { - found = 1; - memcpy(vec, bp->vec, sizeof(float) * 3); - break; - } - count++; - bp++; - } - } - nu = nu->next; - } + Curve *cu = par->data; + ListBase *nurb = BKE_curve_nurbs_get(cu);; + BKE_nurbList_index_get_co(nurb, nr, vec); } else if (par->type == OB_LATTICE) { - Lattice *latt = par->data; - BPoint *bp; - DispList *dl = BKE_displist_find(&par->disp, DL_VERTS); - float *co = dl ? dl->verts : NULL; - + Lattice *latt = par->data; + DispList *dl = BKE_displist_find(&par->disp, DL_VERTS); + float (*co)[3] = dl ? (float (*)[3])dl->verts : NULL; + int tot; + if (latt->editlatt) latt = latt->editlatt->latt; - - a = latt->pntsu * latt->pntsv * latt->pntsw; - count = 0; - bp = latt->def; - while (a--) { - if (count == nr) { - if (co) - memcpy(vec, co, 3 * sizeof(float)); - else - memcpy(vec, bp->vec, 3 * sizeof(float)); - break; + + tot = latt->pntsu * latt->pntsv * latt->pntsw; + + /* ensure dl is correct size */ + BLI_assert(dl == NULL || dl->nr == tot); + + if (nr < tot) { + if (co) { + copy_v3_v3(vec, co[nr]); + } + else { + copy_v3_v3(vec, latt->def[nr].vec); } - count++; - if (co) co += 3; - else bp++; } } } @@ -2899,22 +2878,22 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int int newkey = 0; if (key == NULL) { - key = me->key = add_key((ID *)me); + key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; newkey = 1; } if (newkey || from_mix == FALSE) { /* create from mesh */ - kb = add_keyblock_ctime(key, name, FALSE); - mesh_to_key(me, kb); + kb = BKE_keyblock_add_ctime(key, name, FALSE); + BKE_key_convert_from_mesh(me, kb); } else { /* copy from current values */ float *data = do_ob_key(scene, ob); /* create new block with prepared data */ - kb = add_keyblock_ctime(key, name, FALSE); + kb = BKE_keyblock_add_ctime(key, name, FALSE); kb->data = data; kb->totelem = me->totvert; } @@ -2930,20 +2909,20 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int int newkey = 0; if (key == NULL) { - key = lt->key = add_key((ID *)lt); + key = lt->key = BKE_key_add((ID *)lt); key->type = KEY_RELATIVE; newkey = 1; } if (newkey || from_mix == FALSE) { - kb = add_keyblock_ctime(key, name, FALSE); + kb = BKE_keyblock_add_ctime(key, name, FALSE); if (!newkey) { KeyBlock *basekb = (KeyBlock *)key->block.first; kb->data = MEM_dupallocN(basekb->data); kb->totelem = basekb->totelem; } else { - latt_to_key(lt, kb); + BKE_key_convert_from_lattice(lt, kb); } } else { @@ -2951,7 +2930,7 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int float *data = do_ob_key(scene, ob); /* create new block with prepared data */ - kb = add_keyblock_ctime(key, name, FALSE); + kb = BKE_keyblock_add_ctime(key, name, FALSE); kb->totelem = lt->pntsu * lt->pntsv * lt->pntsw; kb->data = data; } @@ -2968,21 +2947,21 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int int newkey = 0; if (key == NULL) { - key = cu->key = add_key((ID *)cu); + key = cu->key = BKE_key_add((ID *)cu); key->type = KEY_RELATIVE; newkey = 1; } if (newkey || from_mix == FALSE) { /* create from curve */ - kb = add_keyblock_ctime(key, name, FALSE); + kb = BKE_keyblock_add_ctime(key, name, FALSE); if (!newkey) { KeyBlock *basekb = (KeyBlock *)key->block.first; kb->data = MEM_dupallocN(basekb->data); kb->totelem = basekb->totelem; } else { - curve_to_key(cu, kb, lb); + BKE_key_convert_from_curve(cu, kb, lb); } } else { @@ -2990,7 +2969,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int float *data = do_ob_key(scene, ob); /* create new block with prepared data */ - kb = add_keyblock_ctime(key, name, FALSE); + kb = BKE_keyblock_add_ctime(key, name, FALSE); kb->totelem = BKE_nurbList_verts_count(lb); kb->data = data; } @@ -3020,7 +2999,7 @@ int BKE_object_is_modified(Scene *scene, Object *ob) { int flag = 0; - if (ob_get_key(ob)) { + if (BKE_key_from_object(ob)) { flag |= eModifierMode_Render; } else { @@ -3288,7 +3267,7 @@ void BKE_object_groups_clear(Scene *scene, Base *base, Object *object) { Group *group = NULL; - BLI_assert(base->object == object); + BLI_assert((base == NULL) || (base->object == object)); if (scene && base == NULL) { base = BKE_scene_base_find(scene, object); diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index b862a824d50..4f3921936e8 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -1117,19 +1117,20 @@ void BKE_simulate_ocean_cache(struct OceanCache *och, int frame) /* if image is already loaded in mem, return */ if (och->ibufs_disp[f] != NULL) return; + /* use default color spaces since we know for sure cache files were saved with default settings too */ cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE); - och->ibufs_disp[f] = IMB_loadiffname(string, 0); + och->ibufs_disp[f] = IMB_loadiffname(string, 0, NULL); //if (och->ibufs_disp[f] == NULL) printf("error loading %s\n", string); //else printf("loaded cache %s\n", string); cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM); - och->ibufs_foam[f] = IMB_loadiffname(string, 0); + och->ibufs_foam[f] = IMB_loadiffname(string, 0, NULL); //if (och->ibufs_foam[f] == NULL) printf("error loading %s\n", string); //else printf("loaded cache %s\n", string); cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL); - och->ibufs_norm[f] = IMB_loadiffname(string, 0); + och->ibufs_norm[f] = IMB_loadiffname(string, 0, NULL); //if (och->ibufs_norm[f] == NULL) printf("error loading %s\n", string); //else printf("loaded cache %s\n", string); } @@ -1172,8 +1173,6 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v ibuf_disp = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat); ibuf_normal = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat); - ibuf_disp->profile = ibuf_foam->profile = ibuf_normal->profile = IB_PROFILE_LINEAR_RGB; - BKE_simulate_ocean(o, och->time[i], och->wave_scale, och->chop_amount); /* add new foam */ diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 26952db8fba..ef03db7ed8f 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4539,8 +4539,8 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] /* can happen with bad pointcache or physics calculation * since this becomes geometry, nan's and inf's crash raytrace code. * better not allow this. */ - if (!finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) || - !finite(bb->vel[0]) || !finite(bb->vel[1]) || !finite(bb->vel[2]) ) + if ((!finite(bb->vec[0])) || (!finite(bb->vec[1])) || (!finite(bb->vec[2])) || + (!finite(bb->vel[0])) || (!finite(bb->vel[1])) || (!finite(bb->vel[2])) ) { zero_v3(bb->vec); zero_v3(bb->vel); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index bae8efa758e..2c0452bc2d1 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3776,7 +3776,7 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra)) * simulation. This should be called once per particle during a simulation * step, after the velocity has been updated. element_size defines the scale of * the simulation, and is typically the distance to neighbourning particles. */ -void update_courant_num(ParticleSimulationData *sim, ParticleData *pa, +static void update_courant_num(ParticleSimulationData *sim, ParticleData *pa, float dtime, SPHData *sphdata) { float relative_vel[3]; @@ -3788,8 +3788,7 @@ void update_courant_num(ParticleSimulationData *sim, ParticleData *pa, sim->courant_num = speed * dtime / sphdata->element_size; } /* Update time step size to suit current conditions. */ -float update_timestep(ParticleSystem *psys, ParticleSimulationData *sim, - float t_frac) +static float update_timestep(ParticleSystem *psys, ParticleSimulationData *sim, float t_frac) { if (sim->courant_num == 0.0f) psys->dt_frac = 1.0f; diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index 46ddce4b51b..8da4f11fed3 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -27,9 +27,12 @@ /** \file blender/blenkernel/intern/property.c * \ingroup bke + * + * This module deals with bProperty only, + * they are used on blender objects in the game engine + * (where they get converted into C++ classes - CValue and subclasses) */ - #include <stdio.h> #include <stdlib.h> #include <stddef.h> @@ -45,7 +48,7 @@ #include "BKE_property.h" -void free_property(bProperty *prop) +void BKE_bproperty_free(bProperty *prop) { if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin); @@ -53,17 +56,17 @@ void free_property(bProperty *prop) } -void free_properties(ListBase *lb) +void BKE_bproperty_free_list(ListBase *lb) { bProperty *prop; while ( (prop = lb->first) ) { BLI_remlink(lb, prop); - free_property(prop); + BKE_bproperty_free(prop); } } -bProperty *copy_property(bProperty *prop) +bProperty *BKE_bproperty_copy(bProperty *prop) { bProperty *propn; @@ -76,13 +79,13 @@ bProperty *copy_property(bProperty *prop) return propn; } -void copy_properties(ListBase *lbn, ListBase *lbo) +void BKE_bproperty_copy_list(ListBase *lbn, ListBase *lbo) { bProperty *prop, *propn; - free_properties(lbn); /* in case we are copying to an object with props */ + BKE_bproperty_free_list(lbn); /* in case we are copying to an object with props */ prop = lbo->first; while (prop) { - propn = copy_property(prop); + propn = BKE_bproperty_copy(prop); BLI_addtail(lbn, propn); prop = prop->next; } @@ -90,7 +93,7 @@ void copy_properties(ListBase *lbn, ListBase *lbo) } -void init_property(bProperty *prop) +void BKE_bproperty_init(bProperty *prop) { /* also use when property changes type */ @@ -113,22 +116,22 @@ void init_property(bProperty *prop) } -bProperty *new_property(int type) +bProperty *BKE_bproperty_new(int type) { bProperty *prop; prop = MEM_callocN(sizeof(bProperty), "property"); prop->type = type; - init_property(prop); + BKE_bproperty_init(prop); strcpy(prop->name, "prop"); return prop; } -/* used by unique_property() only */ -static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name) +/* used by BKE_bproperty_unique() only */ +static bProperty *bproperty_get(bProperty *first, bProperty *self, const char *name) { bProperty *p; for (p = first; p; p = p->next) { @@ -137,7 +140,7 @@ static bProperty *get_property__internal(bProperty *first, bProperty *self, cons } return NULL; } -void unique_property(bProperty *first, bProperty *prop, int force) +void BKE_bproperty_unique(bProperty *first, bProperty *prop, int force) { bProperty *p; @@ -151,13 +154,13 @@ void unique_property(bProperty *first, bProperty *prop, int force) if (force) { /* change other names to make them unique */ - while ((p = get_property__internal(first, prop, prop->name))) { - unique_property(first, p, 0); + while ((p = bproperty_get(first, prop, prop->name))) { + BKE_bproperty_unique(first, p, 0); } } else { /* change our own name until its unique */ - if (get_property__internal(first, prop, prop->name)) { + if (bproperty_get(first, prop, prop->name)) { /* there is a collision */ char new_name[sizeof(prop->name)]; char base_name[sizeof(prop->name)]; @@ -175,33 +178,34 @@ void unique_property(bProperty *first, bProperty *prop, int force) BLI_snprintf(num, sizeof(num), "%d", i++); BLI_strncpy(new_name, base_name, sizeof(prop->name) - strlen(num)); strcat(new_name, num); - } while (get_property__internal(first, prop, new_name)); + } while (bproperty_get(first, prop, new_name)); BLI_strncpy(prop->name, new_name, sizeof(prop->name)); } } } -bProperty *get_ob_property(Object *ob, const char *name) +bProperty *BKE_bproperty_object_get(Object *ob, const char *name) { return BLI_findstring(&ob->prop, name, offsetof(bProperty, name)); } -void set_ob_property(Object *ob, bProperty *propc) +void BKE_bproperty_object_set(Object *ob, bProperty *propc) { bProperty *prop; - prop = get_ob_property(ob, propc->name); + prop = BKE_bproperty_object_get(ob, propc->name); if (prop) { - free_property(prop); + BKE_bproperty_free(prop); BLI_remlink(&ob->prop, prop); } - BLI_addtail(&ob->prop, copy_property(propc)); + BLI_addtail(&ob->prop, BKE_bproperty_copy(propc)); } /* negative: prop is smaller * positive: prop is larger */ -int compare_property(bProperty *prop, const char *str) +#if 0 /* UNUSED */ +int BKE_bproperty_cmp(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ float fvalue, ftest; @@ -237,8 +241,9 @@ int compare_property(bProperty *prop, const char *str) return 0; } +#endif -void set_property(bProperty *prop, const char *str) +void BKE_bproperty_set(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ @@ -262,7 +267,7 @@ void set_property(bProperty *prop, const char *str) } -void add_property(bProperty *prop, const char *str) +void BKE_bproperty_add(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ @@ -282,7 +287,7 @@ void add_property(bProperty *prop, const char *str) } /* reads value of property, sets it in chars in str */ -void set_property_valstr(bProperty *prop, char *str) +void BKE_bproperty_set_valstr(bProperty *prop, char *str) { // extern int Gdfra; /* sector.c */ @@ -303,11 +308,13 @@ void set_property_valstr(bProperty *prop, char *str) } } +#if 0 /* UNUSED */ void cp_property(bProperty *prop1, bProperty *prop2) { char str[128]; - set_property_valstr(prop2, str); + BKE_bproperty_set_valstr(prop2, str); - set_property(prop1, str); + BKE_bproperty_set(prop1, str); } +#endif diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 7d9d2f02c06..6c1fbbfa9a0 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -210,7 +210,7 @@ void unlink_controllers(ListBase *lb) bController *cont; for (cont= lb->first; cont; cont= cont->next) - unlink_controller(cont); + unlink_controller(cont); } void free_controller(bController *cont) @@ -536,7 +536,7 @@ void clear_sca_new_poins(void) ob= G.main->object.first; while (ob) { clear_sca_new_poins_ob(ob); - ob= ob->id.next; + ob= ob->id.next; } } @@ -624,7 +624,7 @@ void set_sca_new_poins(void) ob= G.main->object.first; while (ob) { set_sca_new_poins_ob(ob); - ob= ob->id.next; + ob= ob->id.next; } } @@ -696,7 +696,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob) if (sta->target == ob) sta->target = NULL; } act= act->next; - } + } } /* ******************** INTERFACE ******************* */ @@ -875,3 +875,20 @@ void unlink_logicbricks(void **poin, void ***ppoin, short *tot) return; } } + +const char *sca_state_name_get(Object *ob, short bit) +{ + bController *cont; + unsigned int mask; + + mask = (1<<bit); + cont = ob->controllers.first; + while (cont) { + if (cont->state_mask & mask) { + return cont->name; + } + cont = cont->next; + } + return NULL; +} + diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 66647a994bc..0c0396ea758 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -57,6 +57,7 @@ #include "BKE_anim.h" #include "BKE_animsys.h" +#include "BKE_colortools.h" #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_group.h" @@ -76,6 +77,8 @@ #include "RE_engine.h" +#include "IMB_colormanagement.h" + //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" @@ -169,6 +172,11 @@ Scene *BKE_scene_copy(Scene *sce, int type) obase = obase->next; base = base->next; } + + /* copy color management settings */ + BKE_color_managed_display_settings_copy(&scen->display_settings, &sce->display_settings); + BKE_color_managed_view_settings_copy(&scen->view_settings, &sce->view_settings); + BKE_color_managed_view_settings_copy(&scen->r.im_format.view_settings, &sce->r.im_format.view_settings); } /* tool settings */ @@ -339,6 +347,8 @@ void BKE_scene_free(Scene *sce) MEM_freeN(sce->fps_info); sound_destroy_scene(sce); + + BKE_color_managed_view_settings_free(&sce->view_settings); } Scene *BKE_scene_add(const char *name) @@ -379,7 +389,14 @@ Scene *BKE_scene_add(const char *name) sce->r.frs_sec_base = 1; sce->r.edgeint = 10; sce->r.ocres = 128; + + /* OCIO_TODO: for forwards compatibiliy only, so if no tonecurve are used, + * images would look in the same way as in current blender + * + * perhaps at some point should be completely deprecated? + */ sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; + sce->r.gauss = 1.0; /* deprecated but keep for upwards compat */ @@ -553,6 +570,9 @@ Scene *BKE_scene_add(const char *name) sound_create_scene(sce); + BKE_color_managed_display_settings_init(&sce->display_settings); + BKE_color_managed_view_settings_init(&sce->view_settings); + return sce; } @@ -1248,3 +1268,19 @@ void BKE_scene_base_flag_from_objects(struct Scene *scene) base = base->next; } } + +void BKE_scene_disable_color_management(Scene *scene) +{ + ColorManagedDisplaySettings *display_settings = &scene->display_settings; + ColorManagedViewSettings *view_settings = &scene->view_settings; + const char *view; + + /* NOTE: None display with Default view should always exist in OCIO configuration, otherwise it wouldn't work as expected */ + BLI_strncpy(display_settings->display_device, "None", sizeof(display_settings->display_device)); + + view = IMB_colormanagement_view_get_default_name(display_settings->display_device); + + if (view) { + BLI_strncpy(view_settings->view_transform, view, sizeof(view_settings->view_transform)); + } +} diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 4dbe0b6290c..eaf3ec384c8 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -52,6 +52,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" #include "RNA_access.h" @@ -119,13 +120,13 @@ static ImBuf *prepare_effect_imbufs(SeqRenderData context, ImBuf *ibuf1, ImBuf * } if (ibuf1 && !ibuf1->rect_float && out->rect_float) { - IMB_float_from_rect_simple(ibuf1); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf1, TRUE); } if (ibuf2 && !ibuf2->rect_float && out->rect_float) { - IMB_float_from_rect_simple(ibuf2); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf2, TRUE); } if (ibuf3 && !ibuf3->rect_float && out->rect_float) { - IMB_float_from_rect_simple(ibuf3); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf3, TRUE); } if (ibuf1 && !ibuf1->rect && !out->rect_float) { @@ -137,7 +138,7 @@ static ImBuf *prepare_effect_imbufs(SeqRenderData context, ImBuf *ibuf1, ImBuf * if (ibuf3 && !ibuf3->rect && !out->rect_float) { IMB_rect_from_float(ibuf3); } - + return out; } diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index 6028b40756d..b0dcad64722 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -140,7 +140,7 @@ static void modifier_apply_threaded(ImBuf *ibuf, ImBuf *mask, modifier_apply_thr /* **** Color Balance Modifier **** */ -void colorBalance_init_data(SequenceModifierData *smd) +static void colorBalance_init_data(SequenceModifierData *smd) { ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *) smd; int c; @@ -154,7 +154,7 @@ void colorBalance_init_data(SequenceModifierData *smd) } } -void colorBalance_apply(SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +static void colorBalance_apply(SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) { ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *) smd; @@ -173,21 +173,21 @@ static SequenceModifierTypeInfo seqModifier_ColorBalance = { /* **** Curves Modifier **** */ -void curves_init_data(SequenceModifierData *smd) +static void curves_init_data(SequenceModifierData *smd) { CurvesModifierData *cmd = (CurvesModifierData *) smd; curvemapping_set_defaults(&cmd->curve_mapping, 4, 0.0f, 0.0f, 1.0f, 1.0f); } -void curves_free_data(SequenceModifierData *smd) +static void curves_free_data(SequenceModifierData *smd) { CurvesModifierData *cmd = (CurvesModifierData *) smd; curvemapping_free_data(&cmd->curve_mapping); } -void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd) +static void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd) { CurvesModifierData *cmd = (CurvesModifierData *) smd; CurvesModifierData *cmd_target = (CurvesModifierData *) target; @@ -195,8 +195,8 @@ void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd) curvemapping_copy_data(&cmd_target->curve_mapping, &cmd->curve_mapping); } -void curves_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, - unsigned char *mask_rect, float *mask_rect_float, void *data_v) +static void curves_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, + unsigned char *mask_rect, float *mask_rect_float, void *data_v) { CurveMapping *curve_mapping = (CurveMapping *) data_v; int x, y; @@ -249,7 +249,7 @@ void curves_apply_threaded(int width, int height, unsigned char *rect, float *re } } -void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +static void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) { CurvesModifierData *cmd = (CurvesModifierData *) smd; @@ -278,7 +278,7 @@ static SequenceModifierTypeInfo seqModifier_Curves = { /* **** Hue Correct Modifier **** */ -void hue_correct_init_data(SequenceModifierData *smd) +static void hue_correct_init_data(SequenceModifierData *smd) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; int c; @@ -296,14 +296,14 @@ void hue_correct_init_data(SequenceModifierData *smd) hcmd->curve_mapping.cur = 1; } -void hue_correct_free_data(SequenceModifierData *smd) +static void hue_correct_free_data(SequenceModifierData *smd) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; curvemapping_free_data(&hcmd->curve_mapping); } -void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *smd) +static void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *smd) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; HueCorrectModifierData *hcmd_target = (HueCorrectModifierData *) target; @@ -311,7 +311,7 @@ void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *s curvemapping_copy_data(&hcmd_target->curve_mapping, &hcmd->curve_mapping); } -void hue_correct_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, +static void hue_correct_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, unsigned char *mask_rect, float *mask_rect_float, void *data_v) { CurveMapping *curve_mapping = (CurveMapping *) data_v; @@ -365,7 +365,7 @@ void hue_correct_apply_threaded(int width, int height, unsigned char *rect, floa } } -void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +static void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; @@ -391,8 +391,8 @@ typedef struct BrightContrastThreadData { float contrast; } BrightContrastThreadData; -void brightcontrast_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, - unsigned char *mask_rect, float *mask_rect_float, void *data_v) +static void brightcontrast_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, + unsigned char *mask_rect, float *mask_rect_float, void *data_v) { BrightContrastThreadData *data = (BrightContrastThreadData *) data_v; int x, y; @@ -460,7 +460,7 @@ void brightcontrast_apply_threaded(int width, int height, unsigned char *rect, f } } -void brightcontrast_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +static void brightcontrast_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) { BrightContrastModifierData *bcmd = (BrightContrastModifierData *) smd; BrightContrastThreadData data; @@ -581,6 +581,11 @@ ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, I SequenceModifierData *smd; ImBuf *processed_ibuf = ibuf; + if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) { + processed_ibuf = IMB_dupImBuf(ibuf); + BKE_sequencer_imbuf_from_sequencer_space(context.scene, processed_ibuf); + } + for (smd = seq->modifiers.first; smd; smd = smd->next) { SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); @@ -605,6 +610,10 @@ ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, I } } + if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) { + BKE_sequencer_imbuf_to_sequencer_space(context.scene, processed_ibuf, FALSE); + } + return processed_ibuf; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 2596bf57f05..8d7ca94ed48 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -71,6 +71,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" #include "BKE_context.h" #include "BKE_sound.h" @@ -308,6 +309,81 @@ void BKE_sequencer_editing_free(Scene *scene) scene->ed = NULL; } +/*********************** Sequencer color space functions *************************/ + +static void sequencer_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf) +{ + IMB_colormanagement_imbuf_assign_float_space(ibuf, &scene->sequencer_colorspace_settings); +} + +void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, int make_float) +{ + const char *from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR); + const char *to_colorspace = scene->sequencer_colorspace_settings.name; + int predivide = ibuf->flags & IB_cm_predivide; + + if (!ibuf->rect_float) { + if (make_float && ibuf->rect) { + /* when converting byte buffer to float in sequencer we need to make float + * buffer be in sequencer's working space, which is currently only doable + * from linear space. + * + */ + + /* + * OCIO_TODO: would be nice to support direct single transform from byte to sequencer's + */ + + IMB_float_from_rect(ibuf); + } + else { + /* if there's only byte buffer in image it's already in compositor's working space, + * nothing to do here + */ + + return; + } + } + + if (from_colorspace && from_colorspace[0] != '\0') { + if (ibuf->rect) + imb_freerectImBuf(ibuf); + + IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, + from_colorspace, to_colorspace, predivide); + } +} + +void BKE_sequencer_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf) +{ + const char *from_colorspace = scene->sequencer_colorspace_settings.name; + const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR); + + if (!ibuf->rect_float) + return; + + if (to_colorspace && to_colorspace[0] != '\0') { + int predivide = ibuf->flags & IB_cm_predivide; + + IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, + from_colorspace, to_colorspace, predivide); + } +} + +void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4]) +{ + const char *from_colorspace = scene->sequencer_colorspace_settings.name; + const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR); + + if (to_colorspace && to_colorspace[0] != '\0') { + IMB_colormanagement_transform_v4(pixel, from_colorspace, to_colorspace); + } + else { + /* if no color management enables fallback to legacy conversion */ + srgb_to_linearrgb_v4(pixel, pixel); + } +} + /*********************** sequencer pipeline functions *************************/ SeqRenderData BKE_sequencer_new_render_data(Main *bmain, Scene *scene, int rectx, int recty, int preview_render_size) @@ -597,7 +673,9 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range) BLI_path_abs(str, G.main->name); if (seq->anim) IMB_free_anim(seq->anim); - seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex); + + /* OCIO_TODO: support configurable input space for strips */ + seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL); if (!seq->anim) { return; @@ -1094,7 +1172,8 @@ static void seq_open_anim_file(Sequence *seq) seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(name, G.main->name); - seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex); + /* OCIO_TODO: support configurable input space for strips */ + seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL); if (seq->anim == NULL) { return; @@ -1200,8 +1279,9 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra) if (seq_proxy_get_fname(seq, cfra, render_size, name) == 0) { return NULL; } - - seq->strip->proxy->anim = openanim(name, IB_rect, 0); + + /* proxies are generated in default color space */ + seq->strip->proxy->anim = openanim(name, IB_rect, 0, NULL); } if (seq->strip->proxy->anim == NULL) { return NULL; @@ -1219,7 +1299,13 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra) } if (BLI_exists(name)) { - return IMB_loadiffname(name, IB_rect); + /* OCIO_TODO: support configurable spaces for strips */ + ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL); + + if (ibuf) + sequencer_imbuf_assign_spaces(context.scene, ibuf); + + return ibuf; } else { return NULL; @@ -1257,7 +1343,8 @@ static void seq_proxy_build_frame(SeqRenderData context, Sequence *seq, int cfra ibuf->planes = 24; BLI_make_existing_file(name); - + + /* OCIO_TODO: support per-strip color space settings */ ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == 0) { perror(name); @@ -1706,7 +1793,7 @@ int BKE_sequencer_input_have_to_preprocess(SeqRenderData UNUSED(context), Sequen { float mul; - if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_PREMUL)) { + if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_PREMUL | SEQ_MAKE_FLOAT)) { return TRUE; } @@ -1826,8 +1913,9 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, } if (seq->flag & SEQ_MAKE_FLOAT) { - if (!ibuf->rect_float) - IMB_float_from_rect_simple(ibuf); + if (!ibuf->rect_float) { + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, TRUE); + } if (ibuf->rect) { imb_freerectImBuf(ibuf); @@ -1893,6 +1981,8 @@ static void copy_to_ibuf_still(SeqRenderData context, Sequence *seq, float nr, I * changing the cached image... */ ibuf = IMB_dupImBuf(ibuf); + sequencer_imbuf_assign_spaces(context.scene, ibuf); + if (nr == 0) { BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); } @@ -2307,7 +2397,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float /* opengl offscreen render */ BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty, - IB_rect, context.scene->r.seq_prev_type, TRUE, err_out); + IB_rect, context.scene->r.seq_prev_type, TRUE, FALSE, err_out); if (ibuf == NULL) { fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out); } @@ -2338,11 +2428,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float } /* float buffers in the sequencer are not linear */ - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - else - ibuf->profile = IB_PROFILE_NONE; - IMB_convert_profile(ibuf, IB_PROFILE_SRGB); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE); } else if (rres.rect32) { ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect); @@ -2442,14 +2528,14 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo BLI_path_abs(name, G.main->name); } - if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect))) { + /* OCIO_TODO: support configurable space for image strips */ + if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, NULL))) { /* we don't need both (speed reasons)! */ if (ibuf->rect_float && ibuf->rect) imb_freerectImBuf(ibuf); /* all sequencer color is done in SRGB space, linear gives odd crossfades */ - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) - IMB_convert_profile(ibuf, IB_PROFILE_NONE); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE); copy_to_ibuf_still(context, seq, nr, ibuf); @@ -2497,6 +2583,7 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo case SEQ_TYPE_MOVIECLIP: { ibuf = seq_render_movieclip_strip(context, seq, nr); + sequencer_imbuf_assign_spaces(context.scene, ibuf); if (ibuf && use_preprocess) { ImBuf *i = IMB_dupImBuf(ibuf); @@ -2520,6 +2607,9 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo } } + if (ibuf) + sequencer_imbuf_assign_spaces(context.scene, ibuf); + return ibuf; } @@ -2561,8 +2651,10 @@ static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra) } } - if (ibuf == NULL) + if (ibuf == NULL) { ibuf = IMB_allocImBuf(context.rectx, context.recty, 32, IB_rect); + sequencer_imbuf_assign_spaces(context.scene, ibuf); + } if (ibuf->x != context.rectx || ibuf->y != context.recty) use_preprocess = TRUE; @@ -2641,12 +2733,12 @@ static ImBuf *seq_render_strip_stack(SeqRenderData context, ListBase *seqbasep, if (count == 1) { out = seq_render_strip(context, seq_arr[0], cfra); + BKE_sequencer_cache_put(context, seq_arr[0], cfra, SEQ_STRIPELEM_IBUF_COMP, out); return out; } - for (i = count - 1; i >= 0; i--) { int early_out; Sequence *seq = seq_arr[i]; @@ -3946,7 +4038,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad BLI_strncpy(path, seq_load->path, sizeof(path)); BLI_path_abs(path, G.main->name); - an = openanim(path, IB_rect, 0); + /* OCIO_TODO: support configurable input space for strips */ + an = openanim(path, IB_rect, 0, NULL); if (an == NULL) return NULL; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index ddcba509301..5e67e094e43 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -80,10 +80,10 @@ /* UNUSED so far, may be enabled later */ /* #define USE_SMOKE_COLLISION_DM */ -#ifdef WITH_SMOKE - #include "smoke_API.h" +#ifdef WITH_SMOKE + #ifdef _WIN32 #include <time.h> #include <stdio.h> @@ -148,7 +148,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) /* Stubs to use when smoke is disabled */ struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype)) { return NULL; } -struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { return NULL; } +// struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { return NULL; } void smoke_free(struct FLUID_3D *UNUSED(fluid)) {} float *smoke_get_density(struct FLUID_3D *UNUSED(fluid)) { return NULL; } void smoke_turbulence_free(struct WTURBULENCE *UNUSED(wt)) {} diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 4a88bfbfdad..4c28fe01895 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -143,7 +143,9 @@ typedef struct SB_thread_context { } SB_thread_context; #define NLF_BUILD 1 -#define NLF_SOLVE 2 +#if 0 +# define NLF_SOLVE 2 +#endif #define MID_PRESERVE 1 diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index f340bcb5b1e..385d1bb6fc5 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -792,7 +792,6 @@ void sound_stop_scene(struct Scene *UNUSED(scene)) {} void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {} float sound_sync_scene(struct Scene *UNUSED(scene)) { return NAN_FLT; } int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; } -int sound_read_sound_buffer(struct bSound *UNUSED(sound), float *UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; } void sound_read_waveform(struct bSound *sound) { (void)sound; } void sound_init_main(struct Main *bmain) { (void)bmain; } void sound_set_cfra(int cfra) { (void)cfra; } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 5c8192b2a62..facf0793f87 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -513,10 +513,14 @@ static float *get_ss_weights(WeightTable *wtable, int gridCuts, int faceLen) w2 = (1.0f - fx + fac2 * fx * -fac) * (fy); w4 = (fx) * (1.0f - fy + -fac2 * fy * fac); - fac2 = 1.0f - (w1 + w2 + w4); - fac2 = fac2 / (float)(faceLen - 3); - for (j = 0; j < faceLen; j++) - w[j] = fac2; + /* these values aren't used for tri's and cause divide by zero */ + if (faceLen > 3) { + fac2 = 1.0f - (w1 + w2 + w4); + fac2 = fac2 / (float)(faceLen - 3); + for (j = 0; j < faceLen; j++) { + w[j] = fac2; + } + } w[i] = w1; w[(i - 1 + faceLen) % faceLen] = w2; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 787def5c20b..1f1d609ae42 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1919,6 +1919,7 @@ static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, s break; case 4: /* 32-bit unicode symbol */ unicode = txt_undo_read_uint32(undo_buf, undo_pos); + break; default: /* should never happen */ BLI_assert(0); @@ -1970,6 +1971,7 @@ static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, s break; case 4: /* 32-bit unicode symbol */ unicode = txt_undo_read_uint32(undo_buf, undo_pos); + break; default: /* should never happen */ BLI_assert(0); @@ -3031,30 +3033,6 @@ void txt_uncomment(Text *text) } } - -void txt_move_lines_up(struct Text *text) -{ - TextLine *prev_line; - - if (!text || !text->curl || !text->sell) return; - - txt_order_cursors(text); - - prev_line = text->curl->prev; - - if (!prev_line) return; - - BLI_remlink(&text->lines, prev_line); - BLI_insertlinkafter(&text->lines, text->sell, prev_line); - - txt_make_dirty(text); - txt_clean_text(text); - - if (!undoing) { - txt_undo_add_op(text, UNDO_MOVE_LINES_UP); - } -} - void txt_move_lines(struct Text *text, const int direction) { TextLine *line_other; @@ -3094,7 +3072,6 @@ int setcurr_tab_spaces(Text *text, int space) const char *comm = "#"; const char indent = (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t'; static const char *back_words[] = {"return", "break", "continue", "pass", "yield", NULL}; - if (!text) return 0; if (!text->curl) return 0; while (text->curl->line[i] == indent) { diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index ee904de4af6..bdd9b424f3b 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -338,7 +338,7 @@ void colorband_table_RGBA(ColorBand *coba, float **array, int *size) do_colorband(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]); } -int vergcband(const void *a1, const void *a2) +static int vergcband(const void *a1, const void *a2) { const CBData *x1 = a1, *x2 = a2; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 2ed9d992c3f..337f1b5d248 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -856,7 +856,7 @@ static void track_mask_gpencil_layer_rasterize(int frame_width, int frame_height } /* TODO: add an option to control whether AA is enabled or not */ - PLX_raskterize((float (*)[2])mask_points, stroke->totpoints, mask, mask_width, mask_height, FALSE); + PLX_raskterize((float (*)[2])mask_points, stroke->totpoints, mask, mask_width, mask_height); MEM_freeN(mask_points); } @@ -1043,14 +1043,6 @@ void BKE_tracking_marker_clamp(MovieTrackingMarker *marker, int event) } } } - else if (event == CLAMP_SEARCH_DIM) { - float dim[2]; - sub_v2_v2v2(dim, pat_max, pat_min); - for (a = 0; a < 2; a++) { - marker->search_min[a] = pat_min[a]; - marker->search_max[a] = pat_max[a]; - } - } } MovieTrackingMarker *BKE_tracking_marker_get(MovieTrackingTrack *track, int framenr) @@ -1627,7 +1619,6 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea float *mask = NULL; pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat); - pattern_ibuf->profile = IB_PROFILE_LINEAR_RGB; if (!search_ibuf->rect_float) { IMB_float_from_rect(search_ibuf); @@ -1722,7 +1713,6 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mov h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y; searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect); - searchibuf->profile = ibuf->profile; IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h); @@ -2031,7 +2021,7 @@ static void track_context_free(void *customdata) { TrackContext *track_context = (TrackContext *)customdata; -#if WITH_LIBMV +#ifdef WITH_LIBMV if (track_context->search_area) MEM_freeN(track_context->search_area); @@ -2225,8 +2215,8 @@ static ImBuf *tracking_context_get_frame_ibuf(MovieTrackingContext *context, int return ibuf; } -MovieTrackingMarker *tracking_context_get_keyframed_marker(MovieTrackingContext *context, MovieTrackingTrack *track, - MovieTrackingMarker *marker) +static MovieTrackingMarker *tracking_context_get_keyframed_marker(MovieTrackingContext *context, MovieTrackingTrack *track, + MovieTrackingMarker *marker) { int a = marker - track->markers; MovieTrackingMarker *marker_keyed = marker; @@ -2291,9 +2281,9 @@ static ImBuf *tracking_context_get_reference_ibuf(MovieTrackingContext *context, return ibuf; } -static void track_context_update_reference(MovieTrackingContext *context, TrackContext *track_context, - MovieTrackingTrack *track, MovieTrackingMarker *marker, int curfra, - int frame_width, int frame_height) +static int track_context_update_reference(MovieTrackingContext *context, TrackContext *track_context, + MovieTrackingTrack *track, MovieTrackingMarker *marker, int curfra, + int frame_width, int frame_height) { MovieTrackingMarker *marker_keyed = NULL; ImBuf *reference_ibuf = NULL; @@ -2301,6 +2291,10 @@ static void track_context_update_reference(MovieTrackingContext *context, TrackC /* calculate patch for keyframed position */ reference_ibuf = tracking_context_get_reference_ibuf(context, track, marker, curfra, &marker_keyed); + + if (!reference_ibuf) + return FALSE; + track_context->marker = *marker_keyed; if (track_context->search_area) { @@ -2319,6 +2313,8 @@ static void track_context_update_reference(MovieTrackingContext *context, TrackC } IMB_freeImBuf(reference_ibuf); + + return TRUE; } static void tracking_configure_tracker(TrackContext *track_context, MovieTrackingTrack *track, @@ -2483,8 +2479,12 @@ int BKE_tracking_context_step(MovieTrackingContext *context) float *patch_new; if (need_readjust) { - track_context_update_reference(context, track_context, track, marker, - curfra, frame_width, frame_height); + if (track_context_update_reference(context, track_context, track, marker, + curfra, frame_width, frame_height) == FALSE) + { + /* happens when reference frame fails to be loaded */ + continue; + } } /* for now track to the same search area dimension as marker has got for current frame @@ -2778,7 +2778,7 @@ static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, L int BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObject *object, char *error_msg, int error_size) { -#if WITH_LIBMV +#ifdef WITH_LIBMV ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object); if (tracking->settings.motion_flag & TRACKING_MOTION_MODAL) { @@ -3317,7 +3317,6 @@ static ImBuf *stabilization_allocate_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int } else { cacheibuf = IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->planes, flags); - cacheibuf->profile = srcibuf->profile; } return cacheibuf; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index bd25ff8c6e6..4019eba5177 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -847,7 +847,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report * parameter. * </p> */ -void flush_ffmpeg(void) +static void flush_ffmpeg(void) { int outsize = 0; int ret = 0; diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h index 3b7f2d6bbaf..833c416c1c1 100644 --- a/source/blender/blenlib/BLI_dynstr.h +++ b/source/blender/blenlib/BLI_dynstr.h @@ -80,7 +80,11 @@ void BLI_dynstr_appendf(DynStr *ds, const char *format, ...) __attribute__ ((format(printf, 2, 3))) #endif ; -void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args); +void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args) +#ifdef __GNUC__ +__attribute__ ((format(printf, 2, 0))) +#endif +; /** * Find the length of a DynStr. @@ -107,7 +111,6 @@ char *BLI_dynstr_get_cstring(DynStr *ds); * * \param ds The DynStr of interest. * \param str The string to fill. - * \return The contents of \a ds as a c-string. */ void BLI_dynstr_get_cstring_ex(DynStr *ds, char *str); diff --git a/source/blender/blenlib/BLI_endian_switch.h b/source/blender/blenlib/BLI_endian_switch.h index 7017e7ba789..7cb2790525d 100644 --- a/source/blender/blenlib/BLI_endian_switch.h +++ b/source/blender/blenlib/BLI_endian_switch.h @@ -27,16 +27,36 @@ * \ingroup bli */ -#include "BLI_endian_switch_inline.h" +#ifdef __GNUC__ +# define ATTR_ENDIAN_SWITCH \ + __attribute__((nonnull(1))) \ + __attribute__((pure)) +#else +# define ATTR_ENDIAN_SWITCH +#endif + +/* BLI_endian_switch_inline.h */ +BLI_INLINE void BLI_endian_switch_int16(short *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_float(float *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_int64(int64_t *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_double(double *val) ATTR_ENDIAN_SWITCH; /* endian_switch.c */ -void BLI_endian_switch_int16_array(short *val, const int size); -void BLI_endian_switch_uint16_array(unsigned short *val, const int size); -void BLI_endian_switch_int32_array(int *val, const int size); -void BLI_endian_switch_uint32_array(unsigned int *val, const int size); -void BLI_endian_switch_float_array(float *val, const int size); -void BLI_endian_switch_int64_array(int64_t *val, const int size); -void BLI_endian_switch_uint64_array(uint64_t *val, const int size); -void BLI_endian_switch_double_array(double *val, const int size); +void BLI_endian_switch_int16_array(short *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_uint16_array(unsigned short *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_int32_array(int *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_uint32_array(unsigned int *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_float_array(float *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_int64_array(int64_t *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_uint64_array(uint64_t *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_double_array(double *val, const int size) ATTR_ENDIAN_SWITCH; + +#include "BLI_endian_switch_inline.h" + +#undef ATTR_ENDIAN_SWITCH #endif /* __BLI_ENDIAN_SWITCH_H__ */ diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h index a19909a8f26..1c6463eb6ea 100644 --- a/source/blender/blenlib/BLI_fileops_types.h +++ b/source/blender/blenlib/BLI_fileops_types.h @@ -46,7 +46,7 @@ struct direntry { mode_t type; char *relname; char *path; -#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER >= 1500) +#if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__) && (_MSC_VER >= 1500) struct _stat64 s; #elif defined(__MINGW32__) struct _stati64 s; diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 886ed6f495d..6ee1498c855 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -30,8 +30,8 @@ * \ingroup bli */ -#ifdef WIN32 -#define _USE_MATH_DEFINES +#ifdef _MSC_VER +# define _USE_MATH_DEFINES #endif #include <math.h> diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 7520f09fe95..7c8bf88943d 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -67,6 +67,8 @@ void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv); void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr, int colorspace); void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv); void rgb_to_hsv_v(const float rgb[3], float r_hsv[3]); +void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll); +void rgb_to_hsl_v(const float rgb[3], float r_hsl[3]); void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv); void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3]); void rgb_to_lab(float r, float g, float b, float *ll, float *la, float *lb); @@ -113,6 +115,8 @@ void rgba_float_to_uchar(unsigned char col_r[4], const float col_f[4]); void xyz_to_lab(float x, float y, float z, float *l, float *a, float *b); +MINLINE int compare_rgb_uchar(const unsigned char a[3], const unsigned char b[3], const int limit); + /***************** lift/gamma/gain / ASC-CDL conversion *****************/ void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power); diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 6c81ca3f0a9..de1d423bfad 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -173,6 +173,7 @@ MINLINE int is_one_v3(const float a[3]); MINLINE int equals_v2v2(const float v1[2], const float v2[2]); MINLINE int equals_v3v3(const float a[3], const float b[3]); +MINLINE int compare_v2v2(const float a[3], const float b[3], const float limit); MINLINE int compare_v3v3(const float a[3], const float b[3], const float limit); MINLINE int compare_len_v3v3(const float a[3], const float b[3], const float limit); diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index eb9915d6c9b..de4c2cf3a86 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -55,6 +55,8 @@ void BLI_rcti_resize(struct rcti *rect, int x, int y); void BLI_rctf_resize(struct rctf *rect, float x, float y); void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, const float fac); //void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac); +int BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]); +int BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]); int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit); int BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b); int BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest); @@ -75,14 +77,28 @@ void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src); void print_rctf(const char *str, const struct rctf *rect); void print_rcti(const char *str, const struct rcti *rect); -#define BLI_RCT_SIZE_X(rct) ((rct)->xmax - (rct)->xmin) -#define BLI_RCT_SIZE_Y(rct) ((rct)->ymax - (rct)->ymin) +/* hrmf, we need to work out this inline stuff */ +#if defined(_MSC_VER) +# define BLI_INLINE static __forceinline +#elif defined(__GNUC__) +# define BLI_INLINE static inline __attribute((always_inline)) +#else +/* #warning "MSC/GNUC defines not found, inline non-functional" */ +# define BLI_INLINE static +#endif -#define BLI_RCT_CENTER_X(rct) (((rct)->xmin + (rct)->xmax) / 2) -#define BLI_RCT_CENTER_Y(rct) (((rct)->ymin + (rct)->ymax) / 2) +#include "DNA_vec_types.h" +BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct) { return (float)(rct->xmin + rct->xmax) / 2.0f; } +BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct) { return (float)(rct->ymin + rct->ymax) / 2.0f; } +BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct) { return (rct->xmin + rct->xmax) / 2; } +BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct) { return (rct->ymin + rct->ymax) / 2; } +BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct) { return (rct->xmin + rct->xmax) / 2.0f; } +BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct) { return (rct->ymin + rct->ymax) / 2.0f; } -#define BLI_RCT_CENTER_X_FL(rct) ((float)((rct)->xmin + (rct)->xmax) / 2.0f) -#define BLI_RCT_CENTER_Y_FL(rct) ((float)((rct)->ymin + (rct)->ymax) / 2.0f) +BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct) { return (rct->xmax - rct->xmin); } +BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct) { return (rct->ymax - rct->ymin); } +BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct) { return (rct->xmax - rct->xmin); } +BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct) { return (rct->ymax - rct->ymin); } #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index b3d0df04eb1..666c74ca36f 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -144,7 +144,11 @@ __attribute__((nonnull)) /* * Replacement for vsnprintf */ -size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg); +size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg) +#ifdef __GNUC__ +__attribute__ ((format(printf, 3, 0))) +#endif +; /* * Print formatted string into a newly mallocN'd string diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 902373bcd6b..9cd801f819d 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -77,6 +77,7 @@ int BLI_system_thread_count(void); /* gets the number of threads the system #define LOCK_OPENGL 5 #define LOCK_NODES 6 #define LOCK_MOVIECLIP 7 +#define LOCK_COLORMANAGE 8 void BLI_lock_thread(int type); void BLI_unlock_thread(int type); diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index c1175192434..ee7d93ea1a9 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -58,7 +58,7 @@ struct Heap { #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) +// #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); \ diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 2b3c314131b..167797946bc 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -42,7 +42,6 @@ #endif #define MAX_TREETYPE 32 -#define DEFAULT_FIND_NEAREST_HEAP_SIZE 1024 typedef struct BVHNode { struct BVHNode **children; @@ -114,6 +113,8 @@ static float KDOP_AXES[13][3] = { {0, 1.0, -1.0} }; +#if 0 + /* * Generic push and pop heap */ @@ -153,7 +154,6 @@ static float KDOP_AXES[13][3] = { heap[parent] = element; \ } (void)0 -#if 0 static int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_size, int size_per_item) { int new_max_size = *max_size * 2; @@ -1167,8 +1167,6 @@ typedef struct NodeDistance { } NodeDistance; -#define NodeDistance_priority(a, b) ( (a).dist < (b).dist) - // TODO: use a priority queue to reduce the number of nodes looked on static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node) { @@ -1211,6 +1209,11 @@ static void dfs_find_nearest_begin(BVHNearestData *data, BVHNode *node) #if 0 + +#define DEFAULT_FIND_NEAREST_HEAP_SIZE 1024 + +#define NodeDistance_priority(a, b) ( (a).dist < (b).dist) + static void NodeDistance_push_heap(NodeDistance *heap, int heap_size) PUSH_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 5da719cd500..1c70a612c4f 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -73,7 +73,9 @@ 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) -#define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b) + +/* UNUSED */ +// #define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b) #define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \ (b)->v[BL]->x = f; \ @@ -93,8 +95,8 @@ typedef struct BoxVert { BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \ BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2)) -#define MIN2(x, y) ((x) < (y) ? (x) : (y)) -#define MAX2(x, y) ((x) > (y) ? (x) : (y)) +/* compiler should inline */ +static float maxf(const float a, const float b) { return b > a ? b : a; } #if 0 #define BOXDEBUG(b) \ @@ -131,8 +133,8 @@ static int vertex_sort(const void *p1, const void *p2) v1 = vertarray + ((int *)p1)[0]; v2 = vertarray + ((int *)p2)[0]; - a1 = MAX2(v1->x + box_width, v1->y + box_height); - a2 = MAX2(v2->x + box_width, v2->y + box_height); + a1 = maxf(v1->x + box_width, v1->y + box_height); + a2 = maxf(v2->x + box_width, v2->y + box_height); /* sort largest to smallest */ if (a1 > a2) return 1; @@ -312,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) = MAX2(BOXRIGHT(box), (*tot_width)); - (*tot_height) = MAX2(BOXTOP(box), (*tot_height)); + (*tot_width) = maxf(BOXRIGHT(box), (*tot_width)); + (*tot_height) = maxf(BOXTOP(box), (*tot_height)); /* Place the box */ vert->free &= ~quad_flags[j]; diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index f3107b565b9..c2f0c38247a 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -341,7 +341,7 @@ void BLI_dir_create_recursive(const char *dirname) { char *lslash; char tmp[MAXPATHLEN]; - + /* First remove possible slash at the end of the dirname. * This routine otherwise tries to create * blah1/blah2/ (with slash) after creating @@ -349,23 +349,29 @@ void BLI_dir_create_recursive(const char *dirname) BLI_strncpy(tmp, dirname, sizeof(tmp)); lslash = BLI_last_slash(tmp); - - if (lslash == tmp + strlen(tmp) - 1) { - *lslash = 0; + + if (lslash && (*(lslash + 1) == '\0')) { + *lslash = '\0'; } - + + /* check special case "c:\foo", don't try create "c:", harmless but prints an error below */ + if (isalpha(tmp[0]) && (tmp[1] == ':') && tmp[2] == '\0') return; + if (BLI_exists(tmp)) return; lslash = BLI_last_slash(tmp); + if (lslash) { /* Split about the last slash and recurse */ *lslash = 0; BLI_dir_create_recursive(tmp); } - - if (dirname[0]) /* patch, this recursive loop tries to create a nameless directory */ - if (umkdir(dirname) == -1) + + if (dirname[0]) { /* patch, this recursive loop tries to create a nameless directory */ + if (umkdir(dirname) == -1) { printf("Unable to create directory %s\n", dirname); + } + } } int BLI_rename(const char *from, const char *to) diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 597a645eb9c..85239270541 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -58,9 +58,6 @@ #include "DNA_packedFile_types.h" #include "DNA_curve_types.h" -#define myMIN_ASCII 32 -#define myMAX_ASCII 255 - /* local variables */ static FT_Library library; static FT_Error err; diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index b93597bf107..64851dbf12c 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -293,6 +293,12 @@ void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll) *ll = l; } +/* convenience function for now */ +void rgb_to_hsl_v(const float rgb[3], float r_hsl[3]) +{ + rgb_to_hsl(rgb[0], rgb[1], rgb[2], &r_hsl[0], &r_hsl[1], &r_hsl[2]); +} + void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv) { float orig_h = *lh; diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 6b90cbfe9c3..f520b2318e5 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -273,5 +273,20 @@ MINLINE float rgb_to_luma_y(const float rgb[3]) return 0.212671f * rgb[0] + 0.71516f * rgb[1] + 0.072169f * rgb[2]; } +MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char col_b[3], const int limit) +{ + int r = (int)col_a[0] - (int)col_b[0]; + if (ABS(r) < limit) { + int g = (int)col_a[1] - (int)col_b[1]; + if (ABS(g) < limit) { + int b = (int)col_a[2] - (int)col_b[2]; + if (ABS(b) < limit) { + return 1; + } + } + } + + return 0; +} #endif /* __MATH_COLOR_INLINE_C__ */ diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 3fb3d2b58ff..1f61b37a1af 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -195,7 +195,7 @@ void mul_m3_m3m3(float m1[][3], float m3_[][3], float m2_[][3]) m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2]; } -void mul_m4_m4m3(float (*m1)[4], float (*m3_)[4], float (*m2_)[3]) +void mul_m4_m4m3(float m1[][4], float m3_[][4], float m2_[][3]) { float m2[3][3], m3[4][4]; @@ -215,8 +215,14 @@ void mul_m4_m4m3(float (*m1)[4], float (*m3_)[4], float (*m2_)[3]) } /* m1 = m2 * m3, ignore the elements on the 4th row/column of m3 */ -void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3]) +void mult_m3_m3m4(float m1[][3], float m3_[][4], float m2_[][3]) { + float m2[3][3], m3[4][4]; + + /* copy so it works when m1 is the same pointer as m2 or m3 */ + copy_m3_m3(m2, m2_); + copy_m4_m4(m3, m3_); + /* m1[i][j] = m2[i][k] * m3[k][j] */ m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0]; m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1]; @@ -231,8 +237,14 @@ void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3]) m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2]; } -void mul_m4_m3m4(float (*m1)[4], float (*m3)[3], float (*m2)[4]) +void mul_m4_m3m4(float m1[][4], float m3_[][3], float m2_[][4]) { + float m2[4][4], m3[3][3]; + + /* copy so it works when m1 is the same pointer as m2 or m3 */ + copy_m4_m4(m2, m2_); + copy_m3_m3(m3, m3_); + m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0]; m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1]; m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2]; diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index f0ed23aabc9..e10b0b3298c 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -35,7 +35,9 @@ /******************************** Quaternions ********************************/ /* used to test is a quat is not normalized (only used for debug prints) */ -#define QUAT_EPSILON 0.0001 +#ifdef DEBUG +# define QUAT_EPSILON 0.0001 +#endif /* convenience, avoids setting Y axis everywhere */ void unit_axis_angle(float axis[3], float *angle) diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 0a8f57214d7..c409e536b45 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -724,6 +724,15 @@ MINLINE int equals_v4v4(const float v1[4], const float v2[4]) return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2]) && (v1[3] == v2[3])); } +MINLINE int compare_v2v2(const float v1[2], const float v2[2], const float limit) +{ + if (fabsf(v1[0] - v2[0]) < limit) + if (fabsf(v1[1] - v2[1]) < limit) + return 1; + + return 0; +} + MINLINE int compare_v3v3(const float v1[3], const float v2[3], const float limit) { if (fabsf(v1[0] - v2[0]) < limit) diff --git a/source/blender/blenlib/intern/md5.c b/source/blender/blenlib/intern/md5.c index a521d0e523b..4a09afe2e3d 100644 --- a/source/blender/blenlib/intern/md5.c +++ b/source/blender/blenlib/intern/md5.c @@ -2,6 +2,8 @@ * \ingroup imbuf */ +#include "BLI_md5.h" /* own include */ + /* md5.c - Functions to compute MD5 message digest of files or memory blocks according to the definition of MD5 in RFC 1321 from April 1992. Copyright (C) 1995 Software Foundation, Inc. diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index bd83c5e018c..792bf929182 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -45,7 +45,8 @@ static float noise3_perlin(float vec[3]); //static float turbulence_perlin(float *point, float lofreq, float hifreq); //static float turbulencep(float noisesize, float x, float y, float z, int nr); -#define HASHVEC(x, y, z) hashvectf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255] +/* UNUSED */ +// #define HASHVEC(x, y, z) hashvectf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255] /* needed for voronoi */ #define HASHPNT(x, y, z) hashpntf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255] diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index a7a66718445..cc482e2d3d8 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1368,7 +1368,7 @@ int BLI_testextensie(const char *str, const char *ext) retval = 0; } else if (BLI_strcasecmp(ext, str + a - b)) { - retval = 0; + retval = 0; } else { retval = 1; diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 22597c9f8e6..0bd9e68cb71 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -487,7 +487,7 @@ static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc, /* Return zero if all primitives in the node can be drawn with the * same material (including flat/smooth shading), non-zerootherwise */ -int leaf_needs_material_split(PBVH *bvh, int offset, int count) +static int leaf_needs_material_split(PBVH *bvh, int offset, int count) { int i, prim; @@ -1169,10 +1169,14 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) break; case PBVH_FACES: GPU_update_mesh_buffers(node->draw_buffers, + bvh->faces, + node->prim_indices, + node->totprim, bvh->verts, node->vert_indices, node->uniq_verts + node->face_verts, + node->face_vert_indices, CustomData_get_layer(bvh->vdata, CD_PAINT_MASK)); break; diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 225ede8a8ef..cab383b60f3 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -252,8 +252,8 @@ void BLI_rctf_translate(rctf *rect, float x, float y) /* change width & height around the central location */ void BLI_rcti_resize(rcti *rect, int x, int y) { - rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect); - rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect); + rect->xmin = rect->xmax = BLI_rcti_cent_x(rect); + rect->ymin = rect->ymax = BLI_rcti_cent_y(rect); rect->xmin -= x / 2; rect->ymin -= y / 2; rect->xmax = rect->xmin + x; @@ -262,8 +262,8 @@ void BLI_rcti_resize(rcti *rect, int x, int y) void BLI_rctf_resize(rctf *rect, float x, float y) { - rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect); - rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect); + rect->xmin = rect->xmax = BLI_rctf_cent_x(rect); + rect->ymin = rect->ymax = BLI_rctf_cent_y(rect); rect->xmin -= x * 0.5f; rect->ymin -= y * 0.5f; rect->xmax = rect->xmin + x; @@ -281,6 +281,27 @@ void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const f /* BLI_rcti_interp() not needed yet */ + +int BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]) +{ + int change = 0; + if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = 1; } + if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = 1; } + if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = 1; } + if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = 1; } + return change; +} + +int BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]) +{ + int change = 0; + if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = 1; } + if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = 1; } + if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = 1; } + if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = 1; } + return change; +} + int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit) { if (fabsf(rect_a->xmin - rect_b->xmin) < limit) @@ -366,9 +387,9 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) void BLI_rcti_rctf_copy(rcti *dst, const rctf *src) { dst->xmin = floorf(src->xmin + 0.5f); - dst->xmax = dst->xmin + floorf(BLI_RCT_SIZE_X(src) + 0.5f); + dst->xmax = dst->xmin + floorf(BLI_rctf_size_x(src) + 0.5f); dst->ymin = floorf(src->ymin + 0.5f); - dst->ymax = dst->ymin + floorf(BLI_RCT_SIZE_Y(src) + 0.5f); + dst->ymax = dst->ymin + floorf(BLI_rctf_size_y(src) + 0.5f); } void BLI_rctf_rcti_copy(rctf *dst, const rcti *src) @@ -382,11 +403,11 @@ void BLI_rctf_rcti_copy(rctf *dst, const rcti *src) void print_rctf(const char *str, const rctf *rect) { printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", str, - rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); + rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rctf_size_x(rect), BLI_rctf_size_y(rect)); } void print_rcti(const char *str, const rcti *rect) { printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str, - rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); + rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); } diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 32afaba2b5c..7ae27b83e67 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -211,7 +211,7 @@ ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3]) copy_v3_v3(eve->co, vec); - return eve; + return eve; } ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, ScanFillVert *v1, ScanFillVert *v2) @@ -521,7 +521,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf) while (eve) { printf("vert: %x co: %f %f\n", eve, eve->xy[0], eve->xy[1]); eve = eve->next; - } + } eed = sf_ctx->filledgebase.first; while (eed) { printf("edge: %x verts: %x %x\n", eed, eed->v1, eed->v2); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 0fccd91fc02..0d3f6aee30f 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -34,7 +34,7 @@ #include <sys/types.h> #include <stdio.h> -#include <stdlib.h> +#include <stdlib.h> #ifndef WIN32 #include <dirent.h> diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index 422a600e51c..bab144266a4 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -147,7 +147,7 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, int *pos, strCursorJumpDirection direction, strCursorJumpType jump) { - const short pos_prev = *pos; + const int pos_prev = *pos; if (direction == STRCUR_DIR_NEXT) { BLI_str_cursor_step_next_utf8(str, maxlen, pos); diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 9994f89acd5..66527b9b92a 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -113,6 +113,7 @@ static pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _opengl_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _nodes_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _movieclip_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t _colormanage_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_t mainid; static int thread_levels = 0; /* threads can be invoked inside threads */ @@ -351,6 +352,8 @@ void BLI_lock_thread(int type) pthread_mutex_lock(&_nodes_lock); else if (type == LOCK_MOVIECLIP) pthread_mutex_lock(&_movieclip_lock); + else if (type == LOCK_COLORMANAGE) + pthread_mutex_lock(&_colormanage_lock); } void BLI_unlock_thread(int type) @@ -371,6 +374,8 @@ void BLI_unlock_thread(int type) pthread_mutex_unlock(&_nodes_lock); else if (type == LOCK_MOVIECLIP) pthread_mutex_unlock(&_movieclip_lock); + else if (type == LOCK_COLORMANAGE) + pthread_mutex_unlock(&_colormanage_lock); } /* Mutex Locks */ diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index 1b59dc6a3f5..05ebc9500a1 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -105,7 +105,7 @@ void BLI_uvproject_from_view(float target[2], float source[3], float persmat[4][ /* rotmat is the object matrix in this case */ mul_m4_v4(rotmat, pv4); - /* almost project_short */ + /* almost ED_view3d_project_short */ mul_m4_v4(persmat, pv4); if (fabsf(pv4[3]) > 0.00001f) { /* avoid division by zero */ target[0] = winx / 2.0f + (winx / 2.0f) * pv4[0] / pv4[3]; diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 80a4da5cace..3030e54eb78 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -480,7 +480,7 @@ static void voronoi_removeParabola(VoronoiProcess *process, VoronoiEvent *event) voronoi_checkCircle(process, p2); } -void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) +static void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) { float mx; @@ -503,12 +503,12 @@ void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) MEM_freeN(parabola); } -void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord) +static void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord) { const float corners[4][2] = {{0.0f, 0.0f}, - {width - 1, 0.0f}, - {width - 1, height - 1}, - {0.0f, height - 1}}; + {width - 1, 0.0f}, + {width - 1, height - 1}, + {0.0f, height - 1}}; int i; if (IN_RANGE_INCL(coord[0], 0, width - 1) && IN_RANGE_INCL(coord[1], 0, height - 1)) { @@ -541,7 +541,7 @@ void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_c } } -void voronoi_clampEdges(ListBase *edges, int width, int height, ListBase *clamped_edges) +static void voronoi_clampEdges(ListBase *edges, int width, int height, ListBase *clamped_edges) { VoronoiEdge *edge; diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 5b5f4cf8b80..a0b31f8d5b8 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -68,7 +68,7 @@ int BLI_getInstallationDir(char *str) return 1; } -void RegisterBlendExtension_Fail(HKEY root) +static void RegisterBlendExtension_Fail(HKEY root) { printf("failed\n"); if (root) diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index f0bf7e99758..16a4d8d46ec 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -244,6 +244,9 @@ void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, struct ReportList *reports); +/* internal function but we need to expose it */ +void blo_lib_link_screen_restore(struct Main *newmain, struct bScreen *curscreen, struct Scene *curscene); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 845228fb1b9..9a2a09a98ae 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -134,7 +134,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_property.h" // for get_ob_property +#include "BKE_property.h" // for BKE_bproperty_object_get #include "BKE_report.h" #include "BKE_sca.h" // for init_actuator #include "BKE_scene.h" @@ -249,6 +249,12 @@ static void convert_tface_mt(FileData *fd, Main *main); * bit kludge but better then doubling up on prints, * we could alternatively have a versions of a report function which forces printing - campbell */ + +static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...) +#ifdef __GNUC__ +__attribute__ ((format(printf, 3, 4))) +#endif +; static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...) { char fixed_buf[1024]; /* should be long enough */ @@ -590,11 +596,7 @@ static void switch_endian_bh8(BHead8 *bhead) static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap) { BHead4 *bhead4 = (BHead4 *) bhead; -#if defined(WIN32) && !defined(FREE_WINDOWS) - __int64 old; -#else - long long old; -#endif + int64_t old; bhead4->code = bhead8->code; bhead4->len = bhead8->len; @@ -2716,6 +2718,16 @@ static void direct_link_lamp(FileData *fd, Lamp *la) /* ************ READ keys ***************** */ +static void do_versions_key_uidgen(Key *key) +{ + KeyBlock *block; + + key->uidgen = 1; + for (block = key->block.first; block; block = block->next) { + block->uid = key->uidgen++; + } +} + static void lib_link_key(FileData *fd, Main *main) { Key *key; @@ -2723,12 +2735,7 @@ static void lib_link_key(FileData *fd, Main *main) for (key = main->key.first; key; key = key->id.next) { /*check if we need to generate unique ids for the shapekeys*/ if (!key->uidgen) { - KeyBlock *block; - - key->uidgen = 1; - for (block=key->block.first; block; block=block->next) { - block->uid = key->uidgen++; - } + do_versions_key_uidgen(key); } if (key->id.flag & LIB_NEED_LINK) { @@ -3815,7 +3822,6 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) mesh->tface = newdataadr(fd, mesh->tface); mesh->mtface = newdataadr(fd, mesh->mtface); mesh->mcol = newdataadr(fd, mesh->mcol); - mesh->msticky = newdataadr(fd, mesh->msticky); mesh->dvert = newdataadr(fd, mesh->dvert); mesh->mloopcol = newdataadr(fd, mesh->mloopcol); mesh->mloopuv = newdataadr(fd, mesh->mloopuv); @@ -4910,6 +4916,14 @@ static void direct_link_sequence_modifiers(FileData *fd, ListBase *lb) } } +static void direct_link_view_settings(FileData *fd, ColorManagedViewSettings *view_settings) +{ + view_settings->curve_mapping = newdataadr(fd, view_settings->curve_mapping); + + if (view_settings->curve_mapping) + direct_link_curvemapping(fd, view_settings->curve_mapping); +} + static void direct_link_scene(FileData *fd, Scene *sce) { Editing *ed; @@ -5095,6 +5109,8 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->nodetree = newdataadr(fd, sce->nodetree); if (sce->nodetree) direct_link_nodetree(fd, sce->nodetree); + + direct_link_view_settings(fd, &sce->view_settings); } /* ************ READ WM ***************** */ @@ -5308,6 +5324,13 @@ static void lib_link_screen(FileData *fd, Main *main) * so fingers crossed this works fine! */ sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd); + + sseq->scopes.reference_ibuf = NULL; + sseq->scopes.zebra_ibuf = NULL; + sseq->scopes.waveform_ibuf = NULL; + sseq->scopes.sep_waveform_ibuf = NULL; + sseq->scopes.vector_ibuf = NULL; + sseq->scopes.histogram_ibuf = NULL; } else if (sl->spacetype == SPACE_NLA) { SpaceNla *snla= (SpaceNla *)sl; @@ -5452,7 +5475,7 @@ static void lib_link_clipboard_restore(Main *newmain) /* called from kernel/blender.c */ /* used to link a file (without UI) to the current UI */ /* note that it assumes the old pointers in UI are still valid, so old Main is not freed */ -void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) +void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) { wmWindow *win; wmWindowManager *wm; @@ -6284,6 +6307,14 @@ static void direct_link_mask(FileData *fd, Mask *mask) for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { masklay_shape->data = newdataadr(fd, masklay_shape->data); + + if (masklay_shape->tot_vert) { + if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { + BLI_endian_switch_float_array(masklay_shape->data, + masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); + + } + } } masklay->act_spline = newdataadr(fd, masklay->act_spline); @@ -6872,7 +6903,7 @@ static void do_versions_nodetree_convert_angle(bNodeTree *ntree) } } -void do_versions_image_settings_2_60(Scene *sce) +static void do_versions_image_settings_2_60(Scene *sce) { /* note: rd->subimtype is moved into individual settings now and no longer * exists */ @@ -7544,7 +7575,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for (ob= main->object.first; ob; ob= ob->id.next) { if (ob->type == OB_FONT) { - prop = get_ob_property(ob, "Text"); + 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 " @@ -7997,7 +8028,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) MovieTrackingMarker *marker = &track->markers[i]; if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) && - is_zero_v2(marker->pattern_corners[3]) && is_zero_v2(marker->pattern_corners[3])) + is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3])) { marker->pattern_corners[0][0] = track->pat_min[0]; marker->pattern_corners[0][1] = track->pat_min[1]; @@ -8095,6 +8126,76 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + /* color management pipeline changes compatibility code */ + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 19)) { + Scene *scene; + Image *ima; + int colormanagement_disabled = FALSE; + + /* make scenes which are not using color management have got None as display device, + * so they wouldn't perform linear-to-sRGB conversion on display + */ + for (scene = main->scene.first; scene; scene = scene->id.next) { + if ((scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) == 0) { + ColorManagedDisplaySettings *display_settings = &scene->display_settings; + + if (display_settings->display_device[0] == 0) { + BKE_scene_disable_color_management(scene); + + } + + colormanagement_disabled = TRUE; + } + } + + for (ima = main->image.first; ima; ima = ima->id.next) { + if (ima->source == IMA_SRC_VIEWER) { + ima->flag |= IMA_VIEW_AS_RENDER; + } + else if (colormanagement_disabled) { + /* if colormanagement not used, set image's color space to raw, so no sRGB->linear conversion + * would happen on display and render + * there's no clear way to check whether color management is enabled or not in render engine + * so set all images to raw if there's at least one scene with color management disabled + * this would still behave incorrect in cases when color management was used for only some + * of scenes, but such a setup is crazy anyway and think it's fair enough to break compatibility + * in that cases + */ + + BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name)); + } + } + } + + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 20)) { + Key *key; + for (key = main->key.first; key; key = key->id.next) { + do_versions_key_uidgen(key); + } + } + + /* remove texco */ + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 21)) { + Material *ma; + for (ma = main->mat.first; ma; ma = ma->id.next) { + int a; + for (a = 0; a < MAX_MTEX; a++) { + if (ma->mtex[a]) { + if (ma->mtex[a]->texco == TEXCO_STICKY_) { + ma->mtex[a]->texco = TEXCO_UV; + } + } + } + } + + { + Mesh *me; + for (me = main->mesh.first; me; me = me->id.next) { + CustomData_free_layers(&me->vdata, CD_MSTICKY, me->totvert); + } + } + } + /* default values in Freestyle settings */ { Scene *sce; diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 1cc0d4180ab..d8333e7c8f4 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -92,7 +92,7 @@ #include "BKE_modifier.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_property.h" // for get_ob_property +#include "BKE_property.h" // for BKE_bproperty_object_get #include "BKE_scene.h" #include "BKE_sequencer.h" @@ -387,8 +387,6 @@ static void customdata_version_242(Mesh *me) if (!me->vdata.totlayer) { CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert); - if (me->msticky) - CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_ASSIGN, me->msticky, me->totvert); if (me->dvert) CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert); } @@ -945,7 +943,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) while (act) { if (act->type == ACT_IPO) { ia = act->data; - prop = get_ob_property(ob, ia->name); + prop = BKE_bproperty_object_get(ob, ia->name); if (prop) { ia->type = ACT_IPO_FROM_PROP; } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index b2d4e905dc9..6fb7faae69c 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2120,6 +2120,13 @@ static void write_sequence_modifiers(WriteData *wd, ListBase *modbase) } } +static void write_view_settings(WriteData *wd, ColorManagedViewSettings *view_settings) +{ + if (view_settings->curve_mapping) { + write_curvemapping(wd, view_settings->curve_mapping); + } +} + static void write_scenes(WriteData *wd, ListBase *scebase) { Scene *sce; @@ -2274,7 +2281,9 @@ static void write_scenes(WriteData *wd, ListBase *scebase) writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree); write_nodetree(wd, sce->nodetree); } - + + write_view_settings(wd, &sce->view_settings); + sce= sce->id.next; } /* flush helps the compression for undo-save */ diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index a74053a4697..691465388e9 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -380,7 +380,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n } sub_v3_v3v3(far_vec, far, cent); - far_dist = len_v3(far_vec); /* real dist */ + // far_dist = len_v3(far_vec); /* real dist */ /* UNUSED */ /* --- */ diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index f03ce9b8543..ccbbb6f170b 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -836,8 +836,6 @@ static void bm_elements_systag_disable(void *veles, int tot, int flag) } } -#define FACE_MARK (1 << 10) - static int count_flagged_radial(BMesh *bm, BMLoop *l, int flag) { BMLoop *l2 = l; diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 9033436d1b2..12fcd51c069 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -424,7 +424,7 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source) float axis_x[3], axis_y[3]; /* ignore 2-edged faces */ - if (target->f->len < 3) + if (UNLIKELY(target->f->len < 3)) return; if (!CustomData_has_layer(&bm->ldata, CD_MDISPS)) diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index c0439311104..e4a838fe893 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -672,7 +672,7 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]) * we cant make a crossvec from a vec thats the same as the vec * unlikely but possible, so make sure if the normal is (0, 0, 1) * that vec isn't the same or in the same direction even. */ - if (efa->len < 3) { + if (UNLIKELY(efa->len < 3)) { /* crappy fallback method */ if (efa->no[0] < 0.5f) vec[0] = 1.0f; else if (efa->no[1] < 0.5f) vec[1] = 1.0f; diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index cf593627e8d..734f08142b1 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -282,7 +282,7 @@ void BM_mesh_normals_update(BMesh *bm, const short skip_hidden) if (skip_hidden && BM_elem_flag_test(v, BM_ELEM_HIDDEN)) continue; - if (normalize_v3(v->no) == 0.0f) { + if (UNLIKELY(normalize_v3(v->no) == 0.0f)) { normalize_v3_v3(v->no, v->co); } } @@ -356,7 +356,7 @@ void bmesh_edit_begin(BMesh *UNUSED(bm), int UNUSED(type_flag)) * (loop cuts, edge subdivides, etc) are not reflected in the higher levels of * the mesh at all, which doesn't seem right. Turning off completely for now, * until this is shown to be better for certain types of mesh edits. */ -#if BMOP_UNTAN_MULTIRES_ENABLED +#ifdef BMOP_UNTAN_MULTIRES_ENABLED /* switch multires data out of tangent space */ if ((type_flag & BMO_OP_FLAG_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) { bmesh_mdisps_space_set(bm, MULTIRES_SPACE_TANGENT, MULTIRES_SPACE_ABSOLUTE); @@ -374,7 +374,7 @@ void bmesh_edit_begin(BMesh *UNUSED(bm), int UNUSED(type_flag)) void bmesh_edit_end(BMesh *bm, int UNUSED(flag)) { /* BMO_OP_FLAG_UNTAN_MULTIRES disabled for now, see comment above in bmesh_edit_begin. */ -#if BMOP_UNTAN_MULTIRES_ENABLED +#ifdef BMOP_UNTAN_MULTIRES_ENABLED /* switch multires data into tangent space */ if ((flag & BMO_OP_FLAG_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) { /* set normals to their previous winding */ diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 51c8b5d3bd8..e6827b1f2cd 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -758,7 +758,7 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess) } if (!currkey) { - currkey = add_keyblock(me->key, bm->vdata.layers[i].name); + currkey = BKE_keyblock_add(me->key, bm->vdata.layers[i].name); currkey->uid = bm->vdata.layers[i].uid; } diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 73e2d83520c..3195899ef01 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -558,7 +558,7 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, /* cant kill data we loop on, build a list and remove those */ BLI_array_empty(bad_faces); BM_ITER_ELEM (f, &fiter, verts[i], BM_FACES_OF_VERT) { - if (f->len < 3) { + if (UNLIKELY(f->len < 3)) { BLI_array_append(bad_faces, f); } } diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 53b95c97c8b..2100cd2bd0b 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1253,7 +1253,7 @@ int BMO_error_occurred(BMesh *bm) return bm->errorstack.first != NULL; } -/* returns error code or 0 if no erro */ +/* returns error code or 0 if no error */ int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op) { BMOpError *err = bm->errorstack.first; diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index 4723b631c5f..1567455e354 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -364,8 +364,6 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) /* BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE); */ /* UNUSE */ int i; -#define SIGN(n) ((n) < 0.0f) - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { BMIter eiter; float no[3], cent[3]; diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index b10556af04e..84f6cb27b3b 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -484,7 +484,7 @@ void dummy_exec(BMesh *bm, BMOperator *op) /* 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. */ -float bm_vert_edge_face_angle(BMVert *v) +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 */ diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 4d4d7e30a4e..32270007a0b 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -37,7 +37,7 @@ #define DUPE_INPUT 1 /* input from operator */ #define DUPE_NEW 2 #define DUPE_DONE 4 -#define DUPE_MAPPED 8 +// #define DUPE_MAPPED 8 // UNUSED /** * COPY VERTEX diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 87ba216d5cf..d97d901777c 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -44,6 +44,8 @@ #include "bmesh.h" +#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] */ @@ -628,7 +630,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op) } } -void hull_tag_holes(BMesh *bm, BMOperator *op) +static void hull_tag_holes(BMesh *bm, BMOperator *op) { BMIter iter; BMOIter oiter; diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c index d780e309118..0d8b397110e 100644 --- a/source/blender/bmesh/operators/bmo_join_triangles.c +++ b/source/blender/bmesh/operators/bmo_join_triangles.c @@ -37,11 +37,6 @@ #include "intern/bmesh_operators_private.h" /* own include */ -/* Bitflags for edges */ -#define T2QDELETE 1 -#define T2QCOMPLEX 2 -#define T2QJOIN 4 - /* assumes edges are validated before reaching this poin */ static float measure_facepair(BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, float limit) @@ -110,93 +105,73 @@ static float measure_facepair(BMVert *v1, BMVert *v2, #define T2QUV_LIMIT 0.005f #define T2QCOL_LIMIT 3 -static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) +static int bm_edge_faces_cmp(BMesh *bm, BMEdge *e, const int do_uv, const int do_tf, const int do_vcol) { - MTexPoly *tp1, *tp2; - MLoopCol *lcol1, *lcol2, *lcol3, *lcol4; - MLoopUV *luv1, *luv2, *luv3, *luv4; - BMLoop *l1, *l2, *l3, *l4; - int mergeok_uvs = !douvs, mergeok_vcols = !dovcols; - - l1 = e->l; - l3 = e->l->radial_next; + /* first get loops */ + BMLoop *l[4]; + + l[0] = e->l; + l[2] = e->l->radial_next; - /* match up loops on each side of an edge corresponding to each ver */ - if (l1->v == l3->v) { - l2 = l1->next; - l4 = l2->next; + /* match up loops on each side of an edge corresponding to each vert */ + if (l[0]->v == l[2]->v) { + l[1] = l[0]->next; + l[3] = l[1]->next; } else { - l2 = l1->next; + l[1] = l[0]->next; - l4 = l3; - l3 = l4->next; + l[3] = l[2]; + l[2] = l[3]->next; } - lcol1 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL); - lcol2 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL); - lcol3 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL); - lcol4 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL); - - luv1 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV); - luv2 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV); - luv3 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV); - luv4 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV); - - tp1 = CustomData_bmesh_get(&bm->pdata, l1->f->head.data, CD_MTEXPOLY); - tp2 = CustomData_bmesh_get(&bm->pdata, l2->f->head.data, CD_MTEXPOLY); - - if (!lcol1) - mergeok_vcols = 1; - - if (!luv1) - mergeok_uvs = 1; - - /* compare faceedges for each face attribute. Additional per face attributes can be added late */ - - /* do VCOL */ - if (lcol1 && dovcols) { - char *cols[4] = {(char *)lcol1, (char *)lcol2, (char *)lcol3, (char *)lcol4}; - int i; - - for (i = 0; i < 3; i++) { - if (cols[0][i] + T2QCOL_LIMIT < cols[2][i] - T2QCOL_LIMIT) - break; - if (cols[1][i] + T2QCOL_LIMIT < cols[3][i] - T2QCOL_LIMIT) - break; + /* Test UV's */ + if (do_uv) { + const MLoopUV *luv[4] = { + CustomData_bmesh_get(&bm->ldata, l[0]->head.data, CD_MLOOPUV), + CustomData_bmesh_get(&bm->ldata, l[1]->head.data, CD_MLOOPUV), + CustomData_bmesh_get(&bm->ldata, l[2]->head.data, CD_MLOOPUV), + CustomData_bmesh_get(&bm->ldata, l[3]->head.data, CD_MLOOPUV), + }; + + /* do UV */ + if (luv[0] && (!compare_v2v2(luv[0]->uv, luv[2]->uv, T2QUV_LIMIT) || + !compare_v2v2(luv[1]->uv, luv[3]->uv, T2QUV_LIMIT))) + { + return FALSE; } - - if (i == 3) - mergeok_vcols = 1; } - /* do UV */ - if (luv1 && douvs) { - if (tp1->tpage != tp2->tpage) { - /* do nothing */ - } - else { - int i; + if (do_tf) { + const MTexPoly *tp[2] = { + CustomData_bmesh_get(&bm->pdata, l[0]->f->head.data, CD_MTEXPOLY), + CustomData_bmesh_get(&bm->pdata, l[1]->f->head.data, CD_MTEXPOLY), + }; - for (i = 0; i < 2; i++) { - if (luv1->uv[0] + T2QUV_LIMIT > luv3->uv[0] && luv1->uv[0] - T2QUV_LIMIT < luv3->uv[0] && - luv1->uv[1] + T2QUV_LIMIT > luv3->uv[1] && luv1->uv[1] - T2QUV_LIMIT < luv3->uv[1]) - { - if (luv2->uv[0] + T2QUV_LIMIT > luv4->uv[0] && luv2->uv[0] - T2QUV_LIMIT < luv4->uv[0] && - luv2->uv[1] + T2QUV_LIMIT > luv4->uv[1] && luv2->uv[1] - T2QUV_LIMIT < luv4->uv[1]) - { - mergeok_uvs = 1; - } - } - } + if (tp[0] && (tp[0]->tpage != tp[1]->tpage)) { + return FALSE; } } - if (douvs == mergeok_uvs && dovcols == mergeok_vcols) { - return TRUE; + /* Test Vertex Colors */ + if (do_vcol) { + const MLoopCol *lcol[4] = { + CustomData_bmesh_get(&bm->ldata, l[0]->head.data, CD_MLOOPCOL), + CustomData_bmesh_get(&bm->ldata, l[1]->head.data, CD_MLOOPCOL), + CustomData_bmesh_get(&bm->ldata, l[2]->head.data, CD_MLOOPCOL), + CustomData_bmesh_get(&bm->ldata, l[3]->head.data, CD_MLOOPCOL), + }; + + if (lcol[0]) { + if (!compare_rgb_uchar((unsigned char*)&lcol[0]->r, (unsigned char*)&lcol[2]->r, T2QCOL_LIMIT) || + !compare_rgb_uchar((unsigned char*)&lcol[1]->r, (unsigned char*)&lcol[3]->r, T2QCOL_LIMIT)) + { + return FALSE; + } + } } - return FALSE; + return TRUE; } typedef struct JoinEdge { @@ -229,11 +204,12 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) BMEdge *e; BLI_array_declare(jedges); JoinEdge *jedges = NULL; - int dosharp = BMO_slot_bool_get(op, "cmp_sharp"); - int douvs = BMO_slot_bool_get(op, "cmp_uvs"); - int dovcols = BMO_slot_bool_get(op, "cmp_vcols"); - int domat = BMO_slot_bool_get(op, "cmp_materials"); - float limit = BMO_slot_float_get(op, "limit"); + int do_sharp = BMO_slot_bool_get(op, "cmp_sharp"); + int do_uv = BMO_slot_bool_get(op, "cmp_uvs"); + int do_tf = do_uv; /* texture face, make make its own option eventually */ + int do_vcol = BMO_slot_bool_get(op, "cmp_vcols"); + int do_mat = BMO_slot_bool_get(op, "cmp_materials"); + float limit = BMO_slot_float_get(op, "limit"); int i, totedge; /* flag all edges of all input face */ @@ -282,13 +258,13 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) v3 = e->l->next->v; v4 = e->l->radial_next->prev->v; - if (dosharp && !BM_elem_flag_test(e, BM_ELEM_SMOOTH)) + if (do_sharp && !BM_elem_flag_test(e, BM_ELEM_SMOOTH)) continue; - - if ((douvs || dovcols) && compareFaceAttribs(bm, e, douvs, dovcols)) + + if (do_mat && f1->mat_nr != f2->mat_nr) continue; - if (domat && f1->mat_nr != f2->mat_nr) + if ((do_uv || do_tf || do_vcol) && (bm_edge_faces_cmp(bm, e, do_uv, do_tf, do_vcol) == FALSE)) continue; measure = measure_facepair(v1, v2, v3, v4, limit); diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index e1a5ef9f905..d3e98dd96c1 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -244,11 +244,11 @@ static int vergaverco(const void *e1, const void *e2) else return 0; } -#define VERT_TESTED 1 +// #define VERT_TESTED 1 // UNUSED #define VERT_DOUBLE 2 #define VERT_TARGET 4 #define VERT_KEEP 8 -#define VERT_MARK 16 +// #define VERT_MARK 16 // UNUSED #define VERT_IN 32 #define EDGE_MARK 1 @@ -487,7 +487,7 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op) } } -void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) +static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) { BMOIter oiter; BMVert *v, *v2; diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c index e0dc5cf48c7..d572a1c5863 100644 --- a/source/blender/bmesh/operators/bmo_wireframe.c +++ b/source/blender/bmesh/operators/bmo_wireframe.c @@ -34,7 +34,7 @@ #include "intern/bmesh_operators_private.h" /* own include */ -BMLoop *bm_edge_tag_faceloop(BMEdge *e) +static BMLoop *bm_edge_tag_faceloop(BMEdge *e) { BMLoop *l, *l_first; diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index 91527313972..98f270abd16 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -66,7 +66,7 @@ /* ------- Bevel code starts here -------- */ -BME_TransData_Head *BME_init_transdata(int bufsize) +static BME_TransData_Head *BME_init_transdata(int bufsize) { BME_TransData_Head *td; @@ -85,9 +85,9 @@ void BME_free_transdata(BME_TransData_Head *td) MEM_freeN(td); } -BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BMesh *bm, BMVert *v, - float *co, float *org, float *vec, float *loc, - float factor, float weight, float maxfactor, float *max) +static BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BMesh *bm, BMVert *v, + float *co, float *org, float *vec, float *loc, + float factor, float weight, float maxfactor, float *max) { BME_TransData *vtd; int is_new = 0; @@ -140,7 +140,7 @@ BME_TransData *BME_get_transdata(BME_TransData_Head *td, BMVert *v) } /* a hack (?) to use the transdata memarena to allocate floats for use with the max limits */ -float *BME_new_transdata_float(BME_TransData_Head *td) +static float *BME_new_transdata_float(BME_TransData_Head *td) { return BLI_memarena_alloc(td->ma, sizeof(float)); } diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index f7e0f75ec5c..fbb18887d1b 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -76,6 +76,7 @@ int collada_export(Scene *sce, if (!BLI_exists(filepath)) { BLI_make_existing_file(filepath); /* makes the dir if its not there */ if (BLI_file_touch(filepath) == 0) { + fprintf(stdout, "Collada export: Can not create: %s\n", filepath); return 0; } } diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h index f35bf71392c..a64583b68ff 100644 --- a/source/blender/compositor/COM_compositor.h +++ b/source/blender/compositor/COM_compositor.h @@ -24,6 +24,7 @@ extern "C" { #endif +#include "DNA_color_types.h" #include "DNA_node_types.h" /** @@ -299,8 +300,20 @@ extern "C" { * * - output nodes can have different priorities in the WorkScheduler. * This is implemented in the COM_execute function. + * + * @param viewSettings + * reference to view settings used for color management + * + * @param displaySettings + * reference to display settings used for color management + * + * OCIO_TODO: this options only used in rare cases, namely in output file node, + * so probably this settings could be passed in a nicer way. + * should be checked further, probably it'll be also needed for preview + * generation in display space */ -void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering); +void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering, + const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings); /** * @brief Deinitialize the compositor caches and allocated memory. diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index fbdb4cd6b28..e1cc25d028a 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -31,6 +31,8 @@ CompositorContext::CompositorContext() this->m_hasActiveOpenCLDevices = false; this->m_activegNode = NULL; this->m_fastCalculation = false; + this->m_viewSettings = NULL; + this->m_displaySettings = NULL; } const int CompositorContext::getFramenumber() const @@ -42,13 +44,3 @@ const int CompositorContext::getFramenumber() const return -1; /* this should never happen */ } } - -const int CompositorContext::isColorManaged() const -{ - if (this->m_rd) { - return this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT; - } - else { - return 0; /* this should never happen */ - } -} diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 2f6abf39985..2f5e8c0648d 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -27,6 +27,7 @@ #include "BKE_text.h" #include <string> #include "DNA_node_types.h" +#include "DNA_color_types.h" #include "BLI_rect.h" #include "DNA_scene_types.h" #include "COM_defines.h" @@ -79,6 +80,9 @@ private: */ bool m_fastCalculation; + /* @brief color management settings */ + const ColorManagedViewSettings *m_viewSettings; + const ColorManagedDisplaySettings *m_displaySettings; public: /** * @brief constructor initializes the context with default values. @@ -126,6 +130,26 @@ public: const RenderData *getRenderData() const { return this->m_rd; } /** + * @brief set view settings of color color management + */ + void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; } + + /** + * @brief get view settings of color color management + */ + const ColorManagedViewSettings *getViewSettings() const { return this->m_viewSettings; } + + /** + * @brief set display settings of color color management + */ + void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; } + + /** + * @brief get display settings of color color management + */ + const ColorManagedDisplaySettings *getDisplaySettings() const { return this->m_displaySettings; } + + /** * @brief set the quality */ void setQuality(CompositorQuality quality) { this->m_quality = quality; } @@ -152,8 +176,6 @@ public: int getChunksize() { return this->getbNodeTree()->chunksize; } - const int isColorManaged() const; - void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;} bool isFastCalculation() {return this->m_fastCalculation;} }; diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 801505e9d39..a13717c9d86 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -44,7 +44,8 @@ #include "MEM_guardedalloc.h" #endif -ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation) +ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation, + const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) { this->m_context.setbNodeTree(editingtree); this->m_context.setFastCalculation(fastcalculation); @@ -69,6 +70,9 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool re ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); this->m_context.setRenderData(rd); + this->m_context.setViewSettings(viewSettings); + this->m_context.setDisplaySettings(displaySettings); + this->convertToOperations(); this->groupOperations(); /* group operations in ExecutionGroups */ unsigned int index; diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 39e7bc80279..56a60bf7a03 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -25,6 +25,7 @@ class ExecutionGroup; #ifndef _COM_ExecutionSystem_h #define _COM_ExecutionSystem_h +#include "DNA_color_types.h" #include "DNA_node_types.h" #include <vector> #include "COM_Node.h" @@ -156,7 +157,8 @@ public: * @param editingtree [bNodeTree *] * @param rendering [true false] */ - ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation); + ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation, + const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings); /** * Destructor diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index e41361fcb2e..bedbfc72722 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -79,14 +79,10 @@ void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node) Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup, bool fast) { - Node *node; - node = Converter::convert(b_node, fast); + Node *node = Converter::convert(b_node, fast); node->setIsInActiveGroup(inActiveGroup); - if (node != NULL) { - addNode(nodes, node); - return node; - } - return NULL; + addNode(nodes, node); + return node; } void ExecutionSystemHelper::addOperation(vector<NodeOperation *>& operations, NodeOperation *operation) { diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp index 0994f3f8890..bdbe21f82ea 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp @@ -253,7 +253,7 @@ static void imp2radangle(float A, float B, float C, float F, float *a, float *b, } } -float clipuv(float x, float limit) +static float clipuv(float x, float limit) { x = (x < 0) ? 0 : ((x >= limit) ? (limit - 1) : x); return x; diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index 50393d14f35..5922b0e6b08 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -75,12 +75,12 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket graph->addOperation(operation); } -void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket) +void Node::addPreviewOperation(ExecutionSystem *system, CompositorContext *context, OutputSocket *outputSocket) { if (this->isInActiveGroup()) { if (!(this->getbNode()->flag & NODE_HIDDEN)) { // do not calculate previews of hidden nodes. if (this->getbNode()->flag & NODE_PREVIEW) { - PreviewOperation *operation = new PreviewOperation(); + PreviewOperation *operation = new PreviewOperation(context->getViewSettings(), context->getDisplaySettings()); system->addOperation(operation); operation->setbNode(this->getbNode()); operation->setbNodeTree(system->getContext().getbNodeTree()); @@ -90,11 +90,11 @@ void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSock } } -void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket) +void Node::addPreviewOperation(ExecutionSystem *system, CompositorContext *context, InputSocket *inputSocket) { if (inputSocket->isConnected() && this->isInActiveGroup()) { OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket(); - this->addPreviewOperation(system, outputsocket); + this->addPreviewOperation(system, context, outputsocket); } } diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 7ce40e3cb34..bfccd069ad1 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -135,8 +135,8 @@ public: */ OutputSocket *findOutputSocketBybNodeSocket(bNodeSocket *socket); protected: - void addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket); - void addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket); + void addPreviewOperation(ExecutionSystem *system, CompositorContext *context, InputSocket *inputSocket); + void addPreviewOperation(ExecutionSystem *system, CompositorContext *context, OutputSocket *outputSocket); bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex); bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex); diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h index b55e444be80..64d669b5e9a 100644 --- a/source/blender/compositor/intern/COM_NodeBase.h +++ b/source/blender/compositor/intern/COM_NodeBase.h @@ -97,7 +97,7 @@ public: * @return [true:false] * @see NodeOperation */ - virtual const int isOperation() const { return false; } + virtual const bool isOperation() const { return false; } /** * @brief check if this is an input node diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 93a19529d34..dfa22a29e41 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -88,7 +88,7 @@ public: * @return [true:false] * @see NodeBase */ - const int isOperation() const { return true; } + const bool isOperation() const { return true; } /** * @brief determine the resolution of this node diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h index dc5ca27cbda..c6b7993c561 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.h +++ b/source/blender/compositor/intern/COM_OutputSocket.h @@ -64,7 +64,7 @@ public: /** * @brief determine the actual data type and channel info. */ - void relinkConnections(OutputSocket *relinkToSocket) { this->relinkConnections(relinkToSocket, false); }; + void relinkConnections(OutputSocket *relinkToSocket) { this->relinkConnections(relinkToSocket, false); } void relinkConnections(OutputSocket *relinkToSocket, bool single); const int getNumberOfConnections() { return this->m_connections.size(); } diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index f732a40e768..eb9c26d4f43 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -25,6 +25,7 @@ #include "BKE_global.h" +#include "COM_compositor.h" #include "COM_WorkScheduler.h" #include "COM_CPUDevice.h" #include "COM_OpenCLDevice.h" @@ -265,7 +266,7 @@ bool WorkScheduler::hasGPUDevices() #endif } -extern void clContextError(const char *errinfo, const void *private_info, size_t cb, void *user_data) +static void clContextError(const char *errinfo, const void *private_info, size_t cb, void *user_data) { printf("OPENCL error: %s\n", errinfo); } diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index cb9166c929d..49ab9db5dd8 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -37,12 +37,14 @@ extern "C" { static ThreadMutex s_compositorMutex; static char is_compositorMutex_init = FALSE; -void intern_freeCompositorCaches() +static void intern_freeCompositorCaches() { deintializeDistortionCache(); } -void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) +void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering, + const ColorManagedViewSettings *viewSettings, + const ColorManagedDisplaySettings *displaySettings) { /* initialize mutex, TODO this mutex init is actually not thread safe and * should be done somewhere as part of blender startup, all the other @@ -71,7 +73,7 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) bool twopass = (editingtree->flag & NTREE_TWO_PASS) > 0 && !rendering; /* initialize execution system */ if (twopass) { - ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass); + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass, viewSettings, displaySettings); system->execute(); delete system; @@ -84,14 +86,14 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) } - ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, false); + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, false, viewSettings, displaySettings); system->execute(); delete system; BLI_mutex_unlock(&s_compositorMutex); } -void COM_freeCaches() +static void UNUSED_FUNCTION(COM_freeCaches)() { if (is_compositorMutex_init) { BLI_mutex_lock(&s_compositorMutex); @@ -100,7 +102,7 @@ void COM_freeCaches() } } -void COM_deinitialize() +void COM_deinitialize() { if (is_compositorMutex_init) { BLI_mutex_lock(&s_compositorMutex); diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp index e39ef2b3f23..4f120ea5a6e 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -57,7 +57,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph); this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0)); graph->addOperation(operationfgb); - addPreviewOperation(graph, operationfgb->getOutputSocket()); + addPreviewOperation(graph, context, operationfgb->getOutputSocket()); } else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) { MathAddOperation *clamp = new MathAddOperation(); @@ -97,7 +97,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co addLink(graph, operationy->getOutputSocket(), operation->getInputSocket(1)); graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - addPreviewOperation(graph, operation->getOutputSocket()); + addPreviewOperation(graph, context, operation->getOutputSocket()); } else if (!data->bokeh) { GaussianXBlurOperation *operationx = new GaussianXBlurOperation(); @@ -115,7 +115,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co graph->addOperation(operationy); addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); - addPreviewOperation(graph, operationy->getOutputSocket()); + addPreviewOperation(graph, context, operationy->getOutputSocket()); if (!connectedSizeSocket) { operationx->setSize(size); @@ -131,7 +131,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setQuality(quality); graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - addPreviewOperation(graph, operation->getOutputSocket()); + addPreviewOperation(graph, context, operation->getOutputSocket()); if (!connectedSizeSocket) { operation->setSize(size); diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp index f6abbbb9a9a..a89ed9e0c64 100644 --- a/source/blender/compositor/nodes/COM_BokehImageNode.cpp +++ b/source/blender/compositor/nodes/COM_BokehImageNode.cpp @@ -35,5 +35,5 @@ void BokehImageNode::convertToOperations(ExecutionSystem *graph, CompositorConte this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); operation->setData((NodeBokehImage *)this->getbNode()->storage); - addPreviewOperation(graph, operation->getOutputSocket(0)); + addPreviewOperation(graph, context, operation->getOutputSocket(0)); } diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp index eab921863e9..c1511ee611b 100644 --- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp @@ -84,7 +84,7 @@ void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCon graph->addOperation(operationAlpha); addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); - addPreviewOperation(graph, operationAlpha->getOutputSocket()); + addPreviewOperation(graph, context, operationAlpha->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp index 0fb09157351..4c4b77ba6cc 100644 --- a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp @@ -65,7 +65,7 @@ void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCont addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); graph->addOperation(operationAlpha); - addPreviewOperation(graph, operationAlpha->getOutputSocket()); + addPreviewOperation(graph, context, operationAlpha->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp index 38ab6ba8da2..54e6762961b 100644 --- a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp @@ -62,7 +62,7 @@ void ColorMatteNode::convertToOperations(ExecutionSystem *graph, CompositorConte addLink(graph, operationRGBToHSV_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); graph->addOperation(operationAlpha); - addPreviewOperation(graph, operationAlpha->getOutputSocket()); + addPreviewOperation(graph, context, operationAlpha->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index d0d66a81c77..e3313750e66 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -45,5 +45,5 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte alphaSocket->relinkConnections(compositorOperation->getInputSocket(1)); depthSocket->relinkConnections(compositorOperation->getInputSocket(2)); graph->addOperation(compositorOperation); - addPreviewOperation(graph, compositorOperation->getInputSocket(0)); + addPreviewOperation(graph, context, compositorOperation->getInputSocket(0)); } diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cpp b/source/blender/compositor/nodes/COM_DespeckleNode.cpp index 603ddcd1389..a97714c870e 100644 --- a/source/blender/compositor/nodes/COM_DespeckleNode.cpp +++ b/source/blender/compositor/nodes/COM_DespeckleNode.cpp @@ -44,7 +44,7 @@ void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContex inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph); inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph); outputSocket->relinkConnections(operation->getOutputSocket()); - addPreviewOperation(graph, operation->getOutputSocket(0)); + addPreviewOperation(graph, context, operation->getOutputSocket(0)); graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp index 6dca049a6ae..b5ad07be319 100644 --- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp @@ -51,5 +51,5 @@ void DifferenceMatteNode::convertToOperations(ExecutionSystem *graph, Compositor addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1)); outputSocketImage->relinkConnections(operation->getOutputSocket()); graph->addOperation(operation); - addPreviewOperation(graph, operation->getOutputSocket()); + addPreviewOperation(graph, context, operation->getOutputSocket()); } diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp index cecc3bf6e86..5bd2f78d8a6 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp @@ -106,7 +106,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont graph->addOperation(operationy); addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); // addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); // no size input yet - addPreviewOperation(graph, operationy->getOutputSocket()); + addPreviewOperation(graph, context, operationy->getOutputSocket()); /* TODO? */ /* see gaussian blue node for original usage */ diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp index 87e7b9d0788..782c897f6fb 100644 --- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp @@ -77,7 +77,7 @@ void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCo addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); graph->addOperation(operationAlpha); - addPreviewOperation(graph, operationAlpha->getOutputSocket()); + addPreviewOperation(graph, context, operationAlpha->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp index 021ec6c2508..990cdb480ca 100644 --- a/source/blender/compositor/nodes/COM_FilterNode.cpp +++ b/source/blender/compositor/nodes/COM_FilterNode.cpp @@ -77,7 +77,7 @@ void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext * inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph); inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph); outputSocket->relinkConnections(operation->getOutputSocket()); - addPreviewOperation(graph, operation->getOutputSocket(0)); + addPreviewOperation(graph, context, operation->getOutputSocket(0)); graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp index 2d13ffb82b6..4ebd28d710a 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.cpp +++ b/source/blender/compositor/nodes/COM_ImageNode.cpp @@ -111,7 +111,7 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c break; } if (index == 0 && operation) { - addPreviewOperation(graph, operation->getOutputSocket()); + addPreviewOperation(graph, context, operation->getOutputSocket()); } } } @@ -134,7 +134,7 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c operation->setImageUser(imageuser); operation->setFramenumber(framenumber); graph->addOperation(operation); - addPreviewOperation(graph, operation->getOutputSocket()); + addPreviewOperation(graph, context, operation->getOutputSocket()); } if (numberOfOutputs > 1) { diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp index be949e2cacb..4656e00b006 100644 --- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp @@ -55,7 +55,7 @@ void LuminanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorC addLink(graph, rgbToYUV->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0)); addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1)); graph->addOperation(operation); - addPreviewOperation(graph, operation->getOutputSocket()); + addPreviewOperation(graph, context, operation->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operation->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp index 7aeaaf56c98..ab4e464327d 100644 --- a/source/blender/compositor/nodes/COM_MixNode.cpp +++ b/source/blender/compositor/nodes/COM_MixNode.cpp @@ -128,7 +128,7 @@ void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *con color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph); color2Socket->relinkConnections(convertProg->getInputSocket(2), 2, graph); outputSocket->relinkConnections(convertProg->getOutputSocket(0)); - addPreviewOperation(graph, convertProg->getOutputSocket(0)); + addPreviewOperation(graph, context, convertProg->getOutputSocket(0)); convertProg->getInputSocket(2)->setResizeMode(color2Socket->getResizeMode()); diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp index 6d5b9bba8aa..5d5e68fba37 100644 --- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp +++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp @@ -62,25 +62,9 @@ void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContex // always connect the output image MovieClipOperation *operation = new MovieClipOperation(); - if (ibuf && context->isColorManaged() && ibuf->profile == IB_PROFILE_NONE) { - ConvertColorProfileOperation *converter = new ConvertColorProfileOperation(); - converter->setFromColorProfile(IB_PROFILE_LINEAR_RGB); - converter->setToColorProfile(IB_PROFILE_SRGB); - addLink(graph, operation->getOutputSocket(), converter->getInputSocket(0)); - addPreviewOperation(graph, converter->getOutputSocket()); - if (outputMovieClip->isConnected()) { - outputMovieClip->relinkConnections(converter->getOutputSocket()); - } - graph->addOperation(converter); - if (ibuf) { - converter->setPredivided(ibuf->flags & IB_cm_predivide); - } - } - else { - addPreviewOperation(graph, operation->getOutputSocket()); - if (outputMovieClip->isConnected()) { - outputMovieClip->relinkConnections(operation->getOutputSocket()); - } + addPreviewOperation(graph, context, operation->getOutputSocket()); + if (outputMovieClip->isConnected()) { + outputMovieClip->relinkConnections(operation->getOutputSocket()); } operation->setMovieClip(movieClip); diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp index b8cee29fee6..921b9e63a73 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp @@ -62,7 +62,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte input->relinkConnections(outputOperation->getInputSocket(i)); } } - if (hasConnections) addPreviewOperation(graph, outputOperation->getInputSocket(0)); + if (hasConnections) addPreviewOperation(graph, context, outputOperation->getInputSocket(0)); graph->addOperation(outputOperation); } @@ -80,11 +80,12 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path); OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation( - context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path); + context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path, + context->getViewSettings(), context->getDisplaySettings()); input->relinkConnections(outputOperation->getInputSocket(0)); graph->addOperation(outputOperation); if (!previewAdded) { - addPreviewOperation(graph, outputOperation->getInputSocket(0)); + addPreviewOperation(graph, context, outputOperation->getInputSocket(0)); previewAdded = true; } } diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp index dfb46af841c..b57e99754d6 100644 --- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp +++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp @@ -52,7 +52,7 @@ RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode) /* pass */ } -void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputSocketNumber, RenderLayersBaseProg *operation) +void RenderLayersNode::testSocketConnection(ExecutionSystem *system, CompositorContext *context, int outputSocketNumber, RenderLayersBaseProg *operation) { OutputSocket *outputSocket = this->getOutputSocket(outputSocketNumber); Scene *scene = (Scene *)this->getbNode()->id; @@ -64,7 +64,7 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS outputSocket->relinkConnections(operation->getOutputSocket()); system->addOperation(operation); if (outputSocketNumber == 0) { // only do for image socket if connected - addPreviewOperation(system, operation->getOutputSocket()); + addPreviewOperation(system, context, operation->getOutputSocket()); } } else { @@ -72,7 +72,7 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS system->addOperation(operation); operation->setScene(scene); operation->setLayerId(layerId); - addPreviewOperation(system, operation->getOutputSocket()); + addPreviewOperation(system, context, operation->getOutputSocket()); } else { delete operation; @@ -82,34 +82,34 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - testSocketConnection(graph, 0, new RenderLayersColorProg()); - testSocketConnection(graph, 1, new RenderLayersAlphaProg()); - testSocketConnection(graph, 2, new RenderLayersDepthProg()); - testSocketConnection(graph, 3, new RenderLayersNormalOperation()); - testSocketConnection(graph, 4, new RenderLayersUVOperation()); - testSocketConnection(graph, 5, new RenderLayersSpeedOperation()); - testSocketConnection(graph, 6, new RenderLayersColorOperation()); - testSocketConnection(graph, 7, new RenderLayersDiffuseOperation()); - testSocketConnection(graph, 8, new RenderLayersSpecularOperation()); - testSocketConnection(graph, 9, new RenderLayersShadowOperation()); - testSocketConnection(graph, 10, new RenderLayersAOOperation()); - testSocketConnection(graph, 11, new RenderLayersReflectionOperation()); - testSocketConnection(graph, 12, new RenderLayersRefractionOperation()); - testSocketConnection(graph, 13, new RenderLayersIndirectOperation()); - testSocketConnection(graph, 14, new RenderLayersObjectIndexOperation()); - testSocketConnection(graph, 15, new RenderLayersMaterialIndexOperation()); - testSocketConnection(graph, 16, new RenderLayersMistOperation()); - testSocketConnection(graph, 17, new RenderLayersEmitOperation()); - testSocketConnection(graph, 18, new RenderLayersEnvironmentOperation()); + testSocketConnection(graph, context, 0, new RenderLayersColorProg()); + testSocketConnection(graph, context, 1, new RenderLayersAlphaProg()); + testSocketConnection(graph, context, 2, new RenderLayersDepthProg()); + testSocketConnection(graph, context, 3, new RenderLayersNormalOperation()); + testSocketConnection(graph, context, 4, new RenderLayersUVOperation()); + testSocketConnection(graph, context, 5, new RenderLayersSpeedOperation()); + testSocketConnection(graph, context, 6, new RenderLayersColorOperation()); + testSocketConnection(graph, context, 7, new RenderLayersDiffuseOperation()); + testSocketConnection(graph, context, 8, new RenderLayersSpecularOperation()); + testSocketConnection(graph, context, 9, new RenderLayersShadowOperation()); + testSocketConnection(graph, context, 10, new RenderLayersAOOperation()); + testSocketConnection(graph, context, 11, new RenderLayersReflectionOperation()); + testSocketConnection(graph, context, 12, new RenderLayersRefractionOperation()); + testSocketConnection(graph, context, 13, new RenderLayersIndirectOperation()); + testSocketConnection(graph, context, 14, new RenderLayersObjectIndexOperation()); + testSocketConnection(graph, context, 15, new RenderLayersMaterialIndexOperation()); + testSocketConnection(graph, context, 16, new RenderLayersMistOperation()); + testSocketConnection(graph, context, 17, new RenderLayersEmitOperation()); + testSocketConnection(graph, context, 18, new RenderLayersEnvironmentOperation()); // cycles passes - testSocketConnection(graph, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT)); - testSocketConnection(graph, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT)); - testSocketConnection(graph, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR)); - testSocketConnection(graph, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT)); - testSocketConnection(graph, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT)); - testSocketConnection(graph, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR)); - testSocketConnection(graph, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT)); - testSocketConnection(graph, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT)); - testSocketConnection(graph, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR)); + testSocketConnection(graph, context, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT)); + testSocketConnection(graph, context, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT)); + testSocketConnection(graph, context, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR)); + testSocketConnection(graph, context, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT)); + testSocketConnection(graph, context, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT)); + testSocketConnection(graph, context, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR)); + testSocketConnection(graph, context, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT)); + testSocketConnection(graph, context, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT)); + testSocketConnection(graph, context, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR)); } diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h index 32672c8ba2d..9bd74624b0c 100644 --- a/source/blender/compositor/nodes/COM_RenderLayersNode.h +++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h @@ -33,5 +33,5 @@ public: RenderLayersNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); private: - void testSocketConnection(ExecutionSystem *graph, int outputSocketNumber, RenderLayersBaseProg *operation); + void testSocketConnection(ExecutionSystem *graph, CompositorContext *context, int outputSocketNumber, RenderLayersBaseProg *operation); }; diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp index 388466cee3c..37b888becca 100644 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp @@ -39,13 +39,14 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont ImageUser *imageUser = (ImageUser *) this->getbNode()->storage; if (image1Socket->isConnected() && image2Socket->isConnected()) { SplitViewerOperation *splitViewerOperation = new SplitViewerOperation(); - splitViewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT); - splitViewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); splitViewerOperation->setImage(image); splitViewerOperation->setImageUser(imageUser); splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()); splitViewerOperation->setSplitPercentage(this->getbNode()->custom1); + splitViewerOperation->setViewSettings(context->getViewSettings()); + splitViewerOperation->setDisplaySettings(context->getDisplaySettings()); + /* defaults - the viewer node has these options but not exposed for split view * we could use the split to define an area of interest on one axis at least */ splitViewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT); @@ -55,7 +56,7 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont splitViewerOperation->setXSplit(!this->getbNode()->custom2); image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph); image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1, graph); - addPreviewOperation(graph, splitViewerOperation->getInputSocket(0)); + addPreviewOperation(graph, context, splitViewerOperation->getInputSocket(0)); graph->addOperation(splitViewerOperation); } } diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp index b035e0a392c..5b386a504e4 100644 --- a/source/blender/compositor/nodes/COM_TextureNode.cpp +++ b/source/blender/compositor/nodes/COM_TextureNode.cpp @@ -40,7 +40,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext operation->setTexture(texture); operation->setRenderData(context->getRenderData()); system->addOperation(operation); - addPreviewOperation(system, operation->getOutputSocket()); + addPreviewOperation(system, context, operation->getOutputSocket()); if (this->getOutputSocket(0)->isConnected()) { TextureAlphaOperation *alphaOperation = new TextureAlphaOperation(); diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index 88ce0ff2016..d67e9e274b0 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -40,8 +40,6 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * ImageUser *imageUser = (ImageUser *) this->getbNode()->storage; bNode *editorNode = this->getbNode(); ViewerOperation *viewerOperation = new ViewerOperation(); - viewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT); - viewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); viewerOperation->setbNodeTree(context->getbNodeTree()); viewerOperation->setImage(image); viewerOperation->setImageUser(imageUser); @@ -50,6 +48,9 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * viewerOperation->setCenterX(editorNode->custom3); viewerOperation->setCenterY(editorNode->custom4); + viewerOperation->setViewSettings(context->getViewSettings()); + viewerOperation->setDisplaySettings(context->getDisplaySettings()); + viewerOperation->setResolutionInputSocketIndex(0); if (!imageSocket->isConnected()) { @@ -62,5 +63,5 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * alphaSocket->relinkConnections(viewerOperation->getInputSocket(1)); depthSocket->relinkConnections(viewerOperation->getInputSocket(2)); graph->addOperation(viewerOperation); - addPreviewOperation(graph, viewerOperation->getInputSocket(0)); + addPreviewOperation(graph, context, viewerOperation->getInputSocket(0)); } diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.h b/source/blender/compositor/operations/COM_DespeckleOperation.h index 5b79d7cb7e0..99635e61544 100644 --- a/source/blender/compositor/operations/COM_DespeckleOperation.h +++ b/source/blender/compositor/operations/COM_DespeckleOperation.h @@ -27,8 +27,8 @@ private: float m_threshold; float m_threshold_neighbour; - int m_filterWidth; - int m_filterHeight; + // int m_filterWidth; + // int m_filterHeight; protected: SocketReader *m_inputOperation; diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index c4b4452fbb0..9c09c9bf034 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -79,7 +79,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y, const int miny = max(y - this->m_scope, rect->ymin); const int maxx = min(x + this->m_scope, rect->xmax); const int maxy = min(y + this->m_scope, rect->ymax); - const int bufferWidth = BLI_RCT_SIZE_X(rect); + const int bufferWidth = BLI_rcti_size_x(rect); int offset; this->m_inputProgram->read(inputValue, x, y, NULL); @@ -199,7 +199,7 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void * const int miny = max(y - this->m_scope, rect->ymin); const int maxx = min(x + this->m_scope, rect->xmax); const int maxy = min(y + this->m_scope, rect->ymax); - const int bufferWidth = BLI_RCT_SIZE_X(rect); + const int bufferWidth = BLI_rcti_size_x(rect); int offset; float value = 0.0f; @@ -273,7 +273,7 @@ void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *d const int miny = max(y - this->m_scope, rect->ymin); const int maxx = min(x + this->m_scope, rect->xmax); const int maxy = min(y + this->m_scope, rect->ymax); - const int bufferWidth = BLI_RCT_SIZE_X(rect); + const int bufferWidth = BLI_rcti_size_x(rect); int offset; float value = 1.0f; diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp index 560bbbdd244..c8ebb845bb6 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp @@ -51,7 +51,7 @@ void DisplaceSimpleOperation::initExecution() /* minimum distance (in pixels) a pixel has to be displaced * in order to take effect */ -#define DISPLACE_EPSILON 0.01f +// #define DISPLACE_EPSILON 0.01f void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp index 7f7429bf2e6..efdf0134c4b 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp @@ -244,7 +244,7 @@ static void fht_convolve(fREAL *d1, fREAL *d2, unsigned int M, unsigned int N) } //------------------------------------------------------------------------------ -void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2) +static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2) { fREAL *data1, *data2, *fp; unsigned int w2, h2, hw, hh, log2_w, log2_h; diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp index 4ec5643c0bb..fb3efbb67ed 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cpp +++ b/source/blender/compositor/operations/COM_ImageOperation.cpp @@ -33,6 +33,7 @@ extern "C" { #include "RE_render_ext.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" + #include "IMB_colormanagement.h" } BaseImageOperation::BaseImageOperation() : NodeOperation() diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h index 7e62de7b9f1..f3eeb2f48ba 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h @@ -99,8 +99,8 @@ public: this->m_inverted == inverted && this->m_width == width && this->m_height == height && - this->m_calibration_width == this->m_calibration_width && - this->m_calibration_height == this->m_calibration_height; + this->m_calibration_width == calibration_width && + this->m_calibration_height == claibration_height; } void getUV(MovieTracking *trackingData, int x, int y, float *u, float *v) diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index b72875ab2f9..21ecfdb5272 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -31,9 +31,12 @@ #include "BKE_global.h" #include "BKE_main.h" +#include "DNA_color_types.h" + extern "C" { #include "MEM_guardedalloc.h" #include "IMB_imbuf.h" + #include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" } @@ -91,7 +94,8 @@ static void write_buffer_rect(rcti *rect, const bNodeTree *tree, OutputSingleLayerOperation::OutputSingleLayerOperation( - const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path) + const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path, + const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) { this->m_rd = rd; this->m_tree = tree; @@ -104,6 +108,9 @@ OutputSingleLayerOperation::OutputSingleLayerOperation( this->m_format = format; BLI_strncpy(this->m_path, path, sizeof(this->m_path)); + + this->m_viewSettings = viewSettings; + this->m_displaySettings = displaySettings; } void OutputSingleLayerOperation::initExecution() @@ -131,8 +138,7 @@ void OutputSingleLayerOperation::deinitExecution() ibuf->mall |= IB_rectfloat; ibuf->dither = this->m_rd->dither_intensity; - if (this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_LINEAR_RGB; + IMB_display_buffer_to_imbuf_rect(ibuf, m_viewSettings, m_displaySettings); BKE_makepicstring(filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format->imtype, (this->m_rd->scemode & R_EXTENSION), true); diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h index 532242c97ce..69d1ad48ced 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileOperation.h @@ -28,6 +28,8 @@ #include "BLI_rect.h" #include "BLI_path_util.h" +#include "DNA_color_types.h" + #include "intern/openexr/openexr_multi.h" /* Writes the image to a single-layer file. */ @@ -43,8 +45,11 @@ private: DataType m_datatype; SocketReader *m_imageInput; + const ColorManagedViewSettings *m_viewSettings; + const ColorManagedDisplaySettings *m_displaySettings; public: - OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); + OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path, + const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings); void executeRegion(rcti *rect, unsigned int tileNumber); bool isOutputOperation(bool rendering) const { return true; } diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index aff374cdded..6e58b277f66 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -35,16 +35,19 @@ extern "C" { #include "MEM_guardedalloc.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" + #include "IMB_colormanagement.h" } -PreviewOperation::PreviewOperation() : NodeOperation() +PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->m_outputBuffer = NULL; this->m_input = NULL; this->m_divider = 1.0f; this->m_node = NULL; + this->m_viewSettings = viewSettings; + this->m_displaySettings = displaySettings; } void PreviewOperation::initExecution() @@ -82,6 +85,10 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber) { int offset; float color[4]; + struct ColormanageProcessor *cm_processor; + + cm_processor = IMB_colormanagement_display_processor_new(this->m_viewSettings, this->m_displaySettings); + for (int y = rect->ymin; y < rect->ymax; y++) { offset = (y * getWidth() + rect->xmin) * 4; for (int x = rect->xmin; x < rect->xmax; x++) { @@ -93,11 +100,13 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber) color[2] = 0.0f; color[3] = 1.0f; this->m_input->read(color, rx, ry, COM_PS_NEAREST); - linearrgb_to_srgb_v4(color, color); + IMB_colormanagement_processor_apply_v4(cm_processor, color); F4TOCHAR4(color, this->m_outputBuffer + offset); offset += 4; } } + + IMB_colormanagement_processor_free(cm_processor); } bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h index ffd80ff27af..9e774d0e41b 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.h +++ b/source/blender/compositor/operations/COM_PreviewOperation.h @@ -24,6 +24,7 @@ #define _COM_PreviewOperation_h #include "COM_NodeOperation.h" #include "DNA_image_types.h" +#include "DNA_color_types.h" #include "BLI_rect.h" class PreviewOperation : public NodeOperation { @@ -37,8 +38,10 @@ protected: SocketReader *m_input; float m_divider; + const ColorManagedViewSettings *m_viewSettings; + const ColorManagedDisplaySettings *m_displaySettings; public: - PreviewOperation(); + PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings); bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp index d59d1f9f10d..7325e32a863 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp @@ -62,7 +62,6 @@ void SplitViewerOperation::deinitExecution() void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float *buffer = this->m_outputBuffer; - unsigned char *bufferDisplay = this->m_outputBufferDisplay; if (!buffer) return; int x1 = rect->xmin; @@ -76,7 +75,6 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) for (y = y1; y < y2; y++) { for (x = x1; x < x2; x++) { bool image1; - float srgb[4]; image1 = this->m_xSplit ? x > perc : y > perc; if (image1) { this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST); @@ -84,21 +82,7 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) else { this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST); } - /// @todo: linear conversion only when scene color management is selected, also check predivide. - if (this->m_doColorManagement) { - if (this->m_doColorPredivide) { - linearrgb_to_srgb_predivide_v4(srgb, buffer + offset); - } - else { - linearrgb_to_srgb_v4(srgb, buffer + offset); - } - } - else { - copy_v4_v4(srgb, buffer + offset); - } - - rgba_float_to_uchar(bufferDisplay + offset, srgb); - + offset += 4; } offset += (this->getWidth() - (x2 - x1)) * 4; diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp index f443c33cd54..d9ca131721f 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp @@ -34,6 +34,7 @@ extern "C" { #include "MEM_guardedalloc.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" + #include "IMB_colormanagement.h" } @@ -43,10 +44,10 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation() this->setImageUser(NULL); this->m_outputBuffer = NULL; this->m_depthBuffer = NULL; - this->m_outputBufferDisplay = NULL; this->m_active = false; - this->m_doColorManagement = true; this->m_doDepthBuffer = false; + this->m_viewSettings = NULL; + this->m_displaySettings = NULL; } void ViewerBaseOperation::initExecution() @@ -60,7 +61,7 @@ void ViewerBaseOperation::initImage() { Image *anImage = this->m_image; ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock); - + if (!ibuf) return; BLI_lock_thread(LOCK_DRAW_IMAGE); if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) { @@ -70,30 +71,44 @@ void ViewerBaseOperation::initImage() IMB_freezbuffloatImBuf(ibuf); ibuf->x = getWidth(); ibuf->y = getHeight(); - imb_addrectImBuf(ibuf); imb_addrectfloatImBuf(ibuf); anImage->ok = IMA_OK_LOADED; + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + + BLI_unlock_thread(LOCK_DRAW_IMAGE); } + if (m_doDepthBuffer) { addzbuffloatImBuf(ibuf); } BLI_unlock_thread(LOCK_DRAW_IMAGE); - - + /* now we combine the input with ibuf */ this->m_outputBuffer = ibuf->rect_float; - this->m_outputBufferDisplay = (unsigned char *)ibuf->rect; + + /* needed for display buffer update + * + * no need to lock / reference the image buffer because it's seems + * to be the single place which changes buffers of viewer image + * which is this node + */ + this->m_ibuf = ibuf; + if (m_doDepthBuffer) { this->m_depthBuffer = ibuf->zbuf_float; } - + BKE_image_release_ibuf(this->m_image, this->m_lock); } void ViewerBaseOperation:: updateImage(rcti *rect) { + IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, NULL, getWidth(), 0, 0, + this->m_viewSettings, this->m_displaySettings, + rect->xmin, rect->ymin, rect->xmax, rect->ymax); + WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL); } diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h index d90eb343f6c..f7d479eb3b8 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h @@ -30,7 +30,6 @@ class ViewerBaseOperation : public NodeOperation { protected: float *m_outputBuffer; float *m_depthBuffer; - unsigned char *m_outputBufferDisplay; Image *m_image; ImageUser *m_imageUser; void *m_lock; @@ -38,9 +37,11 @@ protected: float m_centerX; float m_centerY; OrderOfChunks m_chunkOrder; - bool m_doColorManagement; - bool m_doColorPredivide; bool m_doDepthBuffer; + ImBuf *m_ibuf; + + const ColorManagedViewSettings *m_viewSettings; + const ColorManagedDisplaySettings *m_displaySettings; public: bool isOutputOperation(bool rendering) const { return isActiveViewerOutput(); } @@ -57,10 +58,10 @@ public: float getCenterY() { return this->m_centerY; } OrderOfChunks getChunkOrder() { return this->m_chunkOrder; } const CompositorPriority getRenderPriority() const; - void setColorManagement(bool doColorManagement) { this->m_doColorManagement = doColorManagement; } - void setColorPredivide(bool doColorPredivide) { this->m_doColorPredivide = doColorPredivide; } bool isViewerOperation() { return true; } - + + void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; } + void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; } protected: ViewerBaseOperation(); void updateImage(rcti *rect); diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index b85b86bddc3..576d5da4d74 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -72,7 +72,6 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float *buffer = this->m_outputBuffer; float *depthbuffer = this->m_depthBuffer; - unsigned char *bufferDisplay = this->m_outputBufferDisplay; if (!buffer) return; const int x1 = rect->xmin; const int y1 = rect->ymin; @@ -82,7 +81,7 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) const int offsetadd4 = offsetadd * 4; int offset = (y1 * this->getWidth() + x1); int offset4 = offset * 4; - float alpha[4], srgb[4], depth[4]; + float alpha[4], depth[4]; int x; int y; bool breaked = false; @@ -98,19 +97,6 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) this->m_depthInput->read(depth, x, y, COM_PS_NEAREST); depthbuffer[offset] = depth[0]; } - if (this->m_doColorManagement) { - if (this->m_doColorPredivide) { - linearrgb_to_srgb_predivide_v4(srgb, buffer + offset4); - } - else { - linearrgb_to_srgb_v4(srgb, buffer + offset4); - } - } - else { - copy_v4_v4(srgb, buffer + offset4); - } - - rgba_float_to_uchar(bufferDisplay + offset4, srgb); offset ++; offset4 += 4; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index f220f0ee762..12c0e851f88 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -85,6 +85,7 @@ /* size of indent steps */ #define INDENT_STEP_SIZE 7 +/* size of string buffers used for animation channel displayed names */ #define ANIM_CHAN_NAME_SIZE 256 /* get the pointer used for some flag */ @@ -293,7 +294,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree) } } - // unknown + /* unknown */ return 0; } @@ -423,7 +424,7 @@ static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name) BLI_strncpy(name, "DopeSheet Summary", ANIM_CHAN_NAME_SIZE); } -// TODO: this is really a temp icon I think +// FIXME: this is really a temp icon I think static int acf_summary_icon(bAnimListElem *UNUSED(ale)) { return ICON_BORDERMOVE; @@ -602,7 +603,6 @@ static int acf_object_icon(bAnimListElem *ale) Object *ob = base->object; /* icon depends on object-type */ - switch (ob->type) { case OB_LAMP: return ICON_OUTLINER_OB_LAMP; @@ -629,7 +629,6 @@ static int acf_object_icon(bAnimListElem *ale) default: return ICON_OBJECT_DATA; } - } /* name for object */ @@ -2256,7 +2255,7 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short * { /* clear extra return data first */ *neg = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return SPK_DS_EXPAND; @@ -2280,10 +2279,10 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short * static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type) { Speaker *spk = (Speaker *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(spk->flag, type); @@ -2555,7 +2554,7 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne return GP_LAYER_HIDE; case ACHANNEL_SETTING_PROTECT: /* protected */ - // *neg = 1; - if we change this to edtiability + // *neg = 1; - if we change this to editability return GP_LAYER_LOCKED; default: /* unsupported */ @@ -2604,7 +2603,7 @@ static void acf_mask_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), // TODO: just get this from RNA? static int acf_mask_icon(bAnimListElem *UNUSED(ale)) { - return ICON_GREASEPENCIL; // MASK_TODO - need real icon + return ICON_MOD_MASK; } /* check if some setting exists for this channel */ @@ -2651,15 +2650,15 @@ static void *acf_mask_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short /* mask datablock type define */ static bAnimChannelType ACF_MASKDATA = { - "Mask Datablock", /* type name */ + "Mask Datablock", /* type name */ acf_mask_color, /* backdrop color */ - acf_group_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - acf_generic_group_offset, /* offset */ + acf_group_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_group_offset, /* offset */ - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ acf_mask_icon, /* icon */ acf_mask_setting_valid, /* has setting */ @@ -2720,7 +2719,7 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short // return GP_LAYER_HIDE; case ACHANNEL_SETTING_PROTECT: /* protected */ - // *neg = 1; - if we change this to edtiability + // *neg = 1; - if we change this to editability return MASK_LAYERFLAG_LOCKED; default: /* unsupported */ @@ -2732,7 +2731,7 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { MaskLayer *masklay = (MaskLayer *)ale->data; - + /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(masklay->flag, type); } @@ -2740,20 +2739,20 @@ static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), sh /* grease pencil layer type define */ static bAnimChannelType ACF_MASKLAYER = { - "Mask Layer", /* type name */ - + "Mask Layer", /* type name */ + acf_generic_channel_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ acf_generic_indention_flexible, /* indent level */ acf_generic_group_offset, /* offset */ - - acf_masklay_name, /* name */ - acf_masklay_name_prop, /* name prop */ + + acf_masklay_name, /* name */ + acf_masklay_name_prop, /* name prop */ NULL, /* icon */ - - acf_masklay_setting_valid, /* has setting */ - acf_masklay_setting_flag, /* flag for setting */ - acf_masklay_setting_ptr /* pointer for setting */ + + acf_masklay_setting_valid, /* has setting */ + acf_masklay_setting_flag, /* flag for setting */ + acf_masklay_setting_ptr /* pointer for setting */ }; @@ -2855,7 +2854,7 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) acf->name(ale, name); else BLI_strncpy(name, "<No name>", sizeof(name)); - + /* print type name + ui name */ printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name); } @@ -2999,7 +2998,6 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, #define RENAME_TEXT_WIDTH 100 /* Draw the given channel */ -// TODO: make this use UI controls for the buttons void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); @@ -3089,20 +3087,20 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* TODO: when renaming, we might not want to draw this, especially if name happens to be longer than channel */ if (acf->name) { char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */ - + /* set text color */ /* XXX: if active, highlight differently? */ if (selected) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); - + /* get name */ acf->name(ale, name); - + offset += 3; UI_DrawString(offset, ytext, name); - + /* draw red underline if channel is disabled */ if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) { /* FIXME: replace hardcoded color here, and check on extents! */ @@ -3147,7 +3145,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { + if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) offset += ICON_WIDTH; @@ -3232,7 +3230,6 @@ static void achannel_setting_rename_done_cb(bContext *C, void *ads_poin, void *U ads->renameIndex = 0; /* send notifiers */ - // XXX: right notifier? WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL); } @@ -3278,7 +3275,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi { Key *key = (Key *)key_poin; KeyBlock *kb = (KeyBlock *)kb_poin; - char *rna_path = key_get_curValue_rnaPath(key, kb); + char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); @@ -3516,7 +3513,6 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale offset = 0; // TODO: when drawing sliders, make those draw instead of these toggles if not enough space - if (v2d) { short draw_sliders = 0; @@ -3539,7 +3535,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { + if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset += ICON_WIDTH; @@ -3586,7 +3582,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale KeyBlock *kb = (KeyBlock *)ale->data; Key *key = (Key *)ale->id; - rna_path = key_get_curValue_rnaPath(key, kb); + rna_path = BKE_keyblock_curval_rnapath_get(key, kb); free_path = 1; } diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 6ce9fc638be..98071fafc1e 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -142,7 +142,6 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro /* check if there are bones, and whether the name matches any * NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone */ - // TODO: if bone gets renamed, it would be best to be able to rename the group if (ob->pose) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); bArmature *arm = ob->data; @@ -319,7 +318,6 @@ void ANIM_sync_animchannels_to_data(const bContext *C) FCurve *active_fcurve = NULL; /* get animation context info for filtering the channels */ - // TODO: check on whether we need to set the area specially instead, since active area might not be ok? if (ANIM_animdata_get_context(C, &ac) == 0) return; diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 7a80cab93e5..eb7bc68ff8f 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -100,7 +100,7 @@ /* ----------- Private Stuff - Action Editor ------------- */ /* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */ -/* Note: there's a similar function in key.c (ob_get_key) */ +/* Note: there's a similar function in key.c (BKE_key_from_object) */ static Key *actedit_get_shapekeys(bAnimContext *ac) { Scene *scene = ac->scene; @@ -115,7 +115,7 @@ static Key *actedit_get_shapekeys(bAnimContext *ac) //if (saction->pin) return NULL; /* shapekey data is stored with geometry data */ - key = ob_get_key(ob); + key = BKE_key_from_object(ob); if (key) { if (key->type == KEY_RELATIVE) @@ -164,30 +164,30 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction) ac->mode = saction->mode; return 1; - + case SACTCONT_GPENCIL: /* Grease Pencil */ /* XXX review how this mode is handled... */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ saction->ads.source = (ID *)ac->scene; - + ac->datatype = ANIMCONT_GPENCIL; ac->data = &saction->ads; - + ac->mode = saction->mode; return 1; - - case SACTCONT_MASK: /* Grease Pencil */ /* XXX review how this mode is handled... */ - /* update scene-pointer (no need to check for pinning yet, as not implemented) */ + + case SACTCONT_MASK: /* Mask */ /* XXX review how this mode is handled... */ { /* TODO, other methods to get the mask */ // Sequence *seq = BKE_sequencer_active_get(ac->scene); //MovieClip *clip = ac->scene->clip; // struct Mask *mask = seq ? seq->mask : NULL; - + + /* update scene-pointer (no need to check for pinning yet, as not implemented) */ saction->ads.source = (ID *)ac->scene; - + ac->datatype = ANIMCONT_MASK; ac->data = &saction->ads; - + ac->mode = saction->mode; return 1; } @@ -689,12 +689,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Speaker *spk = (Speaker *)data; AnimData *adt = spk->adt; - + ale->flag = FILTER_SPK_OBJD(spk); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); } break; @@ -813,7 +813,7 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne /* the corresponding keyframes are from the animdata */ if (ale->adt && ale->adt->action) { bAction *act = ale->adt->action; - char *rna_path = key_get_curValue_rnaPath(key, kb); + char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); /* try to find the F-Curve which corresponds to this exactly, * then free the MEM_alloc'd string @@ -838,18 +838,18 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne ale->datatype = ALE_GPFRAME; } break; - + case ANIMTYPE_MASKLAYER: { MaskLayer *masklay = (MaskLayer *)data; - + ale->flag = masklay->flag; - + ale->key_data = NULL; ale->datatype = ALE_MASKLAY; } break; - + case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)data; @@ -1152,7 +1152,6 @@ static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeShee /* don't include anything from this action if it is linked in from another file, * and we're getting stuff for editing... */ - // TODO: need a way of tagging other channels that may also be affected... if ((filter_mode & ANIMFILTER_FOREDIT) && (act->id.lib)) return 0; @@ -1254,11 +1253,11 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope { AnimData *adt = BKE_animdata_from_id(id); size_t items = 0; - + /* image object datablocks have no anim-data so check for NULL */ if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id; - + /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed * in a few places in he rest of the code still - notably for the few cases where special mode-based * different types of data expanders are required. @@ -1279,7 +1278,7 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope } ); } - + return items; } @@ -1297,7 +1296,6 @@ static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Ke /* loop through the channels adding ShapeKeys as appropriate */ for (kb = key->block.first; kb; kb = kb->next) { /* skip the first one, since that's the non-animatable basis */ - // XXX maybe in future this may become handy? if (kb == key->block.first) continue; /* only work with this channel and its subchannels if it is editable */ @@ -1659,7 +1657,6 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data, /* did we find anything? */ if (tmp_items) { /* include material-expand widget first */ - // hmm... do we need to store the index of this material in the array anywhere? if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* check if filtering by active status */ if (ANIMCHANNEL_ACTIVEOK(ma)) { @@ -1871,11 +1868,11 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b { Lamp *la = ob->data; bNodeTree *ntree = la->nodetree; - + /* nodetree */ if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, &la->id, ntree, filter_mode); - + /* textures */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, &la->id, filter_mode); @@ -2005,7 +2002,7 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data /* filter data contained under object first */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob)) { - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); /* object-level animation */ if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) { @@ -2344,7 +2341,7 @@ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bD size_t items = 0; /* data to filter depends on channel type */ - // XXX: only common channel-types have been handled for now + /* NOTE: only common channel-types have been handled for now. More can be added as necessary */ switch (channel->type) { case ANIMTYPE_SUMMARY: items += animdata_filter_dopesheet(ac, anim_data, ads, filter_mode); @@ -2357,6 +2354,10 @@ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bD case ANIMTYPE_OBJECT: items += animdata_filter_dopesheet_ob(ac, anim_data, ads, channel->data, filter_mode); break; + + default: + printf("ERROR: Unsupported channel type (%d) in animdata_filter_animchan()\n", channel->type); + break; } return items; @@ -2481,9 +2482,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo } break; - case ANIMCONT_FCURVES: /* Graph Editor -> FCurves/Animation Editing */ + case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */ case ANIMCONT_DRIVERS: /* Graph Editor -> Drivers Editing */ - case ANIMCONT_NLA: /* NLA Editor */ + case ANIMCONT_NLA: /* NLA Editor */ { /* all of these editors use the basic DopeSheet data for filtering options, but don't have all the same features */ items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 445b684c261..270e7fc8f90 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -354,7 +354,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) xpos = marker->frame; /* no time correction for framelen! space is drawn with old values */ - ypixels = BLI_RCT_SIZE_Y(&v2d->mask); + ypixels = BLI_rcti_size_y(&v2d->mask); UI_view2d_getscale(v2d, &xscale, &yscale); glScalef(1.0f / xscale, 1.0f, 1.0f); @@ -773,7 +773,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) if (hasNumInput(&mm->num)) break; - dx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); + dx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); if (evt->x != mm->evtx) { /* XXX maybe init for first time */ int a, offs, totmark = 0; diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index e254fb7a3c4..30e4d8570cb 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -74,13 +74,6 @@ #define B_REDR 1 #define B_FMODIFIER_REDRAW 20 -/* macro for use here to draw background box and set height */ -// XXX for now, roundbox has it's callback func set to NULL to not intercept events -#define DRAW_BACKDROP(height) \ - { \ - uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco - height, width + 3, height - 1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \ - } (void)0 - /* callback to verify modifier data */ static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED(arg)) { diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 8cd8cfaea51..1791d84d90b 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1086,7 +1086,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou * The flag argument is used for special settings that alter the behavior of * the keyframe deletion. These include the quick refresh options. */ -short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, short UNUSED(flag)) +static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, short UNUSED(flag)) { AnimData *adt = BKE_animdata_from_id(id); PointerRNA id_ptr, ptr; @@ -1836,7 +1836,7 @@ static short object_frame_has_keyframe(Object *ob, float frame, short filter) /* try shapekey keyframes (if available, and allowed by filter) */ if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY) ) { - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); /* shapekeys can have keyframes ('Relative Shape Keys') * or depend on time (old 'Absolute Shape Keys') diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 738fdc229fb..cb52d88f985 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -4589,7 +4589,9 @@ void ED_pose_deselectall(Object *ob, int test) int selectmode = 0; /* we call this from outliner too */ - if (ELEM(NULL, ob, ob->pose)) return; + if (ob->pose == NULL) { + return; + } /* Determine if we're selecting or deselecting */ if (test == 1) { diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 78d3d8dc64d..f3f985fa97d 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -644,7 +644,7 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in short pval[2]; int pdist; - project_short_noclip(ar, stk->points[i].p, pval); + ED_view3d_project_short_noclip(ar, stk->points[i].p, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -679,7 +679,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, { copy_v3_v3(vec, bone->head); mul_m4_v3(ob->obmat, vec); - project_short_noclip(ar, vec, pval); + ED_view3d_project_short_noclip(ar, vec, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -695,7 +695,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, copy_v3_v3(vec, bone->tail); mul_m4_v3(ob->obmat, vec); - project_short_noclip(ar, vec, pval); + ED_view3d_project_short_noclip(ar, vec, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -907,7 +907,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float delta = len_v3v3(stk->points[i].p, stk->points[i + 1].p); float pval[2]; - project_float(ar, stk->points[i].p, pval); + ED_view3d_project_float(ar, stk->points[i].p, pval); ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal); mul_v3_fl(ray_normal, distance * progress / length); @@ -934,7 +934,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr initgrabz(ar->regiondata, fp[0], fp[1], fp[2]); /* method taken from editview.c - mouse_cursor() */ - project_short_noclip(ar, fp, cval); + ED_view3d_project_short_noclip(ar, fp, cval); VECSUB2D(mval_f, cval, dd->mval); ED_view3d_win_to_delta(ar, mval_f, dvec); sub_v3_v3v3(vec, fp, dvec); @@ -1453,8 +1453,8 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu float s_p2[3] = {0, 0, 0}; int g_i; - project_float(ar, gesture->points[s_i].p, s_p1); - project_float(ar, gesture->points[s_i + 1].p, s_p2); + ED_view3d_project_float(ar, gesture->points[s_i].p, s_p1); + ED_view3d_project_float(ar, gesture->points[s_i + 1].p, s_p2); /* start checking from second next, because two consecutive cannot intersect */ for (g_i = s_i + 2; g_i < gesture->nb_points - 1; g_i++) { @@ -1463,8 +1463,8 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu float vi[3]; float lambda; - project_float(ar, gesture->points[g_i].p, g_p1); - project_float(ar, gesture->points[g_i + 1].p, g_p2); + ED_view3d_project_float(ar, gesture->points[g_i].p, g_p1); + ED_view3d_project_float(ar, gesture->points[g_i + 1].p, g_p2); if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); @@ -1531,8 +1531,8 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S float s_p2[3] = {0, 0, 0}; int g_i; - project_float(ar, stk->points[s_i].p, s_p1); - project_float(ar, stk->points[s_i + 1].p, s_p2); + ED_view3d_project_float(ar, stk->points[s_i].p, s_p1); + ED_view3d_project_float(ar, stk->points[s_i + 1].p, s_p2); for (g_i = 0; g_i < gesture->nb_points - 1; g_i++) { float g_p1[3] = {0, 0, 0}; @@ -1540,8 +1540,8 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S float vi[3]; float lambda; - project_float(ar, gesture->points[g_i].p, g_p1); - project_float(ar, gesture->points[g_i + 1].p, g_p2); + ED_view3d_project_float(ar, gesture->points[g_i].p, g_p1); + ED_view3d_project_float(ar, gesture->points[g_i + 1].p, g_p2); if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); @@ -1784,8 +1784,8 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc short start_val[2], end_val[2]; short dist; - project_short_noclip(ar, gest->stk->points[0].p, start_val); - project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val); + ED_view3d_project_short_noclip(ar, gest->stk->points[0].p, start_val); + ED_view3d_project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val); dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1])); diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 6b6d2a1505f..346ed0002bd 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -667,7 +667,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, *err_str = NULL; /* count triangles and create mask */ - if ((use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) || + if ((use_face_sel = ((me->editflag & ME_EDIT_PAINT_MASK) != 0)) || (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) { mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index e9424a08b0c..2f5eaabc12b 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -74,12 +74,30 @@ #include "ED_mesh.h" #include "ED_screen.h" #include "ED_object.h" +#include "ED_util.h" /* clipboard */ #include "UI_interface.h" #include "UI_resources.h" #include "armature_intern.h" +/* matches logic with ED_operator_posemode_context() */ +Object *ED_pose_object_from_context(bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + Object *ob; + + /* since this call may also be used from the buttons window, we need to check for where to get the object */ + if (sa && sa->spacetype == SPACE_BUTS) { + ob = ED_object_context(C); + } + else { + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + } + + return ob; +} + /* This function is used to process the necessary updates for */ void ED_armature_enter_posemode(bContext *C, Base *base) { @@ -727,7 +745,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op) short changed = 0; /* sanity check */ - if (ELEM(NULL, ob, ob->pose)) + if (ob->pose == NULL) return OPERATOR_CANCELLED; /* selection types @@ -1049,7 +1067,7 @@ static void pose_copy_menu(Scene *scene) /* Global copy/paste buffer for pose - cleared on start/end session + before every copy operation */ static bPose *g_posebuf = NULL; -void free_posebuf(void) +void ED_clipboard_posebuf_free(void) { if (g_posebuf) { bPoseChannel *pchan; @@ -1225,7 +1243,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op) } /* free existing pose buffer */ - free_posebuf(); + ED_clipboard_posebuf_free(); /* sets chan->flag to POSE_KEY if bone selected, then copy those bones to the buffer */ set_pose_keys(ob); @@ -1330,15 +1348,8 @@ void POSE_OT_paste(wmOperatorType *ot) static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + Object *ob = ED_pose_object_from_context(C); + /* only continue if there's an object */ if (ob == NULL) return OPERATOR_CANCELLED; @@ -1361,7 +1372,7 @@ void POSE_OT_group_add(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_add_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1370,14 +1381,7 @@ void POSE_OT_group_add(wmOperatorType *ot) static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object */ if (ob == NULL) @@ -1401,7 +1405,7 @@ void POSE_OT_group_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_remove_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1412,8 +1416,7 @@ void POSE_OT_group_remove(wmOperatorType *ot) /* invoke callback which presents a list of bone-groups for the user to choose from */ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); bPose *pose; uiPopupMenu *pup; @@ -1421,12 +1424,6 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( bActionGroup *grp; int i; - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1465,17 +1462,10 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( /* Assign selected pchans to the bone group that the user selects */ static int pose_group_assign_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); bPose *pose; short done = FALSE; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1517,7 +1507,7 @@ void POSE_OT_group_assign(wmOperatorType *ot) /* api callbacks */ ot->invoke = pose_groups_menu_invoke; ot->exec = pose_group_assign_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1529,16 +1519,9 @@ void POSE_OT_group_assign(wmOperatorType *ot) static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); short done = FALSE; - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1572,7 +1555,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_unassign_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1580,7 +1563,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot) static int group_move_exec(bContext *C, wmOperator *op) { - Object *ob = ED_object_context(C); + Object *ob = ED_pose_object_from_context(C); bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; bActionGroup *grp; @@ -1653,7 +1636,7 @@ void POSE_OT_group_move(wmOperatorType *ot) /* api callbacks */ ot->exec = group_move_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1678,7 +1661,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = ED_object_context(C); + Object *ob = ED_pose_object_from_context(C); bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; tSortActionGroup *agrp_array; @@ -1737,7 +1720,7 @@ void POSE_OT_group_sort(wmOperatorType *ot) /* api callbacks */ ot->exec = group_sort_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1765,14 +1748,7 @@ static void pose_group_select(bContext *C, Object *ob, int select) static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1795,7 +1771,7 @@ void POSE_OT_group_select(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_select_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1803,14 +1779,7 @@ void POSE_OT_group_select(wmOperatorType *ot) static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1833,7 +1802,7 @@ void POSE_OT_group_deselect(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_deselect_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index d780429784f..9c13f4be6a9 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1233,12 +1233,12 @@ void make_editNurb(Object *obedit) set_actNurb(obedit, NULL); if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - actkey = ob_get_keyblock(obedit); + actkey = BKE_keyblock_from_object(obedit); if (actkey) { // XXX strcpy(G.editModeTitleExtra, "(Key) "); undo_editmode_clear(); - key_to_curve(actkey, cu, &cu->nurb); + BKE_key_convert_to_curve(actkey, cu, &cu->nurb); } if (editnurb) { @@ -6070,7 +6070,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) } /************** join operator, to be used externally? ****************/ - +/* TODO: shape keys - as with meshes */ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); @@ -6191,10 +6191,9 @@ static const char *get_surf_defname(int type) } -Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) +Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type, int newob) { static int xzproj = 0; /* this function calls itself... */ - Object *obedit = CTX_data_edit_object(C); ListBase *editnurb = object_editcurve_get(obedit); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); @@ -6431,7 +6430,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) break; case CU_PRIM_TUBE: /* Cylinder */ if (cutype == CU_NURBS) { - nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */ + nu = add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */ nu->resolu = cu->resolu; nu->flag = CU_SMOOTH; BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ @@ -6510,7 +6509,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) float tmp_vec[3] = {0.f, 0.f, 1.f}; xzproj = 1; - nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */ + nu = add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */ xzproj = 0; nu->resolu = cu->resolu; nu->resolv = cu->resolv; @@ -6607,7 +6606,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); - nu = add_nurbs_primitive(C, mat, type, newob); + nu = add_nurbs_primitive(C, obedit, mat, type, newob); editnurb = object_editcurve_get(obedit); BLI_addtail(editnurb, nu); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 5d67b63af18..659e99607f0 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -422,8 +422,8 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin } else { if (subrect) { - mvalf[0] = (((float)pt->x / 100.0f) * BLI_RCT_SIZE_X(subrect)) + subrect->xmin; - mvalf[1] = (((float)pt->y / 100.0f) * BLI_RCT_SIZE_Y(subrect)) + subrect->ymin; + mvalf[0] = (((float)pt->x / 100.0f) * BLI_rctf_size_x(subrect)) + subrect->xmin; + mvalf[1] = (((float)pt->y / 100.0f) * BLI_rctf_size_y(subrect)) + subrect->ymin; } else { mvalf[0] = (float)pt->x / 100.0f * ar->winx; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 4e281b96fc3..8ba4985ffc4 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -278,7 +278,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] gp_get_3d_reference(p, rvec); /* method taken from editview.c - mouse_cursor() */ - project_int_noclip(p->ar, rvec, mval_prj); + ED_view3d_project_int_noclip(p->ar, rvec, mval_prj); VECSUB2D(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec); @@ -299,8 +299,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100; } else { /* camera view, use subrect */ - out[0] = ((mval[0] - p->subrect->xmin) / BLI_RCT_SIZE_X(p->subrect)) * 100; - out[1] = ((mval[1] - p->subrect->ymin) / BLI_RCT_SIZE_Y(p->subrect)) * 100; + out[0] = ((mval[0] - p->subrect->xmin) / BLI_rctf_size_x(p->subrect)) * 100; + out[1] = ((mval[1] - p->subrect->ymin) / BLI_rctf_size_y(p->subrect)) * 100; } } } @@ -808,7 +808,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, else if (gps->totpoints == 1) { /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { - project_int(p->ar, &gps->points->x, xyval); + ED_view3d_project_int(p->ar, &gps->points->x, xyval); x0 = xyval[0]; y0 = xyval[1]; } @@ -821,8 +821,8 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, y0 = (int)(gps->points->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0 = (int)((gps->points->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin; - y0 = (int)((gps->points->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin; + x0 = (int)((gps->points->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin; + y0 = (int)((gps->points->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin; } } @@ -847,11 +847,11 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { - project_int(p->ar, &pt1->x, xyval); + ED_view3d_project_int(p->ar, &pt1->x, xyval); x0 = xyval[0]; y0 = xyval[1]; - project_int(p->ar, &pt2->x, xyval); + ED_view3d_project_int(p->ar, &pt2->x, xyval); x1 = xyval[0]; y1 = xyval[1]; } @@ -868,10 +868,10 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, y1 = (int)(pt2->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0 = (int)((pt1->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin; - y0 = (int)((pt1->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin; - x1 = (int)((pt2->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin; - y1 = (int)((pt2->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin; + x0 = (int)((pt1->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin; + y0 = (int)((pt1->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin; + x1 = (int)((pt2->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin; + y1 = (int)((pt2->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin; } } diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 07f3498580c..4e33404be7e 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -148,6 +148,7 @@ void ED_armature_enter_posemode(struct bContext *C, struct Base *base); int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan); void ED_pose_deselectall(struct Object *ob, int test); void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob); +struct Object *ED_pose_object_from_context(struct bContext *C); /* sketch */ diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 13c3b180230..28727c913cb 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -83,7 +83,7 @@ void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mas /* textures buffer */ int ED_space_clip_texture_buffer_supported(struct SpaceClip *sc); -int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf); +int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf, const unsigned char *display_buffer); void ED_space_clip_unload_movieclip_buffer(struct SpaceClip *sc); void ED_space_clip_free_texture_buffer(struct SpaceClip *sc); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index ac8d82e9060..d66cc49a5d0 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -67,7 +67,7 @@ void BKE_curve_editNurb_free(struct Curve *cu); int mouse_nurb(struct bContext *C, const int mval[2], int extend, int deselect, int toggle); -struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newob); +struct Nurb *add_nurbs_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newob); int isNurbsel(struct Nurb *nu); void ED_nurb_set_spline_type(struct Nurb *nu, int type); diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index 87f12b8ac9c..a50b33966c6 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -39,6 +39,7 @@ struct ToolSettings; struct uiBlock; struct wmWindowManager; struct ARegion; +struct Scene; /* image_edit.c, exported for transform */ struct Image *ED_space_image(struct SpaceImage *sima); @@ -77,7 +78,7 @@ int ED_space_image_maskedit_mask_poll(struct bContext *C); /* UI level image (texture) updating... render calls own stuff (too) */ void ED_image_update_frame(const struct Main *mainp, int cfra); -void ED_image_draw_info(struct ARegion *ar, int color_manage, int channels, int x, int y, +void ED_image_draw_info(struct Scene *scene, struct ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y, const unsigned char cp[4], const float fp[4], int *zp, float *zpf); #endif /* __ED_IMAGE_H__ */ diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 8ebf932fd96..dc40b687dfd 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -53,14 +53,14 @@ void ED_keymap_mask(struct wmKeyConfig *keyconf); void ED_operatormacros_mask(void); /* mask_draw.c */ -void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type); +void ED_mask_draw(const struct bContext *C, const char draw_flag, const char draw_type); void ED_mask_draw_region(struct Mask *mask, struct ARegion *ar, const char draw_flag, const char draw_type, const int width_i, const int height_i, const float aspx, const float aspy, const short do_scale_applied, const short do_post_draw, float stabmat[4][4], - const bContext *C); + const struct bContext *C); void ED_mask_draw_frames(struct Mask *mask, struct ARegion *ar, const int cfra, const int sfra, const int efra); diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index b4b739e4d06..5ce6db97305 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -38,7 +38,7 @@ struct wmKeyConfig; void ED_operatortypes_metaball(void); void ED_keymap_metaball(struct wmKeyConfig *keyconf); -struct MetaElem *add_metaball_primitive(struct bContext *C, float mat[4][4], int type, int newname); +struct MetaElem *add_metaball_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newname); int mouse_mball(struct bContext *C, const int mval[2], int extend, int deselect, int toggle); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 1d4fbe81e02..3d15f349f9b 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -148,7 +148,7 @@ struct BMFace *EDBM_face_find_nearest(struct ViewContext *vc, int *dist); int EDBM_select_pick(struct bContext *C, const int mval[2], short extend, short deselect, short toggle); void EDBM_selectmode_set(struct BMEditMesh *em); -void EDBM_selectmode_convert(struct BMEditMesh *em, short oldmode, const short selectmode); +void EDBM_selectmode_convert(struct BMEditMesh *em, short selectmode_old, const short selectmode_new); void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const short select); diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index fc20bdfb9c5..860d176ffb3 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -111,6 +111,7 @@ ScrArea *ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type); void ED_screen_full_prevspace(struct bContext *C, ScrArea *sa); void ED_screen_full_restore(struct bContext *C, ScrArea *sa); struct ScrArea *ED_screen_full_toggle(struct bContext *C, struct wmWindow *win, struct ScrArea *sa); +void ED_screens_header_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg); /* anim */ void ED_update_for_newframe(struct Main *bmain, struct Scene *scene, int mute); @@ -170,6 +171,7 @@ int ED_operator_editmball(struct bContext *C); int ED_operator_uvedit(struct bContext *C); int ED_operator_uvmap(struct bContext *C); int ED_operator_posemode_exclusive(struct bContext *C); +int ED_operator_posemode_context(struct bContext *C); int ED_operator_posemode(struct bContext *C); int ED_operator_mask(struct bContext *C); diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h index 7807f06594e..84fd5332316 100644 --- a/source/blender/editors/include/ED_sequencer.h +++ b/source/blender/editors/include/ED_sequencer.h @@ -36,7 +36,7 @@ void ED_sequencer_deselect_all(struct Scene *scene); int ED_space_sequencer_maskedit_mask_poll(struct bContext *C); int ED_space_sequencer_check_show_maskedit(struct SpaceSeq *sseq, struct Scene *scene); -int ED_space_sequencer_maskedit_poll(bContext *C); +int ED_space_sequencer_maskedit_poll(struct bContext *C); void ED_operatormacros_sequencer(void); diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index e10f049d0bc..d0ca079b8c9 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -84,6 +84,8 @@ void crazyspace_set_quats_mesh(struct Mesh *me, float *origcos, float *mappedcos int sculpt_get_first_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]); void crazyspace_build_sculpt(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]); +/* cut-paste buffer free */ +void ED_clipboard_posebuf_free(void); /* ************** XXX OLD CRUFT WARNING ************* */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 7f40024a056..9536dd76581 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -89,139 +89,45 @@ float *give_cursor(struct Scene *scene, struct View3D *v3d); int initgrabz(struct RegionView3D *rv3d, float x, float y, float z); -/** - * Calculate a 3d location from 2d window coordinates. - * \param ar The region (used for the window width and height). - * \param depth_pt The reference location used to calculate the Z depth. - * \param mval The area relative location (such as event->mval converted to floats). - * \param out The resulting world-space location. - */ void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]); - -/** - * Calculate a 3d difference vector from 2d window offset. - * note that initgrabz() must be called first to determine - * the depth used to calculate the delta. - * \param ar The region (used for the window width and height). - * \param mval The area relative 2d difference (such as event->mval[0] - other_x). - * \param out The resulting world-space delta. - */ void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]); - -/** - * Calculate a 3d direction vector from 2d window coordinates. - * This direction vector starts and the view in the direction of the 2d window coordinates. - * In orthographic view all window coordinates yield the same vector. - * \param ar The region (used for the window width and height). - * \param mval The area relative 2d location (such as event->mval converted to floats). - * \param out The resulting normalized world-space direction vector. - */ void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]); - -/** - * Calculate a 3d segment from 2d window coordinates. - * This ray_start is located at the viewpoint, ray_end is a far point. - * ray_start and ray_end are clipped by the view near and far limits - * so points along this line are always in view. - * In orthographic view all resulting segments will be parallel. - * \param ar The region (used for the window width and height). - * \param v3d The 3d viewport (used for near and far clipping range). - * \param mval The area relative 2d location (such as event->mval, converted into float[2]). - * \param ray_start The world-space starting point of the segment. - * \param ray_end The world-space end point of the segment. - */ void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); - -/** - * Calculate a 3d viewpoint and direction vector from 2d window coordinates. - * This ray_start is located at the viewpoint, ray_normal is the direction towards mval. - * ray_start is clipped by the view near limit so points in front of it are always in view. - * In orthographic view the resulting ray_normal will match the view vector. - * \param ar The region (used for the window width and height). - * \param v3d The 3d viewport (used for near clipping value). - * \param mval The area relative 2d location (such as event->mval, converted into float[2]). - * \param ray_start The world-space starting point of the segment. - * \param ray_normal The normalized world-space direction of towards mval. - */ void ED_view3d_win_to_ray(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]); -/** - * Calculate a normalized 3d direction vector from the viewpoint towards a global location. - * In orthographic view the resulting vector will match the view vector. - * \param rv3d The region (used for the window width and height). - * \param coord The world-space location. - * \param vec The resulting normalized vector. - */ void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], float vec[3]); - -/** - * Calculate the view transformation matrix from RegionView3D input. - * The resulting matrix is equivalent to RegionView3D.viewinv - * \param mat The view 4x4 transformation matrix to calculate. - * \param ofs The view offset, normally from RegionView3D.ofs. - * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. - * \param dist The view distance from ofs, normally from RegionView3D.dist. - */ void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist); - -/** - * Set the view transformation from a 4x4 matrix. - * \param mat The view 4x4 transformation matrix to assign. - * \param ofs The view offset, normally from RegionView3D.ofs. - * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. - * \param dist The view distance from ofs, normally from RegionView3D.dist. - */ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist); -/** - * Set the RegionView3D members from an objects transformation and optionally lens. - * \param ob The object to set the view to. - * \param ofs The view offset to be set, normally from RegionView3D.ofs. - * \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat. - * \param dist The view distance from ofs to be set, normally from RegionView3D.dist. - * \param lens The view lens angle set for cameras and lamps, normally from View3D.lens. - */ void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens); - -/** - * Set the object transformation from RegionView3D members. - * \param ob The object which has the transformation assigned. - * \param ofs The view offset, normally from RegionView3D.ofs. - * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. - * \param dist The view distance from ofs, normally from RegionView3D.dist. - */ void ED_view3d_to_object(struct Object *ob, const float ofs[3], const float quat[4], const float dist); -//#if 0 /* UNUSED */ -void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); -//#endif - /* Depth buffer */ -void ED_view3d_depth_update(struct ARegion *ar); +void ED_view3d_depth_update(struct ARegion *ar); float ED_view3d_depth_read_cached(struct ViewContext *vc, int x, int y); -void ED_view3d_depth_tag_update(struct RegionView3D *rv3d); +void ED_view3d_depth_tag_update(struct RegionView3D *rv3d); /* Projection */ #define IS_CLIPPED 12000 -void ED_view3d_calc_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); - -void project_short(struct ARegion *ar, const float vec[3], short adr[2]); -void project_short_noclip(struct ARegion *ar, const float vec[3], short adr[2]); - -void project_int(struct ARegion *ar, const float vec[3], int adr[2]); -void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]); - -void apply_project_float(float persmat[4][4], int winx, int winy, const float vec[], float adr[2]); -void project_float(struct ARegion *ar, const float vec[3], float adr[2]); -void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]); - -int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); -int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend); +/* TODO, these functions work quite differently, we should make them behave in a uniform way + * otherwise we can't be sure bugs are not added when we need to move from short->float types for eg + * - Campbell */ +void ED_view3d_project_short(struct ARegion *ar, const float co[3], short r_co[2]); +void ED_view3d_project_short_noclip(struct ARegion *ar, const float vec[3], short r_co[2]); +void ED_view3d_project_int(struct ARegion *ar, const float co[3], int r_co[2]); +void ED_view3d_project_int_noclip(struct ARegion *ar, const float co[3], int r_co[2]); +void ED_view3d_project_float(struct ARegion *ar, const float co[3], float r_co[2]); +void ED_view3d_project_float_noclip(struct ARegion *ar, const float co[3], float r_co[2]); +void ED_view3d_project_float_v2_m4(const struct ARegion *a, const float co[3], float r_co[2], float mat[4][4]); +void ED_view3d_project_float_v3_m4(struct ARegion *a, const float co[3], float r_co[3], float mat[4][4]); + +void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z); + +int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); +int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend); void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short no_shift); -void ED_view3d_project_float_v2(const struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); -void ED_view3d_project_float_v3(struct ARegion *a, const float vec[3], float adr[3], float mat[4][4]); void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, float size_r[2]); /* drawobject.c iterators */ @@ -231,6 +137,7 @@ void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData); void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData); +void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]); int ED_view3d_clipping_test(struct RegionView3D *rv3d, const float vec[3], const int is_local); void ED_view3d_clipping_set(struct RegionView3D *rv3d); @@ -282,10 +189,12 @@ 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(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, - int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic); + int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic, int colormanage_background); -struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, int draw_background, char err_out[256]); -struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, int draw_background, char err_out[256]); +struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, + int draw_background, int colormanage_background, char err_out[256]); +struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, + int draw_background, int colormanage_background, char err_out[256]); struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index c6f58fdd70b..32132f497a8 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -120,11 +120,12 @@ typedef struct uiLayout uiLayout; #define UI_BLOCK_CLIP_EVENTS 8192 /* stop handling mouse events */ /* uiPopupBlockHandle->menuretval */ -#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */ -#define UI_RETURN_OK 2 /* choice made */ -#define UI_RETURN_OUT 4 /* left the menu */ -#define UI_RETURN_UPDATE 8 /* update the button that opened */ -#define UI_RETURN_POPUP_OK 16 /* popup is ok to be handled */ +#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */ +#define UI_RETURN_OK 2 /* choice made */ +#define UI_RETURN_OUT 4 /* left the menu */ +#define UI_RETURN_OUT_PARENT 8 /* let the parent handle this event */ +#define UI_RETURN_UPDATE 16 /* update the button that opened */ +#define UI_RETURN_POPUP_OK 32 /* popup is ok to be handled */ /* block->flag bits 12-15 are identical to but->flag bits */ @@ -810,8 +811,10 @@ void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic); void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer); +void uiTemplateGameStates(uiLayout *layout, struct PointerRNA *ptr, const char *propname, + PointerRNA *used_ptr, const char *used_propname, int active_state); void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact); -void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr); +void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management); void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void uiTemplateOperatorSearch(uiLayout *layout); @@ -831,6 +834,9 @@ void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct Poi void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname); void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int cmpact); +void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname); +void uiTemplateColormanagedViewSettings(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname); + /* items */ void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname); void uiItemEnumO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, const char *propname, int value); diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 792c96fe7c8..24759fa778a 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -163,7 +163,8 @@ void UI_view2d_view_orthoSpecial(struct ARegion *ar, struct View2D *v2d, short x void UI_view2d_view_restore(const struct bContext *C); /* grid drawing */ -View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy); +View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d, + short xunits, short xclamp, short yunits, short yclamp, int winx, int winy); void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag); void UI_view2d_constant_grid_draw(struct View2D *v2d); void UI_view2d_multi_grid_draw(struct View2D *v2d, float step, int level_size, int totlevels); @@ -171,14 +172,21 @@ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy); void UI_view2d_grid_free(View2DGrid *grid); /* scrollbar drawing */ -View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp); +View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d, + short xunits, short xclamp, short yunits, short yclamp); void UI_view2d_scrollers_draw(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers); void UI_view2d_scrollers_free(View2DScrollers *scrollers); /* list view tools */ -void UI_view2d_listview_cell_to_view(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, struct rctf *rect); -void UI_view2d_listview_view_to_cell(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, float viewx, float viewy, int *column, int *row); -void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int *column_min, int *column_max, int *row_min, int *row_max); +void UI_view2d_listview_cell_to_view(struct View2D *v2d, short columnwidth, short rowheight, + float startx, float starty, int column, int row, + struct rctf *rect); +void UI_view2d_listview_view_to_cell(struct View2D *v2d, short columnwidth, short rowheight, + float startx, float starty, float viewx, float viewy, + int *column, int *row); +void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, short rowheight, + float startx, float starty, int *column_min, int *column_max, + int *row_min, int *row_max); /* coordinate conversion */ void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 823f8d7be39..810cbc25862 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -75,11 +75,9 @@ #include "BPY_extern.h" -#include "interface_intern.h" +#include "IMB_colormanagement.h" -#define MENU_WIDTH 120 -#define MENU_ITEM_HEIGHT 20 -#define MENU_SEP_HEIGHT 6 +#include "interface_intern.h" #define PRECISION_FLOAT_MAX 6 #define PRECISION_FLOAT_MAX_POW 1000000 /* pow(10, PRECISION_FLOAT_MAX) */ @@ -104,8 +102,8 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y float gx, gy; int sx, sy, getsizex, getsizey; - getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1; - getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + getsizex = BLI_rcti_size_x(&ar->winrct) + 1; + getsizey = BLI_rcti_size_y(&ar->winrct) + 1; sx = ar->winrct.xmin; sy = ar->winrct.ymin; @@ -150,8 +148,8 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y float a, b, c, d, e, f, px, py; int sx, sy, getsizex, getsizey; - getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1; - getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + getsizex = BLI_rcti_size_x(&ar->winrct) + 1; + getsizey = BLI_rcti_size_y(&ar->winrct) + 1; sx = ar->winrct.xmin; sy = ar->winrct.ymin; @@ -277,7 +275,7 @@ void ui_bounds_block(uiBlock *block) block->rect.ymax += block->bounds; } - block->rect.xmax = block->rect.xmin + maxf(BLI_RCT_SIZE_X(&block->rect), block->minbounds); + block->rect.xmax = block->rect.xmin + maxf(BLI_rctf_size_x(&block->rect), block->minbounds); /* hardcoded exception... but that one is annoying with larger safety */ bt = block->buttons.first; @@ -305,8 +303,8 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block) ui_bounds_block(block); - width = BLI_RCT_SIZE_X(&block->rect); - height = BLI_RCT_SIZE_Y(&block->rect); + width = BLI_rctf_size_x(&block->rect); + height = BLI_rctf_size_y(&block->rect); startx = (xmax * 0.5f) - (width * 0.5f); starty = (ymax * 0.5f) - (height * 0.5f); @@ -330,8 +328,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound wm_window_get_size(window, &xmax, &ymax); - oldwidth = BLI_RCT_SIZE_X(&block->rect); - oldheight = BLI_RCT_SIZE_Y(&block->rect); + oldwidth = BLI_rctf_size_x(&block->rect); + oldheight = BLI_rctf_size_y(&block->rect); /* first we ensure wide enough text bounds */ if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) { @@ -346,8 +344,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound ui_bounds_block(block); /* and we adjust the position to fit within window */ - width = BLI_RCT_SIZE_X(&block->rect); - height = BLI_RCT_SIZE_Y(&block->rect); + width = BLI_rctf_size_x(&block->rect); + height = BLI_rctf_size_y(&block->rect); /* avoid divide by zero below, caused by calling with no UI, but better not crash */ oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width); @@ -493,10 +491,10 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines) if (line->from == NULL || line->to == NULL) return; - rect.xmin = BLI_RCT_CENTER_X(&line->from->rect); - rect.ymin = BLI_RCT_CENTER_Y(&line->from->rect); - rect.xmax = BLI_RCT_CENTER_X(&line->to->rect); - rect.ymax = BLI_RCT_CENTER_Y(&line->to->rect); + rect.xmin = BLI_rctf_cent_x(&line->from->rect); + rect.ymin = BLI_rctf_cent_y(&line->from->rect); + rect.xmax = BLI_rctf_cent_x(&line->to->rect); + rect.ymax = BLI_rctf_cent_y(&line->to->rect); if (line->flag & UI_SELECT) glColor3ub(100, 100, 100); @@ -2138,7 +2136,14 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor block->evil_C = (void *)C; /* XXX */ if (scn) { - block->color_profile = (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT); + block->color_profile = TRUE; + + /* store display device name, don't lookup for transformations yet + * block could be used for non-color displays where looking up for transformation + * would slow down redraw, so only lookup for actual transform when it's indeed + * needed + */ + block->display_device = scn->display_settings.display_device; /* copy to avoid crash when scene gets deleted with ui still open */ block->unit = MEM_mallocN(sizeof(scn->unit), "UI UnitSettings"); @@ -2248,7 +2253,7 @@ void ui_check_but(uiBut *but) /* safety is 4 to enable small number buttons (like 'users') */ - // okwidth= -4 + (BLI_RCT_SIZE_X(&but->rect)); // UNUSED + // okwidth= -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED /* name: */ switch (but->type) { @@ -2256,7 +2261,7 @@ void ui_check_but(uiBut *but) case MENU: case ICONTEXTROW: - if (BLI_RCT_SIZE_X(&but->rect) > 24.0f) { + if (BLI_rctf_size_x(&but->rect) > 24.0f) { UI_GET_BUT_VALUE_INIT(but, value); ui_set_name_menu(but, (int)value); } @@ -2563,7 +2568,9 @@ void ui_block_do_align(uiBlock *block) ui_block_do_align_but(but, nr); /* skip with same number */ - for (; but && but->alignnr == nr; but = but->next) ; + for (; but && but->alignnr == nr; but = but->next) { + /* pass */ + } if (!but) { break; @@ -2575,6 +2582,25 @@ void ui_block_do_align(uiBlock *block) } } +struct ColorManagedDisplay *ui_block_display_get(uiBlock *block) +{ + return IMB_colormanagement_display_get_named(block->display_device); +} + +void ui_block_to_display_space_v3(uiBlock *block, float pixel[3]) +{ + struct ColorManagedDisplay *display = ui_block_display_get(block); + + IMB_colormanagement_scene_linear_to_display_v3(pixel, display); +} + +void ui_block_to_scene_linear_v3(uiBlock *block, float pixel[3]) +{ + struct ColorManagedDisplay *display = ui_block_display_get(block); + + IMB_colormanagement_display_to_scene_linear_v3(pixel, display); +} + /** * \brief ui_def_but is the function that draws many button types * @@ -2593,6 +2619,9 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, uiBut *but; int slen; + BLI_assert(width >= 0); + BLI_assert(height >= 0); + /* we could do some more error checks here */ if ((type & BUTTYPE) == LABEL) { BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE); @@ -3760,15 +3789,16 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...) if (type == BUT_GET_LABEL) { if (but->str) { /* Menu labels can have some complex formating stuff marked by pipes or %t, we don't want those here! */ - const char *tc; - - if (but->type == MENU) - tc = strstr(but->str, "%t"); - else - tc = strchr(but->str, '|'); - - if (tc) - tmp = BLI_strdupn(but->str, tc - but->str); + const char *tc1, *tc2; + + tc1 = strstr(but->str, "%t"); + tc2 = strstr(but->str, "|"); /* XXX For some reason strchr seems to not work here? */ + + if (tc2 && (!tc1 || tc1 > tc2)) + tc1 = tc2; + + if (tc1) + tmp = BLI_strdupn(but->str, tc1 - but->str); else tmp = BLI_strdup(but->str); } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 77dbbc878a7..e7c7d934f9f 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -48,6 +48,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -59,8 +60,6 @@ /* own include */ #include "interface_intern.h" -#define UI_DISABLED_ALPHA_OFFS -160 - static int roundboxtype = UI_CNR_ALL; void uiSetRoundBox(int type) @@ -85,7 +84,7 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r /* mult */ for (a = 0; a < 7; a++) { - vec[a][0] *= rad; vec[a][1] *= rad; + mul_v2_fl(vec[a], rad); } glBegin(mode); @@ -156,18 +155,18 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl /* mult */ for (a = 0; a < 7; a++) { - vec[a][0] *= rad; vec[a][1] *= rad; + mul_v2_fl(vec[a], rad); } /* get current color, needs to be outside of glBegin/End */ glGetFloatv(GL_CURRENT_COLOR, color); /* 'shade' defines strength of shading */ - coltop[0] = color[0] + shadetop; if (coltop[0] > 1.0f) coltop[0] = 1.0f; - coltop[1] = color[1] + shadetop; if (coltop[1] > 1.0f) coltop[1] = 1.0f; - coltop[2] = color[2] + shadetop; if (coltop[2] > 1.0f) coltop[2] = 1.0f; - coldown[0] = color[0] + shadedown; if (coldown[0] < 0.0f) coldown[0] = 0.0f; - coldown[1] = color[1] + shadedown; if (coldown[1] < 0.0f) coldown[1] = 0.0f; - coldown[2] = color[2] + shadedown; if (coldown[2] < 0.0f) coldown[2] = 0.0f; + 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); glShadeModel(GL_SMOOTH); glBegin(mode); @@ -265,18 +264,18 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float /* mult */ for (a = 0; a < 7; a++) { - vec[a][0] *= rad; vec[a][1] *= rad; + mul_v2_fl(vec[a], rad); } /* get current color, needs to be outside of glBegin/End */ glGetFloatv(GL_CURRENT_COLOR, color); /* 'shade' defines strength of shading */ - colLeft[0] = color[0] + shadeLeft; if (colLeft[0] > 1.0f) colLeft[0] = 1.0f; - colLeft[1] = color[1] + shadeLeft; if (colLeft[1] > 1.0f) colLeft[1] = 1.0f; - colLeft[2] = color[2] + shadeLeft; if (colLeft[2] > 1.0f) colLeft[2] = 1.0f; - colRight[0] = color[0] + shadeRight; if (colRight[0] < 0.0f) colRight[0] = 0.0f; - colRight[1] = color[1] + shadeRight; if (colRight[1] < 0.0f) colRight[1] = 0.0f; - colRight[2] = color[2] + shadeRight; if (colRight[2] < 0.0f) colRight[2] = 0.0f; + 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); glShadeModel(GL_SMOOTH); glBegin(mode); @@ -439,8 +438,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w //glColor4f(1.0, 0.f, 0.f, 1.f); //fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax) - w = BLI_RCT_SIZE_X(rect); - h = BLI_RCT_SIZE_Y(rect); + w = BLI_rcti_size_x(rect); + h = BLI_rcti_size_y(rect); /* prevent drawing outside widget area */ glGetIntegerv(GL_SCISSOR_BOX, scissor); glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h); @@ -493,8 +492,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) charmax = G.charmax = 0xffff; /* Calculate the size of the button */ - width = abs(BLI_RCT_SIZE_X(rect)); - height = abs(BLI_RCT_SIZE_Y(rect)); + width = abs(BLI_rcti_size_x(rect)); + height = abs(BLI_rcti_size_y(rect)); butw = floor(width / 12); buth = floor(height / 6); @@ -600,7 +599,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) } /* Calculate the next position and character */ - sx += butw; ex += butw; + sx += butw; + ex += butw; cs++; } /* Add the y position and reset x position */ @@ -632,7 +632,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) #endif /* WITH_INTERNATIONAL */ #endif -static void draw_scope_end(rctf *rect, GLint *scissor) +static void draw_scope_end(const rctf *rect, GLint *scissor) { float scaler_x1, scaler_x2; @@ -642,8 +642,8 @@ static void draw_scope_end(rctf *rect, GLint *scissor) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* scale widget */ - scaler_x1 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 - SCOPE_RESIZE_PAD; - scaler_x2 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 + SCOPE_RESIZE_PAD; + scaler_x1 = rect->xmin + BLI_rctf_size_x(rect) / 2 - SCOPE_RESIZE_PAD; + scaler_x2 = rect->xmin + BLI_rctf_size_y(rect) / 2 + SCOPE_RESIZE_PAD; glColor4f(0.f, 0.f, 0.f, 0.25f); fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4); @@ -732,8 +732,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2; rect.ymax = (float)recti->ymax - 1; - w = BLI_RCT_SIZE_X(&rect); - h = BLI_RCT_SIZE_Y(&rect) * hist->ymax; + w = BLI_rctf_size_x(&rect); + h = BLI_rctf_size_y(&rect) * hist->ymax; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -805,9 +805,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), if (scopes->wavefrm_yfac < 0.5f) scopes->wavefrm_yfac = 0.98f; - w = BLI_RCT_SIZE_X(&rect) - 7; - h = BLI_RCT_SIZE_Y(&rect) * scopes->wavefrm_yfac; - yofs = rect.ymin + (BLI_RCT_SIZE_Y(&rect) - h) / 2.0f; + w = BLI_rctf_size_x(&rect) - 7; + h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac; + yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f; w3 = w / 3.0f; /* log scale for alpha */ @@ -1033,8 +1033,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2; rect.ymax = (float)recti->ymax - 1; - w = BLI_RCT_SIZE_X(&rect); - h = BLI_RCT_SIZE_Y(&rect); + w = BLI_rctf_size_x(&rect); + h = BLI_rctf_size_y(&rect); centerx = rect.xmin + w / 2; centery = rect.ymin + h / 2; diam = (w < h) ? w : h; @@ -1110,10 +1110,14 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) float v3[2], v1[2], v2[2], v1a[2], v2a[2]; int a; float pos, colf[4] = {0, 0, 0, 0}; /* initialize in case the colorband isn't valid */ - + struct ColorManagedDisplay *display = NULL; + coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin); if (coba == NULL) return; - + + if (but->block->color_profile) + display = ui_block_display_get(but->block); + x1 = rect->xmin; y1 = rect->ymin; sizex = rect->xmax - x1; @@ -1141,18 +1145,20 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) glBegin(GL_QUAD_STRIP); glColor4fv(&cbd->r); - glVertex2fv(v1); glVertex2fv(v2); - + glVertex2fv(v1); + glVertex2fv(v2); + for (a = 1; a <= sizex; a++) { pos = ((float)a) / (sizex - 1); do_colorband(coba, pos, colf); - if (but->block->color_profile != BLI_PR_NONE) - linearrgb_to_srgb_v3_v3(colf, colf); + if (display) + IMB_colormanagement_scene_linear_to_display_v3(colf, display); v1[0] = v2[0] = x1 + a; glColor4fv(colf); - glVertex2fv(v1); glVertex2fv(v2); + glVertex2fv(v1); + glVertex2fv(v2); } glEnd(); @@ -1239,7 +1245,8 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* sphere color */ glMaterialfv(GL_FRONT, GL_DIFFUSE, diffn); - glCullFace(GL_BACK); glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); /* disable blender light */ for (a = 0; a < 8; a++) { @@ -1262,12 +1269,12 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* transform to button */ glPushMatrix(); - glTranslatef(rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect), rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect), 0.0f); + glTranslatef(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f); - if (BLI_RCT_SIZE_X(rect) < BLI_RCT_SIZE_Y(rect)) - size = BLI_RCT_SIZE_X(rect) / 200.f; + if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect)) + size = BLI_rcti_size_x(rect) / 200.f; else - size = BLI_RCT_SIZE_Y(rect) / 200.f; + size = BLI_rcti_size_y(rect) / 200.f; glScalef(size, size, size); @@ -1373,12 +1380,12 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new); glScissor(scissor_new.xmin, scissor_new.ymin, - BLI_RCT_SIZE_X(&scissor_new), - BLI_RCT_SIZE_Y(&scissor_new)); + BLI_rcti_size_x(&scissor_new), + BLI_rcti_size_y(&scissor_new)); /* calculate offset and zoom */ - zoomx = (BLI_RCT_SIZE_X(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_X(&cumap->curr); - zoomy = (BLI_RCT_SIZE_Y(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_Y(&cumap->curr); + zoomx = (BLI_rcti_size_x(rect) - 2.0f * but->aspect) / BLI_rctf_size_x(&cumap->curr); + zoomy = (BLI_rcti_size_y(rect) - 2.0f * but->aspect) / BLI_rctf_size_y(&cumap->curr); offsx = cumap->curr.xmin - but->aspect / zoomx; offsy = cumap->curr.ymin - but->aspect / zoomy; @@ -1556,8 +1563,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2; rect.ymax = (float)recti->ymax - 1; - width = BLI_RCT_SIZE_X(&rect) + 1; - height = BLI_RCT_SIZE_Y(&rect); + width = BLI_rctf_size_x(&rect) + 1; + height = BLI_rctf_size_y(&rect); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1632,8 +1639,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc glTranslatef(rect.xmin + track_pos[0], rect.ymin + track_pos[1], 0.f); glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin + rect.ymin, - BLI_RCT_SIZE_X(&rect), - BLI_RCT_SIZE_Y(&rect)); + BLI_rctf_size_x(&rect), + BLI_rctf_size_y(&rect)); for (a = 0; a < 2; a++) { if (a == 1) { @@ -1724,7 +1731,7 @@ void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, fl } -void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSED(select)) +void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select)) { int i; float rad; @@ -1733,8 +1740,8 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSE glEnable(GL_BLEND); - if (radius > (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f) - rad = (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f; + if (radius > (BLI_rctf_size_y(rct) - 10.0f) / 2.0f) + rad = (BLI_rctf_size_y(rct) - 10.0f) / 2.0f; else rad = radius; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b8a84e1638a..593744f01e0 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -78,6 +78,9 @@ #include "WM_api.h" #include "WM_types.h" +/* place the mouse at the scaled down location when un-grabbing */ +#define USE_CONT_MOUSE_CORRECT + /* proto */ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to); static void ui_add_link(bContext *C, uiBut *from, uiBut *to); @@ -152,6 +155,12 @@ typedef struct uiHandleButtonData { float dragf, dragfstart; CBData *dragcbd; +#ifdef USE_CONT_MOUSE_CORRECT + /* when ungrabbing buttons which are #ui_is_a_warp_but(), we may want to position them + * FLT_MAX signifies do-nothing, use #ui_block_to_window_fl() to get this into a usable space */ + float ungrab_mval[2]; +#endif + /* menu open (watch uiFreeActiveButtons) */ uiPopupBlockHandle *menu; int menuretval; @@ -697,10 +706,10 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) if (but->imb) ; /* use button size itself */ else if (but->flag & UI_ICON_LEFT) { - rect.xmax = rect.xmin + (BLI_RCT_SIZE_Y(&rect)); + rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect)); } else { - int delta = BLI_RCT_SIZE_X(&rect) - BLI_RCT_SIZE_Y(&rect); + int delta = BLI_rcti_size_x(&rect) - BLI_rcti_size_y(&rect); rect.xmin += delta / 2; rect.xmax -= delta / 2; } @@ -721,7 +730,7 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but)); if (but->imb) - WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_RCT_SIZE_X(&but->rect), BLI_RCT_SIZE_Y(&but->rect)); + WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect)); return 1; } @@ -808,6 +817,8 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) uiLink *link = from->link; + PointerRNA props_ptr, object_ptr; + if (link->ppoin) sens_from_links = (bController ***)(link->ppoin); else return; @@ -836,9 +847,15 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) /* only works if the sensor and the actuator are from the same object */ if (!act_iter) return; + + /* in case the linked controller is not the active one */ + RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); + + WM_operator_properties_create(&props_ptr, "LOGIC_OT_controller_add"); + RNA_string_set(&props_ptr, "object", ob->id.name+2); /* (3) add a new controller */ - if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) { + if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, &props_ptr) & OPERATOR_FINISHED) { cont = (bController *)ob->controllers.last; cont->type = CONT_LOGIC_AND; /* Quick fix to make sure we always have an AND controller. It might be nicer to make sure the operator gives us the right one though... */ @@ -858,6 +875,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) MEM_freeN(tmp_but->link); MEM_freeN(tmp_but); } + WM_operator_properties_free(&props_ptr); } static void ui_add_link(bContext *C, uiBut *from, uiBut *to) @@ -1309,7 +1327,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho /* XXX solve generic */ if (but->type == NUM || but->type == NUMSLI) - startx += (int)(0.5f * (BLI_RCT_SIZE_Y(&but->rect))); + startx += (int)(0.5f * (BLI_rctf_size_y(&but->rect))); else if (ELEM(but->type, TEX, SEARCH_MENU)) { startx += 5; if (but->flag & UI_HAS_ICON) @@ -1386,13 +1404,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, short x) { - if (x > data->selstartx) data->selextend = EXTEND_RIGHT; + if (x > data->selstartx) data->selextend = EXTEND_RIGHT; else if (x < data->selstartx) data->selextend = EXTEND_LEFT; ui_textedit_set_cursor_pos(but, data, x); - if (data->selextend == EXTEND_RIGHT) but->selend = but->pos; - if (data->selextend == EXTEND_LEFT) but->selsta = but->pos; + if (data->selextend == EXTEND_RIGHT) but->selend = but->pos; + else if (data->selextend == EXTEND_LEFT) but->selsta = but->pos; ui_check_but(but); } @@ -1596,6 +1614,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste /* paste */ if (paste) { + /* TODO, ensure UTF8 ui_is_but_utf8() - campbell */ /* extract the first line from the clipboard */ p = pbuf = WM_clipboard_text_get(0); @@ -1955,8 +1974,12 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle if (changed) { /* only update when typing for TAB key */ - if (update && data->interactive) ui_apply_button(C, block, but, data, 1); - else ui_check_but(but); + if (update && data->interactive) { + ui_apply_button(C, block, but, data, 1); + } + else { + ui_check_but(but); + } but->changed = TRUE; if (data->searchbox) @@ -2047,8 +2070,12 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data) static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data) { - if (data->interactive) ui_apply_button(C, block, but, data, 1); - else ui_check_but(but); + if (data->interactive) { + ui_apply_button(C, block, but, data, 1); + } + else { + ui_check_but(but); + } ED_region_tag_redraw(data->region); } @@ -2373,14 +2400,14 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa } if (snap == 1) { - if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf); + if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf); else if (softrange < 21.0f) tempf = floorf(tempf); - else tempf = 10.0f * floorf(tempf / 10.0f); + else tempf = 10.0f * floorf(tempf / 10.0f); } else if (snap == 2) { - if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf); - else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf); - else tempf = floor(tempf); + if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf); + else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf); + else tempf = floor(tempf); } if (fac != 1.0f) @@ -2459,9 +2486,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i } } else { - if (softrange > 256) fac = 1.0; /* 1px == 1 */ - else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */ - else fac = 1.0 / 16.0; /* 16px == 1? */ + if (softrange > 256) fac = 1.0; /* 1px == 1 */ + else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */ + else fac = 1.0 / 16.0; /* 16px == 1? */ temp = data->startvalue + (((double)mx - data->dragstartx) * (double)fac); temp = ui_numedit_apply_snap(temp, softmin, softmax, snap); @@ -2493,10 +2520,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i deler = 500; if (!ui_is_but_float(but)) { /* prevent large ranges from getting too out of control */ - if (softrange > 600) deler = powf(softrange, 0.75); - - if (softrange < 100) deler = 200.0; - if (softrange < 25) deler = 50.0; + if (softrange > 600) deler = powf(softrange, 0.75); + else if (softrange < 100) deler = 200.0; + else if (softrange < 25) deler = 50.0; } deler /= fac; @@ -2582,8 +2608,9 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); retval = WM_UI_HANDLER_BREAK; } - else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) + else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) { click = 1; + } else if (event->type == MINUSKEY && event->val == KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); data->value = -data->value; @@ -2611,7 +2638,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton fac = 1.0f; if (event->shift) fac /= 10.0f; - if (event->alt) fac /= 20.0f; + if (event->alt) fac /= 20.0f; snap = (event->ctrl) ? (event->shift) ? 2 : 1 : 0; @@ -2639,7 +2666,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton softmax = but->softmax; if (!ui_is_but_float(but)) { - if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) { + if (mx < (but->rect.xmin + BLI_rctf_size_x(&but->rect) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value - 1; @@ -2650,7 +2677,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if (mx > (but->rect.xmin + (2 * BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) { + else if (mx > (but->rect.xmin + (2 * BLI_rctf_size_x(&but->rect) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value + 1; @@ -2661,11 +2688,12 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else + else { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); + } } else { - if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) { + if (mx < (but->rect.xmin + BLI_rctf_size_x(&but->rect) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value - 0.01f * but->a1; @@ -2674,7 +2702,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if (mx > but->rect.xmin + (2 * (BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) { + else if (mx > but->rect.xmin + (2 * (BLI_rctf_size_x(&but->rect) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value + 0.01f * but->a1; @@ -2683,8 +2711,9 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else + else { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); + } } retval = WM_UI_HANDLER_BREAK; @@ -2702,14 +2731,20 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short softmax = but->softmax; softrange = softmax - softmin; - if (but->type == NUMSLI) deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect); - else if (but->type == HSVSLI) deler = (BLI_RCT_SIZE_X(&but->rect) / 2.0f - 5.0f * but->aspect); + if (but->type == NUMSLI) { + deler = (BLI_rctf_size_x(&but->rect) - 5.0f * but->aspect); + } + else if (but->type == HSVSLI) { + deler = (BLI_rctf_size_x(&but->rect) / 2.0f - 5.0f * but->aspect); + } else if (but->type == SCROLL) { - int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect)); - float size = (horizontal) ? BLI_RCT_SIZE_X(&but->rect) : -BLI_RCT_SIZE_Y(&but->rect); + int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect)); + float size = (horizontal) ? BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect); deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1); } - else deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect); + else { + deler = (BLI_rctf_size_x(&but->rect) - 5.0f * but->aspect); + } f = (float)(mx - data->dragstartx) / deler + data->dragfstart; @@ -2721,19 +2756,21 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short temp = floorf(tempf + 0.5f); if (ctrl) { - if (tempf == softmin || tempf == softmax) ; + if (tempf == softmin || tempf == softmax) { + /* pass */ + } else if (ui_is_but_float(but)) { if (shift) { - if (tempf == softmin || tempf == softmax) ; + if (tempf == softmin || tempf == softmax) {} else if (softmax - softmin < 2.10f) tempf = 0.01f * floorf(100.0f * tempf); - else if (softmax - softmin < 21.0f) tempf = 0.1f * floorf(10.0f * tempf); - else tempf = floorf(tempf); + else if (softmax - softmin < 21.0f) tempf = 0.1f * floorf(10.0f * tempf); + else tempf = floorf(tempf); } else { - if (softmax - softmin < 2.10f) tempf = 0.1f * floorf(10.0f * tempf); + if (softmax - softmin < 2.10f) tempf = 0.1f * floorf(10.0f * tempf); else if (softmax - softmin < 21.0f) tempf = floorf(tempf); - else tempf = 10.0f * floorf(tempf / 10.0f); + else tempf = 10.0f * floorf(tempf / 10.0f); } } else { @@ -2792,7 +2829,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } /* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */ else if (event->type == LEFTMOUSE && event->alt) { - int halfpos = BLI_RCT_CENTER_X(&but->rect); + int halfpos = BLI_rctf_cent_x(&but->rect); click = 2; if (mx < halfpos) mx = but->rect.xmin; @@ -2805,8 +2842,9 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); retval = WM_UI_HANDLER_BREAK; } - else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) + else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) { click = 1; + } else if (event->type == MINUSKEY && event->val == KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); data->value = -data->value; @@ -2859,12 +2897,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton #if 0 if (but->type == SLI) { - f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); /* same as below */ + f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect)); /* same as below */ } else #endif { - f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); + f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect)); } f = softmin + f * softrange; @@ -2905,7 +2943,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut { int mx, my /*, click= 0 */; int retval = WM_UI_HANDLER_CONTINUE; - int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect)); + int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect)); mx = event->x; my = event->y; @@ -3063,7 +3101,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i * else we'll get a harmless but annoying jump when first clicking */ fp = data->origvec; - rad = BLI_RCT_SIZE_X(&but->rect); + rad = BLI_rctf_size_x(&but->rect); radsq = rad * rad; if (fp[2] > 0.0f) { @@ -3076,7 +3114,9 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i mdx = 2.0f * mrad * fp[0] - (rad * fp[0]); mdy = 2.0f * mrad * fp[1] - (rad * fp[1]); } - else mdx = mdy = 0; + else { + mdx = mdy = 0; + } dx = (float)(mx + mdx - data->dragstartx); dy = (float)(my + mdy - data->dragstarty); @@ -3140,8 +3180,9 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut ui_numedit_apply(C, block, but, data); } } - else if (event->type == LEFTMOUSE && event->val != KM_PRESS) + else if (event->type == LEFTMOUSE && event->val != KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); + } return WM_UI_HANDLER_BREAK; } @@ -3160,19 +3201,30 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); +#ifdef USE_CONT_MOUSE_CORRECT + if (ui_is_a_warp_but(but)) { + /* OK but can go outside bounds */ + data->ungrab_mval[0] = mx_fl; + data->ungrab_mval[1] = my_fl; + BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval); + } +#endif + if (but->rnaprop) { if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = BLI_PR_NONE; + color_profile = FALSE; } ui_get_but_vectorf(but, rgb); - rgb_to_hsv_compat_v(rgb, hsv); + if (color_profile && (int)but->a1) + ui_block_to_display_space_v3(but->block, rgb); + rgb_to_hsv_compat_v(rgb, hsv); /* relative position within box */ - x = ((float)mx_fl - but->rect.xmin) / BLI_RCT_SIZE_X(&but->rect); - y = ((float)my_fl - but->rect.ymin) / BLI_RCT_SIZE_Y(&but->rect); + x = ((float)mx_fl - but->rect.xmin) / BLI_rctf_size_x(&but->rect); + y = ((float)my_fl - but->rect.ymin) / BLI_rctf_size_y(&but->rect); CLAMP(x, 0.0f, 1.0f); CLAMP(y, 0.0f, 1.0f); @@ -3204,17 +3256,16 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, /* exception only for value strip - use the range set in but->min/max */ hsv[2] = y * (but->softmax - but->softmin) + but->softmin; - if (color_profile) - hsv[2] = srgb_to_linearrgb(hsv[2]); - - if (hsv[2] > but->softmax) - hsv[2] = but->softmax; break; default: assert(!"invalid hsv type"); } hsv_to_rgb_v(hsv, rgb); + + if (color_profile && (int)but->a1) + ui_block_to_scene_linear_v3(but->block, rgb); + copy_v3_v3(data->vec, rgb); data->draglastx = mx; @@ -3233,10 +3284,14 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF if (but->rnaprop) { if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = BLI_PR_NONE; + color_profile = FALSE; } ui_get_but_vectorf(but, rgb); + + if (color_profile && (int)but->a1) + ui_block_to_display_space_v3(but->block, rgb); + rgb_to_hsv_compat_v(rgb, hsv); switch ((int)but->a1) { @@ -3267,15 +3322,16 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF /* exception only for value strip - use the range set in but->min/max */ hsv[2] += ndof->rx * sensitivity; - if (color_profile) - hsv[2] = srgb_to_linearrgb(hsv[2]); - CLAMP(hsv[2], but->softmin, but->softmax); default: assert(!"invalid hsv type"); } - + hsv_to_rgb_v(hsv, rgb); + + if (color_profile && (int)but->a1) + ui_block_to_scene_linear_v3(but->block, rgb); + copy_v3_v3(data->vec, rgb); ui_set_but_vectorf(but, data->vec); } @@ -3358,8 +3414,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu ui_numedit_apply(C, block, but, data); } } - else if (event->type == LEFTMOUSE && event->val != KM_PRESS) + else if (event->type == LEFTMOUSE && event->val != KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); + } return WM_UI_HANDLER_BREAK; } @@ -3377,6 +3434,22 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); +#ifdef USE_CONT_MOUSE_CORRECT + if (ui_is_a_warp_but(but)) { + /* OK but can go outside bounds */ + 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 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) { + dist_ensure_v2_v2fl(data->ungrab_mval, cent, radius); + } + } + } +#endif + BLI_rcti_rctf_copy(&rect, &but->rect); ui_get_but_vectorf(but, rgb); @@ -3569,7 +3642,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx if (data->draglastx == mx) return changed; - dx = ((float)(mx - data->draglastx)) / BLI_RCT_SIZE_X(&but->rect); + dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect); data->dragcbd->pos += dx; CLAMP(data->dragcbd->pos, 0.0f, 1.0f); @@ -3598,7 +3671,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle if (event->ctrl) { /* insert new key on mouse location */ - float pos = ((float)(mx - but->rect.xmin)) / BLI_RCT_SIZE_X(&but->rect); + float pos = ((float)(mx - but->rect.xmin)) / BLI_rctf_size_x(&but->rect); colorband_element_add(coba, pos); button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -3610,7 +3683,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle /* activate new key when mouse is close */ for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) { - xco = but->rect.xmin + (cbd->pos * BLI_RCT_SIZE_X(&but->rect)); + xco = but->rect.xmin + (cbd->pos * BLI_rctf_size_x(&but->rect)); xco = ABS(xco - mx); if (a == coba->cur) xco += 5; // selected one disadvantage if (xco < mindist) { @@ -3633,8 +3706,9 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle ui_numedit_apply(C, block, but, data); } } - else if (event->type == LEFTMOUSE && event->val != KM_PRESS) + else if (event->type == LEFTMOUSE && event->val != KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); + } return WM_UI_HANDLER_BREAK; } @@ -3651,8 +3725,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */; int a, changed = 0; - zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr); - zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr); + 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; */ @@ -3667,9 +3741,10 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, } if (data->dragsel != -1) { + CurveMapPoint *cmp_last = NULL; const float mval_factor = ui_mouse_scale_warp_factor(shift); int moved_point = 0; /* for ctrl grid, can't use orig coords because of sorting */ - + fx = (mx - data->draglastx) / zoomx; fy = (my - data->draglasty) / zoomy; @@ -3687,6 +3762,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, } if (cmp[a].x != origx || cmp[a].y != origy) moved_point = 1; + + cmp_last = &cmp[a]; } } @@ -3696,6 +3773,18 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, data->draglastx = mx; data->draglasty = my; changed = 1; + +#ifdef USE_CONT_MOUSE_CORRECT + /* note: using 'cmp_last' is weak since there may be multiple points selected, + * but in practice this isnt really an issue */ + if (ui_is_a_warp_but(but)) { + /* OK but can go outside bounds */ + data->ungrab_mval[0] = but->rect.xmin + ((cmp_last->x - cumap->curr.xmin) * zoomx); + data->ungrab_mval[1] = but->rect.ymin + ((cmp_last->y - cumap->curr.ymin) * zoomy); + BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval); + } +#endif + } data->dragchange = 1; /* mark for selection */ @@ -3747,8 +3836,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt float dist, mindist = 200.0f; // 14 pixels radius int sel = -1; - zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr); - zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr); + 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; @@ -3812,12 +3901,14 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* ok, we move a point */ /* deselect all if this one is deselect. except if we hold shift */ if (event->shift == FALSE) { - for (a = 0; a < cuma->totpoint; a++) + for (a = 0; a < cuma->totpoint; a++) { cmp[a].flag &= ~CUMA_SELECT; + } cmp[sel].flag |= CUMA_SELECT; } - else + else { cmp[sel].flag ^= CUMA_SELECT; + } } else { /* move the view */ @@ -3893,7 +3984,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize histogram widget itself */ - hist->height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); + hist->height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my); } else { /* scale histogram values (dy / 10 for better control) */ @@ -3977,7 +4068,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize waveform widget itself */ - scopes->wavefrm_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); + scopes->wavefrm_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my); } else { /* scale waveform values */ @@ -4059,7 +4150,7 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize vectorscope widget itself */ - scopes->vecscope_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); + scopes->vecscope_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my); } data->draglastx = mx; @@ -4129,8 +4220,8 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { /* Calculate the size of the button */ - width = abs(BLI_RCT_SIZE_X(&but->rect)); - height = abs(BLI_RCT_SIZE_Y(&but->rect)); + width = abs(BLI_rctf_size_x(&but->rect)); + height = abs(BLI_rctf_size_y(&but->rect)); butw = floor(width / 12); buth = floor(height / 6); @@ -4262,7 +4353,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize preview widget itself */ - scopes->track_preview_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); + scopes->track_preview_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my); } else { if (!scopes->track_locked) { @@ -4270,8 +4361,8 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr); scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED); - scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_RCT_SIZE_X(&but->block->rect); - scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_RCT_SIZE_Y(&but->block->rect); + scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_rctf_size_x(&but->block->rect); + scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_rctf_size_y(&but->block->rect); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } @@ -4460,6 +4551,7 @@ static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) static int ui_but_menu(bContext *C, uiBut *but) { + ARegion *ar = CTX_wm_region(C); uiPopupMenu *pup; uiLayout *layout; int length; @@ -4471,17 +4563,8 @@ static int ui_but_menu(bContext *C, uiBut *but) button_timers_tooltip_remove(C, but); -#if 0 - if (but->rnaprop) - name = RNA_property_ui_name(but->rnaprop); - else if (but->optype && but->optype->srna) - name = RNA_struct_ui_name(but->optype->srna); - else - name = IFACE_("<needs_name>"); // XXX - should never happen. -#else uiButGetStrInfo(C, but, 1, &label); name = label.strinfo; -#endif pup = uiPupMenuBegin(C, name, ICON_NONE); layout = uiPupMenuLayout(pup); @@ -4525,7 +4608,9 @@ static int ui_but_menu(bContext *C, uiBut *but) } - else if (but->flag & UI_BUT_DRIVEN) ; + else if (but->flag & UI_BUT_DRIVEN) { + /* pass */ + } else if (is_anim) { if (length) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"), @@ -4533,9 +4618,10 @@ static int ui_but_menu(bContext *C, uiBut *but) uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"), ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); } - else + else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"), ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); + } } if (but->flag & UI_BUT_ANIMATED) { @@ -4561,17 +4647,21 @@ static int ui_but_menu(bContext *C, uiBut *but) uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"), ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0); } - else + else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"), ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0); + } uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"), ICON_NONE, "ANIM_OT_copy_driver_button"); - if (ANIM_driver_can_paste()) + if (ANIM_driver_can_paste()) { uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), ICON_NONE, "ANIM_OT_paste_driver_button"); + } + } + else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) { + /* pass */ } - else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) ; else if (is_anim) { uiItemS(layout); @@ -4581,13 +4671,15 @@ static int ui_but_menu(bContext *C, uiBut *but) uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single Driver"), ICON_NONE, "ANIM_OT_driver_button_add", "all", 0); } - else + else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"), ICON_NONE, "ANIM_OT_driver_button_add", "all", 0); + } - if (ANIM_driver_can_paste()) + if (ANIM_driver_can_paste()) { uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), ICON_NONE, "ANIM_OT_paste_driver_button"); + } } /* Keying Sets */ @@ -4624,9 +4716,10 @@ static int ui_but_menu(bContext *C, uiBut *but) uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"), ICON_NONE, "UI_OT_reset_default_button", "all", 0); } - else + else { uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"), ICON_NONE, "UI_OT_reset_default_button"); + } uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"), ICON_NONE, "UI_OT_copy_data_path_button"); @@ -4673,7 +4766,12 @@ static int ui_but_menu(bContext *C, uiBut *but) uiItemS(layout); } - + /* Show header tools for header buttons. */ + if (ar->regiontype == RGN_TYPE_HEADER) { + uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL); + uiItemS(layout); + } + { /* Docs */ char buf[512]; PointerRNA ptr_props; @@ -5231,12 +5329,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s /* automatic open pulldown block timer */ if (ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) { - if ((data->used_mouse == TRUE) && - (data->autoopentimer == FALSE) && - /* don't popup the first time, - * see description on this member for info */ - (but->block->auto_is_first_event == FALSE)) - { + if (data->used_mouse && !data->autoopentimer) { int time; if (but->block->auto_open == TRUE) { /* test for toolbox */ @@ -5256,8 +5349,6 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s data->autoopentimer = WM_event_add_timer(data->wm, data->window, TIMER, 0.02 * (double)time); } } - - but->block->auto_is_first_event = FALSE; } } else { @@ -5281,8 +5372,24 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s } else if (data->state == BUTTON_STATE_NUM_EDITING) { ui_numedit_end(but, data); - if (ui_is_a_warp_but(but)) - WM_cursor_grab_disable(CTX_wm_window(C)); + if (ui_is_a_warp_but(but)) { + +#ifdef USE_CONT_MOUSE_CORRECT + if (data->ungrab_mval[0] != FLT_MAX) { + int mouse_ungrab_xy[2]; + ui_block_to_window_fl(data->region, but->block, &data->ungrab_mval[0], &data->ungrab_mval[1]); + mouse_ungrab_xy[0] = data->ungrab_mval[0]; + mouse_ungrab_xy[1] = data->ungrab_mval[1]; + + WM_cursor_grab_disable(data->window, mouse_ungrab_xy); + } + else { + WM_cursor_grab_disable(data->window, NULL); + } +#else + WM_cursor_grab_disable(data->window, ); +#endif + } } /* menu open */ if (state == BUTTON_STATE_MENU_OPEN) @@ -5345,6 +5452,10 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data->window = CTX_wm_window(C); data->region = ar; +#ifdef USE_CONT_MOUSE_CORRECT + copy_v2_fl(data->ungrab_mval, FLT_MAX); +#endif + if (ELEM(but->type, BUT_CURVE, SEARCH_MENU)) { /* XXX curve is temp */ } @@ -5626,20 +5737,24 @@ void uiContextAnimUpdate(const bContext *C) ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f); ED_region_tag_redraw(ar); - if (but->active) + if (but->active) { activebut = but; - else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) + } + else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) { activebut = but; + } } } if (activebut) { /* always recurse into opened menu, so all buttons update (like colorpicker) */ uiHandleButtonData *data = activebut->active; - if (data && data->menu) + if (data && data->menu) { ar = data->menu->region; - else + } + else { return; + } } else { /* no active button */ @@ -5669,8 +5784,9 @@ static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar) if (event->type == MOUSEMOVE) { but = ui_but_find_mouse_over(ar, event->x, event->y); - if (but) + if (but) { button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); + } } else if (event->type == EVT_BUT_OPEN) { but = uit_but_find_open_event(ar, event); @@ -6173,7 +6289,7 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my) return 0; } -static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int UNUSED(topmenu)) +static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int level) { ARegion *ar; uiBlock *block; @@ -6218,10 +6334,22 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle } /* first block own event func */ - if (block->block_event_func && block->block_event_func(C, block, event)) ; - /* events not for active search menu button */ + if (block->block_event_func && block->block_event_func(C, block, event)) { + /* pass */ + } /* events not for active search menu button */ else if (but == NULL || but->type != SEARCH_MENU) { switch (event->type) { + + + /* let the parent menu get the event */ +#define PASS_EVENT_TO_PARENT_IF_NONACTIVE \ + if ((level != 0) && (but == NULL)) { \ + menu->menuretval = UI_RETURN_OUT | UI_RETURN_OUT_PARENT; \ + BLI_assert(retval == WM_UI_HANDLER_CONTINUE); \ + break; \ + } (void)0 + + /* closing sublevels of pulldowns */ case LEFTARROWKEY: if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) @@ -6234,6 +6362,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* opening sublevels of pulldowns */ case RIGHTARROWKEY: if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) { + + PASS_EVENT_TO_PARENT_IF_NONACTIVE; + but = ui_but_find_activated(ar); if (!but) { @@ -6259,6 +6390,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle } else if (inside || (block->flag & UI_BLOCK_LOOP)) { if (event->val == KM_PRESS) { + + PASS_EVENT_TO_PARENT_IF_NONACTIVE; + but = ui_but_find_activated(ar); if (but) { /* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */ @@ -6338,6 +6472,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle if (act == 0) act = 10; if ((block->flag & UI_BLOCK_NUMSELECT) && event->val == KM_PRESS) { + + PASS_EVENT_TO_PARENT_IF_NONACTIVE; + if (event->alt) act += 10; count = 0; @@ -6415,6 +6552,8 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle (event->ctrl == FALSE) && (event->oskey == FALSE)) { + PASS_EVENT_TO_PARENT_IF_NONACTIVE; + for (but = block->buttons.first; but; but = but->next) { if (but->menu_key == event->type) { @@ -6504,6 +6643,10 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle retval = WM_UI_HANDLER_BREAK; } } + + /* end switch */ +#undef PASS_EVENT_TO_PARENT_IF_NONACTIVE + } } @@ -6592,7 +6735,7 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo return WM_UI_HANDLER_BREAK; } -static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHandle *menu) +static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int level) { uiBut *but; uiHandleButtonData *data; @@ -6605,14 +6748,20 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa submenu = (data) ? data->menu : NULL; if (submenu) - retval = ui_handle_menus_recursive(C, event, submenu); + retval = ui_handle_menus_recursive(C, event, submenu, level + 1); /* now handle events for our own menu */ if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { - if (submenu && submenu->menuretval) + if (submenu && submenu->menuretval) { retval = ui_handle_menu_return_submenu(C, event, menu); - else - retval = ui_handle_menu_event(C, event, menu, (submenu == NULL)); + /* we may wan't to quit the submenu and handle the even in this menu */ + if ((retval == WM_UI_HANDLER_BREAK) && (submenu->menuretval & UI_RETURN_OUT_PARENT)) { + retval = ui_handle_menu_event(C, event, menu, level); + } + } + else { + retval = ui_handle_menu_event(C, event, menu, level); /* same as above */ + } } return retval; @@ -6700,7 +6849,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user if (data->state == BUTTON_STATE_MENU_OPEN) { /* handle events for menus and their buttons recursively, * this will handle events from the top to the bottom menu */ - retval = ui_handle_menus_recursive(C, event, data->menu); + retval = ui_handle_menus_recursive(C, event, data->menu, 0); /* handle events for the activated button */ if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { @@ -6744,7 +6893,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata) retval = WM_UI_HANDLER_CONTINUE; } - ui_handle_menus_recursive(C, event, menu); + ui_handle_menus_recursive(C, event, menu, 0); /* free if done, does not free handle itself */ if (menu->menuretval) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index f6f12f98181..0921107b8e6 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -466,7 +466,7 @@ static void init_brush_icons(void) { \ bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_ ##name## _png, \ datatoc_ ##name## _png_size, \ - IB_rect, "<brush icon>"); \ + IB_rect, NULL, "<brush icon>"); \ def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \ IMB_freeImBuf(bbuf); \ } (void)0 @@ -520,7 +520,7 @@ static void init_internal_icons(void) char *icondir = BLI_get_folder(BLENDER_DATAFILES, "icons"); if (icondir) { BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile); - bbuf = IMB_loadiffname(iconfilestr, IB_rect); /* if the image is missing bbuf will just be NULL */ + bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL); /* if the image is missing bbuf will just be NULL */ if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) { printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr); IMB_freeImBuf(bbuf); @@ -533,7 +533,7 @@ static void init_internal_icons(void) } if (bbuf == NULL) bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons_png, - datatoc_blender_icons_png_size, IB_rect, "<blender icons>"); + datatoc_blender_icons_png_size, IB_rect, NULL, "<blender icons>"); if (bbuf) { /* free existing texture if any */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 73e6427d1cb..b48c9bcab7e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -305,17 +305,7 @@ struct uiBlock { char direction; char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied to buttons */ char auto_open; - - /* this setting is used so newly opened menu's dont popout the first item under the mouse, - * the reasoning behind this is because of muscle memory for opening menus. - * - * Without this, the first time opening a Submenu and activating an item in it will be 2 steps, - * but the second time the same item is accessed the menu memory would auto activate the - * last used menu and the key intended to select that submenu ends up being passed into the submenu. - * - Campbell - */ - char auto_is_first_event; - char _pad[6]; + char _pad[7]; double auto_open_last; const char *lockstr; @@ -342,7 +332,12 @@ struct uiBlock { struct UnitSettings *unit; /* unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. */ float _hsv[3]; /* XXX, only access via ui_block_hsv_get() */ + char color_profile; /* color profile for correcting linear colors for display */ + + char *display_device; /* display devide name used to display this block, + * used by color widgets to transform colors from/to scene linear + */ }; typedef struct uiSafetyRct { @@ -392,6 +387,10 @@ extern void ui_bounds_block(uiBlock *block); extern void ui_block_translate(uiBlock *block, int x, int y); extern void ui_block_do_align(uiBlock *block); +extern struct ColorManagedDisplay *ui_block_display_get(uiBlock *block); +void ui_block_to_display_space_v3(uiBlock *block, float pixel[3]); +void ui_block_to_scene_linear_v3(uiBlock *block, float pixel[3]); + /* interface_regions.c */ struct uiPopupBlockHandle { @@ -464,7 +463,7 @@ extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event); extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *rect); /* interface_draw.c */ -extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select); +extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select); void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha); @@ -500,7 +499,7 @@ void ui_widget_color_init(struct ThemeUI *tui); void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state); void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state); -extern unsigned char checker_stipple_sml[]; +extern unsigned char checker_stipple_sml[32 * 32 / 8]; /* used for transp checkers */ #define UI_TRANSP_DARK 100 #define UI_TRANSP_LIGHT 160 diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 803fd928085..8ffbcd6d399 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -239,10 +239,8 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - - - if (r_w) *r_w = BLI_RCT_SIZE_X(&bitem->but->rect); - if (r_h) *r_h = BLI_RCT_SIZE_Y(&bitem->but->rect); + if (r_w) *r_w = BLI_rctf_size_x(&bitem->but->rect); + if (r_h) *r_h = BLI_rctf_size_y(&bitem->but->rect); } else { uiLayout *litem = (uiLayout *)item; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index e8b8959fd43..ded5887f7f2 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -58,6 +58,8 @@ #include "UI_interface.h" +#include "IMB_colormanagement.h" + #include "interface_intern.h" #include "WM_api.h" @@ -75,7 +77,7 @@ /* ********************************************************** */ typedef struct Eyedropper { - short do_color_management; + struct ColorManagedDisplay *display; PointerRNA ptr; PropertyRNA *prop; @@ -89,8 +91,6 @@ typedef struct Eyedropper { static int eyedropper_init(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - const int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; - Eyedropper *eye; op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper"); @@ -106,7 +106,12 @@ static int eyedropper_init(bContext *C, wmOperator *op) return FALSE; } - eye->do_color_management = (color_manage && RNA_property_subtype(eye->prop) == PROP_COLOR); + if (RNA_property_subtype(eye->prop) == PROP_COLOR) { + const char *display_device; + + display_device = scene->display_settings.display_device; + eye->display = IMB_colormanagement_display_get_named(display_device); + } return TRUE; } @@ -194,9 +199,10 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3 /* to maintain alpha */ RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv); - /* convert from screen (srgb) space to linear rgb space */ - if (eye->do_color_management) { - srgb_to_linearrgb_v3_v3(col_conv, col); + /* convert from display space to linear rgb space */ + if (eye->display) { + copy_v3_v3(col_conv, col); + IMB_colormanagement_display_to_scene_linear_v3(col_conv, eye->display); } else { copy_v3_v3(col_conv, col); @@ -906,7 +912,7 @@ static void UI_OT_editsource(wmOperatorType *ot) * Note: this includes utility functions and button matching checks. * this only works in conjunction with a py operator! */ -void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen) +static void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen) { char tstr[32]; /* Should be more than enough! */ /* First, full lang code. */ diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index fa3e04d1351..49e96bea6c6 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -357,14 +357,14 @@ void UI_DrawTriIcon(float x, float y, char dir) } /* triangle 'icon' inside rect */ -static void ui_draw_tria_rect(rctf *rect, char dir) +static void ui_draw_tria_rect(const rctf *rect, char dir) { if (dir == 'h') { - float half = 0.5f * BLI_RCT_SIZE_Y(rect); + float half = 0.5f * BLI_rctf_size_y(rect); ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half); } else { - float half = 0.5f * BLI_RCT_SIZE_X(rect); + float half = 0.5f * BLI_rctf_size_x(rect); ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin); } } @@ -479,12 +479,12 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r } } -static void rectf_scale(rctf *rect, float scale) +static void rectf_scale(rctf *rect, const float scale) { - float centx = 0.5f * (rect->xmin + rect->xmax); - float centy = 0.5f * (rect->ymin + rect->ymax); - float sizex = 0.5f * scale * BLI_RCT_SIZE_X(rect); - float sizey = 0.5f * scale * BLI_RCT_SIZE_Y(rect); + float centx = BLI_rctf_cent_x(rect); + float centy = BLI_rctf_cent_y(rect); + float sizex = BLI_rctf_size_x(rect) * 0.5f * scale; + float sizey = BLI_rctf_size_y(rect) * 0.5f * scale; rect->xmin = centx - sizex; rect->xmax = centx + sizex; @@ -547,7 +547,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* itemrect smaller */ itemrect.xmax = headrect.xmax - 5.0f / block->aspect; - itemrect.xmin = itemrect.xmax - BLI_RCT_SIZE_Y(&headrect); + itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect); itemrect.ymin = headrect.ymin; itemrect.ymax = headrect.ymax; @@ -596,7 +596,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* itemrect smaller */ itemrect.xmin = headrect.xmin + 5.0f / block->aspect; - itemrect.xmax = itemrect.xmin + BLI_RCT_SIZE_Y(&headrect); + itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect); itemrect.ymin = headrect.ymin; itemrect.ymax = headrect.ymax; @@ -985,8 +985,8 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) dx = (event->x - data->startx) & ~(PNL_GRID - 1); dy = (event->y - data->starty) & ~(PNL_GRID - 1); - dx *= (float)BLI_RCT_SIZE_X(&ar->v2d.cur) / (float)BLI_RCT_SIZE_X(&ar->winrct); - dy *= (float)BLI_RCT_SIZE_Y(&ar->v2d.cur) / (float)BLI_RCT_SIZE_Y(&ar->winrct); + dx *= (float)BLI_rctf_size_x(&ar->v2d.cur) / (float)BLI_rcti_size_x(&ar->winrct); + dy *= (float)BLI_rctf_size_y(&ar->v2d.cur) / (float)BLI_rcti_size_y(&ar->winrct); if (data->state == PANEL_STATE_DRAG_SCALE) { panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 10a64d50887..adf839d433b 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -66,9 +66,10 @@ #include "ED_screen.h" +#include "IMB_colormanagement.h" + #include "interface_intern.h" -#define MENU_SEPR_HEIGHT 6 #define B_NOP -1 #define MENU_SHADOW_SIDE 8 #define MENU_SHADOW_BOTTOM 10 @@ -391,7 +392,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) /* draw text */ uiStyleFontSet(&data->fstyle); - bbox.ymax = bbox.ymax - 0.5f * (BLI_RCT_SIZE_Y(&bbox) - data->toth); + bbox.ymax = bbox.ymax - 0.5f * (BLI_rcti_size_y(&bbox) - data->toth); bbox.ymin = bbox.ymax - data->lineh; for (i = 0; i < data->totline; i++) { @@ -730,9 +731,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_rcti_size_x(&rect_i) + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_rcti_size_y(&rect_i) + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; @@ -865,8 +866,8 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) { /* thumbnail preview */ if (data->preview) { - int butw = BLI_RCT_SIZE_X(&data->bbox) / data->prv_cols; - int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows; + int butw = BLI_rcti_size_x(&data->bbox) / data->prv_cols; + int buth = (BLI_rcti_size_y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows; int row, col; *rect = data->bbox; @@ -882,7 +883,7 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) } /* list view */ else { - int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS; + int buth = (BLI_rcti_size_y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS; *rect = data->bbox; rect->xmin = data->bbox.xmin + 3.0f; @@ -1095,13 +1096,13 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) if (data->items.more) { ui_searchbox_butrect(&rect, data, data->items.maxitem - 1); glEnable(GL_BLEND); - UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN); + UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN); glDisable(GL_BLEND); } if (data->items.offset) { ui_searchbox_butrect(&rect, data, 0); glEnable(GL_BLEND); - UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP); + UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP); glDisable(GL_BLEND); } } @@ -1176,16 +1177,16 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = BLI_RCT_SIZE_X(&ar->winrct) - MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_rcti_size_x(&ar->winrct) - MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = BLI_RCT_SIZE_Y(&ar->winrct) - MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_rcti_size_y(&ar->winrct) - MENU_SHADOW_BOTTOM; /* check if button is lower half */ - if (but->rect.ymax < BLI_RCT_CENTER_Y(&but->block->rect)) { - data->bbox.ymin += BLI_RCT_SIZE_Y(&but->rect); + if (but->rect.ymax < BLI_rctf_cent_y(&but->block->rect)) { + data->bbox.ymin += BLI_rctf_size_y(&but->rect); } else { - data->bbox.ymax -= BLI_RCT_SIZE_Y(&but->rect); + data->bbox.ymax -= BLI_rctf_size_y(&but->rect); } } else { @@ -1200,7 +1201,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) BLI_rctf_translate(&rect_fl, ofsx, ofsy); /* minimal width */ - if (BLI_RCT_SIZE_X(&rect_fl) < 150) { + if (BLI_rctf_size_x(&rect_fl) < 150) { rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */ } @@ -1233,15 +1234,15 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1); newy1 += butregion->winrct.ymin; - rect_i.ymax = BLI_RCT_SIZE_Y(&rect_i) + newy1; + rect_i.ymax = BLI_rcti_size_y(&rect_i) + newy1; rect_i.ymin = newy1; } /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_rcti_size_x(&rect_i) + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_rcti_size_y(&rect_i) + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; @@ -1356,15 +1357,15 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, } } - /* aspect = (float)(BLI_RCT_SIZE_X(&block->rect) + 4);*/ /*UNUSED*/ + /* aspect = (float)(BLI_rcti_size_x(&block->rect) + 4);*/ /*UNUSED*/ ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin); ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax); //block->rect.xmin -= 2.0; block->rect.ymin -= 2.0; //block->rect.xmax += 2.0; block->rect.ymax += 2.0; - xsize = BLI_RCT_SIZE_X(&block->rect) + 4; /* 4 for shadow */ - ysize = BLI_RCT_SIZE_Y(&block->rect) + 4; + xsize = BLI_rctf_size_x(&block->rect) + 4; /* 4 for shadow */ + ysize = BLI_rctf_size_y(&block->rect) + 4; /* aspect /= (float)xsize;*/ /*UNUSED*/ { @@ -1494,9 +1495,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, BLI_rctf_translate(&block->rect, xof, yof); /* safety calculus */ - if (but) { - const float midx = BLI_RCT_CENTER_X(&butrct); - const float midy = BLI_RCT_CENTER_Y(&butrct); + { + const float midx = BLI_rctf_cent_x(&butrct); + const float midy = BLI_rctf_cent_y(&butrct); /* when you are outside parent button, safety there should be smaller */ @@ -1521,20 +1522,13 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, } block->direction = dir1; } - else { - block->safety.xmin = block->rect.xmin - 40; - block->safety.ymin = block->rect.ymin - 40; - block->safety.xmax = block->rect.xmax + 40; - block->safety.ymax = block->rect.ymax + 40; - } /* keep a list of these, needed for pulldown menus */ saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct"); saferct->parent = butrct; saferct->safety = block->safety; BLI_freelistN(&block->saferct); - if (but) - BLI_duplicatelist(&block->saferct, &but->block->saferct); + BLI_duplicatelist(&block->saferct, &but->block->saferct); BLI_addhead(&block->saferct, saferct); } @@ -1879,12 +1873,6 @@ static void ui_warp_pointer(int x, int y) /********************* Color Button ****************/ -/* picker sizes S hsize, F full size, D spacer, B button/pallette height */ -#define SPICK 110.0 -#define FPICK 180.0 -#define DPICK 6.0 -#define BPICK 24.0 - /* for picker, while editing hsv */ void ui_set_but_hsv(uiBut *but) { @@ -1900,11 +1888,15 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3]) { uiBut *bt; float *hsv = ui_block_hsv_get(block); + struct ColorManagedDisplay *display = NULL; /* this is to keep the H and S value when V is equal to zero * and we are working in HSV mode, of course! */ rgb_to_hsv_compat_v(rgb, hsv); + + if (block->color_profile) + display = ui_block_display_get(block); /* this updates button strings, is hackish... but button pointers are on stack of caller function */ for (bt = block->buttons.first; bt; bt = bt->next) { @@ -1920,12 +1912,11 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3]) /* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */ - if (block->color_profile == BLI_PR_NONE) { - copy_v3_v3(rgb_gamma, rgb); - } - else { - /* make an sRGB version, for Hex code */ - linearrgb_to_srgb_v3_v3(rgb_gamma, rgb); + copy_v3_v3(rgb_gamma, rgb); + + if (display) { + /* make a display version, for Hex code */ + IMB_colormanagement_scene_linear_to_display_v3(rgb_gamma, display); } if (rgb_gamma[0] > 1.0f) rgb_gamma[0] = modf(rgb_gamma[0], &intpart); @@ -2004,9 +1995,9 @@ static void do_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl) hex_to_rgb(hexcol, rgb, rgb + 1, rgb + 2); /* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */ - if (but->block->color_profile != BLI_PR_NONE) { + if (but->block->color_profile) { /* so we need to linearise it for Blender */ - srgb_to_linearrgb_v3_v3(rgb, rgb); + ui_block_to_scene_linear_v3(but->block, rgb); } ui_update_block_buts_rgb(but->block, rgb); @@ -2055,10 +2046,6 @@ static void do_picker_new_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a picker_new_hide_reveal(bt->block, colormode); } -/* picker sizes S hsize, F full size, D spacer, B button/pallette height */ -#define SPICK1 150.0 -#define DPICK1 6.0 - #define PICKER_H 150 #define PICKER_W 150 #define PICKER_SPACE 6 @@ -2114,14 +2101,16 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper /* existence of profile means storage is in linear color space, with display correction */ /* XXX That tip message is not use anywhere! */ - if (block->color_profile == BLI_PR_NONE) { + if (!block->color_profile) { BLI_strncpy(tip, N_("Value in Display Color Space"), sizeof(tip)); copy_v3_v3(rgb_gamma, rgba); } else { BLI_strncpy(tip, N_("Value in Linear RGB Color Space"), sizeof(tip)); - /* make an sRGB version, for Hex code */ - linearrgb_to_srgb_v3_v3(rgb_gamma, rgba); + + /* make a display version, for Hex code */ + copy_v3_v3(rgb_gamma, rgba); + ui_block_to_display_space_v3(block, rgb_gamma); } /* sneaky way to check for alpha */ @@ -2246,7 +2235,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_ if (but->rnaprop) { if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { - block->color_profile = BLI_PR_NONE; + block->color_profile = FALSE; } } @@ -2343,7 +2332,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi if (pup->but) { /* minimum width to enforece */ - minwidth = BLI_RCT_SIZE_X(&pup->but->rect); + minwidth = BLI_rctf_size_x(&pup->but->rect); if (pup->but->type == PULLDOWN || pup->but->menu_create_func) { direction = UI_DOWN; @@ -2385,7 +2374,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi * button, so it doesn't overlap the text too much, also note * the offset is negative because we are inverse moving the * block to be under the mouse */ - offset[0] = -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect)); + offset[0] = -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect)); offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y); } else { @@ -2393,7 +2382,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_RCT_SIZE_X(&bt->rect))); + offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect))); offset[1] = 1.5 * UI_UNIT_Y; } @@ -2502,7 +2491,6 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->block->flag |= UI_BLOCK_POPUP_MEMORY; pup->block->puphash = ui_popup_menu_hash(title); - pup->block->auto_is_first_event = TRUE; pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN); @@ -2576,6 +2564,11 @@ static void confirm_cancel_operator(void *opv) } static void vconfirm_opname(bContext *C, const char *opname, const char *title, const char *itemfmt, va_list ap) +#ifdef __GNUC__ +__attribute__ ((format(printf, 4, 0))) +#endif +; +static void vconfirm_opname(bContext *C, const char *opname, const char *title, const char *itemfmt, va_list ap) { uiPopupBlockHandle *handle; char *s, buf[512]; diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index b16250021d3..acf7712f97b 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -152,17 +152,17 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str, uiStyleFontSet(fs); height = BLF_ascender(fs->uifont_id); - yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height)); + yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height)); if (fs->align == UI_STYLE_TEXT_CENTER) { - xofs = floor(0.5f * (BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str))); + xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str))); /* don't center text if it chops off the start of the text, 2 gives some margin */ if (xofs < 2) { xofs = 2; } } else if (fs->align == UI_STYLE_TEXT_RIGHT) { - xofs = BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str) - 1; + xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str) - 1; } /* clip is very strict, so we give it some space */ @@ -209,7 +209,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) height = BLF_ascender(fs->uifont_id); /* becomes x-offset when rotated */ - xofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height)); + xofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height)); /* ignore UI_STYLE, always aligned to top */ @@ -219,8 +219,8 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) angle = 90.0f; /* translate rect to vertical */ - txtrect.xmin = rect->xmin - BLI_RCT_SIZE_Y(rect); - txtrect.ymin = rect->ymin - BLI_RCT_SIZE_X(rect); + txtrect.xmin = rect->xmin - BLI_rcti_size_y(rect); + txtrect.ymin = rect->ymin - BLI_rcti_size_x(rect); txtrect.xmax = rect->xmin; txtrect.ymax = rect->ymin; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 9f0dc4af226..37503acfeb0 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -35,6 +35,7 @@ #include "DNA_dynamicpaint_types.h" #include "DNA_key_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "DNA_userdef_types.h" #include "BLI_utildefines.h" @@ -56,6 +57,7 @@ #include "BKE_texture.h" #include "BKE_report.h" #include "BKE_displist.h" +#include "BKE_sca.h" #include "BKE_scene.h" #include "ED_screen.h" @@ -428,8 +430,15 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str TIP_("Display number of users of this data (click to make a single-user copy)")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); - if (!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable) + if (/* test only */ + (id_copy(id, NULL, 1) == FALSE) || + (idfrom && idfrom->lib) || + (editable == FALSE) || + /* object in editmode - don't change data */ + (idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT))) + { uiButSetFlag(but, UI_BUT_DISABLED); + } } if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT); @@ -930,28 +939,26 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) #include "BKE_action.h" #include "BKE_constraint.h" -#define REDRAWIPO 1 -#define REDRAWNLA 2 -#define REDRAWBUTSOBJECT 3 -#define REDRAWACTION 4 #define B_CONSTRAINT_TEST 5 -#define B_CONSTRAINT_CHANGETARGET 6 -#define REMAKEIPO 8 -#define B_DIFF 9 +// #define B_CONSTRAINT_CHANGETARGET 6 static void do_constraint_panels(bContext *C, void *ob_pt, int event) { - Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); Object *ob = (Object *)ob_pt; switch (event) { case B_CONSTRAINT_TEST: break; /* no handling */ +#if 0 /* UNUSED */ case B_CONSTRAINT_CHANGETARGET: + { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); if (ob->pose) ob->pose->flag |= POSE_RECALC; /* checks & sorts pose channels */ DAG_scene_sort(bmain, scene); break; + } +#endif default: break; } @@ -1263,8 +1270,6 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) RNA_property_update(C, &cb->ptr, cb->prop); } -#define B_BANDCOL 1 - static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) { ColorBand *coba = coba_v; @@ -1380,7 +1385,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb) { uiBut *bt; - float unit = BLI_RCT_SIZE_X(butr) / 14.0f; + float unit = BLI_rctf_size_x(butr) / 14.0f; float xs = butr->xmin; uiBlockBeginAlign(block); @@ -1406,7 +1411,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand TIP_("Set interpolation between color stops")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_RCT_SIZE_X(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, ""); + bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_rctf_size_x(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); uiBlockEndAlign(block); @@ -1481,7 +1486,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height; - bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), hist->height, hist, 0, 0, 0, 0, ""); + bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), hist->height, hist, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); MEM_freeN(cb); @@ -1518,7 +1523,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height; - bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); + bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); (void)bt; /* UNUSED */ MEM_freeN(cb); @@ -1555,7 +1560,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height; - bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); + bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); MEM_freeN(cb); @@ -1570,11 +1575,11 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar float d; /* we allow 20 times zoom */ - if (BLI_RCT_SIZE_X(&cumap->curr) > 0.04f * BLI_RCT_SIZE_X(&cumap->clipr)) { - d = 0.1154f * BLI_RCT_SIZE_X(&cumap->curr); + if (BLI_rctf_size_x(&cumap->curr) > 0.04f * BLI_rctf_size_x(&cumap->clipr)) { + d = 0.1154f * BLI_rctf_size_x(&cumap->curr); cumap->curr.xmin += d; cumap->curr.xmax -= d; - d = 0.1154f * BLI_RCT_SIZE_Y(&cumap->curr); + d = 0.1154f * BLI_rctf_size_y(&cumap->curr); cumap->curr.ymin += d; cumap->curr.ymax -= d; } @@ -1588,8 +1593,8 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u float d, d1; /* we allow 20 times zoom, but don't view outside clip */ - if (BLI_RCT_SIZE_X(&cumap->curr) < 20.0f * BLI_RCT_SIZE_X(&cumap->clipr)) { - d = d1 = 0.15f * BLI_RCT_SIZE_X(&cumap->curr); + if (BLI_rctf_size_x(&cumap->curr) < 20.0f * BLI_rctf_size_x(&cumap->clipr)) { + d = d1 = 0.15f * BLI_rctf_size_x(&cumap->curr); if (cumap->flag & CUMA_DO_CLIP) if (cumap->curr.xmin - d < cumap->clipr.xmin) @@ -1602,7 +1607,7 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u d1 = -cumap->curr.xmax + cumap->clipr.xmax; cumap->curr.xmax += d1; - d = d1 = 0.15f * BLI_RCT_SIZE_Y(&cumap->curr); + d = d1 = 0.15f * BLI_rctf_size_y(&cumap->curr); if (cumap->flag & CUMA_DO_CLIP) if (cumap->curr.ymin - d < cumap->clipr.ymin) @@ -1870,7 +1875,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - if (cumap->flag & CUMA_DO_CLIP) icon = ICON_CLIPUV_HLT; else icon = ICON_CLIPUV_DEHLT; + icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT; bt = uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -2086,6 +2091,74 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, } } +void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propname, + PointerRNA *used_ptr, const char *used_propname, int active_state) +{ + uiLayout *uRow, *uCol; + PropertyRNA *prop, *used_prop = NULL; + int groups, cols, states; + int group, col, state, row; + int cols_per_group = 5; + Object *ob = (Object *)ptr->id.data; + + prop = RNA_struct_find_property(ptr, propname); + if (!prop) { + RNA_warning("states property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); + return; + } + + /* the number of states determines the way we group them + * - we want 2 rows only (for now) + * - the number of columns (cols) is the total number of buttons per row + * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be + * - for now, only split into groups if group will have at least 5 items + */ + states = RNA_property_array_length(ptr, prop); + cols = (states / 2) + (states % 2); + groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group); + + if (used_ptr && used_propname) { + used_prop = RNA_struct_find_property(used_ptr, used_propname); + if (!used_prop) { + RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname); + return; + } + + if (RNA_property_array_length(used_ptr, used_prop) < states) + used_prop = NULL; + } + + /* layers are laid out going across rows, with the columns being divided into groups */ + + for (group = 0; group < groups; group++) { + uCol = uiLayoutColumn(layout, TRUE); + + for (row = 0; row < 2; row++) { + uiBlock *block; + uiBut *but; + + uRow = uiLayoutRow(uCol, TRUE); + block = uiLayoutGetBlock(uRow); + state = groups * cols_per_group * row + cols_per_group * group; + + /* add layers as toggle buts */ + for (col = 0; (col < cols_per_group) && (state < states); col++, state++) { + int icon = 0; + int butlay = 1 << state; + + if (active_state & butlay) + icon = ICON_LAYER_ACTIVE; + else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state)) + icon = ICON_LAYER_USED; + + but = uiDefIconButR_prop(block, ICONTOG, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop, state, 0, 0, -1, -1, sca_state_name_get(ob, state)); + uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state)); + but->type = TOG; + } + } + } +} + /************************* List Template **************************/ @@ -2802,3 +2875,56 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr) } } +/********************************* Color management *************************************/ + +void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname) +{ + PropertyRNA *prop; + PointerRNA colorspace_settings_ptr; + + prop = RNA_struct_find_property(ptr, propname); + + if (!prop) { + printf("%s: property not found: %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); + return; + } + + colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop); + + uiItemL(layout, "Color Space:", ICON_NONE); + uiItemR(layout, &colorspace_settings_ptr, "name", 0, "", ICON_NONE); +} + +void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr, const char *propname) +{ + PropertyRNA *prop; + PointerRNA view_transform_ptr; + uiLayout *col, *row; + ColorManagedViewSettings *view_settings; + + prop = RNA_struct_find_property(ptr, propname); + + if (!prop) { + printf("%s: property not found: %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); + return; + } + + view_transform_ptr = RNA_property_pointer_get(ptr, prop); + view_settings = view_transform_ptr.data; + + col = uiLayoutColumn(layout, FALSE); + + row = uiLayoutRow(col, FALSE); + uiItemR(row, &view_transform_ptr, "view_transform", UI_ITEM_R_EXPAND, IFACE_("View"), ICON_NONE); + + col = uiLayoutColumn(layout, FALSE); + uiItemR(col, &view_transform_ptr, "exposure", 0, NULL, ICON_NONE); + uiItemR(col, &view_transform_ptr, "gamma", 0, NULL, ICON_NONE); + + col = uiLayoutColumn(layout, FALSE); + uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE); + if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) + uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', TRUE, 0); +} diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 026f02d1089..f3539af821e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -259,8 +259,8 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r rad += step; - if (2.0f * rad > BLI_RCT_SIZE_Y(rect)) - rad = 0.5f * BLI_RCT_SIZE_Y(rect); + if (2.0f * rad > BLI_rcti_size_y(rect)) + rad = 0.5f * BLI_rcti_size_y(rect); minx = rect->xmin - step; miny = rect->ymin - step; @@ -345,8 +345,8 @@ 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_RCT_SIZE_X(rect) * hnum, - BLI_RCT_SIZE_Y(rect) * vnum); + minsize = mini(BLI_rcti_size_x(rect) * hnum, + BLI_rcti_size_y(rect) * vnum); if (2.0f * rad > minsize) rad = 0.5f * 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_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); + minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -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_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); + minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -570,14 +570,14 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect) int a; /* center position and size */ - centx = rect->xmax - 0.5f * BLI_RCT_SIZE_Y(rect); - centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect); - size = 0.4f * BLI_RCT_SIZE_Y(rect); + 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); /* XXX exception */ - asp = ((float)BLI_RCT_SIZE_X(rect)) / ((float)BLI_RCT_SIZE_Y(rect)); + 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_RCT_SIZE_Y(rect); + centx = rect->xmax - 0.3f * BLI_rcti_size_y(rect); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * menu_tria_vert[a][0] + centx; @@ -594,9 +594,9 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect) int a; /* center position and size */ - centx = rect->xmin + 0.5f * BLI_RCT_SIZE_Y(rect); - centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect); - size = 0.5f * BLI_RCT_SIZE_Y(rect); + centx = rect->xmin + 0.5f * BLI_rcti_size_y(rect); + centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect); + size = 0.5f * BLI_rcti_size_y(rect); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * check_tria_vert[a][0] + centx; @@ -840,8 +840,8 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) if (icon == ICON_NONE) return; - w = BLI_RCT_SIZE_X(rect); - h = BLI_RCT_SIZE_Y(rect); + w = BLI_rcti_size_x(rect); + h = BLI_rcti_size_y(rect); size = MIN2(w, h); size -= PREVIEW_PAD * 2; /* padding */ @@ -965,48 +965,77 @@ static void ui_text_clip_give_next_off(uiBut *but) but->ofs += bytes; } -/* sets but->ofs to make sure text is correctly visible */ -static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) +/** + * Cut off the start of the text to fit into the width of \a rect + * + * \note Sets but->ofs to make sure text is correctly visible. + * \note Clips right in some cases, this function could be cleaned up. + */ +static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, rcti *rect) { int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; - int okwidth = BLI_RCT_SIZE_X(rect) - border; - + int okwidth = BLI_rcti_size_x(rect) - border; if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; - + /* need to set this first */ uiStyleFontSet(fstyle); if (fstyle->kerning == 1) /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - /* if text editing we define ofs dynamically */ - if (but->editstr && but->pos >= 0) { + but->ofs = 0; + but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr); + + while (but->strwidth > okwidth) { + ui_text_clip_give_next_off(but); + but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); + if (but->strwidth < 10) break; + } + + if (fstyle->kerning == 1) { + BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } +} + +/** + * Cut off the text, taking into account the cursor location (text display while editing). + */ +static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, rcti *rect) +{ + int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; + int okwidth = BLI_rcti_size_x(rect) - border; + if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; + + BLI_assert(but->editstr && but->pos >= 0); + + /* need to set this first */ + uiStyleFontSet(fstyle); + + if (fstyle->kerning == 1) /* for BLF_width */ + BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + + if ((but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr)) <= okwidth) { + but->ofs = 0; + } + else { + /* define ofs dynamically */ if (but->ofs > but->pos) but->ofs = but->pos; - if (BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth) - but->ofs = 0; - } - else but->ofs = 0; - - but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); - - while (but->strwidth > okwidth) { - - /* textbut exception, clip right when... */ - if (but->editstr && but->pos >= 0) { + while (but->strwidth > okwidth) { float width; char buf[UI_MAX_DRAW_STR]; - + /* copy draw string */ BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf)); /* string position of cursor */ buf[but->pos] = 0; width = BLF_width(fstyle->uifont_id, buf + but->ofs); - + /* if cursor is at 20 pixels of right side button we clip left */ - if (width > okwidth - 20) + if (width > okwidth - 20) { ui_text_clip_give_next_off(but); + } else { int len, bytes; /* shift string to the left */ @@ -1016,25 +1045,30 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len)); but->drawstr[len - bytes] = 0; } - } - else - ui_text_clip_give_next_off(but); - but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); - - if (but->strwidth < 10) break; + but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); + + if (but->strwidth < 10) break; + } } - - if (fstyle->kerning == 1) + + if (fstyle->kerning == 1) { BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } } -static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) +/** + * Cut off the end of text to fit into the width of \a rect. + * + * \note deals with ': ' especially for number buttons + */ +static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, rcti *rect) { int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; - int okwidth = BLI_RCT_SIZE_X(rect) - border; + int okwidth = BLI_rcti_size_x(rect) - border; char *cpoin = NULL; - char *cpend = but->drawstr + strlen(but->drawstr); + int drawstr_len = strlen(but->drawstr); + char *cpend = but->drawstr + drawstr_len; /* need to set this first */ uiStyleFontSet(fstyle); @@ -1045,6 +1079,13 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr); but->ofs = 0; + + /* First shorten num-buttopns eg, + * Translucency: 0.000 + * becomes + * Trans: 0.000 + */ + /* find the space after ':' separator */ cpoin = strrchr(but->drawstr, ':'); @@ -1057,8 +1098,11 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) int bytes = cp2 - prev_utf8; /* shift the text after and including cp2 back by 1 char, +1 to include null terminator */ - memmove(cp2 - bytes, cp2, strlen(cp2) + 1); + memmove(cp2 - bytes, cp2, drawstr_len + 1); cp2 -= bytes; + + drawstr_len -= bytes; + // BLI_assert(strlen(but->drawstr) == drawstr_len); but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); if (but->strwidth < 10) break; @@ -1074,14 +1118,17 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) } + + /* Now just remove trailing chars */ /* once the label's gone, chop off the least significant digits */ while (but->strwidth > okwidth) { - int len = strlen(but->drawstr); - int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len)); + int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + drawstr_len)); if (bytes < 0) bytes = 1; - but->drawstr[len - bytes] = 0; + drawstr_len -= bytes; + but->drawstr[drawstr_len] = 0; + // BLI_assert(strlen(but->drawstr) == drawstr_len); but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); if (but->strwidth < 10) break; @@ -1229,30 +1276,31 @@ 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) return; + if (but == NULL) { + return; + } /* clip but->drawstr to fit in available space */ if (but->editstr && but->pos >= 0) { - ui_text_leftclip(fstyle, but, rect); + ui_text_clip_cursor(fstyle, but, rect); } else if (ELEM4(but->type, NUM, NUMABS, NUMSLI, SLI)) { - ui_text_label_rightclip(fstyle, but, rect); + ui_text_clip_right_label(fstyle, but, rect); } else if (ELEM(but->type, TEX, SEARCH_MENU)) { - ui_text_leftclip(fstyle, but, rect); + ui_text_clip_left(fstyle, but, rect); } else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) { - ui_text_leftclip(fstyle, but, rect); + ui_text_clip_left(fstyle, but, rect); } else but->ofs = 0; - + /* check for button text label */ if (but->type == ICONTEXTROW) { widget_draw_icon(but, (BIFIconID) (but->icon + but->iconadd), 1.0f, rect); } else { - + if (but->type == BUT_TOGDUAL) { int dualset = 0; if (but->pointype == UI_BUT_POIN_SHORT) { @@ -1261,30 +1309,30 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB else if (but->pointype == UI_BUT_POIN_INT) { dualset = UI_BITBUT_TEST(*(((int *)but->poin) + 1), but->bitnr); } - + widget_draw_icon(but, ICON_DOT, dualset ? 1.0f : 0.25f, rect); } else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) { int tmp = rect->xmin; - rect->xmin = rect->xmax - BLI_RCT_SIZE_Y(rect) - 1; + rect->xmin = rect->xmax - BLI_rcti_size_y(rect) - 1; widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect); rect->xmin = tmp; } - + /* If there's an icon too (made with uiDefIconTextBut) then draw the icon * and offset the text label to accommodate it */ - + if (but->flag & UI_HAS_ICON) { widget_draw_icon(but, but->icon + but->iconadd, 1.0f, rect); - + rect->xmin += (int)((float)UI_icon_get_width(but->icon + but->iconadd) * UI_DPI_ICON_FAC); - - if (but->editstr || (but->flag & UI_TEXT_LEFT)) + + if (but->editstr || (but->flag & UI_TEXT_LEFT)) rect->xmin += 5; } - else if ((but->flag & UI_TEXT_LEFT)) + else if ((but->flag & UI_TEXT_LEFT)) rect->xmin += 5; - + /* always draw text for textbutton cursor */ widget_draw_text(fstyle, wcol, but, rect); @@ -1761,8 +1809,8 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float float quad_strip[WIDGET_SIZE_MAX * 2][2]; /* prevent tooltips to not show round shadow */ - if (2.0f * radout > 0.2f * BLI_RCT_SIZE_Y(&rect1)) - rect1.ymax -= 0.2f * BLI_RCT_SIZE_Y(&rect1); + if (2.0f * radout > 0.2f * BLI_rcti_size_y(&rect1)) + rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1); else rect1.ymax -= 2.0f * radout; @@ -1844,14 +1892,14 @@ static void ui_hsv_cursor(float x, float y) void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my) { /* duplication of code... well, simple is better now */ - float centx = BLI_RCT_CENTER_X_FL(rect); - float centy = BLI_RCT_CENTER_Y_FL(rect); + float centx = BLI_rcti_cent_x_fl(rect); + float centy = BLI_rcti_cent_y_fl(rect); float radius, dist; - if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)) - radius = (float)BLI_RCT_SIZE_Y(rect) / 2; + if (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)) + radius = (float)BLI_rcti_size_y(rect) / 2; else - radius = (float)BLI_RCT_SIZE_X(rect) / 2; + radius = (float)BLI_rcti_size_x(rect) / 2; mx -= centx; my -= centy; @@ -1874,30 +1922,33 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) int color_profile = but->block->color_profile; if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = BLI_PR_NONE; + color_profile = FALSE; radstep = 2.0f * (float)M_PI / (float)tot; - centx = BLI_RCT_CENTER_X_FL(rect); - centy = BLI_RCT_CENTER_Y_FL(rect); + centx = BLI_rcti_cent_x_fl(rect); + centy = BLI_rcti_cent_y_fl(rect); - if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)) - radius = (float)BLI_RCT_SIZE_Y(rect) / 2; + if (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)) + radius = (float)BLI_rcti_size_y(rect) / 2; else - radius = (float)BLI_RCT_SIZE_X(rect) / 2; + radius = (float)BLI_rcti_size_x(rect) / 2; /* color */ ui_get_but_vectorf(but, rgb); - copy_v3_v3(hsv, ui_block_hsv_get(but->block)); + /* copy_v3_v3(hsv, ui_block_hsv_get(but->block)); */ /* UNUSED */ + + rgb_to_hsv_compat_v(rgb, hsvo); + + if (color_profile) + ui_block_to_display_space_v3(but->block, rgb); + rgb_to_hsv_compat_v(rgb, hsv); - copy_v3_v3(hsvo, hsv); /* exception: if 'lock' is set * lock the value of the color wheel to 1. * Useful for color correction tools where you're only interested in hue. */ if (but->flag & UI_BUT_COLOR_LOCK) hsv[2] = 1.f; - else if (color_profile) - hsv[2] = linearrgb_to_srgb(hsv[2]); hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent + 1, colcent + 2); @@ -2059,10 +2110,10 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa } /* rect */ - sx1 = rect->xmin + dx * BLI_RCT_SIZE_X(rect); - sx2 = rect->xmin + (dx + color_step) * BLI_RCT_SIZE_X(rect); + sx1 = rect->xmin + dx * BLI_rcti_size_x(rect); + sx2 = rect->xmin + (dx + color_step) * BLI_rcti_size_x(rect); sy = rect->ymin; - dy = BLI_RCT_SIZE_Y(rect) / 3.0; + dy = BLI_rcti_size_y(rect) / 3.0; glBegin(GL_QUADS); for (a = 0; a < 3; a++, sy += dy) { @@ -2117,8 +2168,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) } /* cursor */ - x = rect->xmin + x * BLI_RCT_SIZE_X(rect); - y = rect->ymin + y * BLI_RCT_SIZE_Y(rect); + x = rect->xmin + x * BLI_rcti_size_x(rect); + y = rect->ymin + y * BLI_rcti_size_y(rect); CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); @@ -2133,21 +2184,22 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) { uiWidgetBase wtb; - float rad = 0.5f * BLI_RCT_SIZE_X(rect); + float rad = 0.5f * BLI_rcti_size_x(rect); float x, y; float rgb[3], hsv[3], v, range; int color_profile = but->block->color_profile; if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = BLI_PR_NONE; + color_profile = FALSE; ui_get_but_vectorf(but, rgb); + + if (color_profile) + ui_block_to_display_space_v3(but->block, rgb); + rgb_to_hsv_v(rgb, hsv); v = hsv[2]; - if (color_profile) - v = linearrgb_to_srgb(v); - /* map v from property range to [0,1] */ range = but->softmax - but->softmin; v = (v - but->softmin) / range; @@ -2167,8 +2219,8 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) widgetbase_draw(&wtb, &wcol_tmp); /* cursor */ - x = rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect); - y = rect->ymin + v * BLI_RCT_SIZE_Y(rect); + x = rect->xmin + 0.5f * BLI_rcti_size_x(rect); + y = rect->ymin + v * BLI_rcti_size_y(rect); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); ui_hsv_cursor(x, y); @@ -2179,7 +2231,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) /* ************ separator, for menus etc ***************** */ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol) { - int y = rect->ymin + BLI_RCT_SIZE_Y(rect) / 2 - 1; + int y = rect->ymin + BLI_rcti_size_y(rect) / 2 - 1; unsigned char col[4]; col[0] = wcol->text[0]; @@ -2198,7 +2250,7 @@ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol) static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb; - float rad = 0.5f * BLI_RCT_SIZE_Y(rect); + float rad = 0.5f * BLI_rcti_size_y(rect); float textofs = rad * 0.75f; if (state & UI_SELECT) @@ -2279,12 +2331,12 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat widget_init(&wtb); /* determine horizontal/vertical */ - horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)); + horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)); if (horizontal) - rad = 0.5f * BLI_RCT_SIZE_Y(rect); + rad = 0.5f * BLI_rcti_size_y(rect); else - rad = 0.5f * BLI_RCT_SIZE_X(rect); + rad = 0.5f * BLI_rcti_size_x(rect); wtb.shadedir = (horizontal) ? 1 : 0; @@ -2296,7 +2348,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat widgetbase_draw(&wtb, wcol); /* slider */ - if ((BLI_RCT_SIZE_X(slider) < 2) || (BLI_RCT_SIZE_Y(slider) < 2)) { + if ((BLI_rcti_size_x(slider) < 2) || (BLI_rcti_size_y(slider) < 2)) { /* pass */ } else { @@ -2362,17 +2414,17 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat rect1 = *rect; /* determine horizontal/vertical */ - horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)); + horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)); if (horizontal) { - fac = BLI_RCT_SIZE_X(rect) / size; + fac = BLI_rcti_size_x(rect) / size; rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin)); rect1.xmax = rect1.xmin + ceilf(fac * (but->a1 - but->softmin)); /* ensure minimium size */ - min = BLI_RCT_SIZE_Y(rect); + min = BLI_rcti_size_y(rect); - if (BLI_RCT_SIZE_X(&rect1) < min) { + if (BLI_rcti_size_x(&rect1) < min) { rect1.xmax = rect1.xmin + min; if (rect1.xmax > rect->xmax) { @@ -2382,14 +2434,14 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } } else { - fac = BLI_RCT_SIZE_Y(rect) / size; + fac = BLI_rcti_size_y(rect) / size; rect1.ymax = rect1.ymax - ceilf(fac * ((float)value - but->softmin)); rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin)); /* ensure minimium size */ - min = BLI_RCT_SIZE_X(rect); + min = BLI_rcti_size_x(rect); - if (BLI_RCT_SIZE_Y(&rect1) < min) { + if (BLI_rcti_size_y(&rect1) < min) { rect1.ymax = rect1.ymin + min; if (rect1.ymax > rect->ymax) { @@ -2417,10 +2469,10 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int rect_prog.ymax = rect_prog.ymin + 4; rect_bar.ymax = rect_bar.ymin + 4; - w = value * BLI_RCT_SIZE_X(&rect_prog); + w = value * BLI_rcti_size_x(&rect_prog); /* ensure minimium size */ - min = BLI_RCT_SIZE_Y(&rect_prog); + min = BLI_rcti_size_y(&rect_prog); w = MAX2(w, min); rect_bar.xmax = rect_bar.xmin + w; @@ -2440,8 +2492,8 @@ static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, in UI_ThemeColor(TH_TEXT_HI); - rectlink.xmin = BLI_RCT_CENTER_X(rect); - rectlink.ymin = BLI_RCT_CENTER_Y(rect); + rectlink.xmin = BLI_rcti_cent_x(rect); + rectlink.ymin = BLI_rcti_cent_y(rect); rectlink.xmax = but->linkto[0]; rectlink.ymax = but->linkto[1]; @@ -2463,7 +2515,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s /* backdrop first */ /* fully rounded */ - offs = 0.5f * BLI_RCT_SIZE_Y(rect); + offs = 0.5f * BLI_rcti_size_y(rect); toffs = offs * 0.75f; round_box_edges(&wtb, roundboxalign, rect, offs); @@ -2484,7 +2536,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s rect1 = *rect; value = ui_get_but_val(but); - fac = ((float)value - but->softmin) * (BLI_RCT_SIZE_X(&rect1) - offs) / (but->softmax - but->softmin); + fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin); /* left part of slider, always rounded */ rect1.xmax = rect1.xmin + ceil(offs + 1.0f); @@ -2531,7 +2583,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat if (but->rnaprop) { if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = BLI_PR_NONE; + color_profile = FALSE; if (RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) { col[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3); @@ -2559,7 +2611,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } if (color_profile) - linearrgb_to_srgb_v3_v3(col, col); + ui_block_to_display_space_v3(but->block, col); rgba_float_to_uchar((unsigned char *)wcol->inner, col); @@ -2617,7 +2669,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), widgetbase_draw(&wtb, wcol); /* text space */ - rect->xmax -= BLI_RCT_SIZE_Y(rect); + rect->xmax -= BLI_rcti_size_y(rect); } static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) @@ -2660,7 +2712,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int { if (state & UI_ACTIVE) { uiWidgetBase wtb; - float rad = 0.5f * BLI_RCT_SIZE_Y(rect); /* 4.0f */ + float rad = 0.5f * BLI_rcti_size_y(rect); /* 4.0f */ widget_init(&wtb); @@ -2706,10 +2758,10 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widget_init(&wtb); /* square */ - recttemp.xmax = recttemp.xmin + BLI_RCT_SIZE_Y(&recttemp); + recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp); /* smaller */ - delta = 1 + BLI_RCT_SIZE_Y(&recttemp) / 8; + delta = 1 + BLI_rcti_size_y(&recttemp) / 8; recttemp.xmin += delta; recttemp.ymin += delta; recttemp.xmax -= delta; @@ -2726,7 +2778,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widgetbase_draw(&wtb, wcol); /* text space */ - rect->xmin += BLI_RCT_SIZE_Y(rect) * 0.7 + delta; + rect->xmin += BLI_rcti_size_y(rect) * 0.7 + delta; } @@ -2788,7 +2840,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) { uiWidgetBase wtb; - float rad = 5.0f; /* 0.5f * BLI_RCT_SIZE_Y(rect); */ + float rad = 5.0f; /* 0.5f * BLI_rcti_size_y(rect); */ widget_init(&wtb); @@ -3271,12 +3323,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) if (block->flag & UI_BLOCK_CLIPTOP) { /* XXX no scaling for UI here yet */ glColor3ubv((unsigned char *)wt->wcol.text); - UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymax - 8, 't'); + UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymax - 8, 't'); } if (block->flag & UI_BLOCK_CLIPBOTTOM) { /* XXX no scaling for UI here yet */ glColor3ubv((unsigned char *)wt->wcol.text); - UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymin + 10, 'v'); + UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v'); } } } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 0f1d1a24dcb..47bee92be62 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -96,11 +96,11 @@ static void view2d_masks(View2D *v2d) /* check size if: */ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)) - if (BLI_RCT_SIZE_X(&v2d->tot) <= BLI_RCT_SIZE_X(&v2d->cur)) + if (BLI_rctf_size_x(&v2d->tot) <= BLI_rcti_size_x(&v2d->cur)) v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; if (v2d->scroll & V2D_SCROLL_VERTICAL) if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)) - if (BLI_RCT_SIZE_Y(&v2d->tot) <= BLI_RCT_SIZE_Y(&v2d->cur)) + if (BLI_rctf_size_y(&v2d->tot) <= BLI_rctf_size_y(&v2d->cur)) v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE; #endif scroll = view2d_scroll_mapped(v2d->scroll); @@ -328,8 +328,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) rctf *cur, *tot; /* use mask as size of region that View2D resides in, as it takes into account scrollbars already */ - winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); - winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1); + winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1); + winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1); /* get pointers to rcts for less typing */ cur = &v2d->cur; @@ -347,10 +347,10 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) * - firstly, we calculate the sizes of the rects * - curwidth and curheight are saved as reference... modify width and height values here */ - totwidth = BLI_RCT_SIZE_X(tot); - totheight = BLI_RCT_SIZE_Y(tot); - curwidth = width = BLI_RCT_SIZE_X(cur); - curheight = height = BLI_RCT_SIZE_Y(cur); + totwidth = BLI_rctf_size_x(tot); + totheight = BLI_rctf_size_y(tot); + curwidth = width = BLI_rctf_size_x(cur); + curheight = height = BLI_rctf_size_y(cur); /* if zoom is locked, size on the appropriate axis is reset to mask size */ if (v2d->keepzoom & V2D_LOCKZOOM_X) @@ -499,16 +499,16 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) /* resize from centerpoint, unless otherwise specified */ if (width != curwidth) { if (v2d->keepofs & V2D_LOCKOFS_X) { - cur->xmax += width - BLI_RCT_SIZE_X(cur); + cur->xmax += width - BLI_rctf_size_x(cur); } else if (v2d->keepofs & V2D_KEEPOFS_X) { if (v2d->align & V2D_ALIGN_NO_POS_X) - cur->xmin -= width - BLI_RCT_SIZE_X(cur); + cur->xmin -= width - BLI_rctf_size_x(cur); else - cur->xmax += width - BLI_RCT_SIZE_X(cur); + cur->xmax += width - BLI_rctf_size_x(cur); } else { - temp = BLI_RCT_CENTER_X(cur); + temp = BLI_rctf_cent_x(cur); dh = width * 0.5f; cur->xmin = temp - dh; @@ -517,16 +517,16 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) } if (height != curheight) { if (v2d->keepofs & V2D_LOCKOFS_Y) { - cur->ymax += height - BLI_RCT_SIZE_Y(cur); + cur->ymax += height - BLI_rctf_size_y(cur); } else if (v2d->keepofs & V2D_KEEPOFS_Y) { if (v2d->align & V2D_ALIGN_NO_POS_Y) - cur->ymin -= height - BLI_RCT_SIZE_Y(cur); + cur->ymin -= height - BLI_rctf_size_y(cur); else - cur->ymax += height - BLI_RCT_SIZE_Y(cur); + cur->ymax += height - BLI_rctf_size_y(cur); } else { - temp = BLI_RCT_CENTER_Y(cur); + temp = BLI_rctf_cent_y(cur); dh = height * 0.5f; cur->ymin = temp - dh; @@ -540,8 +540,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) float temp, diff; /* recalculate extents of cur */ - curwidth = BLI_RCT_SIZE_X(cur); - curheight = BLI_RCT_SIZE_Y(cur); + curwidth = BLI_rctf_size_x(cur); + curheight = BLI_rctf_size_y(cur); /* width */ if ((curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM))) { @@ -592,7 +592,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) */ if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) { /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */ - temp = BLI_RCT_CENTER_X(tot); + temp = BLI_rctf_cent_x(tot); diff = curheight * 0.5f; cur->xmin = temp - diff; @@ -642,7 +642,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) */ if ((cur->ymin < tot->ymin) && (cur->ymax > tot->ymax)) { /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */ - temp = BLI_RCT_CENTER_Y(tot); + temp = BLI_rctf_cent_y(tot); diff = curheight * 0.5f; cur->ymin = temp - diff; @@ -791,8 +791,8 @@ void UI_view2d_curRect_reset(View2D *v2d) float width, height; /* assume width and height of 'cur' rect by default, should be same size as mask */ - width = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); - height = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1); + width = (float)(BLI_rcti_size_x(&v2d->mask) + 1); + height = (float)(BLI_rcti_size_y(&v2d->mask) + 1); /* handle width - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { @@ -851,7 +851,7 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, int resize if (scroll & V2D_SCROLL_VERTICAL) height -= V2D_SCROLL_HEIGHT; - if (ELEM3(0, v2d, width, height)) { + if (ELEM(0, width, height)) { if (G.debug & G_DEBUG) printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n", (void *)v2d, width, height); // XXX temp debug info return; @@ -958,8 +958,8 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) *curmasked = v2d->cur; if (view2d_scroll_mapped(v2d->scroll)) { - float dx = BLI_RCT_SIZE_X(&v2d->cur) / ((float)(BLI_RCT_SIZE_X(&v2d->mask) + 1)); - float dy = BLI_RCT_SIZE_Y(&v2d->cur) / ((float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1)); + float dx = BLI_rctf_size_x(&v2d->cur) / ((float)(BLI_rcti_size_x(&v2d->mask) + 1)); + float dy = BLI_rctf_size_y(&v2d->cur) / ((float)(BLI_rcti_size_y(&v2d->mask) + 1)); if (v2d->mask.xmin != 0) curmasked->xmin -= dx * (float)v2d->mask.xmin; @@ -985,14 +985,13 @@ void UI_view2d_view_ortho(View2D *v2d) */ /* XXX brecht: instead of zero at least use a tiny offset, otherwise * pixel rounding is effectively random due to float inaccuracy */ - xofs = 0.001f * BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); - yofs = 0.001f * BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask); + xofs = 0.001f * BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); + yofs = 0.001f * BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */ view2d_map_cur_using_mask(v2d, &curmasked); - - curmasked.xmin -= xofs; curmasked.xmax -= xofs; - curmasked.ymin -= yofs; curmasked.ymax -= yofs; + + BLI_rctf_translate(&curmasked, -xofs, -yofs); /* XXX ton: this flag set by outliner, for icons */ if (v2d->flag & V2D_PIXELOFS_X) { @@ -1044,8 +1043,8 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis) void UI_view2d_view_restore(const bContext *C) { ARegion *ar = CTX_wm_region(C); - int width = BLI_RCT_SIZE_X(&ar->winrct) + 1; - int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + int width = BLI_rcti_size_x(&ar->winrct) + 1; + int height = BLI_rcti_size_y(&ar->winrct) + 1; wmOrtho2(0.0f, (float)width, 0.0f, (float)height); glLoadIdentity(); @@ -1117,7 +1116,8 @@ static void step_to_grid(float *step, int *power, int unit) * - winx = width of region we're drawing to, note: not used but keeping for completeness. * - winy = height of region we're drawing into */ -View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int UNUSED(winx), int winy) +View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, + short xunits, short xclamp, short yunits, short yclamp, int UNUSED(winx), int winy) { View2DGrid *grid; @@ -1140,8 +1140,8 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x /* calculate x-axis grid scale (only if both args are valid) */ if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) { - space = BLI_RCT_SIZE_X(&v2d->cur); - pixels = (float)BLI_RCT_SIZE_X(&v2d->mask); + space = BLI_rctf_size_x(&v2d->cur); + pixels = (float)BLI_rcti_size_x(&v2d->mask); if (pixels != 0.0f) { grid->dx = (U.v2d_min_gridsize * space) / (seconddiv * pixels); @@ -1158,7 +1158,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x /* calculate y-axis grid scale (only if both args are valid) */ if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) { - space = BLI_RCT_SIZE_Y(&v2d->cur); + space = BLI_rctf_size_y(&v2d->cur); pixels = (float)winy; grid->dy = U.v2d_min_gridsize * space / pixels; @@ -1206,7 +1206,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vec2[1] = v2d->cur.ymax; /* minor gridlines */ - step = (BLI_RCT_SIZE_X(&v2d->mask) + 1) / U.v2d_min_gridsize; + step = (BLI_rcti_size_x(&v2d->mask) + 1) / U.v2d_min_gridsize; UI_ThemeColor(TH_GRID); for (a = 0; a < step; a++) { @@ -1240,7 +1240,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vec1[0] = grid->startx; vec2[0] = v2d->cur.xmax; - step = (BLI_RCT_SIZE_Y(&v2d->mask) + 1) / U.v2d_min_gridsize; + step = (BLI_rcti_size_y(&v2d->mask) + 1) / U.v2d_min_gridsize; UI_ThemeColor(TH_GRID); for (a = 0; a <= step; a++) { @@ -1414,7 +1414,8 @@ struct View2DScrollers { }; /* Calculate relevant scroller properties */ -View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp) +View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, + short xunits, short xclamp, short yunits, short yclamp) { View2DScrollers *scrollers; rcti vert, hor; @@ -1457,8 +1458,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* horizontal scrollers */ if (scroll & V2D_SCROLL_HORIZONTAL) { /* scroller 'button' extents */ - totsize = BLI_RCT_SIZE_X(&v2d->tot); - scrollsize = (float)BLI_RCT_SIZE_X(&hor); + totsize = BLI_rctf_size_x(&v2d->tot); + scrollsize = (float)BLI_rcti_size_x(&hor); if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize; @@ -1498,8 +1499,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* vertical scrollers */ if (scroll & V2D_SCROLL_VERTICAL) { /* scroller 'button' extents */ - totsize = BLI_RCT_SIZE_Y(&v2d->tot); - scrollsize = (float)BLI_RCT_SIZE_Y(&vert); + totsize = BLI_rctf_size_y(&v2d->tot); + scrollsize = (float)BLI_rcti_size_y(&vert); if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize; @@ -1547,7 +1548,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, xunits, xclamp, yunits, yclamp, - BLI_RCT_SIZE_X(&hor), BLI_RCT_SIZE_Y(&vert)); + BLI_rcti_size_x(&hor), BLI_rcti_size_y(&vert)); } /* return scrollers */ @@ -1631,7 +1632,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) && - (BLI_RCT_SIZE_X(&slider) > V2D_SCROLLER_HANDLE_SIZE)) + (BLI_rcti_size_x(&slider) > V2D_SCROLLER_HANDLE_SIZE)) { state |= UI_SCROLL_ARROWS; } @@ -1651,11 +1652,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v * - fac is x-coordinate to draw to * - dfac is gap between scale markings */ - fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); - fac = (float)hor.xmin + fac * BLI_RCT_SIZE_X(&hor); + fac = (grid->startx - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); + fac = (float)hor.xmin + fac * BLI_rcti_size_x(&hor); - dfac = grid->dx / BLI_RCT_SIZE_X(&v2d->cur); - dfac = dfac * BLI_RCT_SIZE_X(&hor); + dfac = grid->dx / BLI_rctf_size_x(&v2d->cur); + dfac = dfac * BLI_rcti_size_x(&hor); /* set starting value, and text color */ UI_ThemeColor(TH_TEXT); @@ -1742,7 +1743,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v */ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) && - (BLI_RCT_SIZE_Y(&slider) > V2D_SCROLLER_HANDLE_SIZE)) + (BLI_rcti_size_y(&slider) > V2D_SCROLLER_HANDLE_SIZE)) { state |= UI_SCROLL_ARROWS; } @@ -1765,11 +1766,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v * - these involve a correction for horizontal scrollbar * NOTE: it's assumed that that scrollbar is there if this is involved! */ - fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); - fac = vert.ymin + fac * BLI_RCT_SIZE_Y(&vert); + fac = (grid->starty - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); + fac = vert.ymin + fac * BLI_rcti_size_y(&vert); - dfac = grid->dy / BLI_RCT_SIZE_Y(&v2d->cur); - dfac = dfac * BLI_RCT_SIZE_Y(&vert); + dfac = grid->dy / BLI_rctf_size_y(&v2d->cur); + dfac = dfac * BLI_rcti_size_y(&vert); /* set starting value, and text color */ UI_ThemeColor(TH_TEXT); @@ -1823,7 +1824,9 @@ void UI_view2d_scrollers_free(View2DScrollers *scrollers) * - column, row = the 2d-coordinates (in 2D-view / 'tot' rect space) the cell exists at * - rect = coordinates of the cell (passed as single var instead of 4 separate, as it's more useful this way) */ -void UI_view2d_listview_cell_to_view(View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, rctf *rect) +void UI_view2d_listview_cell_to_view(View2D *v2d, short columnwidth, short rowheight, + float startx, float starty, + int column, int row, rctf *rect) { /* sanity checks */ if (ELEM(NULL, v2d, rect)) { @@ -1927,17 +1930,17 @@ void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *r_viewx, float * float div, ofs; if (r_viewx) { - div = (float)BLI_RCT_SIZE_X(&v2d->mask); + div = (float)BLI_rcti_size_x(&v2d->mask); ofs = (float)v2d->mask.xmin; - *r_viewx = v2d->cur.xmin + BLI_RCT_SIZE_X(&v2d->cur) * ((float)x - ofs) / div; + *r_viewx = v2d->cur.xmin + BLI_rctf_size_x(&v2d->cur) * ((float)x - ofs) / div; } if (r_viewy) { - div = (float)BLI_RCT_SIZE_Y(&v2d->mask); + div = (float)BLI_rcti_size_y(&v2d->mask); ofs = (float)v2d->mask.ymin; - *r_viewy = v2d->cur.ymin + BLI_RCT_SIZE_Y(&v2d->cur) * ((float)y - ofs) / div; + *r_viewy = v2d->cur.ymin + BLI_rctf_size_y(&v2d->cur) * ((float)y - ofs) / div; } } @@ -1956,15 +1959,15 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int * *regiony = V2D_IS_CLIPPED; /* express given coordinates as proportional values */ - x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); - y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); + x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); + y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); /* check if values are within bounds */ if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) { if (regionx) - *regionx = (int)(v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask)); + *regionx = (int)(v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask)); if (regiony) - *regiony = (int)(v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask)); + *regiony = (int)(v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask)); } } @@ -1977,12 +1980,12 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int * void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, int *regiony) { /* step 1: express given coordinates as proportional values */ - x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); - y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); + x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); + y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); /* step 2: convert proportional distances to screen coordinates */ - x = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask); - y = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask); + x = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask); + y = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask); /* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */ if (regionx) { @@ -2035,8 +2038,8 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C) */ void UI_view2d_getscale(View2D *v2d, float *x, float *y) { - if (x) *x = BLI_RCT_SIZE_X(&v2d->mask) / BLI_RCT_SIZE_X(&v2d->cur); - if (y) *y = BLI_RCT_SIZE_Y(&v2d->mask) / BLI_RCT_SIZE_Y(&v2d->cur); + if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur); + if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur); } /* Check if mouse is within scrollers @@ -2142,7 +2145,7 @@ void UI_view2d_text_cache_draw(ARegion *ar) const char *str = (const char *)(v2s + 1); int xofs = 0, yofs; - yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(&v2s->rect) - default_height)); + yofs = ceil(0.5f * (BLI_rcti_size_y(&v2s->rect) - default_height)); if (yofs < 1) yofs = 1; if (col_pack_prev != v2s->col.pack) { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 99313edc289..3d3f309a8d4 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -119,10 +119,10 @@ static int view_pan_init(bContext *C, wmOperator *op) vpd->ar = ar; /* calculate translation factor - based on size of view */ - winx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1); - winy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1); - vpd->facx = (BLI_RCT_SIZE_X(&v2d->cur)) / winx; - vpd->facy = (BLI_RCT_SIZE_Y(&v2d->cur)) / winy; + winx = (float)(BLI_rcti_size_x(&ar->winrct) + 1); + winy = (float)(BLI_rcti_size_y(&ar->winrct) + 1); + vpd->facx = (BLI_rctf_size_x(&v2d->cur)) / winx; + vpd->facy = (BLI_rctf_size_y(&v2d->cur)) / winy; return 1; } @@ -471,7 +471,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "page")) { ARegion *ar = CTX_wm_region(C); - RNA_int_set(op->ptr, "deltay", BLI_RCT_SIZE_Y(&ar->v2d.mask)); + RNA_int_set(op->ptr, "deltay", BLI_rcti_size_y(&ar->v2d.mask)); } /* apply movement, then we're done */ @@ -590,12 +590,12 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) facy = RNA_float_get(op->ptr, "zoomfacy"); if (facx >= 0.0f) { - dx = BLI_RCT_SIZE_X(&v2d->cur) * facx; - dy = BLI_RCT_SIZE_Y(&v2d->cur) * facy; + dx = BLI_rctf_size_x(&v2d->cur) * facx; + dy = BLI_rctf_size_y(&v2d->cur) * facy; } else { - dx = (BLI_RCT_SIZE_X(&v2d->cur) / (1.0f + 2.0f * facx)) * facx; - dy = (BLI_RCT_SIZE_Y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy; + dx = (BLI_rctf_size_x(&v2d->cur) / (1.0f + 2.0f * facx)) * facx; + dy = (BLI_rctf_size_y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy; } /* only resize view on an axis if change is allowed */ @@ -611,7 +611,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) } else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { - float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); + float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dx) - (mval_faci * dx); @@ -636,7 +636,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) } else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { - float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); + float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dy) - (mval_faci * dy); @@ -845,7 +845,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) } else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { - float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); + float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dx) - (mval_faci * dx); @@ -864,7 +864,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) } else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { - float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); + float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dy) - (mval_faci * dy); @@ -942,8 +942,8 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) * with magnify information that is stored in x axis */ fac = 0.01f * (event->x - event->prevx); - dx = fac * BLI_RCT_SIZE_X(&v2d->cur) / 10.0f; - dy = fac * BLI_RCT_SIZE_Y(&v2d->cur) / 10.0f; + dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f; + dy = fac * BLI_rctf_size_y(&v2d->cur) / 10.0f; RNA_float_set(op->ptr, "deltax", dx); RNA_float_set(op->ptr, "deltay", dy); @@ -1009,14 +1009,14 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) float dist; /* x-axis transform */ - dist = BLI_RCT_SIZE_X(&v2d->mask) / 2.0f; + dist = BLI_rcti_size_x(&v2d->mask) / 2.0f; dx = 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f); - dx *= 0.5f * BLI_RCT_SIZE_X(&v2d->cur); + dx *= 0.5f * BLI_rctf_size_x(&v2d->cur); /* y-axis transform */ - dist = BLI_RCT_SIZE_Y(&v2d->mask) / 2.0f; + dist = BLI_rcti_size_y(&v2d->mask) / 2.0f; dy = 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f); - dy *= 0.5f * BLI_RCT_SIZE_Y(&v2d->cur); + dy *= 0.5f * BLI_rctf_size_y(&v2d->cur); } else { /* 'continuous' or 'dolly' */ @@ -1024,11 +1024,11 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* x-axis transform */ fac = 0.01f * (event->x - vzd->lastx); - dx = fac * BLI_RCT_SIZE_X(&v2d->cur); + dx = fac * BLI_rctf_size_x(&v2d->cur); /* y-axis transform */ fac = 0.01f * (event->y - vzd->lasty); - dy = fac * BLI_RCT_SIZE_Y(&v2d->cur); + dy = fac * BLI_rctf_size_y(&v2d->cur); #if 0 /* continuous zoom shouldn't move that fast... */ if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop? @@ -1161,17 +1161,17 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) /* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { - size = BLI_RCT_SIZE_X(&cur_new); - zoom = size / BLI_RCT_SIZE_X(&rect); - center = BLI_RCT_CENTER_X(&cur_new); + size = BLI_rctf_size_x(&cur_new); + zoom = size / BLI_rctf_size_x(&rect); + center = BLI_rctf_cent_x(&cur_new); cur_new.xmin = center - (size * zoom); cur_new.xmax = center + (size * zoom); } if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { - size = BLI_RCT_SIZE_Y(&cur_new); - zoom = size / BLI_RCT_SIZE_Y(&rect); - center = BLI_RCT_CENTER_Y(&cur_new); + size = BLI_rctf_size_y(&cur_new); + zoom = size / BLI_rctf_size_y(&rect); + center = BLI_rctf_cent_y(&cur_new); cur_new.ymin = center - (size * zoom); cur_new.ymax = center + (size * zoom); @@ -1221,14 +1221,14 @@ struct SmoothView2DStore { */ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) { - float size_a[2] = {BLI_RCT_SIZE_X(rect_a), - BLI_RCT_SIZE_Y(rect_a)}; - float size_b[2] = {BLI_RCT_SIZE_X(rect_b), - BLI_RCT_SIZE_Y(rect_b)}; - float cent_a[2] = {BLI_RCT_CENTER_X(rect_a), - BLI_RCT_CENTER_Y(rect_a)}; - float cent_b[2] = {BLI_RCT_CENTER_X(rect_b), - BLI_RCT_CENTER_Y(rect_b)}; + float size_a[2] = {BLI_rctf_size_x(rect_a), + BLI_rctf_size_y(rect_a)}; + float size_b[2] = {BLI_rctf_size_x(rect_b), + BLI_rctf_size_y(rect_b)}; + float cent_a[2] = {BLI_rctf_cent_x(rect_a), + BLI_rctf_cent_y(rect_a)}; + float cent_b[2] = {BLI_rctf_cent_x(rect_b), + BLI_rctf_cent_y(rect_b)}; float fac_max = 0.0f; float tfac; @@ -1501,8 +1501,8 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, if (in_scroller == 'h') { /* horizontal scroller - calculate adjustment factor first */ - mask_size = (float)BLI_RCT_SIZE_X(&v2d->hor); - vsm->fac = BLI_RCT_SIZE_X(&v2d->tot) / mask_size; + mask_size = (float)BLI_rcti_size_x(&v2d->hor); + vsm->fac = BLI_rctf_size_x(&v2d->tot) / mask_size; /* get 'zone' (i.e. which part of scroller is activated) */ vsm->zone = mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max); @@ -1517,8 +1517,8 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, } else { /* vertical scroller - calculate adjustment factor first */ - mask_size = (float)BLI_RCT_SIZE_Y(&v2d->vert); - vsm->fac = BLI_RCT_SIZE_Y(&v2d->tot) / mask_size; + mask_size = (float)BLI_rcti_size_y(&v2d->vert); + vsm->fac = BLI_rctf_size_y(&v2d->tot) / mask_size; /* get 'zone' (i.e. which part of scroller is activated) */ vsm->zone = mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max); @@ -1798,8 +1798,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op)) int winx, winy; /* zoom 1.0 */ - winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); - winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1); + winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1); + winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1); v2d->cur.xmax = v2d->cur.xmin + winx; v2d->cur.ymax = v2d->cur.ymin + winy; diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 0e6b8f77528..0ec99325752 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -54,6 +54,8 @@ #include "../../collada/collada.h" +#include "io_collada.h" + static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { @@ -121,32 +123,32 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) /* get editmode results */ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - if (collada_export( - CTX_data_scene(C), - filepath, - apply_modifiers, - export_mesh_type, - selected, - include_children, - include_armatures, - deform_bones_only, - - active_uv_only, - include_uv_textures, - include_material_textures, - use_texture_copies, - - use_object_instantiation, - sort_by_name, - second_life)) { + if (collada_export(CTX_data_scene(C), + filepath, + apply_modifiers, + export_mesh_type, + selected, + include_children, + include_armatures, + deform_bones_only, + + active_uv_only, + include_uv_textures, + include_material_textures, + use_texture_copies, + + use_object_instantiation, + sort_by_name, + second_life)) { return OPERATOR_FINISHED; } else { + BKE_report(op->reports, RPT_WARNING, "Export file not created."); return OPERATOR_CANCELLED; } } -void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) +static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) { uiLayout *box, *row, *col, *split; @@ -233,7 +235,7 @@ void WM_OT_collada_export(wmOperatorType *ot) ot->name = "Export COLLADA"; ot->description = "Save a Collada file"; ot->idname = "WM_OT_collada_export"; - + ot->invoke = wm_collada_export_invoke; ot->exec = wm_collada_export_exec; ot->poll = WM_operator_winactive; @@ -241,7 +243,7 @@ void WM_OT_collada_export(wmOperatorType *ot) ot->flag |= OPTYPE_PRESET; ot->ui = wm_collada_export_draw; - + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); @@ -296,7 +298,7 @@ void WM_OT_collada_export(wmOperatorType *ot) static int wm_collada_import_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; - + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; @@ -304,9 +306,9 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", filename); if (collada_import(C, filename)) return OPERATOR_FINISHED; - + BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log."); - + return OPERATOR_FINISHED; } @@ -315,11 +317,11 @@ void WM_OT_collada_import(wmOperatorType *ot) ot->name = "Import COLLADA"; ot->description = "Load a Collada file"; ot->idname = "WM_OT_collada_import"; - + ot->invoke = WM_operator_filesel; ot->exec = wm_collada_import_exec; ot->poll = WM_operator_winactive; - + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); } diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c index d2b0ddd4e7e..f2a0532932d 100644 --- a/source/blender/editors/io/io_ops.c +++ b/source/blender/editors/io/io_ops.c @@ -34,6 +34,8 @@ #include "WM_types.h" #include "WM_api.h" +#include "io_ops.h" /* own include */ + void ED_operatortypes_io(void) { #ifdef WITH_COLLADA diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 7fe1ac09df6..a254a6a9278 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -64,7 +64,7 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no MaskLayer *masklay, *point_masklay; MaskSpline *point_spline; MaskSplinePoint *point = NULL; - float dist, co[2]; + float dist = FLT_MAX, co[2]; int width, height; float u; float scalex, scaley; @@ -125,7 +125,7 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no cur_dist = dist_to_line_segment_v2(co, a, b); - if (point == NULL || cur_dist < dist) { + if (cur_dist < dist) { if (tangent) sub_v2_v2v2(tangent, &diff_points[2 * i + 2], &diff_points[2 * i]); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 655458bd4cb..fe6567424b6 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -520,12 +520,12 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - /* w = BLI_RCT_SIZE_X(&v2d->tot); */ - /* h = BLI_RCT_SIZE_Y(&v2d->tot);/*/ + /* w = BLI_rctf_size_x(&v2d->tot); */ + /* h = BLI_rctf_size_y(&v2d->tot);/*/ - zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur)); - zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur)); + zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / BLI_rctf_size_x(&ar->v2d.cur); + zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / BLI_rctf_size_y(&ar->v2d.cur); if (do_scale_applied) { zoomx /= width; diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 6124947e3b9..561ad004a1d 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -48,6 +48,7 @@ #include "ED_anim_api.h" #include "ED_keyframes_edit.h" +#include "ED_mask.h" /* own include */ /* ***************************************** */ /* NOTE ABOUT THIS FILE: diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 94e10b53b29..a677f1272a3 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -533,8 +533,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) unsigned int *rt; char *selar; int a, index; - int sx = BLI_RCT_SIZE_X(rect) + 1; - int sy = BLI_RCT_SIZE_Y(rect) + 1; + int sx = BLI_rcti_size_x(rect) + 1; + int sy = BLI_rcti_size_y(rect) + 1; me = BKE_mesh_from_object(ob); diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 8b032bb1a3d..fdaddec5246 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -55,9 +55,9 @@ /* ********* add primitive operators ************* */ -static void make_prim_init(bContext *C, const char *idname, - float *dia, float mat[][4], - int *state, const float loc[3], const float rot[3], const unsigned int layer) +static Object *make_prim_init(bContext *C, const char *idname, + float *dia, float mat[][4], + int *state, const float loc[3], const float rot[3], const unsigned int layer) { Object *obedit = CTX_data_edit_object(C); @@ -74,11 +74,12 @@ static void make_prim_init(bContext *C, const char *idname, } *dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); + + return obedit; } -static void make_prim_finish(bContext *C, int *state, int enter_editmode) +static void make_prim_finish(bContext *C, Object *obedit, int *state, int enter_editmode) { - Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); /* Primitive has all verts selected, use vert select flush @@ -104,9 +105,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "vertout", @@ -115,7 +114,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } @@ -148,9 +147,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_cube mat=%m4 size=%f", mat, dia * 2.0f)) { @@ -158,7 +155,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) } /* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */ - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } @@ -200,9 +197,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) cap_tri = (cap_end == 2); ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "vertout", @@ -213,7 +208,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } @@ -257,9 +252,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) cap_tri = (cap_end == 2); ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( @@ -274,7 +267,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } @@ -320,9 +313,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) cap_tri = (cap_end == 2); ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( @@ -334,7 +325,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } @@ -379,9 +370,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "vertout", @@ -393,7 +382,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } @@ -436,16 +425,14 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) if (!view_aligned) rot[0] += (float)M_PI / 2.0f; - make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_monkey mat=%m4", mat)) { return OPERATOR_CANCELLED; } - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } @@ -477,9 +464,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "vertout", @@ -490,7 +475,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } @@ -531,9 +516,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer); - - obedit = CTX_data_edit_object(C); + obedit = make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( @@ -545,7 +528,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - make_prim_finish(C, &state, enter_editmode); + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index 0b7d396b696..c249d764ac1 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -309,7 +309,7 @@ static void vertsearchcallback(void *userdata, int index, const float *UNUSED(co } } -BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist) +BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], const float maxdist) { BVHTreeNearest hit; @@ -325,7 +325,7 @@ BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist) float dist, curdist = tree->maxdist, v[3]; int cur = 0, i; - maxdist = tree->maxdist; + /* maxdist = tree->maxdist; */ /* UNUSED */ for (i = 0; i < 3; i++) { sub_v3_v3v3(v, hit.co, ls[i]->v->co); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 7ecfb712c18..1dcbf574b44 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -29,7 +29,9 @@ * \ingroup edmesh */ -#define _USE_MATH_DEFINES +#ifdef _MSC_VER +# define _USE_MATH_DEFINES +#endif #include "MEM_guardedalloc.h" @@ -222,7 +224,7 @@ static void knife_update_header(bContext *C, KnifeTool_OpData *kcd) static void knife_project_v3(KnifeTool_OpData *kcd, const float co[3], float sco[3]) { - ED_view3d_project_float_v3(kcd->ar, co, sco, kcd->projmat); + ED_view3d_project_float_v3_m4(kcd->ar, co, sco, kcd->projmat); } static void knife_pos_data_clear(KnifePosData *kpd) @@ -1203,7 +1205,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, } knife_project_v3(kcd, p, sp); - view3d_unproject(mats, view, sp[0], sp[1], 0.0f); + ED_view3d_unproject(mats, view, sp[0], sp[1], 0.0f); mul_m4_v3(kcd->ob->imat, view); if (kcd->cut_through) { @@ -1386,7 +1388,7 @@ static void knife_input_ray_cast(KnifeTool_OpData *kcd, const int mval_i[2], mval[1] = (float)mval_i[1]; /* unproject to find view ray */ - view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f); + ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f); if (kcd->is_ortho) { negate_v3_v3(r_ray, kcd->vc.rv3d->viewinv[2]); @@ -1753,6 +1755,9 @@ static int knife_update_active(KnifeTool_OpData *kcd) return 1; } +#define SCANFILL_CUTS 0 +#if SCANFILL_CUTS + #define MARK 4 #define DEL 8 #define VERT_ON_EDGE 16 @@ -1761,9 +1766,6 @@ static int knife_update_active(KnifeTool_OpData *kcd) #define BOUNDARY 128 #define FACE_NEW 256 -#define SCANFILL_CUTS 0 -#if SCANFILL_CUTS - typedef struct facenet_entry { struct facenet_entry *next, *prev; KnifeEdge *kfe; diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 60c5244ddbc..8b13cc61d3e 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -29,7 +29,9 @@ */ #include <float.h> -#define _USE_MATH_DEFINES +#ifdef _MSC_VER +# define _USE_MATH_DEFINES +#endif #include <math.h> #include <string.h> #include <ctype.h> diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 4d4a890300f..53b877f2a6e 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -61,8 +61,8 @@ static float edbm_rip_rip_edgedist(ARegion *ar, float mat[][4], { float vec1[3], vec2[3]; - ED_view3d_project_float_v2(ar, co1, vec1, mat); - ED_view3d_project_float_v2(ar, co2, vec2, mat); + ED_view3d_project_float_v2_m4(ar, co1, vec1, mat); + ED_view3d_project_float_v2_m4(ar, co2, vec2, mat); /* TODO: use dist_squared_to_line_segment_v2() looks like we only ever use for comparison */ return dist_to_line_segment_v2(mvalf, vec1, vec2); @@ -97,11 +97,11 @@ static float edbm_rip_edge_side_measure(BMEdge *e, BMLoop *e_l, mid_v3_v3v3(cent, v1_other->co, v2_other->co); mid_v3_v3v3(mid, e->v1->co, e->v2->co); - ED_view3d_project_float_v2(ar, cent, cent, projectMat); - ED_view3d_project_float_v2(ar, mid, mid, projectMat); + ED_view3d_project_float_v2_m4(ar, cent, cent, projectMat); + ED_view3d_project_float_v2_m4(ar, mid, mid, projectMat); - ED_view3d_project_float_v2(ar, e->v1->co, e_v1_co, projectMat); - ED_view3d_project_float_v2(ar, e->v2->co, e_v2_co, projectMat); + ED_view3d_project_float_v2_m4(ar, e->v1->co, e_v1_co, projectMat); + ED_view3d_project_float_v2_m4(ar, e->v2->co, e_v2_co, projectMat); sub_v2_v2v2(vec, cent, mid); normalize_v2(vec); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index de9b3c5ba05..f6ae661a369 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -487,7 +487,6 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int vec[0] = eed->v1->co[0] + labda * (eed->v2->co[0] - eed->v1->co[0]); vec[1] = eed->v1->co[1] + labda * (eed->v2->co[1] - eed->v1->co[1]); vec[2] = eed->v1->co[2] + labda * (eed->v2->co[2] - eed->v1->co[2]); - mul_m4_v3(data->vc.obedit->obmat, vec); if (ED_view3d_clipping_test(data->vc.rv3d, vec, TRUE) == 0) { data->dist = distance; @@ -531,7 +530,7 @@ BMEdge *EDBM_edge_find_nearest(ViewContext *vc, int *dist) data.closest = NULL; ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - mesh_foreachScreenEdge(vc, findnearestedge__doClosest, &data, 2); + mesh_foreachScreenEdge(vc, findnearestedge__doClosest, &data, V3D_CLIP_TEST_REGION); *dist = data.dist; return data.closest; @@ -1058,8 +1057,8 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) /* We can't be sure this has already been set... */ ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); - project_float_noclip(vc.ar, eed->v1->co, v1_co); - project_float_noclip(vc.ar, eed->v2->co, v2_co); + ED_view3d_project_float_noclip(vc.ar, eed->v1->co, v1_co); + ED_view3d_project_float_noclip(vc.ar, eed->v2->co, v2_co); #if 0 printf("mouse to v1: %f\nmouse to v2: %f\n", len_squared_v2v2(mvalf, v1_co), len_squared_v2v2(mvalf, v2_co)); @@ -1087,7 +1086,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) float co[2], tdist; BM_face_calc_center_mean(f, cent); - project_float_noclip(vc.ar, cent, co); + ED_view3d_project_float_noclip(vc.ar, cent, co); tdist = len_squared_v2v2(mvalf, co); if (tdist < best_dist) { /* printf("Best face: %p (%f)\n", f, tdist);*/ diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c index 86ea5bc8651..bd1d13f3528 100644 --- a/source/blender/editors/mesh/editmesh_slide.c +++ b/source/blender/editors/mesh/editmesh_slide.c @@ -388,10 +388,10 @@ static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2]) edge = vso->edge_frame[i]; mul_v3_m4v3(v1_proj, vso->obj->obmat, edge->v1->co); - project_float_noclip(vso->active_region, v1_proj, v1_proj); + ED_view3d_project_float_noclip(vso->active_region, v1_proj, v1_proj); mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co); - project_float_noclip(vso->active_region, v2_proj, v2_proj); + ED_view3d_project_float_noclip(vso->active_region, v2_proj, v2_proj); dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj); if (dist < min_dist) { @@ -455,10 +455,10 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event) /* Project points onto screen and do interpolation in 2D */ mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co); - project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj); + ED_view3d_project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj); mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co); - project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj); + ED_view3d_project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj); closest_to_line_v2(closest_2d, mval_float, start_vtx_proj, edge_other_proj); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 9e83742a909..7c700cc9731 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -163,7 +163,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMes float mval[2], vec[3], no_dummy[3]; int dist_dummy; mul_v3_m4v3(vec, obedit->obmat, eve->co); - project_float_noclip(ar, vec, mval); + ED_view3d_project_float_noclip(ar, vec, mval); if (snapObjectsContext(C, mval, &dist_dummy, vec, no_dummy, SNAP_NOT_OBEDIT)) { mul_v3_m4v3(eve->co, obedit->imat, vec); } @@ -761,8 +761,8 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent float co1[3], co2[3]; mul_v3_m4v3(co1, vc.obedit->obmat, eed->v1->co); mul_v3_m4v3(co2, vc.obedit->obmat, eed->v2->co); - project_float_noclip(vc.ar, co1, co1); - project_float_noclip(vc.ar, co2, co2); + ED_view3d_project_float_noclip(vc.ar, co1, co1); + ED_view3d_project_float_noclip(vc.ar, co2, co2); /* 2D rotate by 90d while adding. * (x, y) = (y, -x) @@ -2526,12 +2526,6 @@ void MESH_OT_solidify(wmOperatorType *ot) RNA_def_property_ui_range(prop, -10, 10, 0.1, 4); } -#define TRAIL_POLYLINE 1 /* For future use, They don't do anything yet */ -#define TRAIL_FREEHAND 2 -#define TRAIL_MIXED 3 /* (1|2) */ -#define TRAIL_AUTO 4 -#define TRAIL_MIDPOINTS 8 - typedef struct CutCurve { float x; float y; @@ -2776,7 +2770,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) copy_v3_v3(co, bv->co); co[3] = 1.0f; mul_m4_v4(obedit->obmat, co); - project_float(ar, co, scr); + ED_view3d_project_float(ar, co, scr); BLI_ghash_insert(gh, bv, scr); } @@ -2858,9 +2852,6 @@ void MESH_OT_knife_cut(wmOperatorType *ot) static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old) { Base *base_new; - BMIter iter; - BMVert *v; - BMEdge *e; Object *obedit = base_old->object; BMesh *bm_new; @@ -2886,15 +2877,10 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh BMO_op_callf(bm_old, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "delete geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES); - /* deselect loose data - this used to get deleted */ - BM_ITER_MESH (e, &iter, bm_old, BM_EDGES_OF_MESH) { - BM_edge_select_set(bm_old, e, FALSE); - } - - /* clean up any loose verts */ - BM_ITER_MESH (v, &iter, bm_old, BM_VERTS_OF_MESH) { - BM_vert_select_set(bm_old, v, FALSE); - } + /* deselect loose data - this used to get deleted, + * we could de-select edges and verts only, but this turns out to be less complicated + * since de-selecting all skips selection flushing logic */ + BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); BM_mesh_normals_update(bm_new, FALSE); @@ -2908,7 +2894,10 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh static int mesh_separate_selected(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old) { - /* tag -> select */ + /* we may have tags from previous operators */ + BM_mesh_elem_hflag_disable_all(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, FALSE); + + /* sel -> tag */ BM_mesh_elem_hflag_enable_test(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, TRUE, BM_ELEM_SELECT); return mesh_separate_tagged(bmain, scene, base_old, bm_old); @@ -4721,7 +4710,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event) mdiff[0] = opdata->mcenter[0] - event->mval[0]; mdiff[1] = opdata->mcenter[1] - event->mval[1]; - factor = -len_v2(mdiff) / opdata->initial_length + 1.0f; + factor = opdata->initial_length / -len_v2(mdiff) + 1.0f; /* Fake shift-transform... */ if (event->shift) { @@ -5085,9 +5074,9 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event) mdiff[1] = opdata->mcenter[1] - event->mval[1]; if (opdata->modify_depth) - amount = opdata->old_depth + len_v2(mdiff) / opdata->initial_length - 1.0f; + amount = opdata->old_depth + opdata->initial_length / len_v2(mdiff) - 1.0f; else - amount = opdata->old_thickness - len_v2(mdiff) / opdata->initial_length + 1.0f; + amount = opdata->old_thickness - opdata->initial_length / len_v2(mdiff) + 1.0f; /* Fake shift-transform... */ if (opdata->shift) diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 03e2f2691a8..b844ba0baa2 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -535,6 +535,16 @@ static void *getEditMesh(bContext *C) typedef struct UndoMesh { Mesh me; int selectmode; + + /** \note + * this isn't a prefect solution, if you edit keys and change shapes this works well (fixing [#32442]), + * but editing shape keys, going into object mode, removing or changing their order, + * then go back into editmode and undo will give issues - where the old index will be out of sync + * with the new object index. + * + * There are a few ways this could be made to work but for now its a known limitation with mixing + * object and editmode operations - Campbell */ + int shapenr; } UndoMesh; /* undo simply makes copies of a bmesh */ @@ -546,13 +556,14 @@ static void *editbtMesh_to_undoMesh(void *emv, void *obdata) UndoMesh *um = MEM_callocN(sizeof(UndoMesh), "undo Mesh"); /* make sure shape keys work */ - um->me.key = obme->key ? copy_key_nolib(obme->key) : NULL; + um->me.key = obme->key ? BKE_key_copy_nolib(obme->key) : NULL; /* BM_mesh_validate(em->bm); */ /* for troubleshooting */ BM_mesh_bm_to_me(em->bm, &um->me, FALSE); um->selectmode = em->selectmode; + um->shapenr = em->bm->shapenr; return um; } @@ -564,7 +575,7 @@ static void undoMesh_to_editbtMesh(void *umv, void *em_v, void *UNUSED(obdata)) UndoMesh *um = umv; BMesh *bm; - ob->shapenr = em->bm->shapenr; + ob->shapenr = em->bm->shapenr = um->shapenr; EDBM_mesh_free(em); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 09d89a961e4..a52c8d47ecd 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -47,6 +47,8 @@ #include "BLI_array.h" #include "BLI_math.h" #include "BLI_edgehash.h" +#include "BLI_linklist.h" +#include "BLI_listbase.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -74,6 +76,64 @@ #include "mesh_intern.h" +static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot) +{ + CustomData *data; + BMesh *bm = (me->edit_btmesh) ? me->edit_btmesh->bm : NULL; + int tot; + + /* this */ + switch (htype) { + case BM_VERT: + if (bm) { + data = &bm->vdata; + tot = bm->totvert; + } + else { + data = &me->vdata; + tot = me->totvert; + } + break; + case BM_EDGE: + if (bm) { + data = &bm->edata; + tot = bm->totedge; + } + else { + data = &me->edata; + tot = me->totedge; + } + break; + case BM_LOOP: + if (bm) { + data = &bm->ldata; + tot = bm->totloop; + } + else { + data = &me->ldata; + tot = me->totloop; + } + break; + case BM_FACE: + if (bm) { + data = &bm->pdata; + tot = bm->totface; + } + else { + data = &me->pdata; + tot = me->totpoly; + } + break; + default: + BLI_assert(0); + tot = 0; + data = NULL; + } + + *r_tot = tot; + return data; +} + #define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data) static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer) { @@ -85,24 +145,10 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la int i, actindex, rndindex, cloneindex, stencilindex, tot; if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) { - if (me->edit_btmesh) { - data = &me->edit_btmesh->bm->ldata; - tot = me->edit_btmesh->bm->totloop; - } - else { - data = &me->ldata; - tot = me->totloop; - } + data = mesh_customdata_get_type(me, BM_LOOP, &tot); } else { - if (me->edit_btmesh) { - data = &me->edit_btmesh->bm->pdata; - tot = me->edit_btmesh->bm->totface; - } - else { - data = &me->pdata; - tot = me->totpoly; - } + data = mesh_customdata_get_type(me, BM_FACE, &tot); } index = CustomData_get_layer_index(data, type); @@ -701,22 +747,20 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/*********************** sticky operators ************************/ +/* *** CustomData clear functions, we need an operator for each *** */ -static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op)) +static int mesh_customdata_clear_exec__internal(bContext *C, + char htype, int type) { - Scene *scene = CTX_data_scene(C); - View3D *v3d = CTX_wm_view3d(C); - Object *ob = ED_object_context(C); - Mesh *me = ob->data; + Object *obedit = ED_object_context(C); + Mesh *me = obedit->data; - /* why is this commented out? */ -#if 0 - if (me->msticky) - return OPERATOR_CANCELLED; -#endif + int tot; + CustomData *data = mesh_customdata_get_type(me, htype, &tot); - RE_make_sticky(scene, v3d); + BLI_assert(CustomData_layertype_is_singleton(type) == TRUE); + + CustomData_free_layers(data, type, tot); DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); @@ -724,48 +768,79 @@ static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void MESH_OT_sticky_add(wmOperatorType *ot) +/* Clear Mask */ +static int mesh_customdata_clear_mask_poll(bContext *C) +{ + Object *ob = ED_object_context(C); + if (ob && ob->type == OB_MESH) { + Mesh *me = ob->data; + + /* special case - can't run this if we're in sculpt mode */ + if (ob->mode & OB_MODE_SCULPT) { + return FALSE; + } + + if (me->id.lib == NULL) { + CustomData *data = GET_CD_DATA(me, vdata); + if (CustomData_has_layer(data, CD_PAINT_MASK)) { + return TRUE; + } + } + } + return FALSE; +} +static int mesh_customdata_clear_mask_exec(bContext *C, wmOperator *UNUSED(op)) +{ + return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_PAINT_MASK); +} + +void MESH_OT_customdata_clear_mask(wmOperatorType *ot) { + /* identifiers */ - ot->name = "Add Sticky"; - ot->description = "Add sticky UV texture layer"; - ot->idname = "MESH_OT_sticky_add"; - + ot->name = "Clear Sculpt-Mask Data"; + ot->idname = "MESH_OT_customdata_clear_mask"; + ot->description = "Clear vertex sculpt masking data from the mesh"; + /* api callbacks */ - ot->poll = layers_poll; - ot->exec = mesh_sticky_add_exec; + ot->exec = mesh_customdata_clear_mask_exec; + ot->poll = mesh_customdata_clear_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int mesh_sticky_remove_exec(bContext *C, wmOperator *UNUSED(op)) +/* Clear Skin */ +static int mesh_customdata_clear_skin_poll(bContext *C) { Object *ob = ED_object_context(C); - Mesh *me = ob->data; - if (!me->msticky) - return OPERATOR_CANCELLED; - - CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert); - me->msticky = NULL; - - DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); - - return OPERATOR_FINISHED; + if (ob && ob->type == OB_MESH) { + Mesh *me = ob->data; + if (me->id.lib == NULL) { + CustomData *data = GET_CD_DATA(me, vdata); + if (CustomData_has_layer(data, CD_MVERT_SKIN)) { + return TRUE; + } + } + } + return FALSE; +} +static int mesh_customdata_clear_skin_exec(bContext *C, wmOperator *UNUSED(op)) +{ + return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_MVERT_SKIN); } -void MESH_OT_sticky_remove(wmOperatorType *ot) +void MESH_OT_customdata_clear_skin(wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove Sticky"; - ot->description = "Remove sticky UV texture layer"; - ot->idname = "MESH_OT_sticky_remove"; - + ot->name = "Clear Skin Data"; + ot->idname = "MESH_OT_customdata_clear_skin"; + ot->description = "Clear vertex skin layer"; + /* api callbacks */ - ot->poll = layers_poll; - ot->exec = mesh_sticky_remove_exec; + ot->exec = mesh_customdata_clear_skin_exec; + ot->poll = mesh_customdata_clear_skin_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index aed57141c2a..b68c1836992 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -189,8 +189,10 @@ void MESH_OT_uv_texture_add(struct wmOperatorType *ot); void MESH_OT_uv_texture_remove(struct wmOperatorType *ot); void MESH_OT_vertex_color_add(struct wmOperatorType *ot); void MESH_OT_vertex_color_remove(struct wmOperatorType *ot); -void MESH_OT_sticky_add(struct wmOperatorType *ot); -void MESH_OT_sticky_remove(struct wmOperatorType *ot); +/* no create_mask yet */ +void MESH_OT_customdata_clear_mask(struct wmOperatorType *ot); +void MESH_OT_customdata_clear_skin(struct wmOperatorType *ot); + void MESH_OT_drop_named_image(struct wmOperatorType *ot); /* ************* bmesh_tools.c ***********/ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 7f73851f2a8..ccf91958e08 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -136,7 +136,6 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_vertices_smooth); WM_operatortype_append(MESH_OT_noise); WM_operatortype_append(MESH_OT_flip_normals); - //WM_operatortype_append(MESH_OT_knife_cut); WM_operatortype_append(MESH_OT_rip); WM_operatortype_append(MESH_OT_blend_from_shape); WM_operatortype_append(MESH_OT_shape_propagate_to_all); @@ -145,8 +144,8 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_uv_texture_remove); WM_operatortype_append(MESH_OT_vertex_color_add); WM_operatortype_append(MESH_OT_vertex_color_remove); - WM_operatortype_append(MESH_OT_sticky_add); - WM_operatortype_append(MESH_OT_sticky_remove); + WM_operatortype_append(MESH_OT_customdata_clear_mask); + WM_operatortype_append(MESH_OT_customdata_clear_skin); WM_operatortype_append(MESH_OT_drop_named_image); WM_operatortype_append(MESH_OT_edgering_select); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index a7467ee4c79..f2b7a2e9c22 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -104,7 +104,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) MLoop *mloop = NULL; Key *key, *nkey = NULL; KeyBlock *kb, *okb, *kbn; - float imat[4][4], cmat[4][4], *fp1, *fp2, curpos; + float imat[4][4], cmat[4][4], *fp1, *fp2; int a, b, totcol, totmat = 0, totedge = 0, totvert = 0, ok = 0; int totloop = 0, totpoly = 0, vertofs, *matmap = NULL; int i, j, index, haskey = 0, edgeofs, loopofs, polyofs; @@ -196,7 +196,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) } else if (haskey) { /* add a new key-block and add to the mesh */ - key = me->key = add_key((ID *)me); + key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; } @@ -243,29 +243,29 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* if this mesh has shapekeys, check if destination mesh already has matching entries too */ if (me->key && key) { - for (kb = me->key->block.first; kb; kb = kb->next) { + /* for remapping KeyBlock.relative */ + int *index_map = MEM_mallocN(sizeof(int) * me->key->totkey, __func__); + KeyBlock **kb_map = MEM_mallocN(sizeof(KeyBlock *) * me->key->totkey, __func__); + + for (kb = me->key->block.first, i = 0; kb; kb = kb->next, i++) { + BLI_assert(i < me->key->totkey); + + kbn = BKE_keyblock_find_name(key, kb->name); /* if key doesn't exist in destination mesh, add it */ - if (key_get_named_keyblock(key, kb->name) == NULL) { - /* copy this existing one over to the new shapekey block */ - kbn = MEM_dupallocN(kb); - kbn->prev = kbn->next = NULL; - + if (kbn) { + index_map[i] = BLI_findindex(&key->block, kbn); + } + else { + index_map[i] = key->totkey; + + kbn = BKE_keyblock_add(key, kb->name); + + BKE_keyblock_copy_settings(kbn, kb); + /* adjust settings to fit (allocate a new data-array) */ kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey"); - kbn->totelem = totvert; - kbn->weights = NULL; - - okb = key->block.last; - curpos = (okb) ? okb->pos : -0.1f; - if (key->type == KEY_RELATIVE) - kbn->pos = curpos + 0.1f; - else - kbn->pos = curpos; - - BLI_addtail(&key->block, kbn); - key->totkey++; - if (key->totkey == 1) key->refkey = kbn; - + kbn->totelem = totvert; + /* XXX 2.5 Animato */ #if 0 /* also, copy corresponding ipo-curve to ipo-block if applicable */ @@ -275,13 +275,26 @@ int join_mesh_exec(bContext *C, wmOperator *op) } #endif } + + kb_map[i] = kbn; } + + /* remap relative index values */ + for (kb = me->key->block.first, i = 0; kb; kb = kb->next, i++) { + if (LIKELY(kb->relative < me->key->totkey)) { /* sanity check, should always be true */ + kb_map[i]->relative = index_map[kb->relative]; + } + } + + MEM_freeN(index_map); + MEM_freeN(kb_map); } } } } CTX_DATA_END; - + + /* setup new data for destination mesh */ memset(&vdata, 0, sizeof(vdata)); memset(&edata, 0, sizeof(edata)); @@ -356,7 +369,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) fp1 = ((float *)kb->data) + (vertofs * 3); /* check if this mesh has such a shapekey */ - okb = key_get_named_keyblock(me->key, kb->name); + okb = me->key ? BKE_keyblock_find_name(me->key, kb->name) : NULL; + if (okb) { /* copy this mesh's shapekey to the destination shapekey (need to transform first) */ fp2 = ((float *)(okb->data)); @@ -386,7 +400,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) fp1 = ((float *)kb->data) + (vertofs * 3); /* check if this was one of the original shapekeys */ - okb = key_get_named_keyblock(nkey, kb->name); + okb = BKE_keyblock_find_name(nkey, kb->name); if (okb) { /* copy this mesh's shapekey to the destination shapekey */ fp2 = ((float *)(okb->data)); @@ -427,8 +441,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) if ((mmd = get_multires_modifier(scene, base->object, TRUE))) { ED_object_iter_other(bmain, base->object, TRUE, - ED_object_multires_update_totlevels_cb, - &mmd->totlvl); + ED_object_multires_update_totlevels_cb, + &mmd->totlvl); } } @@ -548,6 +562,12 @@ int join_mesh_exec(bContext *C, wmOperator *op) MEM_freeN(nkey); } + /* ensure newly inserted keys are time sorted */ + if (key && (key->type != KEY_RELATIVE)) { + BKE_key_sort(key); + } + + DAG_scene_sort(bmain, scene); // removed objects, need to rebuild dag before editmode call #if 0 @@ -607,12 +627,12 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) } if (key == NULL) { - key = me->key = add_key((ID *)me); + key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; /* first key added, so it was the basis. initialize it with the existing mesh */ - kb = add_keyblock(key, NULL); - mesh_to_key(me, kb); + kb = BKE_keyblock_add(key, NULL); + BKE_key_convert_from_mesh(me, kb); } /* now ready to add new keys from selected meshes */ @@ -628,7 +648,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) if (!dm) continue; - kb = add_keyblock(key, base->object->id.name + 2); + kb = BKE_keyblock_add(key, base->object->id.name + 2); DM_to_meshkey(dm, me, kb); @@ -709,9 +729,9 @@ static void mesh_octree_add_nodes(MocNode **basetable, const float co[3], const float fx, fy, fz; int vx, vy, vz; - if (!finite(co[0]) || - !finite(co[1]) || - !finite(co[2])) + if ((finite(co[0]) == FALSE) || + (finite(co[1]) == FALSE) || + (finite(co[2]) == FALSE)) { return; } @@ -940,9 +960,9 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c intptr_t poinval; /* ignore nan verts */ - if (!finite(co[0]) || - !finite(co[1]) || - !finite(co[2])) + if ((finite(co[0]) == FALSE) || + (finite(co[1]) == FALSE) || + (finite(co[2]) == FALSE)) { return NULL; } @@ -1217,7 +1237,7 @@ int ED_mesh_pick_face_vert(bContext *C, Mesh *me, Object *ob, const int mval[2], const int v_idx = me->mloop[mp->loopstart + fidx].v; dm->getVertCo(dm, v_idx, co); mul_m4_v3(ob->obmat, co); - project_float_noclip(ar, co, sco); + ED_view3d_project_float_noclip(ar, co, sco); len = len_squared_v2v2(mval_f, sco); if (len < len_best) { len_best = len; diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 50d5569c483..22ccd7bbed8 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -98,9 +98,8 @@ void load_editMball(Object *UNUSED(obedit)) } /* Add metaelem primitive to metaball object (which is in edit mode) */ -MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNUSED(newname)) +MetaElem *add_metaball_primitive(bContext *UNUSED(C), Object *obedit, float mat[4][4], int type, int UNUSED(newname)) { - Object *obedit = CTX_data_edit_object(C); MetaBall *mball = (MetaBall *)obedit->data; MetaElem *ml; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d90735ca5ac..4942b9e4390 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -198,7 +198,7 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit, /********************* Add Object Operator ********************/ -void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(scene), struct PointerRNA *ptr) +static void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(scene), struct PointerRNA *ptr) { RNA_struct_idprops_unset(ptr, "rotation"); } @@ -439,7 +439,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) ((Curve *)ob->data)->flag |= CU_PATH | CU_3D; ED_object_enter_editmode(C, 0); ED_object_new_primitive_matrix(C, ob, loc, rot, mat); - BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_PATH, 1)); + BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, 1)); if (!enter_editmode) ED_object_exit_editmode(C, EM_FREEDATA); @@ -574,7 +574,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); - /* elem= (MetaElem *) */ add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); + /* elem= (MetaElem *) */ add_metaball_primitive(C, obedit, mat, RNA_enum_get(op->ptr, "type"), newob); /* userdef */ if (newob && !enter_editmode) { @@ -1826,7 +1826,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base /* check if obdata is copied */ if (didit) { - Key *key = ob_get_key(obn); + Key *key = BKE_key_from_object(obn); if (dupflag & USER_DUP_ACT) { bActuator *act; diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index f9b73a56403..0ea2f78a415 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -69,6 +69,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" #include "GPU_draw.h" /* GPU_free_image */ @@ -685,7 +686,7 @@ static void apply_heights_data(void *bake_data) } } - ibuf->userflags = IB_RECT_INVALID; + ibuf->userflags = IB_RECT_INVALID | IB_DISPLAY_BUFFER_INVALID; } static void free_heights_data(void *bake_data) @@ -769,6 +770,8 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, char *rrgb = (char *)ibuf->rect + pixel * 4; rrgb[3] = 255; } + + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; } /* MultiresBake callback for normals' baking @@ -826,6 +829,8 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, rgb_float_to_uchar(rrgb, vec); rrgb[3] = 255; } + + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; } static void count_images(MultiresBakeRender *bkr) @@ -895,7 +900,7 @@ static void finish_images(MultiresBakeRender *bkr) RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter); - ibuf->userflags |= IB_BITMAPDIRTY; + ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;; if (ibuf->rect_float) ibuf->userflags |= IB_RECT_INVALID; @@ -1324,11 +1329,12 @@ static int test_bake_internal(bContext *C, ReportList *reports) static void init_bake_internal(BakeRender *bkr, bContext *C) { Scene *scene = CTX_data_scene(C); + bScreen *sc = CTX_wm_screen(C); /* get editmode results */ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - bkr->sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_IMAGE, 10); /* can be NULL */ + bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; /* can be NULL */ bkr->main = CTX_data_main(C); bkr->scene = scene; bkr->actob = (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL; @@ -1369,6 +1375,7 @@ static void finish_bake_internal(BakeRender *bkr) if (ima->ok == IMA_OK_LOADED) { if (ibuf) { if (ibuf->userflags & IB_BITMAPDIRTY) { + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; GPU_free_image(ima); imb_freemipmapImBuf(ibuf); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index aa885320b37..f95a186990e 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -649,11 +649,11 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) for (base = FIRSTBASE; base; base = base->next) { if ((base != BASACT) && (TESTBASELIB(v3d, base))) { if (nr == 1) { /* replace */ - copy_properties(&base->object->prop, &ob->prop); + BKE_bproperty_copy_list(&base->object->prop, &ob->prop); } else { for (prop = ob->prop.first; prop; prop = prop->next) { - set_ob_property(base->object, prop); + BKE_bproperty_object_set(base->object, prop); } } } @@ -665,7 +665,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) if (prop) { for (base = FIRSTBASE; base; base = base->next) { if ((base != BASACT) && (TESTBASELIB(v3d, base))) { - set_ob_property(base->object, prop); + BKE_bproperty_object_set(base->object, prop); } } } @@ -1585,7 +1585,7 @@ static int game_property_new(bContext *C, wmOperator *op) char name[MAX_NAME]; int type = RNA_enum_get(op->ptr, "type"); - prop = new_property(type); + prop = BKE_bproperty_new(type); BLI_addtail(&ob->prop, prop); RNA_string_get(op->ptr, "name", name); @@ -1593,7 +1593,7 @@ static int game_property_new(bContext *C, wmOperator *op) BLI_strncpy(prop->name, name, sizeof(prop->name)); } - unique_property(NULL, prop, 0); // make_unique_prop_names(prop->name); + BKE_bproperty_unique(NULL, prop, 0); // make_unique_prop_names(prop->name); WM_event_add_notifier(C, NC_LOGIC, NULL); return OPERATOR_FINISHED; @@ -1631,7 +1631,7 @@ static int game_property_remove(bContext *C, wmOperator *op) if (prop) { BLI_remlink(&ob->prop, prop); - free_property(prop); + BKE_bproperty_free(prop); WM_event_add_notifier(C, NC_LOGIC, NULL); return OPERATOR_FINISHED; @@ -1711,7 +1711,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) - set_ob_property(ob_iter, prop); + BKE_bproperty_object_set(ob_iter, prop); } CTX_DATA_END; } } @@ -1721,12 +1721,12 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) { if (ob != ob_iter) { if (type == COPY_PROPERTIES_REPLACE) { - copy_properties(&ob_iter->prop, &ob->prop); + BKE_bproperty_copy_list(&ob_iter->prop, &ob->prop); } else { /* merge - the default when calling with no argument */ for (prop = ob->prop.first; prop; prop = prop->next) { - set_ob_property(ob_iter, prop); + BKE_bproperty_object_set(ob_iter, prop); } } } @@ -1763,7 +1763,7 @@ static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op)) { CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { - free_properties(&ob_iter->prop); + BKE_bproperty_free_list(&ob_iter->prop); } CTX_DATA_END; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 7c8386d55dc..a6afe6b2d04 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -585,13 +585,11 @@ void OBJECT_OT_hook_add_newobj(wmOperatorType *ot) static int object_hook_remove_exec(bContext *C, wmOperator *op) { int num = RNA_enum_get(op->ptr, "modifier"); - Object *ob = NULL; + Object *ob = CTX_data_edit_object(C); HookModifierData *hmd = NULL; - ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); - - if (!ob || !hmd) { + if (!hmd) { BKE_report(op->reports, RPT_ERROR, "Couldn't 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 89f9f5de311..1f7be0bf9a6 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -92,9 +92,9 @@ void make_editLatt(Object *obedit) free_editLatt(obedit); - actkey = ob_get_keyblock(obedit); + actkey = BKE_keyblock_from_object(obedit); if (actkey) - key_to_latt(actkey, lt); + BKE_key_convert_to_lattice(actkey, lt); lt->editlatt = MEM_callocN(sizeof(EditLatt), "editlatt"); lt->editlatt->latt = MEM_dupallocN(lt); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 4858fdf1c35..6fe7ad05a70 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -565,15 +565,15 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M } if (key == NULL) { - key = me->key = add_key((ID *)me); + key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; /* if that was the first key block added, then it was the basis. * Initialize it with the mesh, and add another for the modifier */ - kb = add_keyblock(key, NULL); - mesh_to_key(me, kb); + kb = BKE_keyblock_add(key, NULL); + BKE_key_convert_from_mesh(me, kb); } - kb = add_keyblock(key, md->name); + kb = BKE_keyblock_add(key, md->name); DM_to_meshkey(dm, me, kb); dm->release(dm); @@ -1692,11 +1692,9 @@ static void skin_armature_bone_create(Object *skin_ob, v = (e->v1 == parent_v ? e->v2 : e->v1); - bone = MEM_callocN(sizeof(EditBone), - "skin_armature_bone_create EditBone"); + bone = ED_armature_edit_bone_add(arm, "Bone"); bone->parent = parent_bone; - bone->layer = 1; bone->flag |= BONE_CONNECTED; copy_v3_v3(bone->head, mvert[parent_v].co); @@ -1704,8 +1702,6 @@ static void skin_armature_bone_create(Object *skin_ob, bone->rad_head = bone->rad_tail = 0.25; BLI_snprintf(bone->name, sizeof(bone->name), "Bone.%.2d", endx); - BLI_addtail(arm->edbo, bone); - /* add bDeformGroup */ if ((dg = ED_vgroup_add_name(skin_ob, bone->name))) { ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE); @@ -1770,16 +1766,13 @@ static Object *modifier_skin_armature_create(struct Scene *scene, * a fake root bone (have it going off in the Y direction * (arbitrary) */ if (emap[v].count > 1) { - bone = MEM_callocN(sizeof(EditBone), "EditBone"); + bone = ED_armature_edit_bone_add(arm, "Bone"); copy_v3_v3(bone->head, me->mvert[v].co); copy_v3_v3(bone->tail, me->mvert[v].co); - bone->layer = 1; bone->head[1] = 1.0f; bone->rad_head = bone->rad_tail = 0.25; - - BLI_addtail(arm->edbo, bone); } if (emap[v].count >= 1) { diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 7eb8cc01db9..ff7f33f6107 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -723,7 +723,7 @@ static short objects_share_gameprop(Object *a, Object *b) /*make a copy of all its properties*/ for (prop = a->prop.first; prop; prop = prop->next) { - if (get_ob_property(b, prop->name) ) + if (BKE_bproperty_object_get(b, prop->name) ) return 1; } return 0; diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 40b653a62fd..cfd4945688b 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -78,7 +78,7 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int f { KeyBlock *kb; if ((kb = BKE_object_insert_shape_key(scene, ob, NULL, from_mix))) { - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); /* for absolute shape keys, new keys may not be added last */ ob->shapenr = BLI_findindex(&key->block, kb) + 1; @@ -95,7 +95,7 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) Key *key; //IpoCurve *icu; - key = ob_get_key(ob); + key = BKE_key_from_object(ob); if (key == NULL) return 0; @@ -115,14 +115,14 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) /* apply new basis key on original data */ switch (ob->type) { case OB_MESH: - key_to_mesh(key->refkey, ob->data); + BKE_key_convert_to_mesh(key->refkey, ob->data); break; case OB_CURVE: case OB_SURF: - key_to_curve(key->refkey, ob->data, BKE_curve_nurbs_get(ob->data)); + BKE_key_convert_to_curve(key->refkey, ob->data, BKE_curve_nurbs_get(ob->data)); break; case OB_LATTICE: - key_to_latt(key->refkey, ob->data); + BKE_key_convert_to_lattice(key->refkey, ob->data); break; } } @@ -155,7 +155,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob) KeyBlock *kb; Key *key; - key = ob_get_key(ob); + key = BKE_key_from_object(ob); if (key == NULL) return 0; @@ -323,8 +323,8 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - Key *key = ob_get_key(ob); - KeyBlock *kb = ob_get_keyblock(ob); + Key *key = BKE_key_from_object(ob); + KeyBlock *kb = BKE_keyblock_from_object(ob); if (!key || !kb) return OPERATOR_CANCELLED; @@ -357,8 +357,8 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot) static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - Key *key = ob_get_key(ob); - KeyBlock *kb = ob_get_keyblock(ob); + Key *key = BKE_key_from_object(ob); + KeyBlock *kb = BKE_keyblock_from_object(ob); float cfra = 0.0f; if (!key || !kb) @@ -419,7 +419,7 @@ static int shape_key_move_exec(bContext *C, wmOperator *op) Object *ob = ED_object_context(C); int type = RNA_enum_get(op->ptr, "type"); - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); if (key) { KeyBlock *kb, *kb_other; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index b7ce32aa10a..72bbcda2b5e 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -409,7 +409,7 @@ static int key_test_depth(PEData *data, const float co[3]) if ((v3d->drawtype<=OB_WIRE) || (v3d->flag & V3D_ZBUF_SELECT)==0) return 1; - project_short(data->vc.ar, co, wco); + ED_view3d_project_short(data->vc.ar, co, wco); if (wco[0] == IS_CLIPPED) return 0; @@ -447,7 +447,7 @@ static int key_inside_circle(PEData *data, float rad, const float co[3], float * float dx, dy, dist; int sco[2]; - project_int(data->vc.ar, co, sco); + ED_view3d_project_int(data->vc.ar, co, sco); if (sco[0] == IS_CLIPPED) return 0; @@ -473,7 +473,7 @@ static int key_inside_rect(PEData *data, const float co[3]) { int sco[2]; - project_int(data->vc.ar, co, sco); + ED_view3d_project_int(data->vc.ar, co, sco); if (sco[0] == IS_CLIPPED) return 0; @@ -1666,7 +1666,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho LOOP_KEYS { copy_v3_v3(co, key->co); mul_m4_v3(mat, co); - project_int(ar, co, vertco); + ED_view3d_project_int(ar, co, vertco); if (BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) && key_test_depth(&data, co)) { @@ -1686,7 +1686,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho copy_v3_v3(co, key->co); mul_m4_v3(mat, co); - project_int(ar, co, vertco); + ED_view3d_project_int(ar, co, vertco); if (BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) && key_test_depth(&data, co)) { @@ -2802,7 +2802,7 @@ static void brush_cut(PEData *data, int pa_index) cut=0; - project_int_noclip(ar, key->co, vertco); + ED_view3d_project_int_noclip(ar, key->co, vertco); x0= (float)vertco[0]; x1= (float)vertco[1]; @@ -2820,7 +2820,7 @@ static void brush_cut(PEData *data, int pa_index) else { /* calculate path time closest to root that was inside the circle */ for (k=1, key++; k<=keys; k++, key++) { - project_int_noclip(ar, key->co, vertco); + ED_view3d_project_int_noclip(ar, key->co, vertco); if (key_test_depth(data, key->co) == 0) { x0= (float)vertco[0]; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index f95b07bd71e..099d868a0ad 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -782,7 +782,7 @@ static void fluidbake_endjob(void *customdata) } } -int runSimulationCallback(void *data, int status, int frame) +static int runSimulationCallback(void *data, int status, int frame) { FluidBakeJob *fb = (FluidBakeJob *)data; elbeemSimulationSettings *settings = fb->settings; @@ -1095,7 +1095,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor return 1; } -void fluidsimFreeBake(Object *UNUSED(ob)) +static void UNUSED_FUNCTION(fluidsimFreeBake)(Object *UNUSED(ob)) { /* not implemented yet */ } diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index b236b555850..c08ea2b6429 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -61,6 +61,7 @@ #include "ED_object.h" #include "RE_pipeline.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -78,8 +79,8 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat { float *rectf = NULL; int ymin, ymax, xmin, xmax; - int rymin, rxmin, predivide, profile_from; - unsigned char *rectc; + int rymin, rxmin; + /* unsigned char *rectc; */ /* UNUSED */ /* if renrect argument, we only refresh scanlines */ if (renrect) { @@ -123,8 +124,14 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat if (rr->rectf) rectf = rr->rectf; else { - if (rr->rect32) + if (rr->rect32) { + /* special case, currently only happens with sequencer rendering, + * which updates the whole frame, so we can only mark display buffer + * as invalid here (sergey) + */ + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; return; + } else { if (rr->renlay == NULL || rr->renlay->rectf == NULL) return; rectf = rr->renlay->rectf; @@ -136,20 +143,11 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat imb_addrectImBuf(ibuf); rectf += 4 * (rr->rectx * ymin + xmin); - rectc = (unsigned char *)(ibuf->rect + ibuf->x * rymin + rxmin); - - if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) { - profile_from = IB_PROFILE_LINEAR_RGB; - predivide = (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); - } - else { - profile_from = IB_PROFILE_SRGB; - predivide = 0; - } + /* rectc = (unsigned char *)(ibuf->rect + ibuf->x * rymin + rxmin); */ /* UNUSED */ - IMB_buffer_byte_from_float(rectc, rectf, - 4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide, - xmax, ymax, ibuf->x, rr->rectx); + IMB_partial_display_buffer_update(ibuf, rectf, NULL, rr->rectx, rxmin, rymin, + &scene->view_settings, &scene->display_settings, + rxmin, rymin, rxmin + xmax, rymin + ymax); } /* ****************************** render invoking ***************** */ diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 55df1caf3eb..d9618e89b68 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -63,6 +63,7 @@ #include "RE_pipeline.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" #include "RNA_access.h" #include "RNA_define.h" @@ -143,22 +144,30 @@ static void screen_opengl_render_apply(OGLRender *oglrender) ibuf = BKE_sequencer_give_ibuf(context, CFRA, chanshown); if (ibuf) { + ImBuf *linear_ibuf; + BLI_assert((oglrender->sizex == ibuf->x) && (oglrender->sizey == ibuf->y)); - if (ibuf->rect_float == NULL) { - /* internally sequencer working in sRGB space and stores both bytes and float - * buffers in sRGB space, but if byte->float onversion doesn't happen in sequencer - * (e.g. when adding image sequence/movie into sequencer) there'll be only - * byte buffer and profile will still indicate sRGB->linear space conversion is needed - * here we're ensure there'll be no conversion happen and float buffer would store - * linear frame (sergey) */ - ibuf->profile = IB_PROFILE_NONE; - IMB_float_from_rect(ibuf); + linear_ibuf = IMB_dupImBuf(ibuf); + IMB_freeImBuf(ibuf); + + if (linear_ibuf->rect_float == NULL) { + /* internally sequencer working in display space and stores both bytes and float buffers in that space. + * It is possible that byte->float onversion didn't happen in sequencer (e.g. when adding image sequence/movie + * into sequencer) there'll be only byte buffer. Create float buffer from existing byte buffer, making it linear + */ + + IMB_float_from_rect(linear_ibuf); + } + else { + /* ensure float buffer is in linear space, not in display space */ + BKE_sequencer_imbuf_from_sequencer_space(scene, linear_ibuf); } - memcpy(rr->rectf, ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey); - IMB_freeImBuf(ibuf); + memcpy(rr->rectf, linear_ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey); + + IMB_freeImBuf(linear_ibuf); } } else if (view_context) { @@ -181,7 +190,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) } if ((scene->r.mode & R_OSA) == 0) { - ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE); + ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE, FALSE); GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, rr->rectf); } else { @@ -195,7 +204,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) BLI_jitter_init(jit_ofs[0], scene->r.osa); /* first sample buffer, also initializes 'rv3d->persmat' */ - ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE); + ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE, FALSE); GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_buffer); /* skip the first sample */ @@ -205,7 +214,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) (jit_ofs[j][0] * 2.0f) / sizex, (jit_ofs[j][1] * 2.0f) / sizey); - ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter, TRUE); + ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter, TRUE, FALSE); GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_tmp); add_vn_vn(accum_buffer, accum_tmp, sizex * sizey * sizeof(float)); } @@ -221,7 +230,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) else { /* shouldnt suddenly give errors mid-render but possible */ char err_out[256] = "unknown"; - ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, err_out); + ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, FALSE, err_out); camera = scene->camera; if (ibuf_view) { @@ -233,27 +242,27 @@ static void screen_opengl_render_apply(OGLRender *oglrender) } } - /* rr->rectf is now filled with image data */ - - if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) - BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4); - /* note on color management: * * OpenGL renders into sRGB colors, but render buffers are expected to be - * linear if color management is enabled. So we convert to linear here, so - * the conversion back to bytes using the color management flag can make it - * sRGB again, and so that e.g. openexr saving also saves the correct linear - * float buffer. */ + * linear So we convert to linear here, so the conversion back to bytes can make it + * sRGB (or other display space) again, and so that e.g. openexr saving also saves the + * correct linear float buffer. + */ - if (oglrender->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) { - int predivide = 0; /* no alpha */ + if (!oglrender->is_sequencer) { + /* sequencer has got tricker ocnversion happened above */ IMB_buffer_float_from_float(rr->rectf, rr->rectf, - 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide, + 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, FALSE, oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex); } + /* rr->rectf is now filled with image data */ + + if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) + BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4); + RE_ReleaseResult(oglrender->re); /* update byte from float buffer */ @@ -536,12 +545,28 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock); if (ibuf) { + int needs_free = FALSE; + + if (is_movie || !BKE_imtype_supports_float(scene->r.im_format.imtype)) { + ImBuf *colormanage_ibuf = IMB_dupImBuf(ibuf); + + IMB_display_buffer_to_imbuf_rect(colormanage_ibuf, &scene->view_settings, &scene->display_settings); + imb_freerectfloatImBuf(colormanage_ibuf); + + // IMB_freeImBuf(ibuf); /* owned by the image */ + ibuf = colormanage_ibuf; + needs_free = TRUE; + } + /* color -> grayscale */ /* editing directly would alter the render view */ if (scene->r.im_format.planes == R_IMF_PLANES_BW) { - ImBuf *ibuf_bw = IMB_dupImBuf(ibuf); + ImBuf *ibuf_bw = IMB_dupImBuf(ibuf); IMB_color_to_bw(ibuf_bw); - // IMB_freeImBuf(ibuf); /* owned by the image */ + + if (needs_free) + IMB_freeImBuf(ibuf); + ibuf = ibuf_bw; } else { @@ -551,6 +576,13 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) ibuf_cpy->rect = ibuf->rect; ibuf_cpy->rect_float = ibuf->rect_float; ibuf_cpy->zbuf_float = ibuf->zbuf_float; + + if (needs_free) { + ibuf_cpy->mall = ibuf->mall; + ibuf->mall = 0; + IMB_freeImBuf(ibuf); + } + ibuf = ibuf_cpy; } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 068a7aaa50a..6b6018e51d2 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -64,6 +64,7 @@ #include "BKE_brush.h" #include "BKE_context.h" +#include "BKE_colortools.h" #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_idprop.h" @@ -75,11 +76,13 @@ #include "BKE_material.h" #include "BKE_node.h" #include "BKE_object.h" +#include "BKE_scene.h" #include "BKE_texture.h" #include "BKE_world.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -115,7 +118,8 @@ ImBuf *get_brush_icon(Brush *brush) BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath)); BLI_path_abs(path, G.main->name); - brush->icon_imbuf = IMB_loadiffname(path, flags); + /* use default colorspaces for brushes */ + brush->icon_imbuf = IMB_loadiffname(path, flags, NULL); // otherwise lets try to find it in other directories if (!(brush->icon_imbuf)) { @@ -123,8 +127,10 @@ ImBuf *get_brush_icon(Brush *brush) BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath); - if (path[0]) - brush->icon_imbuf = IMB_loadiffname(path, flags); + if (path[0]) { + /* use fefault color spaces */ + brush->icon_imbuf = IMB_loadiffname(path, flags, NULL); + } } if (brush->icon_imbuf) @@ -254,6 +260,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } sce->r.color_mgt_flag = scene->r.color_mgt_flag; + BKE_color_managed_display_settings_copy(&sce->display_settings, &scene->display_settings); + + BKE_color_managed_view_settings_free(&sce->view_settings); + BKE_color_managed_view_settings_copy(&sce->view_settings, &scene->view_settings); /* prevent overhead for small renders and icons (32) */ if (id && sp->sizex < 40) @@ -263,7 +273,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre /* exception: don't color manage texture previews or icons */ if ((id && sp->pr_method == PR_ICON_RENDER) || id_type == ID_TE) - sce->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT; + BKE_scene_disable_color_management(sce); if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO) sce->r.alphamode = R_ALPHAPREMUL; @@ -475,13 +485,13 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int char name[32]; int do_gamma_correct = FALSE, do_predivide = FALSE; int offx = 0; - int newx = BLI_RCT_SIZE_X(rect); - int newy = BLI_RCT_SIZE_Y(rect); + int newx = BLI_rcti_size_x(rect); + int newy = BLI_rcti_size_y(rect); if (id && GS(id->name) != ID_TE) { /* exception: don't color manage texture previews - show the raw values */ if (sce) { - do_gamma_correct = sce->r.color_mgt_flag & R_COLOR_MANAGEMENT; + do_gamma_correct = TRUE; do_predivide = sce->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE; } } @@ -514,15 +524,25 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int /* temporary conversion to byte for drawing */ float fx = rect->xmin + offx; float fy = rect->ymin; - int profile_from = (do_gamma_correct) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB; int dither = 0; unsigned char *rect_byte; rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect"); - IMB_buffer_byte_from_float(rect_byte, rres.rectf, - 4, dither, IB_PROFILE_SRGB, profile_from, do_predivide, - rres.rectx, rres.recty, rres.rectx, rres.rectx); + if (do_gamma_correct) { + IMB_display_buffer_transform_apply(rect_byte, rres.rectf, rres.rectx, rres.recty, 4, + &sce->view_settings, &sce->display_settings, do_predivide); + + } + else { + /* OCIO_TODO: currently seems an exception for textures (came fro mlegacish time), + * but is it indeed expected behavior, or textures should be + * color managed as well? + */ + IMB_buffer_byte_from_float(rect_byte, rres.rectf, + 4, dither, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, do_predivide, + rres.rectx, rres.recty, rres.rectx, rres.rectx); + } glaDrawPixelsSafe(fx, fy, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect_byte); @@ -549,8 +569,8 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r SpaceButs *sbuts = sa->spacedata.first; rcti newrect; int ok; - int newx = BLI_RCT_SIZE_X(rect); - int newy = BLI_RCT_SIZE_Y(rect); + int newx = BLI_rcti_size_x(rect); + int newy = BLI_rcti_size_y(rect); newrect.xmin = rect->xmin; newrect.xmax = rect->xmin; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 0bfe5d04e5e..d14514546f5 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -104,8 +104,8 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct) void ED_region_pixelspace(ARegion *ar) { - int width = BLI_RCT_SIZE_X(&ar->winrct) + 1; - int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + int width = BLI_rcti_size_x(&ar->winrct) + 1; + int height = BLI_rcti_size_y(&ar->winrct) + 1; wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); glLoadIdentity(); @@ -901,10 +901,10 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) static int rct_fits(rcti *rect, char dir, int size) { if (dir == 'h') { - return BLI_RCT_SIZE_X(rect) - size; + return BLI_rcti_size_x(rect) - size; } else { /* 'v' */ - return BLI_RCT_SIZE_Y(rect) - size; + return BLI_rcti_size_y(rect) - size; } } @@ -1010,7 +1010,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int if (alignment == RGN_ALIGN_HSPLIT) { if (rct_fits(remainder, 'h', prefsizex) > 4) { - ar->winrct.xmax = BLI_RCT_CENTER_X(remainder); + ar->winrct.xmax = BLI_rcti_cent_x(remainder); remainder->xmin = ar->winrct.xmax + 1; } else { @@ -1019,7 +1019,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } else { if (rct_fits(remainder, 'v', prefsizey) > 4) { - ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder); + ar->winrct.ymax = BLI_rcti_cent_y(remainder); remainder->ymin = ar->winrct.ymax + 1; } else { @@ -1051,20 +1051,20 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } if (quad) { if (quad == 1) { /* left bottom */ - ar->winrct.xmax = BLI_RCT_CENTER_X(remainder); - ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder); + ar->winrct.xmax = BLI_rcti_cent_x(remainder); + ar->winrct.ymax = BLI_rcti_cent_y(remainder); } else if (quad == 2) { /* left top */ - ar->winrct.xmax = BLI_RCT_CENTER_X(remainder); - ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1; + ar->winrct.xmax = BLI_rcti_cent_x(remainder); + ar->winrct.ymin = BLI_rcti_cent_y(remainder) + 1; } else if (quad == 3) { /* right bottom */ - ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1; - ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder); + ar->winrct.xmin = BLI_rcti_cent_x(remainder) + 1; + ar->winrct.ymax = BLI_rcti_cent_y(remainder); } else { /* right top */ - ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1; - ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1; + ar->winrct.xmin = BLI_rcti_cent_x(remainder) + 1; + ar->winrct.ymin = BLI_rcti_cent_y(remainder) + 1; BLI_rcti_init(remainder, 0, 0, 0, 0); } @@ -1073,8 +1073,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } /* for speedup */ - ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; - ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + ar->winx = BLI_rcti_size_x(&ar->winrct) + 1; + ar->winy = BLI_rcti_size_y(&ar->winrct) + 1; /* set winrect for azones */ if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { @@ -1096,8 +1096,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int if (ar->alignment & RGN_SPLIT_PREV) { if (ar->prev) { remainder = remainder_prev; - ar->prev->winx = BLI_RCT_SIZE_X(&ar->prev->winrct) + 1; - ar->prev->winy = BLI_RCT_SIZE_Y(&ar->prev->winrct) + 1; + ar->prev->winx = BLI_rcti_size_x(&ar->prev->winrct) + 1; + ar->prev->winy = BLI_rcti_size_y(&ar->prev->winrct) + 1; } } @@ -1133,8 +1133,8 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) else sa->totrct.ymax = sa->v2->vec.y; /* for speedup */ - sa->winx = BLI_RCT_SIZE_X(&sa->totrct) + 1; - sa->winy = BLI_RCT_SIZE_Y(&sa->totrct) + 1; + sa->winx = BLI_rcti_size_x(&sa->totrct) + 1; + sa->winy = BLI_rcti_size_y(&sa->totrct) + 1; } @@ -1268,8 +1268,8 @@ void ED_region_init(bContext *C, ARegion *ar) /* refresh can be called before window opened */ region_subwindow(CTX_wm_window(C), ar); - ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; - ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + ar->winx = BLI_rcti_size_x(&ar->winrct) + 1; + ar->winy = BLI_rcti_size_y(&ar->winrct) + 1; /* UI convention */ wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f); @@ -1574,7 +1574,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * newcontext = UI_view2d_tab_set(v2d, contextnr); if (vertical) { - w = BLI_RCT_SIZE_X(&v2d->cur); + w = BLI_rctf_size_x(&v2d->cur); em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y; } else { @@ -1769,7 +1769,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_RCT_SIZE_Y(&ar->v2d.tot)); + UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_rctf_size_y(&ar->v2d.tot)); /* restore view matrix? */ UI_view2d_view_restore(C); @@ -1798,16 +1798,16 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) /* background box */ rect = ar->winrct; rect.xmin = 0; - rect.ymin = BLI_RCT_SIZE_Y(&ar->winrct) - header_height; + rect.ymin = BLI_rcti_size_y(&ar->winrct) - header_height; if (block) { - rect.xmax = BLI_RCT_SIZE_X(&ar->winrct); + rect.xmax = BLI_rcti_size_x(&ar->winrct); } else { rect.xmax = rect.xmin + BLF_width(fontid, text) + 24; } - rect.ymax = BLI_RCT_SIZE_Y(&ar->winrct); + rect.ymax = BLI_rcti_size_y(&ar->winrct); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index c93f4156eeb..24053d76672 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -669,8 +669,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo void glaDefine2DArea(rcti *screen_rect) { - const int sc_w = BLI_RCT_SIZE_X(screen_rect) + 1; - const int sc_h = BLI_RCT_SIZE_Y(screen_rect) + 1; + const int sc_w = BLI_rcti_size_x(screen_rect) + 1; + const int sc_h = BLI_rcti_size_y(screen_rect) + 1; glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); @@ -714,10 +714,10 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) di->world_rect = *rect; - sc_w = BLI_RCT_SIZE_X(&di->screen_rect); - sc_h = BLI_RCT_SIZE_Y(&di->screen_rect); - wo_w = BLI_RCT_SIZE_X(&di->world_rect); - wo_h = BLI_RCT_SIZE_Y(&di->world_rect); + sc_w = BLI_rcti_size_x(&di->screen_rect); + sc_h = BLI_rcti_size_y(&di->screen_rect); + wo_w = BLI_rcti_size_x(&di->world_rect); + wo_h = BLI_rcti_size_y(&di->world_rect); di->wo_to_sc[0] = sc_w / wo_w; di->wo_to_sc[1] = sc_h / wo_h; @@ -745,10 +745,10 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) di->world_rect.ymax = di->screen_rect.ymax; } - sc_w = BLI_RCT_SIZE_X(&di->screen_rect); - sc_h = BLI_RCT_SIZE_Y(&di->screen_rect); - wo_w = BLI_RCT_SIZE_X(&di->world_rect); - wo_h = BLI_RCT_SIZE_Y(&di->world_rect); + sc_w = BLI_rcti_size_x(&di->screen_rect); + sc_h = BLI_rcti_size_y(&di->screen_rect); + wo_w = BLI_rcti_size_x(&di->world_rect); + wo_h = BLI_rcti_size_y(&di->world_rect); di->wo_to_sc[0] = sc_w / wo_w; di->wo_to_sc[1] = sc_h / wo_h; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 11d32e11cd0..2e1723027b8 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -40,6 +40,7 @@ #include "BLI_utildefines.h" #include "BKE_context.h" +#include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" @@ -704,10 +705,6 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) /* *********************** DRAWING **************************************** */ - -#define SCR_BACK 0.55 -#define SCR_ROUND 12 - /* draw vertical shape visualizing future joining (left as well * right direction of future joining) */ static void draw_horizontal_join_shape(ScrArea *sa, char dir) @@ -1506,6 +1503,7 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) CTX_data_scene_set(C, scene); BKE_scene_set_background(bmain, scene); + DAG_on_visible_update(bmain, FALSE); ED_render_engine_changed(bmain); ED_update_for_newframe(bmain, scene, 1); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 50a210e5d7c..c64a4a37f3a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -372,6 +372,21 @@ int ED_operator_posemode_exclusive(bContext *C) return 0; } +/* allows for pinned pose objects to be used in the object buttons + * and the the non-active pose object to be used in the 3D view */ +int ED_operator_posemode_context(bContext *C) +{ + Object *obpose = ED_pose_object_from_context(C); + + if (obpose && !(obpose->mode & OB_MODE_EDIT)) { + if (BKE_object_pose_context_check(obpose)) { + return 1; + } + } + + return 0; +} + int ED_operator_posemode(bContext *C) { Object *obact = CTX_data_active_object(C); @@ -1196,9 +1211,6 @@ static void SCREEN_OT_area_move(wmOperatorType *ot) * call exit() or cancel() and remove handler */ -#define SPLIT_STARTED 1 -#define SPLIT_PROGRESS 2 - typedef struct sAreaSplitData { int x, y; /* last used mouse position */ @@ -1635,10 +1647,10 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) int dist; if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { - dist = BLI_RCT_SIZE_X(&sa->totrct); + dist = BLI_rcti_size_x(&sa->totrct); } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ - dist = BLI_RCT_SIZE_Y(&sa->totrct); + dist = BLI_rcti_size_y(&sa->totrct); } /* subtractwidth of regions on opposite side @@ -2850,35 +2862,40 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot) } /* ************** header tools operator ***************************** */ - -static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) +void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - uiPopupMenu *pup; - uiLayout *layout; - - pup = uiPupMenuBegin(C, "Header", ICON_NONE); - layout = uiPupMenuLayout(pup); - - // XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator + + /* XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator. */ if (ar->alignment == RGN_ALIGN_TOP) - uiItemO(layout, "Flip to Bottom", ICON_NONE, "SCREEN_OT_header_flip"); + uiItemO(layout, IFACE_("Flip to Bottom"), ICON_NONE, "SCREEN_OT_header_flip"); else - uiItemO(layout, "Flip to Top", ICON_NONE, "SCREEN_OT_header_flip"); - + uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip"); + uiItemS(layout); - + /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */ if (sa->spacetype != SPACE_FILE) { if (sa->full) - uiItemO(layout, "Tile Area", ICON_NONE, "SCREEN_OT_screen_full_area"); + uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area"); else - uiItemO(layout, "Maximize Area", ICON_NONE, "SCREEN_OT_screen_full_area"); + uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area"); } - +} + +static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) +{ + uiPopupMenu *pup; + uiLayout *layout; + + pup = uiPupMenuBegin(C, N_("Header"), ICON_NONE); + layout = uiPupMenuLayout(pup); + + ED_screens_header_tools_menu_create(C, layout, NULL); + uiPupMenuEnd(C, pup); - + return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 4e71c49465f..aeae79aa9d0 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -149,8 +149,8 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop) { unsigned int *to = ibuf->rect; unsigned int *from = ibuf->rect + crop.ymin * ibuf->x + crop.xmin; - int crop_x = BLI_RCT_SIZE_X(&crop); - int crop_y = BLI_RCT_SIZE_Y(&crop); + int crop_x = BLI_rcti_size_x(&crop); + int crop_y = BLI_rcti_size_y(&crop); int y; if (crop_x > 0 && crop_y > 0) { @@ -245,7 +245,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op) /* image template */ RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr); - uiTemplateImageSettings(layout, &ptr); + uiTemplateImageSettings(layout, &ptr, FALSE); /* main draw call */ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 8616d4e66eb..e14266c83a7 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -322,8 +322,8 @@ static int project_brush_radius(ViewContext *vc, add_v3_v3v3(offset, location, ortho); /* project the center of the brush, and the tangent point to the view onto the screen */ - project_float(vc->ar, location, p1); - project_float(vc->ar, offset, p2); + ED_view3d_project_float(vc->ar, location, p1); + ED_view3d_project_float(vc->ar, offset, p2); /* the distance between these points is the size of the projected brush in pixels */ return len_v2v2(p1, p2); @@ -441,8 +441,8 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, else { quad.xmin = 0; quad.ymin = 0; - quad.xmax = BLI_RCT_SIZE_X(&vc->ar->winrct); - quad.ymax = BLI_RCT_SIZE_Y(&vc->ar->winrct); + quad.xmax = BLI_rcti_size_x(&vc->ar->winrct); + quad.ymax = BLI_rcti_size_y(&vc->ar->winrct); } /* set quad color */ diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index e809267d076..2970bdfb5a4 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -251,7 +251,7 @@ static void clip_planes_from_rect(bContext *C, view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats); - ED_view3d_calc_clipping(&bb, clip_planes, &mats, rect); + ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect); mul_m4_fl(clip_planes, -1.0f); } @@ -388,7 +388,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) ot->modal = WM_border_select_modal; ot->exec = hide_show_exec; /* sculpt-only for now */ - ot->poll = sculpt_mode_poll; + ot->poll = sculpt_mode_poll_view3d; ot->flag = OPTYPE_REGISTER; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 7c3f376df91..b8e365c4c8e 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -104,6 +104,8 @@ #include "GPU_draw.h" #include "GPU_extensions.h" +#include "IMB_colormanagement.h" + #include "paint_intern.h" /* Defines and Structs */ @@ -139,7 +141,7 @@ #define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS) #define IMAPAINT_TILE_NUMBER(size) (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS) -static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint); +static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint); typedef struct ImagePaintState { @@ -153,7 +155,6 @@ typedef struct ImagePaintState { Image *image; ImBuf *canvas; ImBuf *clonecanvas; - short clonefreefloat; char *warnpackedfile; char *warnmultifile; @@ -239,8 +240,6 @@ typedef struct ImagePaintRegion { /* vert flags */ #define PROJ_VERT_CULL 1 -#define PI_80_DEG ((M_PI_2 / 9) * 8) - /* This is mainly a convenience struct used so we can keep an array of images we use * Thir imbufs, etc, in 1 array, When using threads this array is copied for each thread * because 'partRedrawRect' and 'touch' values would not be thread safe */ @@ -510,7 +509,7 @@ static void image_undo_restore(bContext *C, ListBase *lb) ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ - + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; } IMB_freeImBuf(tmpibuf); @@ -3137,7 +3136,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->is_ortho = params.is_ortho; } - /* same as view3d_get_object_project_mat */ + /* same as #ED_view3d_ob_project_mat_get */ mult_m4_m4m4(vmat, viewmat, ps->ob->obmat); mult_m4_m4m4(ps->projectMat, winmat, vmat); } @@ -3615,7 +3614,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps) pr = &(projIma->partRedrawRect[i]); if (pr->x2 != -1) { /* TODO - use 'enabled' ? */ imapaintpartial = *pr; - imapaint_image_update(NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/ + imapaint_image_update(NULL, NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/ redraw = 1; } } @@ -3945,7 +3944,7 @@ static void *do_projectpaint_thread(void *ph_v) last_projIma->touch = 1; is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0; - use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0; + use_color_correction = TRUE; } /* end copy */ @@ -4028,7 +4027,7 @@ static void *do_projectpaint_thread(void *ph_v) last_projIma->touch = 1; is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0; - use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0; + use_color_correction = TRUE; } /* end copy */ @@ -4244,10 +4243,17 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, IMB_freeImBuf(tmpibuf); } -static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint) +static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint) { - if (ibuf->rect_float) - ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ + if (scene) { + IMB_partial_display_buffer_update(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect, ibuf->x, 0, 0, + &scene->view_settings, &scene->display_settings, + imapaintpartial.x1, imapaintpartial.y1, + imapaintpartial.x2, imapaintpartial.y2); + } + else { + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + } if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; @@ -4257,7 +4263,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s int w = imapaintpartial.x2 - imapaintpartial.x1; int h = imapaintpartial.y2 - imapaintpartial.y1; /* Testing with partial update in uv editor too */ - GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, 0); //!texpaint); + GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h); //!texpaint); } } @@ -4571,15 +4577,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) /* temporarily add float rect for cloning */ if (s->canvas->rect_float && !s->clonecanvas->rect_float) { - short profile = IB_PROFILE_NONE; - - /* Don't want to color manage, but don't disturb existing profiles */ - SWAP(short, s->clonecanvas->profile, profile); - IMB_float_from_rect(s->clonecanvas); - s->clonefreefloat = 1; - - SWAP(short, s->clonecanvas->profile, profile); } else if (!s->canvas->rect_float && !s->clonecanvas->rect) IMB_rect_from_float(s->clonecanvas); @@ -4588,28 +4586,32 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) return 1; } -static void imapaint_canvas_free(ImagePaintState *s) +static void imapaint_canvas_free(ImagePaintState *UNUSED(s)) { - if (s->clonefreefloat) - imb_freerectfloatImBuf(s->clonecanvas); } static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, Image *image, short texpaint, float *uv, double time, int update, float pressure) { ImBuf *ibuf = BKE_image_get_ibuf(image, s->sima ? &s->sima->iuser : NULL); float pos[2]; + int is_data; if (!ibuf) return 0; + is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA; + pos[0] = uv[0] * ibuf->x; pos[1] = uv[1] * ibuf->y; BKE_brush_painter_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0); - if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, ibuf->profile == IB_PROFILE_LINEAR_RGB)) { + /* OCIO_TODO: float buffers are now always linear, so always use color correction + * this should probably be changed when texture painting color space is supported + */ + if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, is_data == FALSE)) { if (update) - imapaint_image_update(s->sima, image, ibuf, texpaint); + imapaint_image_update(s->scene, s->sima, image, ibuf, texpaint); return 1; } else return 0; @@ -5257,7 +5259,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot) RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } -int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) +static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) { RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -5884,7 +5886,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) if (w > maxsize) w = maxsize; if (h > maxsize) h = maxsize; - ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, err_out); + ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, FALSE, err_out); if (!ibuf) { /* Mostly happens when OpenGL offscreen buffer was failed to create, */ /* but could be other reasons. Should be handled in the future. nazgul */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index cc71be4938e..39a95300d5d 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -602,7 +602,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p } } -void paint_partial_visibility_keys(wmKeyMap *keymap) +static void paint_partial_visibility_keys(wmKeyMap *keymap) { wmKeyMapItem *kmi; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index b53edeadb51..7fabaf7f23d 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -254,7 +254,10 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const pressure = event_tablet_data(event, NULL); if (pressure > FLT_EPSILON) { - scale = (BKE_brush_size_get(scene, stroke->brush) * pressure * stroke->brush->spacing / 50.0f) / length; + /* 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); + scale = (size_clamp * stroke->brush->spacing / 50.0f) / length; if (scale > FLT_EPSILON) { mul_v2_fl(vec, scale); @@ -521,8 +524,10 @@ int paint_poll(bContext *C) { Paint *p = paint_get_active_from_context(C); Object *ob = CTX_data_active_object(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); return p && ob && paint_brush(p) && - CTX_wm_area(C)->spacetype == SPACE_VIEW3D && - CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; + (sa && sa->spacetype == SPACE_VIEW3D) && + (ar && ar->regiontype == RGN_TYPE_WINDOW); } diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index df64e1c9d90..29a59651cf7 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -98,7 +98,7 @@ int paint_convert_bb_to_rect(rcti *rect, vec[1] = j ? bb_min[1] : bb_max[1]; vec[2] = k ? bb_min[2] : bb_max[2]; /* convert corner to screen space */ - ED_view3d_project_float_v2(ar, vec, proj, projection_mat); + ED_view3d_project_float_v2_m4(ar, vec, proj, projection_mat); /* expand 2D rectangle */ /* we could project directly to int? */ @@ -137,7 +137,7 @@ void paint_calc_redraw_planes(float planes[4][4], rect.ymin -= 2; rect.ymax += 2; - ED_view3d_calc_clipping(&bb, planes, &mats, &rect); + ED_view3d_clipping_calc(&bb, planes, &mats, &rect); mul_m4_fl(planes, -1.0f); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index ba440e98290..8aed92df3af 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -134,7 +134,7 @@ int vertex_paint_poll(bContext *C) paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { ScrArea *sa = CTX_wm_area(C); - if (sa->spacetype == SPACE_VIEW3D) { + if (sa && sa->spacetype == SPACE_VIEW3D) { ARegion *ar = CTX_wm_region(C); if (ar->regiontype == RGN_TYPE_WINDOW) return 1; @@ -257,7 +257,7 @@ static void do_shared_vertex_tesscol(Mesh *me) MEM_freeN(scolmain); } -void do_shared_vertexcol(Mesh *me, int do_tessface) +static void do_shared_vertexcol(Mesh *me, int do_tessface) { const int use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK); MPoly *mp; @@ -850,7 +850,7 @@ static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_n float dist_squared; float vertco[2], delta[2]; - project_float_noclip(vc->ar, vert_nor, vertco); + ED_view3d_project_float_noclip(vc->ar, vert_nor, vertco); sub_v2_v2v2(delta, mval, vertco); dist_squared = dot_v2v2(delta, delta); /* len squared */ if (dist_squared > brush_size_pressure * brush_size_pressure) { @@ -2227,19 +2227,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if (indexar[0]) totindex = 1; else totindex = 0; } - - if (wp->flag & VP_COLINDEX) { - for (index = 0; index < totindex; index++) { - if (indexar[index] && indexar[index] <= me->totpoly) { - MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 1); - - if (mpoly->mat_nr != ob->actcol - 1) { - indexar[index] = 0; - } - } - } - } - + if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { for (index = 0; index < totindex; index++) { if (indexar[index] && indexar[index] <= me->totpoly) { @@ -2639,52 +2627,13 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl return 1; } -#if 0 -static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, - const unsigned int index, const float mval[2], - const float brush_size_pressure, const float brush_alpha_pressure, - int UNUSED(flip)) +static void copy_lcol_to_mcol(MCol *mcol, const MLoopCol *lcol) { - ViewContext *vc = &vpd->vc; - Brush *brush = paint_brush(&vp->paint); - Mesh *me = BKE_mesh_from_object(ob); - MFace *mface = &me->mface[index]; - unsigned int *mcol = ((unsigned int *)me->mcol) + 4 * index; - unsigned int *mcolorig = ((unsigned int *)vp->vpaint_prev) + 4 * index; - float alpha; - int i; - - int brush_alpha_pressure_i; - - if ((vp->flag & VP_COLINDEX && mface->mat_nr != ob->actcol - 1) || - ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL))) - return; - - if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { - unsigned int fcol1 = mcol_blend(mcol[0], mcol[1], 128); - if (mface->v4) { - unsigned int fcol2 = mcol_blend(mcol[2], mcol[3], 128); - vpd->paintcol = mcol_blend(fcol1, fcol2, 128); - } - else { - vpd->paintcol = mcol_blend(mcol[2], fcol1, 170); - } - } - - brush_alpha_pressure_i = (int)(brush_alpha_pressure * 255.0f); - - for (i = 0; i < (mface->v4 ? 4 : 3); ++i) { - alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos + 6 * (&mface->v1)[i], - mval, brush_size_pressure, brush_alpha_pressure); - if (alpha) { - const int alpha_i = (int)(alpha * 255.0f); - mcol[i] = vpaint_blend(vp, mcol[i], mcolorig[i], vpd->paintcol, alpha_i, brush_alpha_pressure_i); - } - } + mcol->a = lcol->a; + mcol->r = lcol->r; + mcol->g = lcol->g; + mcol->b = lcol->b; } -#endif - -/* BMESH version of vpaint_paint_face (commented above) */ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, const unsigned int index, const float mval[2], @@ -2744,33 +2693,22 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, } if (vpd->use_fast_update) { - -#ifdef CPYCOL -# undef CPYCOL -#endif -#define CPYCOL(c, l) (c)->a = (l)->a, (c)->r = (l)->r, (c)->g = (l)->g, (c)->b = (l)->b - /* update vertex colors for tessellations incrementally, * rather then regenerating the tessellation altogether */ for (e = vpd->polyfacemap[index].first; e; e = e->next) { - mf = me->mface + e->facenr; - mc = me->mcol + e->facenr * 4; + mf = &me->mface[e->facenr]; + mc = &me->mcol[e->facenr * 4]; ml = me->mloop + mpoly->loopstart; mlc = me->mloopcol + mpoly->loopstart; for (j = 0; j < mpoly->totloop; j++, ml++, mlc++) { - if (ml->v == mf->v1) - CPYCOL(mc, mlc); - else if (ml->v == mf->v2) - CPYCOL(mc + 1, mlc); - else if (ml->v == mf->v3) - CPYCOL(mc + 2, mlc); - else if (mf->v4 && ml->v == mf->v4) - CPYCOL(mc + 3, mlc); + if (ml->v == mf->v1) copy_lcol_to_mcol(mc + 0, mlc); + else if (ml->v == mf->v2) copy_lcol_to_mcol(mc + 1, mlc); + else if (ml->v == mf->v3) copy_lcol_to_mcol(mc + 2, mlc); + else if (mf->v4 && ml->v == mf->v4) copy_lcol_to_mcol(mc + 3, mlc); } } -#undef CPYCOL } } @@ -2804,7 +2742,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P mval[0] -= vc->ar->winrct.xmin; mval[1] -= vc->ar->winrct.ymin; - + /* which faces are involved */ if (vp->flag & VP_AREA) { totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); @@ -2814,19 +2752,6 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if (indexar[0]) totindex = 1; else totindex = 0; } - - - if (vp->flag & VP_COLINDEX) { - for (index = 0; index < totindex; index++) { - if (indexar[index] && indexar[index] <= me->totpoly) { - MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 1); - - if (mpoly->mat_nr != ob->actcol - 1) { - indexar[index] = 0; - } - } - } - } if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { for (index = 0; index < totindex; index++) { @@ -2835,15 +2760,13 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if ((mpoly->flag & ME_FACE_SEL) == 0) indexar[index] = 0; - } + } } } swap_m4m4(vc->rv3d->persmat, mat); - for (index = 0; index < totindex; index++) { - if (indexar[index] && indexar[index] <= me->totpoly) { vpaint_paint_poly(vp, vpd, ob, indexar[index] - 1, mval, brush_size_pressure, brush_alpha_pressure); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 210477e3e5a..05b5b90344c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -771,7 +771,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], if (ss->cache->radial_symmetry_pass) mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point); - ED_view3d_project_float_v2(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat); + ED_view3d_project_float_v2_m4(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat); if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { /* keep coordinates relative to mouse */ @@ -2649,7 +2649,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) } if (is_basis) { - ofs = key_to_vertcos(ob, kb); + ofs = BKE_key_convert_to_vertcos(ob, kb); /* calculate key coord offsets (from previous location) */ for (a = 0; a < me->totvert; a++) { @@ -2662,7 +2662,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) int apply_offset = ((currkey != kb) && (ob->shapenr - 1 == currkey->relative)); if (apply_offset) - offset_to_key(ob, currkey, ofs); + BKE_key_convert_from_offset(ob, currkey, ofs); currkey = currkey->next; } @@ -2683,7 +2683,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) } /* apply new coords on active key block */ - vertcos_to_key(ob, kb, vertCos); + BKE_key_convert_from_vertcos(ob, kb, vertCos); } static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) @@ -3074,7 +3074,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ /* BMESH ONLY --- at some point we should move sculpt code to use polygons only - but for now it needs tessfaces */ BKE_mesh_tessface_ensure(me); - if (!mmd) ss->kb = ob_get_keyblock(ob); + if (!mmd) ss->kb = BKE_keyblock_from_object(ob); else ss->kb = NULL; /* needs to be called after we ensure tessface */ @@ -3109,7 +3109,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ free_sculptsession_deformMats(ss); - ss->orig_cos = (ss->kb) ? key_to_vertcos(ob, ss->kb) : mesh_getVertexCos(me, NULL); + ss->orig_cos = (ss->kb) ? BKE_key_convert_to_vertcos(ob, ss->kb) : mesh_getVertexCos(me, NULL); crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos); BLI_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos); @@ -3123,7 +3123,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ /* if pbvh is deformed, key block is already applied to it */ if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) { - float (*vertCos)[3] = key_to_vertcos(ob, ss->kb); + float (*vertCos)[3] = BKE_key_convert_to_vertcos(ob, ss->kb); if (vertCos) { /* apply shape keys coordinates to PBVH */ @@ -3139,6 +3139,11 @@ int sculpt_mode_poll(bContext *C) return ob && ob->mode & OB_MODE_SCULPT; } +int sculpt_mode_poll_view3d(bContext *C) +{ + return (sculpt_mode_poll(C) && CTX_wm_region_view3d(C)); +} + int sculpt_poll(bContext *C) { return sculpt_mode_poll(C) && paint_poll(C); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index f4467dc22fc..5e79616b0b0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -56,6 +56,7 @@ struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct void sculpt(struct Sculpt *sd); int sculpt_mode_poll(struct bContext *C); +int sculpt_mode_poll_view3d(struct bContext *C); int sculpt_poll(struct bContext *C); void sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob, int need_pmap); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index c62dc687c73..bb2b4b8c743 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -107,8 +107,8 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) { /* shape key has been changed before calling undo operator */ - Key *key = ob_get_key(ob); - KeyBlock *kb = key_get_named_keyblock(key, unode->shapeName); + Key *key = BKE_key_from_object(ob); + KeyBlock *kb = BKE_keyblock_find_name(key, unode->shapeName); if (kb) { ob->shapenr = BLI_findindex(&key->block, kb) + 1; @@ -127,7 +127,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo if (ss->kb) { float (*vertCos)[3]; - vertCos = key_to_vertcos(ob, ss->kb); + vertCos = BKE_key_convert_to_vertcos(ob, ss->kb); for (i = 0; i < unode->totvert; i++) { if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index fdce8ec04a4..0bcccd9479c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -156,8 +156,8 @@ typedef struct Temp_UvData { -void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float mouse_coord[2], - float alpha, float radius, float aspectRatio) +static void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float mouse_coord[2], + float alpha, float radius, float aspectRatio) { Temp_UVData *tmp_uvdata; float diff[2]; diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 878fd20b27e..10adeb3e721 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -89,7 +89,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) * start of list offset, and the second is as a correction for the scrollers. */ height = ((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); - if (height > BLI_RCT_SIZE_Y(&v2d->mask)) { + if (height > BLI_rcti_size_y(&v2d->mask)) { /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index c95f1dba31d..7635f85a37e 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -365,13 +365,13 @@ static int actkeys_viewall(bContext *C, const short onlySel) /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel); - extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur); + extra = 0.1f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; /* set vertical range */ v2d->cur.ymax = 0.0f; - v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask); + v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask); /* do View2D syncing */ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 9ab79d73e76..5da348b2a84 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -309,7 +309,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... */ - if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect)) + if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect)) mode = ACTKEYS_BORDERSEL_FRAMERANGE; else mode = ACTKEYS_BORDERSEL_CHANNELS; @@ -912,9 +912,6 @@ void ACTION_OT_select_leftright(wmOperatorType *ot) * selection mode between replacing the selection (without) and inverting the selection (with). */ -/* sensitivity factor for frame-selections */ -#define FRAME_CLICK_THRESH 0.1f - /* ------------------- */ /* option 1) select keyframe directly under mouse */ diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 4bcd4a933ed..ebba7d92819 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -148,7 +148,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockEndAlign(block); /* always as last */ - UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_RCT_SIZE_Y(&ar->v2d.tot)); + UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_rctf_size_y(&ar->v2d.tot)); uiEndBlock(C, block); uiDrawBlock(C, block); diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index e66faa88b93..969b0e25928 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -119,6 +119,8 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL); if (clip) { + uiLayout *col; + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, ""); @@ -129,6 +131,9 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload"); + + col = uiLayoutColumn(layout, FALSE); + uiTemplateColorspaceSettings(col, &clipptr, "colorspace_settings"); } } @@ -169,7 +174,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->track_preview_height = (scopes->track_preview_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->track_preview_height; - uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), + uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); } diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 5d890155e25..cc1b8d444bc 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -274,7 +274,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) dopesheet = &tracking->dopesheet; height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2); - if (height > BLI_RCT_SIZE_Y(&v2d->mask)) { + if (height > BLI_rcti_size_y(&v2d->mask)) { /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 2353f8f8c12..b22c9a60bdc 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -42,6 +42,7 @@ #include "BKE_tracking.h" #include "BKE_mask.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -246,14 +247,7 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) ED_region_info_draw(ar, str, block, 0.6f); } -static void verify_buffer_float(ImBuf *ibuf) -{ - if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID))) { - IMB_rect_from_float(ibuf); - } -} - -static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, +static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf, int width, int height, float zoomx, float zoomy) { int x, y; @@ -267,13 +261,16 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, glRectf(x, y, x + zoomx * width, y + zoomy * height); } else { - verify_buffer_float(ibuf); + unsigned char *display_buffer; + void *cache_handle; + + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - if (ibuf->rect) { + if (display_buffer) { int need_fallback = 1; if (ED_space_clip_texture_buffer_supported(sc)) { - if (ED_space_clip_load_movieclip_buffer(sc, ibuf)) { + if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) { glPushMatrix(); glTranslatef(x, y, 0.0f); glScalef(zoomx, zoomy, 1.0f); @@ -299,12 +296,14 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, /* set zoom */ glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); /* reset zoom */ glPixelZoom(1.0f, 1.0f); } } + + IMB_display_buffer_release(cache_handle); } /* draw boundary border for frame if stabilization is enabled */ @@ -958,12 +957,12 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony) { /* express given coordinates as proportional values */ - x = -v2d->cur.xmin / BLI_RCT_SIZE_X(&v2d->cur); - y = -v2d->cur.ymin / BLI_RCT_SIZE_Y(&v2d->cur); + x = -v2d->cur.xmin / BLI_rctf_size_x(&v2d->cur); + y = -v2d->cur.ymin / BLI_rctf_size_y(&v2d->cur); /* convert proportional distances to screen coordinates */ - *regionx = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask); - *regiony = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask); + *regionx = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask); + *regiony = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask); } static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, @@ -1461,7 +1460,7 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar) } if (ibuf) { - draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy); + draw_movieclip_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy); IMB_freeImBuf(ibuf); } else { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 08ad6aac970..32f91671daf 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -149,8 +149,8 @@ void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoo ED_space_clip_get_size(sc, &width, &height); - *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width); - *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height); + *zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / (BLI_rctf_size_x(&ar->v2d.cur) * width); + *zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / (BLI_rctf_size_y(&ar->v2d.cur) * height); } void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy) @@ -277,13 +277,7 @@ int ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_ if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - /* IB_PROFILE_NONE is default but infact its linear */ - if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) { - linearrgb_to_srgb_v3_v3(r_col, fp); - } - else { - copy_v3_v3(r_col, fp); - } + linearrgb_to_srgb_v3_v3(r_col, fp); ret = TRUE; } else if (ibuf->rect) { @@ -394,8 +388,8 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) ED_space_clip_get_aspect(sc, &aspx, &aspy); - width = BLI_RCT_SIZE_X(&ar->winrct) + 1; - height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + width = BLI_rcti_size_x(&ar->winrct) + 1; + height = BLI_rcti_size_y(&ar->winrct) + 1; zoomx = (float)width / w / aspx; zoomy = (float)height / h / aspy; @@ -583,12 +577,15 @@ typedef struct SpaceClipDrawContext { GLuint texture; /* OGL texture ID */ short texture_allocated; /* flag if texture was allocated by glGenTextures */ struct ImBuf *texture_ibuf; /* image buffer for which texture was created */ + const unsigned char *display_buffer; /* display buffer for which texture was created */ int image_width, image_height; /* image width and height for which texture was created */ unsigned last_texture; /* ID of previously used texture, so it'll be restored after clip drawing */ /* fields to check if cache is still valid */ int framenr, start_frame, frame_offset; short render_size, render_flag; + + char colorspace[64]; } SpaceClipDrawContext; int ED_space_clip_texture_buffer_supported(SpaceClip *sc) @@ -613,7 +610,7 @@ int ED_space_clip_texture_buffer_supported(SpaceClip *sc) return context->buffers_supported; } -int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) +int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf, const unsigned char *display_buffer) { SpaceClipDrawContext *context = sc->draw_context; MovieClip *clip = ED_space_clip_get_clip(sc); @@ -625,12 +622,22 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) * assuming displaying happens of footage frames only on which painting doesn't heppen. * so not changed image buffer pointer means unchanged image content */ need_rebind |= context->texture_ibuf != ibuf; + need_rebind |= context->display_buffer != display_buffer; need_rebind |= context->framenr != sc->user.framenr; need_rebind |= context->render_size != sc->user.render_size; need_rebind |= context->render_flag != sc->user.render_flag; need_rebind |= context->start_frame != clip->start_frame; need_rebind |= context->frame_offset != clip->frame_offset; + if (!need_rebind) { + /* OCIO_TODO: not entirely nice, but currently it seems to be easiest way + * to deal with changing input color space settings + * pointer-based check could fail due to new buffers could be + * be allocated on on old memory + */ + need_rebind = strcmp(context->colorspace, clip->colorspace_settings.name) != 0; + } + if (need_rebind) { int width = ibuf->x, height = ibuf->y; int need_recreate = 0; @@ -670,16 +677,12 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) glBindTexture(GL_TEXTURE_2D, context->texture); } - if (ibuf->rect_float) { - if (ibuf->rect == NULL) - IMB_rect_from_float(ibuf); - } - - if (ibuf->rect) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + if (display_buffer) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); /* store settings */ context->texture_allocated = 1; + context->display_buffer = display_buffer; context->texture_ibuf = ibuf; context->image_width = ibuf->x; context->image_height = ibuf->y; @@ -688,6 +691,8 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) context->render_flag = sc->user.render_flag; context->start_frame = clip->start_frame; context->frame_offset = clip->frame_offset; + + strcpy(context->colorspace, clip->colorspace_settings.name); } else { /* displaying exactly the same image which was loaded t oa texture, diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 91501971d9d..7b070fde6ba 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -94,7 +94,7 @@ static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack glVertex2f(scene_framenr, val); } -void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord) +static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord) { static float colors[2][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}}; @@ -116,7 +116,7 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co glBegin(GL_LINE_STRIP); } -void tracking_segment_end_cb(void *UNUSED(userdata)) +static void tracking_segment_end_cb(void *UNUSED(userdata)) { glEnd(); diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 71dcd326887..fa235bd2997 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -130,7 +130,7 @@ static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack copy_v2_v2(data->prev_co, co); } -void find_nearest_tracking_segment_end_cb(void *userdata) +static void find_nearest_tracking_segment_end_cb(void *userdata) { MouseSelectUserData *data = userdata; @@ -580,11 +580,11 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) } /* we need an extra "buffer" factor on either side so that the endpoints are visible */ - extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur); + extra = 0.01f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - extra = 0.01f * BLI_RCT_SIZE_Y(&v2d->cur); + extra = 0.01f * BLI_rctf_size_y(&v2d->cur); v2d->cur.ymin -= extra; v2d->cur.ymax += extra; @@ -610,7 +610,7 @@ void CLIP_OT_graph_view_all(wmOperatorType *ot) void ED_clip_graph_center_current_frame(Scene *scene, ARegion *ar) { View2D *v2d = &ar->v2d; - float extra = BLI_RCT_SIZE_X(&v2d->cur) / 2.0f; + float extra = BLI_rctf_size_x(&v2d->cur) / 2.0f; /* set extents of view to start/end frames */ v2d->cur.xmin = (float)CFRA - extra; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index aa2cadbd2d3..5c338f3e6f1 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -90,9 +90,9 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) if ((width < 4) && (height < 4)) sc->zoom = oldzoom; - else if (BLI_RCT_SIZE_X(&ar->winrct) <= sc->zoom) + else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; - else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sc->zoom) + else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; } @@ -726,8 +726,8 @@ static int view_all_exec(bContext *C, wmOperator *op) h = h * aspy; /* check if the image will fit in the image with zoom == 1 */ - width = BLI_RCT_SIZE_X(&ar->winrct) + 1; - height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + width = BLI_rcti_size_x(&ar->winrct) + 1; + height = BLI_rcti_size_y(&ar->winrct) + 1; if (fit_view) { const int margin = 5; /* margin from border */ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 7f43c404095..3f925df30c7 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1036,8 +1036,8 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) if (clip) h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect; - winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; - winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + winx = BLI_rcti_size_x(&ar->winrct) + 1; + winy = BLI_rcti_size_y(&ar->winrct) + 1; ar->v2d.tot.xmin = 0; ar->v2d.tot.ymin = 0; diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index a4f7e30ed7b..b7ef278275e 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -142,7 +142,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) /* always keep the bottom part of the view aligned, less annoying */ if (prev_y_min != ar->v2d.cur.ymin) { - const float cur_y_range = BLI_RCT_SIZE_Y(&ar->v2d.cur); + const float cur_y_range = BLI_rctf_size_y(&ar->v2d.cur); ar->v2d.cur.ymin = prev_y_min; ar->v2d.cur.ymax = prev_y_min + cur_y_range; } diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index a07a560328c..e5c6a839380 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -66,6 +66,7 @@ void FILE_OT_select_border(struct wmOperatorType *ot); void FILE_OT_select_bookmark(struct wmOperatorType *ot); void FILE_OT_bookmark_add(struct wmOperatorType *ot); void FILE_OT_delete_bookmark(struct wmOperatorType *ot); +void FILE_OT_reset_recent(wmOperatorType *ot); void FILE_OT_hidedot(struct wmOperatorType *ot); void FILE_OT_execute(struct wmOperatorType *ot); void FILE_OT_cancel(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 040f276940d..fcbeb064e4d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -64,11 +64,6 @@ #include <stdio.h> #include <ctype.h> -/* for events */ -#define NOTACTIVEFILE 0 -#define ACTIVATE 1 -#define INACTIVATE 2 - /* ---------- FILE SELECTION ------------ */ static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect) { @@ -459,7 +454,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) if (params->dir[0] != '\0') { char name[FILE_MAX]; - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, FS_INSERT_SAVE); BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); } @@ -515,6 +510,35 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000); } +static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op)) +{ + ScrArea *sa = CTX_wm_area(C); + char name[FILE_MAX]; + struct FSMenu *fsmenu = fsmenu_get(); + + while (fsmenu_get_entry(fsmenu, FS_CATEGORY_RECENT, 0) != NULL) { + fsmenu_remove_entry(fsmenu, FS_CATEGORY_RECENT, 0); + } + BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); + fsmenu_write_file(fsmenu, name); + ED_area_tag_redraw(sa); + + return OPERATOR_FINISHED; +} + +void FILE_OT_reset_recent(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Reset Recent"; + ot->description = "Reset Recent files"; + ot->idname = "FILE_OT_reset_recent"; + + /* api callbacks */ + ot->exec = reset_recent_exec; + ot->poll = ED_operator_file_active; + +} + int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { View2D *v2d = &ar->v2d; @@ -770,8 +794,9 @@ int file_exec(bContext *C, wmOperator *exec_op) file_sfile_to_operator(op, sfile, filepath); - if (BLI_exists(sfile->params->dir)) - fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, 0, 1); + if (BLI_exists(sfile->params->dir)) { + fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, FS_INSERT_SAVE | FS_INSERT_FIRST); + } BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu_get(), filepath); diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 51bd660e126..a7054909aaa 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -67,14 +67,14 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v)) WM_operator_properties_free(&ptr); } -static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete, int reverse) +static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete) { SpaceFile *sfile = CTX_wm_space_file(C); uiBlock *block; uiBut *but; uiLayout *box, *col; struct FSMenu *fsmenu = fsmenu_get(); - int i, i_iter, nentries = fsmenu_get_nentries(fsmenu, category); + int i, nentries = fsmenu_get_nentries(fsmenu, category); /* reset each time */ *nr = -1; @@ -89,13 +89,11 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat box = uiLayoutBox(pa->layout); col = uiLayoutColumn(box, TRUE); - for (i_iter = 0; i_iter < nentries; ++i_iter) { + for (i = 0; i < nentries; ++i) { char dir[FILE_MAX]; char temp[FILE_MAX]; uiLayout *layout = uiLayoutRow(col, FALSE); char *entry; - - i = reverse ? nentries - (i_iter + 1) : i_iter; entry = fsmenu_get_entry(fsmenu, category, i); @@ -134,7 +132,7 @@ static void file_panel_system(const bContext *C, Panel *pa) SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) - file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0); + file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0); } static void file_panel_bookmarks(const bContext *C, Panel *pa) @@ -147,17 +145,22 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa) uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add"); uiItemL(row, NULL, ICON_NONE); - file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, &sfile->bookmarknr, ICON_BOOKMARKS, 1, 0); + file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, &sfile->bookmarknr, ICON_BOOKMARKS, 1); } } static void file_panel_recent(const bContext *C, Panel *pa) { SpaceFile *sfile = CTX_wm_space_file(C); + uiLayout *row; if (sfile) { if (!(U.uiflag & USER_HIDE_RECENT) ) { - file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0, 1); + row = uiLayoutRow(pa->layout, FALSE); + uiItemO(row, IFACE_("Reset"), ICON_X, "file.reset_recent"); + uiItemL(row, NULL, ICON_NONE); + + file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0); } } } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 4abe41d5714..699cb9b4feb 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -389,7 +389,7 @@ void filelist_init_icons(void) #ifdef WITH_HEADLESS bbuf = NULL; #else - bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, "<splash>"); + bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, "<splash>"); #endif if (bbuf) { for (y = 0; y < SPECIAL_IMG_ROWS; y++) { diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 09231efd367..1fa89e5db9a 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -270,12 +270,12 @@ int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *ar) int numfiles; if (layout->flag & FILE_LAYOUT_HOR) { - int width = (int)(BLI_RCT_SIZE_X(&ar->v2d.cur) - 2 * layout->tile_border_x); + int width = (int)(BLI_rctf_size_x(&ar->v2d.cur) - 2 * layout->tile_border_x); numfiles = (int)((float)width / (float)layout->tile_w + 0.5f); return numfiles * layout->rows; } else { - int height = (int)(BLI_RCT_SIZE_Y(&ar->v2d.cur) - 2 * layout->tile_border_y); + int height = (int)(BLI_rctf_size_y(&ar->v2d.cur) - 2 * layout->tile_border_y); numfiles = (int)((float)height / (float)layout->tile_h + 0.5f); return numfiles * layout->columns; } @@ -503,7 +503,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->prv_border_y = 6; layout->tile_w = layout->prv_w + 2 * layout->prv_border_x; layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight; - layout->width = (int)(BLI_RCT_SIZE_X(&v2d->cur) - 2 * layout->tile_border_x); + layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x); layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x); if (layout->columns > 0) layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero @@ -522,7 +522,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->prv_border_x = 0; layout->prv_border_y = 0; layout->tile_h = textheight * 3 / 2; - layout->height = (int)(BLI_RCT_SIZE_Y(&v2d->cur) - 2 * layout->tile_border_y); + layout->height = (int)(BLI_rctf_size_y(&v2d->cur) - 2 * layout->tile_border_y); layout->rows = layout->height / (layout->tile_h + 2 * layout->tile_border_y); column_widths(sfile->files, layout); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index a127e2ca2bc..66cda3082ea 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -97,84 +97,94 @@ FSMenu *fsmenu_get(void) static FSMenuEntry *fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory category) { - FSMenuEntry *fsms = NULL; + FSMenuEntry *fsm_head = NULL; switch (category) { case FS_CATEGORY_SYSTEM: - fsms = fsmenu->fsmenu_system; + fsm_head = fsmenu->fsmenu_system; break; case FS_CATEGORY_BOOKMARKS: - fsms = fsmenu->fsmenu_bookmarks; + fsm_head = fsmenu->fsmenu_bookmarks; break; case FS_CATEGORY_RECENT: - fsms = fsmenu->fsmenu_recent; + fsm_head = fsmenu->fsmenu_recent; break; } - return fsms; + return fsm_head; } -static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsms) +static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsm_head) { switch (category) { case FS_CATEGORY_SYSTEM: - fsmenu->fsmenu_system = fsms; + fsmenu->fsmenu_system = fsm_head; break; case FS_CATEGORY_BOOKMARKS: - fsmenu->fsmenu_bookmarks = fsms; + fsmenu->fsmenu_bookmarks = fsm_head; break; case FS_CATEGORY_RECENT: - fsmenu->fsmenu_recent = fsms; + fsmenu->fsmenu_recent = fsm_head; break; } } int fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category) { - FSMenuEntry *fsme; + FSMenuEntry *fsm_iter; int count = 0; - for (fsme = fsmenu_get_category(fsmenu, category); fsme; fsme = fsme->next) + for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter; fsm_iter = fsm_iter->next) { count++; + } return count; } char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx) { - FSMenuEntry *fsme; + FSMenuEntry *fsm_iter; - for (fsme = fsmenu_get_category(fsmenu, category); fsme && idx; fsme = fsme->next) + for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter && idx; fsm_iter = fsm_iter->next) { idx--; + } - return fsme ? fsme->path : NULL; + return fsm_iter ? fsm_iter->path : NULL; } short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int idx) { - FSMenuEntry *fsme; + FSMenuEntry *fsm_iter; - for (fsme = fsmenu_get_category(fsmenu, category); fsme && idx; fsme = fsme->next) + for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter && idx; fsm_iter = fsm_iter->next) { idx--; + } - return fsme ? fsme->save : 0; + return fsm_iter ? fsm_iter->save : 0; } -void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save) +void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, FSMenuInsert flag) { - FSMenuEntry *prev; - FSMenuEntry *fsme; - FSMenuEntry *fsms; + FSMenuEntry *fsm_prev; + FSMenuEntry *fsm_iter; + FSMenuEntry *fsm_head; - fsms = fsmenu_get_category(fsmenu, category); - prev = fsme = fsms; + fsm_head = fsmenu_get_category(fsmenu, category); + fsm_prev = fsm_head; /* this is odd and not really correct? */ - for (; fsme; prev = fsme, fsme = fsme->next) { - if (fsme->path) { - const int cmp_ret = BLI_path_cmp(path, fsme->path); + for (fsm_iter = fsm_head; fsm_iter; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next) { + if (fsm_iter->path) { + const int cmp_ret = BLI_path_cmp(path, fsm_iter->path); if (cmp_ret == 0) { + if (flag & FS_INSERT_FIRST) { + if (fsm_iter != fsm_head) { + fsm_prev->next = fsm_iter->next; + fsm_iter->next = fsm_head; + fsmenu_set_category(fsmenu, category, fsm_iter); + } + } return; } - else if (sorted && cmp_ret < 0) { + else if ((flag & FS_INSERT_SORTED) && cmp_ret < 0) { break; } } @@ -182,78 +192,82 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c /* if we're bookmarking this, file should come * before the last separator, only automatically added * current dir go after the last sep. */ - if (save) { + if (flag & FS_INSERT_SAVE) { break; } } } - fsme = MEM_mallocN(sizeof(*fsme), "fsme"); - fsme->path = BLI_strdup(path); - fsme->save = save; + fsm_iter = MEM_mallocN(sizeof(*fsm_iter), "fsme"); + fsm_iter->path = BLI_strdup(path); + fsm_iter->save = (flag & FS_INSERT_SAVE) != 0; - if (prev) { - fsme->next = prev->next; - prev->next = fsme; + if (fsm_prev) { + if (flag & FS_INSERT_FIRST) { + fsm_iter->next = fsm_head; + fsmenu_set_category(fsmenu, category, fsm_iter); + } + else { + fsm_iter->next = fsm_prev->next; + fsm_prev->next = fsm_iter; + } } else { - fsme->next = fsms; - fsmenu_set_category(fsmenu, category, fsme); + fsm_iter->next = fsm_head; + fsmenu_set_category(fsmenu, category, fsm_iter); } } void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx) { - FSMenuEntry *prev = NULL, *fsme = NULL; - FSMenuEntry *fsms = fsmenu_get_category(fsmenu, category); + FSMenuEntry *fsm_prev = NULL; + FSMenuEntry *fsm_iter; + FSMenuEntry *fsm_head; + + fsm_head = fsmenu_get_category(fsmenu, category); - for (fsme = fsms; fsme && idx; prev = fsme, fsme = fsme->next) + for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next) idx--; - if (fsme) { + if (fsm_iter) { /* you should only be able to remove entries that were * not added by default, like windows drives. * also separators (where path == NULL) shouldn't be removed */ - if (fsme->save && fsme->path) { + if (fsm_iter->save && fsm_iter->path) { /* remove fsme from list */ - if (prev) { - prev->next = fsme->next; + if (fsm_prev) { + fsm_prev->next = fsm_iter->next; } else { - fsms = fsme->next; - fsmenu_set_category(fsmenu, category, fsms); + fsm_head = fsm_iter->next; + fsmenu_set_category(fsmenu, category, fsm_head); } /* free entry */ - MEM_freeN(fsme->path); - MEM_freeN(fsme); + MEM_freeN(fsm_iter->path); + MEM_freeN(fsm_iter); } } } void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename) { - FSMenuEntry *fsme = NULL; - int nskip = 0; + FSMenuEntry *fsm_iter = NULL; + int nwritten = 0; FILE *fp = BLI_fopen(filename, "w"); if (!fp) return; fprintf(fp, "[Bookmarks]\n"); - for (fsme = fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsme; fsme = fsme->next) { - if (fsme->path && fsme->save) { - fprintf(fp, "%s\n", fsme->path); + for (fsm_iter = fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsm_iter; fsm_iter = fsm_iter->next) { + if (fsm_iter->path && fsm_iter->save) { + fprintf(fp, "%s\n", fsm_iter->path); } } fprintf(fp, "[Recent]\n"); - nskip = fsmenu_get_nentries(fsmenu, FS_CATEGORY_RECENT) - FSMENU_RECENT_MAX; - /* skip first entries if list too long */ - for (fsme = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsme && (nskip > 0); fsme = fsme->next, --nskip) { - /* pass */ - } - for (; fsme; fsme = fsme->next) { - if (fsme->path && fsme->save) { - fprintf(fp, "%s\n", fsme->path); + for (fsm_iter = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsm_iter && (nwritten < FSMENU_RECENT_MAX); fsm_iter = fsm_iter->next, ++nwritten) { + if (fsm_iter->path && fsm_iter->save) { + fprintf(fp, "%s\n", fsm_iter->path); } } fclose(fp); @@ -288,7 +302,7 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename) if (BLI_exists(line)) #endif { - fsmenu_insert_entry(fsmenu, category, line, 0, 1); + fsmenu_insert_entry(fsmenu, category, line, FS_INSERT_SAVE); } } } @@ -315,16 +329,16 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) tmps[2] = '\\'; tmps[3] = 0; - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, FS_INSERT_SORTED); } } /* Adding Desktop and My Documents */ if (read_bookmarks) { SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); } } #else @@ -347,7 +361,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, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED); } } @@ -357,26 +371,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, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); BLI_snprintf(line, 256, "%s/Desktop/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); } BLI_snprintf(line, 256, "%s/Documents/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); } BLI_snprintf(line, 256, "%s/Pictures/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); } BLI_snprintf(line, 256, "%s/Music/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); } BLI_snprintf(line, 256, "%s/Movies/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); } } #else @@ -409,7 +423,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, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED); CFRelease(pathString); CFRelease(cfURL); @@ -436,7 +450,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, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED); } /* Finally get user favorite places */ @@ -459,7 +473,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, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); CFRelease(pathString); CFRelease(cfURL); @@ -477,10 +491,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, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_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, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); } } @@ -505,10 +519,11 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) len = strlen(mnt->mnt_dir); if (len && mnt->mnt_dir[len - 1] != '/') { BLI_snprintf(line, FILE_MAXDIR, "%s/", mnt->mnt_dir); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED); + } + else { + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, FS_INSERT_SORTED); } - else - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, 1, 0); found = 1; } @@ -520,7 +535,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) /* fallback */ if (!found) - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", FS_INSERT_SORTED); } } #endif @@ -530,15 +545,17 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) static void fsmenu_free_category(struct FSMenu *fsmenu, FSMenuCategory category) { - FSMenuEntry *fsme = fsmenu_get_category(fsmenu, category); + FSMenuEntry *fsm_iter = fsmenu_get_category(fsmenu, category); - while (fsme) { - FSMenuEntry *n = fsme->next; + while (fsm_iter) { + FSMenuEntry *fsm_next = fsm_iter->next; - if (fsme->path) MEM_freeN(fsme->path); - MEM_freeN(fsme); + if (fsm_iter->path) { + MEM_freeN(fsm_iter->path); + } + MEM_freeN(fsm_iter); - fsme = n; + fsm_iter = fsm_next; } } diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index d7576d71933..30730578085 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -43,6 +43,12 @@ typedef enum FSMenuCategory { FS_CATEGORY_RECENT } FSMenuCategory; +typedef enum FSMenuInsert { + FS_INSERT_SORTED = (1 << 0), + FS_INSERT_SAVE = (1 << 1), + FS_INSERT_FIRST = (1 << 2) /* moves the item to the front of the list when its not already there */ +} FSMenuInsert; + struct FSMenu; struct FSMenu *fsmenu_get(void); @@ -59,7 +65,7 @@ char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index * Duplicate entries are not added. * \param sorted Should entry be inserted in sorted order? */ -void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save); +void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, const FSMenuInsert flag); /** Return whether the entry was created by the user and can be saved and deleted */ short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int index); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 4b568b43695..7f39545258d 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -386,6 +386,7 @@ static void file_operatortypes(void) WM_operatortype_append(FILE_OT_bookmark_toggle); WM_operatortype_append(FILE_OT_bookmark_add); WM_operatortype_append(FILE_OT_delete_bookmark); + WM_operatortype_append(FILE_OT_reset_recent); WM_operatortype_append(FILE_OT_hidedot); WM_operatortype_append(FILE_OT_filenum); WM_operatortype_append(FILE_OT_directory_new); @@ -537,7 +538,7 @@ static void file_ui_area_draw(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); /* scrolling here is just annoying, disable it */ - ar->v2d.cur.ymax = BLI_RCT_SIZE_Y(&ar->v2d.cur); + ar->v2d.cur.ymax = BLI_rctf_size_y(&ar->v2d.cur); ar->v2d.cur.ymin = 0; /* set view2d view matrix for scrolling (without scrollers) */ diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index efe62eaf495..0d56b02e086 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -69,12 +69,6 @@ #include "graph_intern.h" // own include -/* XXX */ - -/* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */ -#define UI_FLT_MAX 10000.0f - - /* ******************* graph editor space & buttons ************** */ #define B_REDR 1 diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index e4bda15bc7d..ef2e56afca0 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -88,7 +88,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) { FMod_Envelope *env = (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed; - const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur); + const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur); int i; /* draw two black lines showing the standard reference levels */ @@ -137,7 +137,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel) { BezTriple *bezt = fcu->bezt; - const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur); + const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur); int i; /* we use bgl points not standard gl points, to workaround vertex diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index f01d64b46b8..7107a6a2369 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -229,11 +229,11 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i &cur_new.ymin, &cur_new.ymax, do_sel_only, include_handles); - extra = 0.1f * BLI_RCT_SIZE_X(&cur_new); + extra = 0.1f * BLI_rctf_size_x(&cur_new); cur_new.xmin -= extra; cur_new.xmax += extra; - extra = 0.1f * BLI_RCT_SIZE_Y(&cur_new); + extra = 0.1f * BLI_rctf_size_y(&cur_new); cur_new.ymin -= extra; cur_new.ymax += extra; diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 633f2b72cf6..e2fc1657379 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -325,7 +325,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... */ - if ((BLI_RCT_SIZE_X(&rect)) >= (BLI_RCT_SIZE_Y(&rect))) + if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect))) mode = BEZT_OK_FRAMERANGE; else mode = BEZT_OK_VALUERANGE; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 40f0683a852..0b904f36a8c 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -71,28 +71,6 @@ #include "image_intern.h" -#define B_REDR 1 -#define B_IMAGECHANGED 2 -#define B_NOP 0 -#define B_TWINANIM 5 -#define B_SIMAGETILE 6 -#define B_IDNAME 10 -#define B_FACESEL_PAINT_TEST 11 -#define B_SIMA_RECORD 12 -#define B_SIMA_PLAY 13 - -#define B_SIMANOTHING 16 -#define B_SIMABRUSHCHANGE 17 -#define B_SIMABRUSHBROWSE 18 -#define B_SIMABRUSHLOCAL 19 -#define B_SIMABRUSHDELETE 20 -#define B_KEEPDATA 21 -#define B_SIMABTEXBROWSE 22 -#define B_SIMABTEXDELETE 23 -#define B_VPCOLSLI 24 -#define B_SIMACLONEBROWSE 25 -#define B_SIMACLONEDELETE 26 - /* proto */ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, char *str) @@ -169,47 +147,6 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) /* ************ panel stuff ************* */ -/* is used for both read and write... */ - -static int image_panel_poll(const bContext *C, PanelType *UNUSED(pt)) -{ - SpaceImage *sima = CTX_wm_space_image(C); - ImBuf *ibuf; - void *lock; - int result; - - ibuf = ED_space_image_acquire_buffer(sima, &lock); - result = ibuf && ibuf->rect_float; - ED_space_image_release_buffer(sima, lock); - - return result; -} - -static void image_panel_curves(const bContext *C, Panel *pa) -{ - bScreen *sc = CTX_wm_screen(C); - SpaceImage *sima = CTX_wm_space_image(C); - ImBuf *ibuf; - PointerRNA simaptr; - int levels; - void *lock; - - ibuf = ED_space_image_acquire_buffer(sima, &lock); - - if (ibuf) { - if (sima->cumap == NULL) - sima->cumap = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); - - /* curvemap black/white levels only works for RGBA */ - levels = (ibuf->channels == 4); - - RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &simaptr); - uiTemplateCurveMapping(pa->layout, &simaptr, "curve", 'c', levels, 0); - } - - ED_space_image_release_buffer(sima, lock); -} - #if 0 /* 0: disable preview * otherwise refresh preview @@ -234,6 +171,7 @@ void image_preview_event(int event) } if (exec && G.scene->nodetree) { + Scene *scene = G.scene; /* should work when no node editor in screen..., so we execute right away */ ntreeCompositTagGenerators(G.scene->nodetree); @@ -244,7 +182,7 @@ void image_preview_event(int event) BIF_store_spare(); - ntreeCompositExecTree(G.scene->nodetree, &G.scene->r, 1); /* 1 is do_previews */ + ntreeCompositExecTree(scene->nodetree, &scene->r, 1, &scene->view_settings, &scene->display_settings); /* 1 is do_previews */ G.scene->nodetree->timecursor = NULL; G.scene->nodetree->test_break = NULL; @@ -268,13 +206,13 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block) int mval[2]; if (G.scene->r.mode & R_BORDER) { - winx *= BLI_RCT_SIZE_X(&G.scene->r.border); - winy *= BLI_RCT_SIZE_Y(&G.scene->r.border); + winx *= BLI_rcti_size_x(&G.scene->r.border); + winy *= BLI_rctf_size_y(&G.scene->r.border); } /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ - BLI_rctf_init(&dispf, 15.0f, BLI_RCT_SIZE_X(&block->rect) - 15.0f, 15.0f, (BLI_RCT_SIZE_Y(&block->rect)) - 15.0f); + BLI_rctf_init(&dispf, 15.0f, BLI_rcti_size_x(&block->rect) - 15.0f, 15.0f, (BLI_rctf_size_y(&block->rect)) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); /* correction for gla draw */ @@ -611,6 +549,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiLayout *row, *split, *col; uiBlock *block; char str[128]; + void *lock; if (!ptr->data) @@ -728,7 +667,11 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemL(layout, str, ICON_NONE); } } - + + col = uiLayoutColumn(layout, FALSE); + uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings"); + uiItemR(col, &imaptr, "view_as_render", 0, NULL, ICON_NONE); + if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { /* background image view doesnt need these */ uiItemS(layout); @@ -794,15 +737,18 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char MEM_freeN(cb); } -void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) +void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_management) { ImageFormatData *imf = imfptr->data; ID *id = imfptr->id.data; + PointerRNA display_settings_ptr; + PropertyRNA *prop; const int depth_ok = BKE_imtype_valid_depths(imf->imtype); /* some settings depend on this being a scene thats rendered */ const short is_render_out = (id && GS(id->name) == ID_SCE); uiLayout *col, *row, *split, *sub; + int show_preview = FALSE; col = uiLayoutColumn(layout, FALSE); @@ -843,6 +789,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) } if (is_render_out && (imf->imtype == R_IMF_IMTYPE_OPENEXR)) { + show_preview = TRUE; uiItemR(row, imfptr, "use_preview", 0, NULL, ICON_NONE); } @@ -864,6 +811,22 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE); #endif } + + /* color management */ + if (color_management && + (!BKE_imtype_supports_float(imf->imtype) || + (show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG))) + { + prop = RNA_struct_find_property(imfptr, "display_settings"); + display_settings_ptr = RNA_property_pointer_get(imfptr, prop); + + col = uiLayoutColumn(layout, FALSE); + uiItemL(col, IFACE_("Color Management"), ICON_NONE); + + uiItemR(col, &display_settings_ptr, "display_device", 0, NULL, ICON_NONE); + + uiTemplateColormanagedViewSettings(col, NULL, imfptr, "view_settings"); + } } void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser) @@ -886,14 +849,6 @@ void image_buttons_register(ARegionType *art) { PanelType *pt; - pt = MEM_callocN(sizeof(PanelType), "spacetype image panel curves"); - strcpy(pt->idname, "IMAGE_PT_curves"); - strcpy(pt->label, "Curves"); - pt->draw = image_panel_curves; - pt->poll = image_panel_poll; - pt->flag |= PNL_DEFAULT_CLOSED; - BLI_addtail(&art->paneltypes, pt); - pt = MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil"); strcpy(pt->idname, "IMAGE_PT_gpencil"); strcpy(pt->label, "Grease Pencil"); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index e293264c021..749ba75cfa1 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -51,6 +51,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" #include "BKE_context.h" #include "BKE_global.h" @@ -70,34 +71,13 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "WM_api.h" +#include "WM_types.h" #include "RE_pipeline.h" #include "image_intern.h" -#define HEADER_HEIGHT 18 - -static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage) -{ - /* detect if we need to redo the curve map. - * ibuf->rect is zero for compositor and render results after change - * convert to 32 bits always... drawing float rects isn't supported well (atis) - * - * NOTE: if float buffer changes, we have to manually remove the rect - */ - - if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID)) ) { - if (color_manage) { - if (ima && ima->source == IMA_SRC_VIEWER) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - } - else - ibuf->profile = IB_PROFILE_NONE; - - IMB_rect_from_float(ibuf); - } -} - static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) { RenderResult *rr; @@ -112,7 +92,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) } /* used by node view too */ -void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y, +void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y, const unsigned char cp[4], const float fp[4], int *zp, float *zpf) { char str[256]; @@ -136,7 +116,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int /* noisy, high contrast make impossible to read if lower alpha is used. */ glColor4ub(0, 0, 0, 190); - glRecti(0.0, 0.0, BLI_RCT_SIZE_X(&ar->winrct) + 1, 20); + glRecti(0.0, 0.0, BLI_rcti_size_x(&ar->winrct) + 1, 20); glDisable(GL_BLEND); BLF_size(blf_mono_font, 11, 72); @@ -209,6 +189,20 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } + + if (color_manage && channels == 4) { + float pixel[4]; + + if (use_default_view) + IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, NULL, &scene->display_settings); + else + IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, &scene->view_settings, &scene->display_settings); + + BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", pixel[0], pixel[1], pixel[2]); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } } /* color rectangle */ @@ -252,11 +246,15 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int } if (color_manage) { - linearrgb_to_srgb_v4(finalcol, col); + if (use_default_view) + IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings); + else + IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, &scene->view_settings, &scene->display_settings); } else { copy_v4_v4(finalcol, col); } + glDisable(GL_BLEND); glColor3fv(finalcol); dx += 5; @@ -418,10 +416,9 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec MEM_freeN(rectf); } -static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy) +static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy) { int x, y; - int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; /* set zoom */ glPixelZoom(zoomx, zoomy); @@ -445,6 +442,9 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float); } else { + unsigned char *display_buffer; + void *cache_handle; + if (sima->flag & SI_USE_ALPHA) { fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); @@ -452,17 +452,17 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - /* we don't draw floats buffers directly but - * convert them, and optionally apply curves */ - image_verify_buffer_float(ima, ibuf, color_manage); + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - if (ibuf->rect) - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + if (display_buffer) + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); #if 0 else glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float); #endif - + + IMB_display_buffer_release(cache_handle); + if (sima->flag & SI_USE_ALPHA) glDisable(GL_BLEND); } @@ -471,14 +471,14 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image glPixelZoom(1.0f, 1.0f); } -static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy) +static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, short startx, short starty, short endx, short endy) { unsigned int *rt, *rp, *rectmain; short y, heigth, len; /* the right offset in rectot */ - rt = ibuf->rect + (starty * ibuf->x + startx); + rt = buffer + (starty * width + startx); len = (endx - startx); heigth = (endy - starty); @@ -487,7 +487,7 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, for (y = 0; y < heigth; y++) { memcpy(rp, rt, len * 4); - rt += ibuf->x; + rt += width; rp += len; } return rectmain; @@ -495,28 +495,34 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy) { + unsigned char *display_buffer; unsigned int *rect; int dx, dy, sx, sy, x, y; - int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; + void *cache_handle; /* verify valid values, just leave this a while */ if (ima->xrep < 1) return; if (ima->yrep < 1) return; - + + if (ima->flag & IMA_VIEW_AS_RENDER) + display_buffer = IMB_display_buffer_acquire(ibuf, &scene->view_settings, &scene->display_settings, &cache_handle); + else + display_buffer = IMB_display_buffer_acquire(ibuf, NULL, &scene->display_settings, &cache_handle); + + if (!display_buffer) + return; + glPixelZoom(zoomx, zoomy); if (sima->curtile >= ima->xrep * ima->yrep) sima->curtile = ima->xrep * ima->yrep - 1; - /* create char buffer from float if needed */ - image_verify_buffer_float(ima, ibuf, color_manage); - /* retrieve part of image buffer */ dx = ibuf->x / ima->xrep; dy = ibuf->y / ima->yrep; sx = (sima->curtile % ima->xrep) * dx; sy = (sima->curtile / ima->xrep) * dy; - rect = get_part_from_ibuf(ibuf, sx, sy, sx + dx, sy + dy); + rect = get_part_from_buffer((unsigned int*)display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy); /* draw repeated */ for (sy = 0; sy + dy <= ibuf->y; sy += dy) { @@ -529,10 +535,12 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, glPixelZoom(1.0f, 1.0f); + IMB_display_buffer_release(cache_handle); + MEM_freeN(rect); } -static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy) +static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy) { const double time_current = PIL_check_seconds_timer(); @@ -549,7 +557,7 @@ static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *sce if (ima && (ima->tpageflag & IMA_TILES)) draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy); else - draw_image_buffer(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy); + draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy); /* only draw until running out of time */ if ((PIL_check_seconds_timer() - time_current) > 0.25) @@ -632,22 +640,35 @@ static void draw_image_view_tool(Scene *scene) } #endif -static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height) +static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int *width, int *height) { Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint); ImBuf *ibuf; unsigned int size, alpha; + unsigned char *display_buffer; unsigned char *rect, *cp; + void *cache_handle; if (!brush || !brush->clone.image) return NULL; ibuf = BKE_image_get_ibuf(brush->clone.image, NULL); - if (!ibuf || !ibuf->rect) + if (!ibuf) return NULL; - rect = MEM_dupallocN(ibuf->rect); + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + + if (!display_buffer) { + IMB_display_buffer_release(cache_handle); + + return NULL; + } + + rect = MEM_dupallocN(display_buffer); + + IMB_display_buffer_release(cache_handle); + if (!rect) return NULL; @@ -666,7 +687,7 @@ static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *heigh return rect; } -static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, float zoomy) +static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scene, float zoomx, float zoomy) { Brush *brush; int x, y, w, h; @@ -677,7 +698,7 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) { /* this is not very efficient, but glDrawPixels doesn't allow * drawing with alpha */ - clonerect = get_alpha_clone_image(scene, &w, &h); + clonerect = get_alpha_clone_image(C, scene, &w, &h); if (clonerect) { UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); @@ -698,8 +719,10 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo /* draw main image area */ -void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) +void draw_image_main(const bContext *C, ARegion *ar) { + SpaceImage *sima = CTX_wm_space_image(C); + Scene *scene = CTX_data_scene(C); Image *ima; ImBuf *ibuf; float zoomx, zoomy; @@ -748,15 +771,15 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) if (ibuf == NULL) ED_region_grid_draw(ar, zoomx, zoomy); else if (sima->flag & SI_DRAW_TILE) - draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy); + draw_image_buffer_repeated(C, sima, ar, scene, ima, ibuf, zoomx, zoomy); else if (ima && (ima->tpageflag & IMA_TILES)) draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy); else - draw_image_buffer(sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy); + draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); /* paint helpers */ if (sima->mode == SI_MODE_PAINT) - draw_image_paint_helpers(ar, scene, zoomx, zoomy); + draw_image_paint_helpers(C, ar, scene, zoomx, zoomy); /* XXX integrate this code */ diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 79d01491df7..92433449985 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -161,8 +161,8 @@ void ED_space_image_get_size(SpaceImage *sima, int *width, int *height) *height = (scene->r.ysch * scene->r.size) / 100; if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) { - *width *= BLI_RCT_SIZE_X(&scene->r.border); - *height *= BLI_RCT_SIZE_Y(&scene->r.border); + *width *= BLI_rctf_size_x(&scene->r.border); + *height *= BLI_rctf_size_y(&scene->r.border); } } @@ -204,8 +204,8 @@ void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float ED_space_image_get_size(sima, &width, &height); - *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width); - *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height); + *zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / (float)(BLI_rctf_size_x(&ar->v2d.cur) * width); + *zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / (float)(BLI_rctf_size_y(&ar->v2d.cur) * height); } void ED_space_image_get_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 0d3a7614f10..f86e59c41a8 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -52,7 +52,7 @@ struct ARegion *image_has_scope_region(struct ScrArea *sa); extern const char *image_context_dir[]; /* doc access */ /* image_draw.c */ -void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene); +void draw_image_main(const struct bContext *C, struct ARegion *ar); void draw_image_grease_pencil(struct bContext *C, short onlyv2d); void draw_image_sample_line(struct SpaceImage *sima); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 86722c5158e..16c9405e098 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -55,6 +55,7 @@ #include "BKE_report.h" #include "BKE_screen.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -98,9 +99,9 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat if ((width < 4) && (height < 4)) sima->zoom = oldzoom; - else if (BLI_RCT_SIZE_X(&ar->winrct) <= sima->zoom) + else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom) sima->zoom = oldzoom; - else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sima->zoom) + else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom) sima->zoom = oldzoom; } @@ -191,7 +192,7 @@ int space_image_main_area_poll(bContext *C) } /* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode or editmode */ -int space_image_main_area_not_uv_brush_poll(bContext *C) +static int space_image_main_area_not_uv_brush_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); @@ -581,8 +582,8 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op)) h = height * aspy; /* check if the image will fit in the image with (zoom == 1) */ - width = BLI_RCT_SIZE_X(&ar->winrct) + 1; - height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + width = BLI_rcti_size_x(&ar->winrct) + 1; + height = BLI_rcti_size_y(&ar->winrct) + 1; if ((w >= width || h >= height) && (width > 0 && height > 0)) { /* find the zoom value that will fit the image in the image space */ @@ -1168,6 +1169,10 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, } BLI_path_abs(simopts->filepath, G.main->name); } + + /* color management */ + BKE_color_managed_display_settings_copy(&simopts->im_format.display_settings, &scene->display_settings); + BKE_color_managed_view_settings_copy(&simopts->im_format.view_settings, &scene->view_settings); } ED_space_image_release_buffer(sima, lock); @@ -1178,6 +1183,8 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op) { if (op->customdata) { + BKE_color_managed_view_settings_free(&simopts->im_format.view_settings); + simopts->im_format = *(ImageFormatData *)op->customdata; } @@ -1190,12 +1197,47 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op) { if (op->customdata) { + BKE_color_managed_view_settings_free(&((ImageFormatData *)op->customdata)->view_settings); + *(ImageFormatData *)op->customdata = simopts->im_format; } RNA_string_set(op->ptr, "filepath", simopts->filepath); } +static ImBuf *save_image_colormanaged_imbuf_acquire(ImBuf *ibuf, SaveImageOptions *simopts, int save_as_render, void **cache_handle) +{ + ImageFormatData *imf = &simopts->im_format; + ImBuf *colormanaged_ibuf; + int do_colormanagement; + + *cache_handle = NULL; + do_colormanagement = save_as_render && !BKE_imtype_supports_float(imf->imtype); + + if (do_colormanagement) { + unsigned char *display_buffer; + + display_buffer = IMB_display_buffer_acquire(ibuf, &imf->view_settings, &imf->display_settings, cache_handle); + + if (*cache_handle) { + colormanaged_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0); + colormanaged_ibuf->rect = (unsigned int *) display_buffer; + } + else { + /* no cache handle means color management didn't run transformation + * or performed transformation to image's byte buffer which doesn't + * require allocating new image buffer + */ + colormanaged_ibuf = ibuf; + } + } + else { + colormanaged_ibuf = ibuf; + } + + return colormanaged_ibuf; +} + /* assumes name is FILE_MAX */ /* ima->name and ibuf->name should end up the same */ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath) @@ -1205,9 +1247,12 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); if (ibuf) { + void *cache_handle; + ImBuf *colormanaged_ibuf; const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id); const short relative = (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path")); const short save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy")); + const short save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") && RNA_boolean_get(op->ptr, "save_as_render")); short ok = FALSE; /* old global to ensure a 2nd save goes to same dir */ @@ -1231,7 +1276,9 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? 32 : 24; } } - + + colormanaged_ibuf = save_image_colormanaged_imbuf_acquire(ibuf, simopts, save_as_render, &cache_handle); + if (simopts->im_format.imtype == R_IMF_IMTYPE_MULTILAYER) { Scene *scene = CTX_data_scene(C); RenderResult *rr = BKE_image_acquire_renderresult(scene, ima); @@ -1245,7 +1292,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI BKE_image_release_renderresult(scene, ima); } else { - if (BKE_imbuf_write_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) { + if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy)) + { ok = TRUE; } } @@ -1284,6 +1332,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI if (relative) { BLI_path_rel(ima->name, relbase); /* only after saving */ } + + IMB_colormanagment_colorspace_from_ibuf_ftype(&ima->colorspace_settings, ibuf); } } else { @@ -1294,6 +1344,13 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image); WM_cursor_wait(0); + + if (cache_handle) { + colormanaged_ibuf->rect = NULL; + IMB_freeImBuf(colormanaged_ibuf); + + IMB_display_buffer_release(cache_handle); + } } ED_space_image_release_buffer(sima, lock); @@ -1302,6 +1359,9 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI static void image_save_as_free(wmOperator *op) { if (op->customdata) { + ImageFormatData *im_format = (ImageFormatData *)op->customdata; + BKE_color_managed_view_settings_free(&im_format->view_settings); + MEM_freeN(op->customdata); op->customdata = NULL; } @@ -1354,6 +1414,11 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve RNA_boolean_set(op->ptr, "copy", TRUE); } + if (ima->source == IMA_SRC_VIEWER || (ima->flag & IMA_VIEW_AS_RENDER)) + RNA_boolean_set(op->ptr, "save_as_render", TRUE); + else + RNA_boolean_set(op->ptr, "save_as_render", FALSE); + op->customdata = MEM_mallocN(sizeof(simopts.im_format), __func__); memcpy(op->customdata, &simopts.im_format, sizeof(simopts.im_format)); @@ -1389,7 +1454,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op) /* image template */ RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &ptr); - uiTemplateImageSettings(layout, &ptr); + uiTemplateImageSettings(layout, &ptr, FALSE); /* main draw call */ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); @@ -1417,6 +1482,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + RNA_def_boolean(ot->srna, "save_as_render", 0, "Save As Render", "Apply render part of display transform when saving byte image"); RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender"); WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_SAVE, @@ -1601,8 +1667,10 @@ static int image_new_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "color", color); alpha = RNA_boolean_get(op->ptr, "alpha"); - if (!floatbuf && scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + if (!floatbuf) { + /* OCIO_TODO: perhaps we need to convert to display space, not just to sRGB */ linearrgb_to_srgb_v3_v3(color, color); + } if (!alpha) color[3] = 1.0f; @@ -1938,14 +2006,18 @@ typedef struct ImageSampleInfo { float *zfp; int draw; + int color_manage; + int use_default_view; } ImageSampleInfo; -static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info) +static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info) { ImageSampleInfo *info = arg_info; if (info->draw) { - /* no color management needed for images (color_manage=0) */ - ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp); + Scene *scene = CTX_data_scene(C); + + ED_image_draw_info(scene, ar, info->color_manage, info->use_default_view, info->channels, + info->x, info->y, info->colp, info->colfp, info->zp, info->zfp); } } @@ -1975,13 +2047,7 @@ int ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], floa if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - - if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) { - linearrgb_to_srgb_v3_v3(r_col, fp); - } - else { - copy_v3_v3(r_col, fp); - } + linearrgb_to_srgb_v3_v3(r_col, fp); ret = TRUE; } else if (ibuf->rect) { @@ -2003,7 +2069,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); ImageSampleInfo *info = op->customdata; float fx, fy; - + Scene *scene = CTX_data_scene(C); + CurveMapping *curve_mapping = scene->view_settings.curve_mapping; + if (ibuf == NULL) { ED_space_image_release_buffer(sima, lock); info->draw = 0; @@ -2016,6 +2084,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) float *fp; unsigned char *cp; int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); + Image *image = ED_space_image(sima); CLAMP(x, 0, ibuf->x - 1); CLAMP(y, 0, ibuf->y - 1); @@ -2029,7 +2098,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colfp = NULL; info->zp = NULL; info->zfp = NULL; - + + info->use_default_view = (image->flag & IMA_VIEW_AS_RENDER) ? FALSE : TRUE; + if (ibuf->rect) { cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); @@ -2044,6 +2115,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[2] = (float)cp[2] / 255.0f; info->colf[3] = (float)cp[3] / 255.0f; info->colfp = info->colf; + + info->color_manage = FALSE; } if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); @@ -2053,6 +2126,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[2] = fp[2]; info->colf[3] = fp[3]; info->colfp = info->colf; + + info->color_manage = TRUE; } if (ibuf->zbuf) { @@ -2063,25 +2138,21 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->zf = ibuf->zbuf_float[y * ibuf->x + x]; info->zfp = &info->zf; } - - if (sima->cumap && ibuf->channels == 4) { + + if (curve_mapping && ibuf->channels == 4) { /* we reuse this callback for set curves point operators */ if (RNA_struct_find_property(op->ptr, "point")) { int point = RNA_enum_get(op->ptr, "point"); if (point == 1) { - curvemapping_set_black_white(sima->cumap, NULL, info->colfp); - if (ibuf->rect_float) - curvemapping_do_ibuf(sima->cumap, ibuf); + curvemapping_set_black_white(curve_mapping, NULL, info->colfp); } else if (point == 0) { - curvemapping_set_black_white(sima->cumap, info->colfp, NULL); - if (ibuf->rect_float) - curvemapping_do_ibuf(sima->cumap, ibuf); + curvemapping_set_black_white(curve_mapping, info->colfp, NULL); } } } - + // XXX node curve integration .. #if 0 { @@ -2211,7 +2282,7 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) hist->co[1][0] = x2f; hist->co[1][1] = y2f; - BKE_histogram_update_sample_line(hist, ibuf, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0); + BKE_histogram_update_sample_line(hist, ibuf, &scene->view_settings, &scene->display_settings); /* reset y zoom */ hist->ymax = 1.0f; @@ -2306,7 +2377,8 @@ static int image_record_composite_apply(bContext *C, wmOperator *op) BKE_image_all_free_anim_ibufs(scene->r.cfra); ntreeCompositTagAnimated(scene->nodetree); - ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra); /* 1 is no previews */ + ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra, + &scene->view_settings, &scene->display_settings); /* 1 is no previews */ ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 91a0cba2555..abe8dfb751b 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -195,9 +195,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) static void image_free(SpaceLink *sl) { SpaceImage *simage = (SpaceImage *) sl; - - if (simage->cumap) - curvemapping_free(simage->cumap); + scopes_free(&simage->scopes); } @@ -217,8 +215,6 @@ static SpaceLink *image_duplicate(SpaceLink *sl) SpaceImage *simagen = MEM_dupallocN(sl); /* clear or remove stuff from old */ - if (simagen->cumap) - simagen->cumap = curvemapping_copy(simagen->cumap); scopes_new(&simagen->scopes); @@ -442,7 +438,12 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); break; case ND_MODE: + if (wmn->subtype == NS_EDITMODE_MESH) + ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); + break; case ND_RENDER_RESULT: + case ND_RENDER_OPTIONS: case ND_COMPO_RESULT: if (ED_space_image_show_render(sima)) image_scopes_tag_refresh(sa); @@ -561,8 +562,8 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar) if (ima) h *= ima->aspy / ima->aspx; - winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; - winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + winx = BLI_rcti_size_x(&ar->winrct) + 1; + winy = BLI_rcti_size_y(&ar->winrct) + 1; ar->v2d.tot.xmin = 0; ar->v2d.tot.ymin = 0; @@ -652,7 +653,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) image_main_area_set_view2d(sima, ar); /* we draw image in pixelspace */ - draw_image_main(sima, ar, scene); + draw_image_main(C, ar); /* and uvs in 0.0-1.0 space */ UI_view2d_view_ortho(v2d); @@ -776,9 +777,9 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar) ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); if (ibuf) { if (!sima->scopes.ok) { - BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT); + BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings); } - scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT); + scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); } ED_space_image_release_buffer(sima, lock); diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 4ffa99319c4..5e5e0c87feb 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -368,7 +368,7 @@ static void stats_string(Scene *scene) s += sprintf(s, "%s | ", versionstr); if (scene->obedit) { - if (ob_get_keyblock(scene->obedit)) + if (BKE_keyblock_from_object(scene->obedit)) s += sprintf(s, "(Key) "); if (scene->obedit->type == OB_MESH) { diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index abffb955405..abdfa0ef4dd 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -84,10 +84,10 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot) int i, b; rcti rectlink; - rectlink.xmin = (int)BLI_RCT_CENTER_X(&line->from->rect); - rectlink.ymin = (int)BLI_RCT_CENTER_Y(&line->from->rect); - rectlink.xmax = (int)BLI_RCT_CENTER_X(&line->to->rect); - rectlink.ymax = (int)BLI_RCT_CENTER_Y(&line->to->rect); + rectlink.xmin = (int)BLI_rctf_cent_x(&line->from->rect); + rectlink.ymin = (int)BLI_rctf_cent_y(&line->from->rect); + rectlink.xmax = (int)BLI_rctf_cent_x(&line->to->rect); + rectlink.ymax = (int)BLI_rctf_cent_y(&line->to->rect); if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) { for (i=0; i<tot-1; i++) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 6ffac1dcd34..5d7ff77e032 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -72,10 +72,7 @@ #include "logic_intern.h" - -#define MAX_RENDER_PASS 100 #define B_REDR 1 -#define B_IDNAME 2 #define B_ADD_SENS 2703 #define B_CHANGE_SENS 2704 @@ -91,7 +88,6 @@ #define B_SOUNDACT_BROWSE 2712 -#define B_SETSECTOR 2713 #define B_SETPROP 2714 #define B_SETACTOR 2715 #define B_SETMAINACTOR 2716 @@ -187,178 +183,6 @@ void make_unique_prop_names(bContext *C, char *str) MEM_freeN(names); } -static void make_unique_prop_names_cb(bContext *C, void *strv, void *UNUSED(redraw_view3d_flagv)) -{ - char *str= strv; -// int redraw_view3d_flag= GET_INT_FROM_POINTER(redraw_view3d_flagv); - - make_unique_prop_names(C, str); -} - - -static void old_sca_move_sensor(bContext *C, void *datav, void *move_up) -{ - /* deprecated, no longer using it (moved to sca.c) */ - Scene *scene= CTX_data_scene(C); - bSensor *sens_to_delete= datav; - int val; - Base *base; - bSensor *sens, *tmp; - - // val= pupmenu("Move up%x1|Move down %x2"); - val = move_up ? 1:2; - - if (val>0) { - /* now find out which object has this ... */ - base= FIRSTBASE; - while (base) { - - sens= base->object->sensors.first; - while (sens) { - if (sens == sens_to_delete) break; - sens= sens->next; - } - - if (sens) { - if ( val==1 && sens->prev) { - for (tmp=sens->prev; tmp; tmp=tmp->prev) { - if (tmp->flag & SENS_VISIBLE) - break; - } - if (tmp) { - BLI_remlink(&base->object->sensors, sens); - BLI_insertlinkbefore(&base->object->sensors, tmp, sens); - } - } - else if ( val==2 && sens->next) { - for (tmp=sens->next; tmp; tmp=tmp->next) { - if (tmp->flag & SENS_VISIBLE) - break; - } - if (tmp) { - BLI_remlink(&base->object->sensors, sens); - BLI_insertlink(&base->object->sensors, tmp, sens); - } - } - ED_undo_push(C, "Move sensor"); - break; - } - - base= base->next; - } - } -} - -static void old_sca_move_controller(bContext *C, void *datav, void *move_up) -{ - /* deprecated, no longer using it (moved to sca.c) */ - Scene *scene= CTX_data_scene(C); - bController *controller_to_del= datav; - int val; - Base *base; - bController *cont, *tmp; - - //val= pupmenu("Move up%x1|Move down %x2"); - val = move_up ? 1:2; - - if (val>0) { - /* now find out which object has this ... */ - base= FIRSTBASE; - while (base) { - - cont= base->object->controllers.first; - while (cont) { - if (cont == controller_to_del) break; - cont= cont->next; - } - - if (cont) { - if ( val==1 && cont->prev) { - /* locate the controller that has the same state mask but is earlier in the list */ - tmp = cont->prev; - while (tmp) { - if (tmp->state_mask & cont->state_mask) - break; - tmp = tmp->prev; - } - if (tmp) { - BLI_remlink(&base->object->controllers, cont); - BLI_insertlinkbefore(&base->object->controllers, tmp, cont); - } - } - else if ( val==2 && cont->next) { - tmp = cont->next; - while (tmp) { - if (tmp->state_mask & cont->state_mask) - break; - tmp = tmp->next; - } - BLI_remlink(&base->object->controllers, cont); - BLI_insertlink(&base->object->controllers, tmp, cont); - } - ED_undo_push(C, "Move controller"); - break; - } - - base= base->next; - } - } -} - -static void old_sca_move_actuator(bContext *C, void *datav, void *move_up) -{ - /* deprecated, no longer using it (moved to sca.c) */ - Scene *scene= CTX_data_scene(C); - bActuator *actuator_to_move= datav; - int val; - Base *base; - bActuator *act, *tmp; - - //val= pupmenu("Move up%x1|Move down %x2"); - val = move_up ? 1:2; - - if (val>0) { - /* now find out which object has this ... */ - base= FIRSTBASE; - while (base) { - - act= base->object->actuators.first; - while (act) { - if (act == actuator_to_move) break; - act= act->next; - } - - if (act) { - if ( val==1 && act->prev) { - /* locate the first visible actuators before this one */ - for (tmp = act->prev; tmp; tmp=tmp->prev) { - if (tmp->flag & ACT_VISIBLE) - break; - } - if (tmp) { - BLI_remlink(&base->object->actuators, act); - BLI_insertlinkbefore(&base->object->actuators, tmp, act); - } - } - else if ( val==2 && act->next) { - for (tmp=act->next; tmp; tmp=tmp->next) { - if (tmp->flag & ACT_VISIBLE) - break; - } - if (tmp) { - BLI_remlink(&base->object->actuators, act); - BLI_insertlink(&base->object->actuators, tmp, act); - } - } - ED_undo_push(C, "Move actuator"); - break; - } - - base= base->next; - } - } -} - static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) { Main *bmain= CTX_data_main(C); @@ -631,14 +455,6 @@ static const char *sensor_name(int type) return "unknown"; } -static const char *sensor_pup(void) -{ - /* the number needs to match defines in DNA_sensor_types.h */ - return "Sensors %t|Always %x0|Delay %x13|Keyboard %x3|Mouse %x5|" - "Touch %x1|Collision %x6|Near %x2|Radar %x7|" - "Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11|Actuator %x12|Armature %x14"; -} - static const char *controller_name(int type) { switch (type) { @@ -662,11 +478,6 @@ static const char *controller_name(int type) return "unknown"; } -static const char *controller_pup(void) -{ - return "Controllers %t|AND %x0|OR %x1|XOR %x6|NAND %x4|NOR %x5|XNOR %x7|Expression %x2|Python %x3"; -} - static const char *actuator_name(int type) { switch (type) { @@ -718,36 +529,6 @@ static const char *actuator_name(int type) return "unknown"; } - - - -static const char *actuator_pup(Object *owner) -{ - switch (owner->type) { - case OB_ARMATURE: - return ("Actuators %t|Action %x15|Armature %x23|Motion %x0|Constraint %x9|Ipo %x1" - "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|Game %x17" - "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"); - break; - - case OB_MESH: - return ("Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1" - "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|Game %x17" - "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"); - break; - - default: - return ("Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" - "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|Game %x17" - "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"); - } -} - - - static void set_sca_ob(Object *ob) { bController *cont; @@ -935,151 +716,6 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf return idar; } - -static int get_col_sensor(int type) -{ - /* XXX themecolors not here */ - - switch (type) { - case SENS_ALWAYS: return TH_PANEL; - case SENS_DELAY: return TH_PANEL; - case SENS_TOUCH: return TH_PANEL; - case SENS_COLLISION: return TH_PANEL; - case SENS_NEAR: return TH_PANEL; - case SENS_KEYBOARD: return TH_PANEL; - case SENS_PROPERTY: return TH_PANEL; - case SENS_ARMATURE: return TH_PANEL; - case SENS_ACTUATOR: return TH_PANEL; - case SENS_MOUSE: return TH_PANEL; - case SENS_RADAR: return TH_PANEL; - case SENS_RANDOM: return TH_PANEL; - case SENS_RAY: return TH_PANEL; - case SENS_MESSAGE: return TH_PANEL; - case SENS_JOYSTICK: return TH_PANEL; - default: return TH_PANEL; - } -} -static void set_col_sensor(int type, int medium) -{ - int col= get_col_sensor(type); - UI_ThemeColorShade(col, medium?30:0); -} - - -static void verify_logicbutton_func(bContext *UNUSED(C), void *data1, void *data2) -{ - bSensor *sens= (bSensor*)data1; - - if (sens->level && sens->tap) { - if (data2 == &(sens->level)) - sens->tap= 0; - else - sens->level= 0; - } -} - -static void test_scriptpoin_but(struct bContext *C, const char *name, ID **idpp) -{ - *idpp= BLI_findstring(&CTX_data_main(C)->text, name, offsetof(ID, name) + 2); -} - -static void test_actionpoin_but(struct bContext *C, const char *name, ID **idpp) -{ - *idpp= BLI_findstring(&CTX_data_main(C)->action, name, offsetof(ID, name) + 2); - if (*idpp) - id_us_plus(*idpp); -} - - -static void test_obpoin_but(struct bContext *C, const char *name, ID **idpp) -{ - *idpp= BLI_findstring(&CTX_data_main(C)->object, name, offsetof(ID, name) + 2); - if (*idpp) - id_lib_extern(*idpp); /* checks lib data, sets correct flag for saving then */ -} - -static void test_meshpoin_but(struct bContext *C, const char *name, ID **idpp) -{ - *idpp= BLI_findstring(&CTX_data_main(C)->mesh, name, offsetof(ID, name) + 2); - if (*idpp) - id_us_plus(*idpp); -} - -static void test_matpoin_but(struct bContext *C, const char *name, ID **idpp) -{ - *idpp= BLI_findstring(&CTX_data_main(C)->mat, name, offsetof(ID, name) + 2); - if (*idpp) - id_us_plus(*idpp); -} - -static void test_scenepoin_but(struct bContext *C, const char *name, ID **idpp) -{ - *idpp= BLI_findstring(&CTX_data_main(C)->scene, name, offsetof(ID, name) + 2); - if (*idpp) - id_us_plus(*idpp); -} - -static void test_keyboard_event(struct bContext *UNUSED(C), void *arg_ks, void *UNUSED(arg)) -{ - bKeyboardSensor *ks= (bKeyboardSensor*)arg_ks; - - if (!ISKEYBOARD(ks->key)) - ks->key= 0; - if (!ISKEYBOARD(ks->qual)) - ks->qual= 0; - if (!ISKEYBOARD(ks->qual2)) - ks->qual2= 0; -} - -/** - * Draws a toggle for pulse mode, a frequency field and a toggle to invert - * the value of this sensor. Operates on the shared data block of sensors. - */ -static void draw_default_sensor_header(bSensor *sens, - uiBlock *block, - short x, - short y, - short w) -{ - uiBut *but; - - /* Pulsing and frequency */ - uiBlockBeginAlign(block); - uiDefIconButBitS(block, TOG, SENS_PULSE_REPEAT, 1, ICON_DOTSUP, - (short)(x + 10 + 0.0 * (w - 20)), (short)(y - 21), (short)(0.1 * (w - 20)), 19, - &sens->pulse, 0.0, 0.0, 0, 0, - "Activate TRUE level triggering (pulse mode)"); - - uiDefIconButBitS(block, TOG, SENS_NEG_PULSE_MODE, 1, ICON_DOTSDOWN, - (short)(x + 10 + 0.1 * (w-20)), (short)(y - 21), (short)(0.1 * (w-20)), 19, - &sens->pulse, 0.0, 0.0, 0, 0, - "Activate FALSE level triggering (pulse mode)"); - uiDefButS(block, NUM, 1, "f:", - (short)(x + 10 + 0.2 * (w-20)), (short)(y - 21), (short)(0.275 * (w-20)), 19, - &sens->freq, 0.0, 10000.0, 0, 0, - "Delay between repeated pulses (in logic tics, 0 = no delay)"); - uiBlockEndAlign(block); - - /* value or shift? */ - uiBlockBeginAlign(block); - but = uiDefButS(block, TOG, 1, "Level", - (short)(x + 10 + 0.5 * (w-20)), (short)(y - 21), (short)(0.20 * (w-20)), 19, - &sens->level, 0.0, 0.0, 0, 0, - "Level detector, trigger controllers of new states (only applicable upon logic state transition)"); - uiButSetFunc(but, verify_logicbutton_func, sens, &(sens->level)); - but = uiDefButS(block, TOG, 1, "Tap", - (short)(x + 10 + 0.702 * (w-20)), (short)(y - 21), (short)(0.12 * (w-20)), 19, - &sens->tap, 0.0, 0.0, 0, 0, - "Trigger controllers only for an instant, even while the sensor remains true"); - uiButSetFunc(but, verify_logicbutton_func, sens, &(sens->tap)); - uiBlockEndAlign(block); - - uiDefButS(block, TOG, 1, "Inv", - (short)(x + 10 + 0.85 * (w-20)), (short)(y - 21), (short)(0.15 * (w-20)), 19, - &sens->invert, 0.0, 0.0, 0, 0, - "Invert the level (output) of this sensor"); -} - static void get_armature_bone_constraint(Object *ob, const char *posechannel, const char *constraint_name, bConstraint **constraint) { /* check that bone exist in the active object */ @@ -1094,1848 +730,6 @@ static void get_armature_bone_constraint(Object *ob, const char *posechannel, co } /* didn't find any */ } -static void check_armature_bone_constraint(Object *ob, char *posechannel, char *constraint) -{ - /* check that bone exist in the active object */ - if (ob->type == OB_ARMATURE && ob->pose) { - bPoseChannel *pchan; - bPose *pose = ob->pose; - for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) { - if (!strcmp(pchan->name, posechannel)) { - /* found it, now look for constraint channel */ - bConstraint *con; - for (con=pchan->constraints.first; con; con=con->next) { - if (!strcmp(con->name, constraint)) { - /* found it, all ok */ - return; - } - } - /* didn't find constraint, make empty */ - constraint[0] = 0; - return; - } - } - } - /* didn't find any */ - posechannel[0] = 0; - constraint[0] = 0; -} - -static void check_armature_sensor(bContext *C, void *arg1_but, void *arg2_sens) -{ - bArmatureSensor *sens = arg2_sens; - uiBut *but = arg1_but; - Object *ob= CTX_data_active_object(C); - - /* check that bone exist in the active object */ - but->retval = B_REDR; - check_armature_bone_constraint(ob, sens->posechannel, sens->constraint); -} - -static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short xco, short yco, short width) -{ - bNearSensor *ns = NULL; - bTouchSensor *ts = NULL; - bKeyboardSensor *ks = NULL; - bPropertySensor *ps = NULL; - bArmatureSensor *arm = NULL; - bMouseSensor *ms = NULL; - bCollisionSensor *cs = NULL; - bRadarSensor *rs = NULL; - bRandomSensor *randomSensor = NULL; - bRaySensor *raySens = NULL; - bMessageSensor *mes = NULL; - bJoystickSensor *joy = NULL; - bActuatorSensor *as = NULL; - bDelaySensor *ds = NULL; - uiBut *but; - short ysize; - const char *str; - - /* yco is at the top of the rect, draw downwards */ - - set_col_sensor(sens->type, 0); - - switch (sens->type) { - case SENS_ALWAYS: - { - ysize= 24; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - - yco-= ysize; - - break; - } - case SENS_TOUCH: - { - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - - ts= sens->data; - - // uiDefBut(block, TEX, 1, "Property:", xco, yco-22, width, 19, &ts->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); - uiDefIDPoinBut(block, test_matpoin_but, ID_MA, 1, "MA:", (short)(xco + 10), (short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material"); - // uiDefButF(block, NUM, 1, "Margin:", xco+width/2, yco-44, width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity"); - yco-= ysize; - break; - } - case SENS_COLLISION: - { - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - cs= sens->data; - - /* The collision sensor will become a generic collision (i.e. it */ - /* absorb the old touch sensor). */ - - uiDefButBitS(block, TOG, SENS_COLLISION_PULSE, B_REDR, "Pulse", (short)(xco + 10), (short)(yco - 44), - (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0, - "Changes to the set of colliding objects generated pulses"); - - uiDefButBitS(block, TOG, SENS_COLLISION_MATERIAL, B_REDR, "M/P", (short)(xco + 10 + (0.20 * (width-20))), (short)(yco - 44), - (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0, - "Toggle collision on material or property"); - - if (cs->mode & SENS_COLLISION_MATERIAL) { - uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.40 * (width-20)), - (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, MAX_NAME, 0, 0, - "Only look for Objects with this material"); - } - else { - uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.40 * (width-20)), (short)(yco-44), - (short)(0.6*(width-20)), 19, &cs->name, 0, MAX_NAME, 0, 0, - "Only look for Objects with this property"); - } - - /* uiDefButS(block, NUM, 1, "Damp:", xco+10+width-90, yco-24, 70, 19, &cs->damp, 0, 250, 0, 0, "For 'damp' time don't detect another collision"); */ - - yco-= ysize; - break; - } - case SENS_NEAR: - { - ysize= 72; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - ns= sens->data; - - uiDefBut(block, TEX, 1, "Property:", (short)(10+xco), (short)(yco-44), (short)(width-20), 19, - &ns->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); - uiDefButF(block, NUM, 1, "Dist", (short)(10+xco), (short)(yco-68), (short)((width-22)/2), 19, - &ns->dist, 0.0, 1000.0, 1000, 0, "Trigger distance"); - uiDefButF(block, NUM, 1, "Reset", (short)(10+xco+(width-22)/2), (short)(yco-68), (short)((width-22)/2), 19, - &ns->resetdist, 0.0, 1000.0, 1000, 0, "Reset distance"); - yco-= ysize; - break; - } - case SENS_RADAR: - { - ysize= 72; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - - rs= sens->data; - - uiDefBut(block, TEX, 1, "Prop:", - (short)(10+xco), (short)(yco-44), (short)(0.7 * (width-20)), 19, - &rs->name, 0, MAX_NAME, 0, 0, - "Only look for Objects with this property"); - - str = "Type %t|+X axis %x0|+Y axis %x1|+Z axis %x2|-X axis %x3|-Y axis %x4|-Z axis %x5"; - uiDefButS(block, MENU, B_REDR, str, - (short)(10+xco+0.7 * (width-20)), (short)(yco-44), (short)(0.3 * (width-22)), 19, - &rs->axis, 2.0, 31, 0, 0, - "Specify along which axis the radar cone is cast"); - - uiDefButF(block, NUM, 1, "Ang:", - (short)(10+xco), (short)(yco-68), (short)((width-20)/2), 19, - &rs->angle, 0.0, 179.9, 10, 0, - "Opening angle of the radar cone"); - uiDefButF(block, NUM, 1, "Dist:", - (short)(xco+10 + (width-20)/2), (short)(yco-68), (short)((width-20)/2), 19, - &rs->range, 0.01, 10000.0, 100, 0, - "Depth of the radar cone"); - yco-= ysize; - break; - } - case SENS_KEYBOARD: - { - ks= sens->data; - - /* 5 lines: 120 height */ - ysize= (ks->type&1) ? 96:120; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - /* header line */ - draw_default_sensor_header(sens, block, xco, yco, width); - - /* part of line 1 */ - uiDefBut(block, LABEL, 0, "Key", xco, yco-44, 40, 19, NULL, 0, 0, 0, 0, ""); - uiDefButBitS(block, TOG, 1, B_REDR, "All keys", xco+40+(width/2), yco-44, (width/2)-50, 19, - &ks->type, 0, 0, 0, 0, ""); - - - if ((ks->type&1)==0) { /* is All Keys option off? */ - /* line 2: hotkey and allkeys toggle */ - but = uiDefKeyevtButS(block, 0, "", xco+40, yco-44, (width)/2, 19, &ks->key, "Key code"); - uiButSetFunc(but, test_keyboard_event, ks, NULL); - - /* line 3: two key modifyers (qual1, qual2) */ - uiDefBut(block, LABEL, 0, "Hold", xco, yco-68, 40, 19, NULL, 0, 0, 0, 0, ""); - but = uiDefKeyevtButS(block, 0, "", xco+40, yco-68, (width-50)/2, 19, &ks->qual, "Modifier key code"); - uiButSetFunc(but, test_keyboard_event, ks, NULL); - but = uiDefKeyevtButS(block, 0, "", xco+40+(width-50)/2, yco-68, (width-50)/2, 19, &ks->qual2, "Second Modifier key code"); - uiButSetFunc(but, test_keyboard_event, ks, NULL); - } - - /* line 4: toggle property for string logging mode */ - uiDefBut(block, TEX, 1, "LogToggle: ", - xco+10, yco-((ks->type&1) ? 68:92), (width-20), 19, - ks->toggleName, 0, MAX_NAME, 0, 0, - "Property that indicates whether to log " - "keystrokes as a string"); - - /* line 5: target property for string logging mode */ - uiDefBut(block, TEX, 1, "Target: ", - xco+10, yco-((ks->type&1) ? 92:116), (width-20), 19, - ks->targetName, 0, MAX_NAME, 0, 0, - "Property that receives the keystrokes in case " - "a string is logged"); - - yco-= ysize; - break; - } - case SENS_PROPERTY: - { - ysize= 96; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - ps= sens->data; - - str= "Type %t|Equal %x0|Not Equal %x1|Interval %x2|Changed %x3"; - /* str= "Type %t|Equal %x0|Not Equal %x1"; */ - uiDefButI(block, MENU, B_REDR, str, xco+30, yco-44, width-60, 19, - &ps->type, 0, 31, 0, 0, "Type"); - - if (ps->type != SENS_PROP_EXPRESSION) { - uiDefBut(block, TEX, 1, "Prop: ", xco+30, yco-68, width-60, 19, - ps->name, 0, MAX_NAME, 0, 0, "Property name"); - } - - if (ps->type == SENS_PROP_INTERVAL) { - uiDefBut(block, TEX, 1, "Min: ", xco, yco-92, width/2, 19, - ps->value, 0, MAX_NAME, 0, 0, "check for min value"); - uiDefBut(block, TEX, 1, "Max: ", xco+width/2, yco-92, width/2, 19, - ps->maxvalue, 0, MAX_NAME, 0, 0, "check for max value"); - } - else if (ps->type == SENS_PROP_CHANGED) { - /* pass */ - } - else { - uiDefBut(block, TEX, 1, "Value: ", xco+30, yco-92, width-60, 19, - ps->value, 0, MAX_NAME, 0, 0, "check for value"); - } - - yco-= ysize; - break; - } - case SENS_ARMATURE: - { - ysize= 70; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - arm= sens->data; - - if (ob->type == OB_ARMATURE) { - uiBlockBeginAlign(block); - but = uiDefBut(block, TEX, 1, "Bone: ", - (xco+10), (yco-44), (width-20)/2, 19, - arm->posechannel, 0, MAX_NAME, 0, 0, - "Bone on which you want to check a constraint"); - uiButSetFunc(but, check_armature_sensor, but, arm); - but = uiDefBut(block, TEX, 1, "Cons: ", - (xco+10)+(width-20)/2, (yco-44), (width-20)/2, 19, - arm->constraint, 0, MAX_NAME, 0, 0, - "Name of the constraint you want to control"); - uiButSetFunc(but, check_armature_sensor, but, arm); - uiBlockEndAlign(block); - - str= "Type %t|State changed %x0|Lin error below %x1|Lin error above %x2|Rot error below %x3|Rot error above %x4"; - - uiDefButI(block, MENU, B_REDR, str, xco+10, yco-66, 0.4*(width-20), 19, - &arm->type, 0, 31, 0, 0, "Type"); - - if (arm->type != SENS_ARM_STATE_CHANGED) { - uiDefButF(block, NUM, 1, "Value: ", xco+10+0.4*(width-20), yco-66, 0.6*(width-20), 19, - &arm->value, -10000.0, 10000.0, 100, 0, "Test the error against this value"); - } - } - yco-= ysize; - break; - } - case SENS_ACTUATOR: - { - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - as= sens->data; - - uiDefBut(block, TEX, 1, "Act: ", xco+30, yco-44, width-60, 19, - as->name, 0, MAX_NAME, 0, 0, "Actuator name, actuator active state modifications will be detected"); - yco-= ysize; - break; - } - case SENS_DELAY: - { - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - ds = sens->data; - - uiDefButS(block, NUM, 0, "Delay", (short)(10+xco), (short)(yco-44), (short)((width-22)*0.4+10), 19, - &ds->delay, 0.0, 5000.0, 0, 0, "Delay in number of logic tics before the positive trigger (default 60 per second)"); - uiDefButS(block, NUM, 0, "Dur", (short)(10+xco+(width-22)*0.4+10), (short)(yco-44), (short)((width-22)*0.4-10), 19, - &ds->duration, 0.0, 5000.0, 0, 0, "If >0, delay in number of logic tics before the negative trigger following the positive trigger"); - uiDefButBitS(block, TOG, SENS_DELAY_REPEAT, 0, "REP", (short)(xco + 10 + (width-22)*0.8), (short)(yco - 44), - (short)(0.20 * (width-22)), 19, &ds->flag, 0.0, 0.0, 0, 0, - "Toggle repeat option. If selected, the sensor restarts after Delay+Dur logic tics"); - yco-= ysize; - break; - } - case SENS_MOUSE: - { - ms= sens->data; - /* Two lines: 48 pixels high. */ - ysize = 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - /* line 1: header */ - draw_default_sensor_header(sens, block, xco, yco, width); - - /* Line 2: type selection. The number are a bit mangled to get - * proper compatibility with older .blend files. */ - - /* Any sensor type default is 0 but the ms enum starts in 1. - * Therefore the mouse sensor is initialized to 1 in sca.c */ - str= "Type %t|Left button %x1|Middle button %x2|" - "Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32"; - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, (width*0.8f)-20, 19, - &ms->type, 0, 31, 0, 0, - "Specify the type of event this mouse sensor should trigger on"); - - if (ms->type==32) { - uiDefButBitS(block, TOG, SENS_MOUSE_FOCUS_PULSE, B_REDR, "Pulse", (short)(xco + 10) + (width*0.8f)-20, (short)(yco - 44), - (short)(0.20 * (width-20)), 19, &ms->flag, 0.0, 0.0, 0, 0, - "Moving the mouse over a different object generates a pulse"); - } - - yco-= ysize; - break; - } - case SENS_RANDOM: - { - ysize = 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - randomSensor = sens->data; - /* some files were wrongly written, avoid crash now */ - if (randomSensor) { - uiDefButI(block, NUM, 1, "Seed: ", xco+10, yco-44, (width-20), 19, - &randomSensor->seed, 0, 1000, 0, 0, - "Initial seed of the generator. (Choose 0 for not random)"); - } - yco-= ysize; - break; - } - case SENS_RAY: - { - ysize = 72; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - draw_default_sensor_header(sens, block, xco, yco, width); - raySens = sens->data; - - /* 1. property or material */ - uiDefButBitS(block, TOG, SENS_COLLISION_MATERIAL, B_REDR, "M/P", - xco + 10, yco - 44, 0.20 * (width-20), 19, - &raySens->mode, 0.0, 0.0, 0, 0, - "Toggle collision on material or property"); - - if (raySens->mode & SENS_COLLISION_MATERIAL) { - uiDefBut(block, TEX, 1, "Material:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, - &raySens->matname, 0, MAX_NAME, 0, 0, - "Only look for Objects with this material"); - } - else { - uiDefBut(block, TEX, 1, "Property:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, - &raySens->propname, 0, MAX_NAME, 0, 0, - "Only look for Objects with this property"); - } - - /* X-Ray option */ - uiDefButBitS(block, TOG, SENS_RAY_XRAY, 1, "X", - xco + 10, yco - 68, 0.10 * (width-20), 19, - &raySens->mode, 0.0, 0.0, 0, 0, - "Toggle X-Ray option (see through objects that don't have the property)"); - /* 2. sensing range */ - uiDefButF(block, NUM, 1, "Range", xco+10 + 0.10 * (width-20), yco-68, 0.5 * (width-20), 19, - &raySens->range, 0.01, 10000.0, 100, 0, - "Sense objects no farther than this distance"); - - /* 3. axis choice */ - str = "Type %t|+ X axis %x1|+ Y axis %x0|+ Z axis %x2|- X axis %x3|- Y axis %x4|- Z axis %x5"; - uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, - &raySens->axisflag, 2.0, 31, 0, 0, - "Specify along which axis the ray is cast"); - - yco-= ysize; - break; - } - case SENS_MESSAGE: - { - mes = sens->data; - ysize = 2 * 24; /* total number of lines * 24 pixels/line */ - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - /* line 1: header line */ - draw_default_sensor_header(sens, block, xco, yco, width); - - /* line 2: Subject filter */ - uiDefBut(block, TEX, 1, "Subject: ", - (xco+10), (yco-44), (width-20), 19, - mes->subject, 0, MAX_NAME, 0, 0, - "Optional subject filter: only accept messages with this subject" - ", or empty for all"); - - yco -= ysize; - break; - } - case SENS_JOYSTICK: - { - - ysize = 72; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - /* line 1: header */ - draw_default_sensor_header(sens, block, xco, yco, width); - - joy= sens->data; - - uiDefButC(block, NUM, 1, "Index:", xco+10, yco-44, 0.33 * (width-20), 19, - &joy->joyindex, 0, SENS_JOY_MAXINDEX-1, 100, 0, - "Specify which joystick to use"); - - str= "Type %t|Button %x0|Axis %x1|Single Axis %x3|Hat%x2"; - uiDefButC(block, MENU, B_REDR, str, xco+87, yco-44, 0.26 * (width-20), 19, - &joy->type, 0, 31, 0, 0, - "The type of event this joystick sensor is triggered on"); - - if (joy->type != SENS_JOY_AXIS_SINGLE) { - if (joy->flag & SENS_JOY_ANY_EVENT) { - switch (joy->type) { - case SENS_JOY_AXIS: - str = "All Axis Events"; - break; - case SENS_JOY_BUTTON: - str = "All Button Events"; - break; - default: - str = "All Hat Events"; - break; - } - } - else { - str = "All"; - } - - uiDefButBitS(block, TOG, SENS_JOY_ANY_EVENT, B_REDR, str, - xco+10 + 0.475 * (width-20), yco-68, ((joy->flag & SENS_JOY_ANY_EVENT) ? 0.525 : 0.12) * (width-20), 19, - &joy->flag, 0, 0, 0, 0, - "Triggered by all events on this joysticks current type (axis/button/hat)"); - } - if (joy->type == SENS_JOY_BUTTON) { - if ((joy->flag & SENS_JOY_ANY_EVENT)==0) { - uiDefButI(block, NUM, 1, "Number:", xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, - &joy->button, 0, 18, 100, 0, - "Specify which button to use"); - } - } - else if (joy->type == SENS_JOY_AXIS) { - uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, - &joy->axis, 1, 8.0, 100, 0, - "Specify which axis pair to use, 1 is useually the main direction input"); - - uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20), yco-44, 0.4 * (width-20), 19, - &joy->precision, 0, 32768.0, 100, 0, - "Specify the precision of the axis"); - - if ((joy->flag & SENS_JOY_ANY_EVENT)==0) { - str = "Type %t|Up Axis %x1 |Down Axis %x3|Left Axis %x2|Right Axis %x0"; - uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, - &joy->axisf, 2.0, 31, 0, 0, - "The direction of the axis, use 'All Events' to receive events on any direction"); - } - } - else if (joy->type == SENS_JOY_HAT) { - uiDefButI(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, - &joy->hat, 1, 4.0, 100, 0, - "Specify which hat to use"); - - if ((joy->flag & SENS_JOY_ANY_EVENT)==0) { - str = "Direction%t|Up%x1|Down%x4|Left%x8|Right%x2|%l|Up/Right%x3|Down/Left%x12|Up/Left%x9|Down/Right%x6"; - uiDefButI(block, MENU, 0, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, - &joy->hatf, 2.0, 31, 0, 0, - "The direction of the hat, use 'All Events' to receive events on any direction"); - } - } - else { /* (joy->type == SENS_JOY_AXIS_SINGLE)*/ - uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, - &joy->axis_single, 1, 16.0, 100, 0, - "Specify a single axis (verticle/horizontal/other) to detect"); - - uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20), yco-44, 0.4 * (width-20), 19, - &joy->precision, 0, 32768.0, 100, 0, - "Specify the precision of the axis"); - } - yco-= ysize; - break; - } - } - - return yco-4; -} - - - -static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco, short yco, short width) -{ - bExpressionCont *ec; - bPythonCont *pc; - short ysize; - - switch (cont->type) { - case CONT_EXPRESSION: - ysize= 28; - - UI_ThemeColor(TH_PANEL); - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - /* uiDefBut(block, LABEL, 1, "Not yet...", xco, yco-24, 80, 19, NULL, 0, 0, 0, 0, ""); */ - ec= cont->data; - /* uiDefBut(block, BUT, 1, "Variables", xco, yco-24, 80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */ - uiDefBut(block, TEX, 1, "Exp:", xco + 10, yco-21, width-20, 19, - ec->str, 0, sizeof(ec->str), 0, 0, - "Expression"); - - yco-= ysize; - break; - case CONT_PYTHON: - ysize= 28; - - if (cont->data==NULL) init_controller(cont); - pc= cont->data; - - UI_ThemeColor(TH_PANEL); - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - - uiBlockBeginAlign(block); - uiDefButI(block, MENU, B_REDR, "Execution Method%t|Script%x0|Module%x1", xco+4, yco-23, 66, 19, &pc->mode, 0, 0, 0, 0, "Python script type (textblock or module - faster)"); - if (pc->mode==0) - uiDefIDPoinBut(block, test_scriptpoin_but, ID_TXT, 1, "", xco+70, yco-23, width-74, 19, &pc->text, "Blender textblock to run as a script"); - else { - uiDefBut(block, TEX, 1, "", xco+70, yco-23, (width-70)-25, 19, pc->module, 0, sizeof(pc->module), 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used"); - uiDefButBitI(block, TOG, CONT_PY_DEBUG, B_REDR, "D", (xco+width)-25, yco-23, 19, 19, &pc->flag, 0, 0, 0, 0, "Continuously reload the module from disk for editing external modules without restarting"); - } - uiBlockEndAlign(block); - - yco-= ysize; - break; - - default: - ysize= 4; - - UI_ThemeColor(TH_PANEL); - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - yco-= ysize; - } - - return yco; -} - -static int get_col_actuator(int type) -{ - switch (type) { - case ACT_ACTION: return TH_PANEL; - case ACT_SHAPEACTION: return TH_PANEL; - case ACT_OBJECT: return TH_PANEL; - case ACT_IPO: return TH_PANEL; - case ACT_PROPERTY: return TH_PANEL; - case ACT_SOUND: return TH_PANEL; - case ACT_CAMERA: return TH_PANEL; - case ACT_EDIT_OBJECT: return TH_PANEL; - case ACT_GROUP: return TH_PANEL; - case ACT_RANDOM: return TH_PANEL; - case ACT_SCENE: return TH_PANEL; - case ACT_MESSAGE: return TH_PANEL; - case ACT_GAME: return TH_PANEL; - case ACT_VISIBILITY: return TH_PANEL; - case ACT_CONSTRAINT: return TH_PANEL; - case ACT_STATE: return TH_PANEL; - case ACT_ARMATURE: return TH_PANEL; - case ACT_STEERING: return TH_PANEL; - default: return TH_PANEL; - } -} -static void set_col_actuator(int item, int medium) -{ - int col= get_col_actuator(item); - UI_ThemeColorShade(col, medium?30:10); - -} - -static void change_object_actuator(bContext *UNUSED(C), void *act, void *UNUSED(arg)) -{ - bObjectActuator *oa = act; - - if (oa->type != oa->otype) { - switch (oa->type) { - case ACT_OBJECT_NORMAL: - memset(oa, 0, sizeof(bObjectActuator)); - oa->flag = ACT_FORCE_LOCAL|ACT_TORQUE_LOCAL|ACT_DLOC_LOCAL|ACT_DROT_LOCAL; - oa->type = ACT_OBJECT_NORMAL; - break; - - case ACT_OBJECT_SERVO: - memset(oa, 0, sizeof(bObjectActuator)); - oa->flag = ACT_LIN_VEL_LOCAL; - oa->type = ACT_OBJECT_SERVO; - oa->forcerot[0] = 30.0f; - oa->forcerot[1] = 0.5f; - oa->forcerot[2] = 0.0f; - break; - } - } -} - -static void change_ipo_actuator(bContext *UNUSED(C), void *arg1_but, void *arg2_ia) -{ - bIpoActuator *ia = arg2_ia; - uiBut *but = arg1_but; - - if (but->retval & ACT_IPOFORCE) - ia->flag &= ~ACT_IPOADD; - else if (but->retval & ACT_IPOADD) - ia->flag &= ~ACT_IPOFORCE; - but->retval = B_REDR; -} - -static void update_object_actuator_PID(bContext *UNUSED(C), void *act, void *UNUSED(arg)) -{ - bObjectActuator *oa = act; - oa->forcerot[0] = 60.0f*oa->forcerot[1]; -} - -static char *get_state_name(Object *ob, short bit) -{ - bController *cont; - unsigned int mask; - - mask = (1<<bit); - cont = ob->controllers.first; - while (cont) { - if (cont->state_mask & mask) { - return cont->name; - } - cont = cont->next; - } - return (char*)""; -} - -static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask) -{ - wmWindow *win= CTX_wm_window(C); - int shift= win->eventstate->shift; - unsigned int *cont_mask = arg2_mask; - uiBut *but = arg1_but; - - if (*cont_mask == 0 || !(shift)) - *cont_mask = (1<<but->retval); - but->retval = B_REDR; -} - -static void check_armature_actuator(bContext *C, void *arg1_but, void *arg2_act) -{ - bArmatureActuator *act = arg2_act; - uiBut *but = arg1_but; - Object *ob= CTX_data_active_object(C); - - /* check that bone exist in the active object */ - but->retval = B_REDR; - check_armature_bone_constraint(ob, act->posechannel, act->constraint); -} - - -static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) -{ - bSoundActuator *sa = NULL; - bObjectActuator *oa = NULL; - bIpoActuator *ia = NULL; - bPropertyActuator *pa = NULL; - bCameraActuator *ca = NULL; - bEditObjectActuator *eoa = NULL; - bConstraintActuator *coa = NULL; - bSceneActuator *sca = NULL; - bGroupActuator *ga = NULL; - bRandomActuator *randAct = NULL; - bMessageActuator *ma = NULL; - bActionActuator *aa = NULL; - bGameActuator *gma = NULL; - bVisibilityActuator *visAct = NULL; - bTwoDFilterActuator *tdfa = NULL; - bParentActuator *parAct = NULL; - bStateActuator *staAct = NULL; - bArmatureActuator *armAct = NULL; - - float *fp; - short ysize = 0, wval; - const char *str; - int myline, stbit; - uiBut *but; - - - /* yco is at the top of the rect, draw downwards */ - set_col_actuator(act->type, 0); - - switch (act->type) { - case ACT_OBJECT: - { - oa = act->data; - wval = (width-100)/3; - if (oa->type == ACT_OBJECT_NORMAL) { - if (ob->gameflag & OB_DYNAMIC) { - ysize= 175; - } - else { - ysize= 72; - } - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiBlockBeginAlign(block); - uiDefBut(block, LABEL, 0, "Loc", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, "Sets the location"); - uiDefButF(block, NUM, 0, "", xco+45, yco-45, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-45, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-45, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, ""); - uiBlockEndAlign(block); - - uiDefBut(block, LABEL, 0, "Rot", xco, yco-64, 45, 19, NULL, 0, 0, 0, 0, "Sets the rotation"); - uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "", xco+45, yco-64, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-64, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-64, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, ""); - uiBlockEndAlign(block); - - uiDefButBitS(block, TOG, ACT_DLOC_LOCAL, 0, "L", xco+45+3*wval, yco-45, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_DROT_LOCAL, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - - if (ob->gameflag & OB_DYNAMIC) { - uiDefBut(block, LABEL, 0, "Force", xco, yco-87, 55, 19, NULL, 0, 0, 0, 0, "Sets the force"); - uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "", xco+45, yco-87, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-87, wval, 19, oa->forceloc+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-87, wval, 19, oa->forceloc+2, -10000.0, 10000.0, 10, 0, ""); - uiBlockEndAlign(block); - - uiDefBut(block, LABEL, 0, "Torque", xco, yco-106, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque"); - uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-106, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, ""); - uiBlockEndAlign(block); - } - - if (ob->gameflag & OB_DYNAMIC) { - uiDefBut(block, LABEL, 0, "LinV", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity"); - uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, ""); - uiBlockEndAlign(block); - - uiDefBut(block, LABEL, 0, "AngV", xco, yco-148, 45, 19, NULL, 0, 0, 0, 0, "Sets the angular velocity"); - uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "", xco+45, yco-148, wval, 19, oa->angularvelocity, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-148, wval, 19, oa->angularvelocity+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-148, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, ""); - uiBlockEndAlign(block); - - uiDefBut(block, LABEL, 0, "Damp", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Number of frames to reach the target velocity"); - uiDefButS(block, NUM, 0, "", xco+45, yco-171, wval, 19, &oa->damping, 0.0, 1000.0, 100, 0, ""); - - uiDefButBitS(block, TOG, ACT_FORCE_LOCAL, 0, "L", xco+45+3*wval, yco-87, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_TORQUE_LOCAL, 0, "L", xco+45+3*wval, yco-106, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-129, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_ANG_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-148, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - - uiDefButBitS(block, TOG, ACT_ADD_LIN_VEL, 0, "use_additive", xco+45+3*wval+15, yco-129, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV"); - } - } - else if (oa->type == ACT_OBJECT_SERVO) { - ysize= 195; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefBut(block, LABEL, 0, "Ref", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, ""); - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+45, yco-45, wval*3, 19, &(oa->reference), "Reference object for velocity calculation, leave empty for world reference"); - uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19, NULL, 0, 0, 0, 0, "Sets the target relative linear velocity, it will be achieved by automatic application of force. Null velocity is a valid target"); - uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, ""); - uiBlockEndAlign(block); - uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-68, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Velocity is defined in local coordinates"); - - uiDefBut(block, LABEL, 0, "Limit", xco, yco-91, 45, 19, NULL, 0, 0, 0, 0, "Select if the force needs to be limited along certain axis (local or global depending on LinV Local flag)"); - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_X, B_REDR, "X", xco+45, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the X axis"); - uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_Y, B_REDR, "Y", xco+45+wval, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the Y axis"); - uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_Z, B_REDR, "Z", xco+45+2*wval, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the Z axis"); - uiBlockEndAlign(block); - uiDefBut(block, LABEL, 0, "Max", xco, yco-110, 45, 19, NULL, 0, 0, 0, 0, "Set the upper limit for force"); - uiDefBut(block, LABEL, 0, "Min", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Set the lower limit for force"); - if (oa->flag & ACT_SERVO_LIMIT_X) { - uiDefButF(block, NUM, 0, "", xco+45, yco-110, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, ""); - } - if (oa->flag & ACT_SERVO_LIMIT_Y) { - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-110, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, ""); - } - if (oa->flag & ACT_SERVO_LIMIT_Z) { - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-110, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, ""); - } - uiDefBut(block, LABEL, 0, "Servo", xco, yco-152, 45, 19, NULL, 0, 0, 0, 0, "Coefficients of the PID servo controller"); - uiDefButF(block, NUMSLI, B_REDR, "P: ", xco+45, yco-152, wval*3, 19, oa->forcerot, 0.00, 200.0, 100, 0, "Proportional coefficient, typical value is 60x Integral coefficient"); - uiDefBut(block, LABEL, 0, "Slow", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Low value of I coefficient correspond to slow response"); - but = uiDefButF(block, NUMSLI, B_REDR, " I : ", xco+45, yco-171, wval*3, 19, oa->forcerot+1, 0.0, 3.0, 1, 0, "Integral coefficient, low value (0.01) for slow response, high value (0.5) for fast response"); - uiButSetFunc(but, update_object_actuator_PID, oa, NULL); - uiDefBut(block, LABEL, 0, "Fast", xco+45+3*wval, yco-171, 45, 19, NULL, 0, 0, 0, 0, "High value of I coefficient correspond to fast response"); - uiDefButF(block, NUMSLI, B_REDR, "D: ", xco+45, yco-190, wval*3, 19, oa->forcerot+2, -100.0, 100.0, 100, 0, "Derivate coefficient, not required, high values can cause instability"); - } - str= "Motion Type %t|Simple motion %x0|Servo Control %x1"; - but = uiDefButS(block, MENU, B_REDR, str, xco+40, yco-23, (width-80), 19, &oa->type, 0.0, 0.0, 0, 0, ""); - oa->otype = oa->type; - uiButSetFunc(but, change_object_actuator, oa, NULL); - yco-= ysize; - break; - } - case ACT_ACTION: - case ACT_SHAPEACTION: - { - /* DrawAct */ -#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - ysize = 112; -#else - ysize= 92; -#endif - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - aa = act->data; - wval = (width-60)/3; - - // str= "Action types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; -#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6|Displacement %x7"; -#else - str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; -#endif - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, width/3, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type"); - uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+10+ (width/3), yco-24, ((width/3)*2) - (20 + 60), 19, &aa->act, "Action name"); - - uiDefButBitS(block, TOGN, 1, 0, "Continue", xco+((width/3)*2)+20, yco-24, 60, 19, - &aa->end_reset, 0.0, 0.0, 0, 0, "Restore last frame when switching on/off, otherwise play from the start each time"); - - - if (aa->type == ACT_ACTION_FROM_PROP) { - uiDefBut(block, TEX, 0, "Prop: ", xco+10, yco-44, width-20, 19, aa->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Action position"); - } - else { - uiDefButF(block, NUM, 0, "Sta: ", xco+10, yco-44, (width-20)/2, 19, &aa->sta, 1.0, MAXFRAMEF, 0, 0, "Start frame"); - uiDefButF(block, NUM, 0, "End: ", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &aa->end, 1.0, MAXFRAMEF, 0, 0, "End frame"); - } - - uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending"); - uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack"); - - uiDefBut(block, TEX, 0, "FrameProp: ", xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, MAX_NAME, 0, 0, "Assign the action's current frame number to this property"); - - -#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - if (aa->type == ACT_ACTION_MOTION) { - uiDefButF(block, NUM, 0, "Cycle: ", xco+30, yco-84, (width-60)/2, 19, &aa->stridelength, 0.0, 2500.0, 0, 0, "Distance covered by a single cycle of the action"); - } -#endif - - - - yco-=ysize; - break; - } - case ACT_IPO: - { - ia= act->data; - - ysize= 72; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - str = "Ipo types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; - - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, (width-20)/2, 19, &ia->type, 0, 0, 0, 0, ""); - - but = uiDefButBitS(block, TOG, ACT_IPOFORCE, ACT_IPOFORCE, - "Force", xco+10+(width-20)/2, yco-24, (width-20)/4-10, 19, - &ia->flag, 0, 0, 0, 0, - "Apply Ipo as a global or local force depending on the local option (dynamic objects only)"); - uiButSetFunc(but, change_ipo_actuator, but, ia); - - but = uiDefButBitS(block, TOG, ACT_IPOADD, ACT_IPOADD, - "Add", xco+3*(width-20)/4, yco-24, (width-20)/4-10, 19, - &ia->flag, 0, 0, 0, 0, - "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag"); - uiButSetFunc(but, change_ipo_actuator, but, ia); - - /* Only show the do-force-local toggle if force is requested */ - if (ia->flag & (ACT_IPOFORCE|ACT_IPOADD)) { - uiDefButBitS(block, TOG, ACT_IPOLOCAL, 0, - "L", xco+width-30, yco-24, 20, 19, - &ia->flag, 0, 0, 0, 0, - "Let the ipo acts in local coordinates, used in Force and Add mode"); - } - - if (ia->type==ACT_IPO_FROM_PROP) { - uiDefBut(block, TEX, 0, - "Prop: ", xco+10, yco-44, width-80, 19, - ia->name, 0.0, MAX_NAME, 0, 0, - "Use this property to define the Ipo position"); - } - else { - uiDefButF(block, NUM, 0, - "Sta", xco+10, yco-44, (width-80)/2, 19, - &ia->sta, 1.0, MAXFRAMEF, 0, 0, - "Start frame"); - uiDefButF(block, NUM, 0, - "End", xco+10+(width-80)/2, yco-44, (width-80)/2, 19, - &ia->end, 1.0, MAXFRAMEF, 0, 0, - "End frame"); - } - uiDefButBitS(block, TOG, ACT_IPOCHILD, B_REDR, - "Child", xco+10+(width-80), yco-44, 60, 19, - &ia->flag, 0, 0, 0, 0, - "Update IPO on all children Objects as well"); - uiDefBut(block, TEX, 0, - "FrameProp: ", xco+10, yco-64, width-20, 19, - ia->frameProp, 0.0, MAX_NAME, 0, 0, - "Assign the action's current frame number to this property"); - - yco-= ysize; - break; - } - case ACT_PROPERTY: - { - ysize= 68; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - pa= act->data; - - str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle (bool/int/float/timer)%x3"; - uiDefButI(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &pa->type, 0, 31, 0, 0, "Type"); - - uiDefBut(block, TEX, 1, "Prop: ", xco+30, yco-44, width-60, 19, pa->name, 0, MAX_NAME, 0, 0, "Property name"); - - - if (pa->type==ACT_PROP_TOGGLE) { - /* no ui */ - ysize -= 22; - } - else if (pa->type==ACT_PROP_COPY) { - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); - uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, MAX_NAME, 0, 0, "Copy this property"); - } - else { - uiDefBut(block, TEX, 1, "Value: ", xco+30, yco-64, width-60, 19, pa->value, 0, MAX_NAME, 0, 0, "change with this value, use \"\" around strings"); - } - yco-= ysize; - - break; - } - case ACT_SOUND: - { - sa = act->data; - sa->sndnr = 0; - - if (sa->flag & ACT_SND_3D_SOUND) - ysize = 180; - else - ysize = 92; - - wval = (width-20)/2; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - if (bmain->sound.first) { - IDnames_to_pupstring(&str, "Sound files", NULL, &(bmain->sound), (ID *)sa->sound, &(sa->sndnr)); - /* reset this value, it is for handling the event */ - sa->sndnr = 0; - uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10, yco-22, 20, 19, &(sa->sndnr), 0, 0, 0, 0, ""); - uiDefButO(block, BUT, "sound.open", 0, "Load Sound", xco+wval+10, yco-22, wval, 19, - "Load a sound file (remember to set caching on for small sounds that are played often)"); - - if (sa->sound) { - char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|" - "Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; - uiDefBut(block, TEX, B_IDNAME, "SO:", xco+30, yco-22, wval-20, 19, - ((ID *)sa->sound)->name+2, 0.0, MAX_ID_NAME-2, 0, 0, ""); - uiDefButS(block, MENU, 1, dummy_str, xco+10, yco-44, width-20, 19, - &sa->type, 0.0, 0.0, 0, 0, ""); - uiDefButF(block, NUM, 0, "Volume:", xco+10, yco-66, wval, 19, &sa->volume, - 0.0, 1.0, 0, 0, "Sets the volume of this sound"); - uiDefButF(block, NUM, 0, "Pitch:", xco+wval+10, yco-66, wval, 19, &sa->pitch, -12.0, - 12.0, 0, 0, "Sets the pitch of this sound"); - uiDefButS(block, TOG | UI_BUT_POIN_BIT, 0, "3D Sound", xco+10, yco-88, width-20, 19, - &sa->flag, 0.0, 1.0, 0.0, 0.0, "Plays the sound positioned in 3D space"); - if (sa->flag & ACT_SND_3D_SOUND) { - uiDefButF(block, NUM, 0, "Minimum Gain: ", xco+10, yco-110, wval, 19, - &sa->sound3D.min_gain, 0.0, 1.0, 0.0, 0.0, - "The minimum gain of the sound, no matter how far it is away"); - uiDefButF(block, NUM, 0, "Maximum Gain: ", xco+10, yco-132, wval, 19, - &sa->sound3D.max_gain, 0.0, 1.0, 0.0, 0.0, - "The maximum gain of the sound, no matter how near it is"); - uiDefButF(block, NUM, 0, "Reference Distance: ", xco+10, yco-154, wval, 19, - &sa->sound3D.reference_distance, 0.0, FLT_MAX, 0.0, 0.0, - "The reference distance is the distance where the sound has a gain of 1.0"); - uiDefButF(block, NUM, 0, "Maximum Distance: ", xco+10, yco-176, wval, 19, - &sa->sound3D.max_distance, 0.0, FLT_MAX, 0.0, 0.0, - "The maximum distance at which you can hear the sound"); - uiDefButF(block, NUM, 0, "Rolloff: ", xco+wval+10, yco-110, wval, 19, - &sa->sound3D.rolloff_factor, 0.0, 5.0, 0.0, 0.0, - "The rolloff factor defines the influence factor on volume depending on distance"); - uiDefButF(block, NUM, 0, "Cone Outer Gain: ", xco+wval+10, yco-132, wval, 19, - &sa->sound3D.cone_outer_gain, 0.0, 1.0, 0.0, 0.0, - "The gain outside the outer cone. The gain in the outer cone will be " - "interpolated between this value and the normal gain in the inner cone"); - uiDefButF(block, NUM, 0, "Cone Outer Angle: ", xco+wval+10, yco-154, wval, - 19, &sa->sound3D.cone_outer_angle, 0.0, 360.0, 0.0, 0.0, - "The angle of the outer cone"); - uiDefButF(block, NUM, 0, "Cone Inner Angle: ", xco+wval+10, yco-176, wval, - 19, &sa->sound3D.cone_inner_angle, 0.0, 360.0, 0.0, 0.0, - "The angle of the inner cone"); - } - } - MEM_freeN((void *)str); - } - else { - uiDefButO(block, BUT, "sound.open", 0, "Load Sound", xco+10, yco-22, width-20, 19, "Load a sound file"); - } - - yco-= ysize; - - break; - } - case ACT_CAMERA: - - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - ca= act->data; - - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object"); - uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, ""); - - uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, ""); - - if (ca->axis==0) ca->axis= 'x'; - uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis"); - uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis"); - - uiDefButF(block, NUM, 0, "Max:", xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, ""); - - yco-= ysize; - - break; - - case ACT_EDIT_OBJECT: - - eoa= act->data; - - if (eoa->type==ACT_EDOB_ADD_OBJECT) { - ysize = 92; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object and all its children (cant be on an visible layer)"); - uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives"); - - wval= (width-60)/3; - uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19, - NULL, 0, 0, 0, 0, - "Velocity upon creation"); - uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19, - eoa->linVelocity, -100.0, 100.0, 10, 0, - "Velocity upon creation, x component"); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19, - eoa->linVelocity+1, -100.0, 100.0, 10, 0, - "Velocity upon creation, y component"); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19, - eoa->linVelocity+2, -100.0, 100.0, 10, 0, - "Velocity upon creation, z component"); - uiDefButBitS(block, TOG, ACT_EDOB_LOCAL_LINV, 0, "L", xco+45+3*wval, yco-68, 15, 19, - &eoa->localflag, 0.0, 0.0, 0, 0, - "Apply the transformation locally"); - - - uiDefBut(block, LABEL, 0, "AngV", xco, yco-90, 45, 19, - NULL, 0, 0, 0, 0, - "Angular velocity upon creation"); - uiDefButF(block, NUM, 0, "", xco+45, yco-90, wval, 19, - eoa->angVelocity, -10000.0, 10000.0, 10, 0, - "Angular velocity upon creation, x component"); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-90, wval, 19, - eoa->angVelocity+1, -10000.0, 10000.0, 10, 0, - "Angular velocity upon creation, y component"); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-90, wval, 19, - eoa->angVelocity+2, -10000.0, 10000.0, 10, 0, - "Angular velocity upon creation, z component"); - uiDefButBitS(block, TOG, ACT_EDOB_LOCAL_ANGV, 0, "L", xco+45+3*wval, yco-90, 15, 19, - &eoa->localflag, 0.0, 0.0, 0, 0, - "Apply the rotation locally"); - - - } - else if (eoa->type==ACT_EDOB_END_OBJECT) { - ysize= 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - else if (eoa->type==ACT_EDOB_REPLACE_MESH) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_meshpoin_but, ID_ME, 1, "ME:", xco+40, yco-44, (width-80)/2, 19, &(eoa->me), "replace the existing, when left blank 'Phys' will remake the existing physics mesh"); - - uiDefButBitS(block, TOGN, ACT_EDOB_REPLACE_MESH_NOGFX, 0, "Gfx", xco+40 + (width-80)/2, yco-44, (width-80)/4, 19, &eoa->flag, 0, 0, 0, 0, "Replace the display mesh"); - uiDefButBitS(block, TOG, ACT_EDOB_REPLACE_MESH_PHYS, 0, "Phys", xco+40 + (width-80)/2 +(width-80)/4, yco-44, (width-80)/4, 19, &eoa->flag, 0, 0, 0, 0, "Replace the physics mesh (triangle bounds only. compound shapes not supported)"); - } - else if (eoa->type==ACT_EDOB_TRACK_TO) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Track to this Object"); - uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2-40, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the tracking takes"); - uiDefButS(block, TOG, 0, "3D", xco+width-50, yco-44, 40, 19, &eoa->flag, 0.0, 0.0, 0, 0, "Enable 3D tracking"); - } - else if (eoa->type==ACT_EDOB_DYNAMICS) { - ysize= 69; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - str= "Dynamic Operation %t|Restore Dynamics %x0|Suspend Dynamics %x1|Enable Rigid Body %x2|Disable Rigid Body %x3|Set Mass %x4"; - uiDefButS(block, MENU, B_REDR, str, xco+40, yco-44, (width-80), 19, &(eoa->dyn_operation), 0.0, 0.0, 0, 0, ""); - if (eoa->dyn_operation==4) { - uiDefButF(block, NUM, 0, "", xco+40, yco-63, width-80, 19, - &eoa->mass, 0.0, 10000.0, 10, 0, - "Mass for object"); - } - } - str= "Edit Object %t|Add Object %x0|End Object %x1|Replace Mesh %x2|Track to %x3|Dynamics %x4"; - uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &eoa->type, 0.0, 0.0, 0, 0, ""); - - yco-= ysize; - - break; - - case ACT_CONSTRAINT: - coa= act->data; - - if (coa->type == ACT_CONST_TYPE_LOC) { - ysize= 69; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - /* str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4|Rot X %x8|Rot Y %x16|Rot Z %x32"; */ - /* coa->flag &= ~(63); */ - str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4"; - coa->flag &= 7; - coa->time = 0; - uiDefButS(block, MENU, 1, str, xco+10, yco-65, 70, 19, &coa->flag, 0.0, 0.0, 0, 0, ""); - - uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter"); - uiDefBut(block, LABEL, 0, "Min", xco+80, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, LABEL, 0, "Max", xco+80+(width-90)/2, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); - - if (coa->flag & ACT_CONST_LOCX) fp= coa->minloc; - else if (coa->flag & ACT_CONST_LOCY) fp= coa->minloc+1; - else if (coa->flag & ACT_CONST_LOCZ) fp= coa->minloc+2; - else if (coa->flag & ACT_CONST_ROTX) fp= coa->minrot; - else if (coa->flag & ACT_CONST_ROTY) fp= coa->minrot+1; - else fp= coa->minrot+2; - - uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-90)/2, 19, fp, -2000.0, 2000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+80+(width-90)/2, yco-65, (width-90)/2, 19, fp+3, -2000.0, 2000.0, 10, 0, ""); - } - else if (coa->type == ACT_CONST_TYPE_DIST) { - ysize= 106; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32"; - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray"); - - uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter"); - uiDefBut(block, LABEL, 0, "Range", xco+80, yco-45, (width-115)/2, 19, NULL, 0.0, 0.0, 0, 0, "Set the maximum length of ray"); - uiDefButBitS(block, TOG, ACT_CONST_DISTANCE, B_REDR, "Dist", xco+80+(width-115)/2, yco-45, (width-115)/2, 19, &coa->flag, 0.0, 0.0, 0, 0, "Force distance of object to point of impact of ray"); - uiDefButBitS(block, TOG, ACT_CONST_LOCAL, 0, "L", xco+80+(width-115), yco-45, 25, 19, - &coa->flag, 0.0, 0.0, 0, 0, "Set ray along object's axis or global axis"); - - if (coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc; - else if (coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1; - else fp= coa->minloc+2; - - uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/2, 19, fp+3, 0.0, 2000.0, 10, 0, "Maximum length of ray"); - if (coa->flag & ACT_CONST_DISTANCE) - uiDefButF(block, NUM, 0, "", xco+80+(width-115)/2, yco-65, (width-115)/2, 19, fp, -2000.0, 2000.0, 10, 0, "Keep this distance to target"); - uiDefButBitS(block, TOG, ACT_CONST_NORMAL, 0, "N", xco+80+(width-115), yco-65, 25, 19, - &coa->flag, 0.0, 0.0, 0, 0, "Set object axis along (local axis) or parallel (global axis) to the normal at hit position"); - uiDefButBitS(block, TOG, ACT_CONST_MATERIAL, B_REDR, "M/P", xco+10, yco-84, 40, 19, - &coa->flag, 0.0, 0.0, 0, 0, "Detect material instead of property"); - if (coa->flag & ACT_CONST_MATERIAL) { - uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, MAX_NAME, 0, 0, - "Ray detects only Objects with this material"); - } - else { - uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, MAX_NAME, 0, 0, - "Ray detect only Objects with this property"); - } - uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19, - &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target"); - uiDefButS(block, NUM, 0, "time", xco+50, yco-103, (width-60)/2, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited"); - uiDefButS(block, NUM, 0, "rotDamp", xco+50+(width-60)/2, yco-103, (width-60)/2, 19, &(coa->rotdamp), 0.0, 100.0, 0, 0, "Use a different damping for orientation"); - } - else if (coa->type == ACT_CONST_TYPE_ORI) { - ysize= 87; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4"; - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Select the axis to be aligned along the reference direction"); - - uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter"); - uiDefBut(block, LABEL, 0, "X", xco+80, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, LABEL, 0, "Y", xco+80+(width-115)/3, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, LABEL, 0, "Z", xco+80+2*(width-115)/3, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/3, 19, &coa->maxrot[0], -2000.0, 2000.0, 10, 0, "X component of reference direction"); - uiDefButF(block, NUM, 0, "", xco+80+(width-115)/3, yco-65, (width-115)/3, 19, &coa->maxrot[1], -2000.0, 2000.0, 10, 0, "Y component of reference direction"); - uiDefButF(block, NUM, 0, "", xco+80+2*(width-115)/3, yco-65, (width-115)/3, 19, &coa->maxrot[2], -2000.0, 2000.0, 10, 0, "Z component of reference direction"); - - uiDefButS(block, NUM, 0, "time", xco+10, yco-84, 70, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited"); - uiDefButF(block, NUM, 0, "min", xco+80, yco-84, (width-115)/2, 19, &(coa->minloc[0]), 0.0, 180.0, 10, 1, "Minimum angle (in degree) to maintain with target direction. No correction is done if angle with target direction is between min and max"); - uiDefButF(block, NUM, 0, "max", xco+80+(width-115)/2, yco-84, (width-115)/2, 19, &(coa->maxloc[0]), 0.0, 180.0, 10, 1, "Maximum angle (in degree) allowed with target direction. No correction is done if angle with target direction is between min and max"); - } - else if (coa->type == ACT_CONST_TYPE_FH) { - ysize= 106; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32"; - uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray (in world coordinate)"); - - if (coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc; - else if (coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1; - else fp= coa->minloc+2; - - uiDefButF(block, NUM, 0, "damp", xco+10, yco-45, (width-70)/2, 19, &coa->maxrot[0], 0.0, 1.0, 1, 0, "Damping factor of the Fh spring force"); - uiDefButF(block, NUM, 0, "dist", xco+10+(width-70)/2, yco-45, (width-70)/2, 19, fp, 0.010, 2000.0, 10, 0, "Height of the Fh area"); - uiDefButBitS(block, TOG, ACT_CONST_DOROTFH, 0, "Rot Fh", xco+10+(width-70), yco-45, 50, 19, &coa->flag, 0.0, 0.0, 0, 0, "Keep object axis parallel to normal"); - - uiDefButF(block, NUMSLI, 0, "Fh ", xco+80, yco-65, (width-115), 19, fp+3, 0.0, 1.0, 0, 0, "Spring force within the Fh area"); - uiDefButBitS(block, TOG, ACT_CONST_NORMAL, 0, "N", xco+80+(width-115), yco-65, 25, 19, - &coa->flag, 0.0, 0.0, 0, 0, "Add a horizontal spring force on slopes"); - uiDefButBitS(block, TOG, ACT_CONST_MATERIAL, B_REDR, "M/P", xco+10, yco-84, 40, 19, - &coa->flag, 0.0, 0.0, 0, 0, "Detect material instead of property"); - if (coa->flag & ACT_CONST_MATERIAL) { - uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, MAX_NAME, 0, 0, - "Ray detects only Objects with this material"); - } - else { - uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, MAX_NAME, 0, 0, - "Ray detect only Objects with this property"); - } - uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19, - &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target"); - uiDefButS(block, NUM, 0, "time", xco+50, yco-103, 90, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited"); - uiDefButF(block, NUM, 0, "rotDamp", xco+140, yco-103, (width-150), 19, &coa->maxrot[1], 0.0, 1.0, 1, 0, "Use a different damping for rotation"); - } - str= "Constraint Type %t|Location %x0|Distance %x1|Orientation %x2|Force field %x3"; - but = uiDefButS(block, MENU, B_REDR, str, xco+40, yco-23, (width-80), 19, &coa->type, 0.0, 0.0, 0, 0, ""); - yco-= ysize; - break; - - case ACT_SCENE: - sca= act->data; - - if (sca->type==ACT_SCENE_RESTART) { - ysize= 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - else if (sca->type==ACT_SCENE_CAMERA) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object"); - } - else if (sca->type==ACT_SCENE_SET) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); - } - else if (sca->type==ACT_SCENE_ADD_FRONT) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); - } - else if (sca->type==ACT_SCENE_ADD_BACK) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); - } - else if (sca->type==ACT_SCENE_REMOVE) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); - } - else if (sca->type==ACT_SCENE_SUSPEND) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); - } - else if (sca->type==ACT_SCENE_RESUME) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene"); - } - - str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7"; - uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &sca->type, 0.0, 0.0, 0, 0, ""); - - yco-= ysize; - break; - case ACT_GAME: - { - gma = act->data; - if (gma->type == ACT_GAME_LOAD) { - //ysize = 68; - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44, width-20, 19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this blend file, use the \"//\" prefix for a path relative to the current blend file"); - // uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64, width-20, 19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation"); - } -#if 0 - else if (gma->type == ACT_GAME_START) { - ysize = 68; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44, width-20, 19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this file"); - uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64, width-20, 19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation"); - } -#endif - else if (ELEM4(gma->type, ACT_GAME_RESTART, ACT_GAME_QUIT, ACT_GAME_SAVECFG, ACT_GAME_LOADCFG)) { - ysize = 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - - //str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3"; - str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save bge.logic.globalDict %x4|Load bge.logic.globalDict %x5"; - uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &gma->type, 0.0, 0.0, 0, 0, ""); - - yco -= ysize; - break; - } - case ACT_GROUP: - ga= act->data; - - ysize= 52; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - str= "GroupKey types %t|Set Key %x6|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x5"; - - uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, ""); - if (ga->type==ACT_GROUP_SET) { - uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, MAX_NAME, 0, 0, "This name defines groupkey to be set"); - uiDefButI(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame"); - } - else if (ga->type==ACT_GROUP_FROM_PROP) { - uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Group position"); - } - else { - uiDefButI(block, NUM, 0, "State", xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame"); - uiDefButI(block, NUM, 0, "End", xco+20+(width-40)/2, yco-44, (width-40)/2, 19, &ga->end, 0.0, 2500.0, 0, 0, "End frame"); - } - yco-= ysize; - break; - - case ACT_VISIBILITY: - ysize = 24; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, - (float)yco-ysize, (float)xco+width, (float)yco, 1); - - visAct = act->data; - - uiBlockBeginAlign(block); - uiDefButBitI(block, TOGN, ACT_VISIBILITY_INVISIBLE, B_REDR, - "Visible", - xco + 10, yco - 20, (width - 20)/3, 19, &visAct->flag, - 0.0, 0.0, 0, 0, - "Set the objects visible. Initialized from the objects render restriction toggle (access in the outliner)"); - uiDefButBitI(block, TOG, ACT_VISIBILITY_OCCLUSION, B_REDR, - "Occlusion", - xco + 10 + ((width - 20)/3), yco - 20, (width - 20)/3, 19, &visAct->flag, - 0.0, 0.0, 0, 0, - "Set the object to occlude objects behind it. Initialized from the object type in physics button"); - uiBlockEndAlign(block); - - uiDefButBitI(block, TOG, ACT_VISIBILITY_RECURSIVE, 0, - "Children", - xco + 10 + (((width - 20)/3)*2)+10, yco - 20, ((width - 20)/3)-10, 19, &visAct->flag, - 0.0, 0.0, 0, 0, - "Sets all the children of this object to the same visibility/occlusion recursively"); - - yco-= ysize; - - break; - - case ACT_STATE: - ysize = 34; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, - (float)yco-ysize, (float)xco+width, (float)yco, 1); - - staAct = act->data; - - str= "Operation %t|Cpy %x0|Add %x1|Sub %x2|Inv %x3"; - - uiDefButI(block, MENU, B_REDR, str, - xco + 10, yco - 24, 65, 19, &staAct->type, - 0.0, 0.0, 0, 0, - "Select the bit operation on object state mask"); - - for (wval=0; wval<15; wval+=5) { - uiBlockBeginAlign(block); - for (stbit=0; stbit<5; stbit++) { - but = uiDefButBitI(block, TOG, 1<<(stbit+wval), stbit+wval, "", (short)(xco+85+12*stbit+13*wval), yco-17, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+wval))); - uiButSetFunc(but, check_state_mask, but, &(staAct->mask)); - } - for (stbit=0; stbit<5; stbit++) { - but = uiDefButBitI(block, TOG, 1<<(stbit+wval+15), stbit+wval+15, "", (short)(xco+85+12*stbit+13*wval), yco-29, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+wval+15))); - uiButSetFunc(but, check_state_mask, but, &(staAct->mask)); - } - } - uiBlockEndAlign(block); - - yco-= ysize; - - break; - - case ACT_RANDOM: - ysize = 69; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, - (float)yco-ysize, (float)xco+width, (float)yco, 1); - - randAct = act->data; - - /* 1. seed */ - uiDefButI(block, NUM, 1, "Seed: ", (xco+10), yco-24, 0.4 *(width-20), 19, - &randAct->seed, 0, 1000, 0, 0, - "Initial seed of the random generator. Use Python for more freedom. " - " (Choose 0 for not random)"); - - /* 2. distribution type */ - /* One pick per distribution. These numbers MUST match the #defines */ - /* in game.h !!! */ - str= "Distribution %t|Bool Constant %x0|Bool Uniform %x1" - "|Bool Bernoulli %x2|Int Constant %x3|Int Uniform %x4" - "|Int Poisson %x5|Float Constant %x6|Float Uniform %x7" - "|Float Normal %x8|Float Neg. Exp. %x9"; - uiDefButI(block, MENU, B_REDR, str, (xco+10) + 0.4 * (width-20), yco-24, 0.6 * (width-20), 19, - &randAct->distribution, 0.0, 0.0, 0, 0, - "Choose the type of distribution"); - - /* 3. property */ - uiDefBut(block, TEX, 1, "Property:", (xco+10), yco-44, (width-20), 19, - &randAct->propname, 0, MAX_NAME, 0, 0, - "Assign the random value to this property"); - - /*4. and 5. arguments for the distribution*/ - switch (randAct->distribution) { - case ACT_RANDOM_BOOL_CONST: - uiDefButBitI(block, TOG, 1, 1, "Always true", (xco+10), yco-64, (width-20), 19, - &randAct->int_arg_1, 2.0, 1, 0, 0, - "Always false or always true"); - break; - case ACT_RANDOM_BOOL_UNIFORM: - uiDefBut(block, LABEL, 0, " Do a 50-50 pick", (xco+10), yco-64, (width-20), 19, - NULL, 0, 0, 0, 0, - "Choose between true and false, 50% chance each"); - break; - case ACT_RANDOM_BOOL_BERNOUILLI: - uiDefButF(block, NUM, 1, "Chance", (xco+10), yco-64, (width-20), 19, - &randAct->float_arg_1, 0.0, 1.0, 0, 0, - "Pick a number between 0 and 1. Success if you stay " - "below this value"); - break; - case ACT_RANDOM_INT_CONST: - uiDefButI(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19, - &randAct->int_arg_1, -1000, 1000, 0, 0, - "Always return this number"); - break; - case ACT_RANDOM_INT_UNIFORM: - uiDefButI(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19, - &randAct->int_arg_1, -1000, 1000, 0, 0, - "Choose a number from a range. " - "Lower boundary of the range"); - uiDefButI(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, - &randAct->int_arg_2, -1000, 1000, 0, 0, - "Choose a number from a range. " - "Upper boundary of the range"); - break; - case ACT_RANDOM_INT_POISSON: - uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20), 19, - &randAct->float_arg_1, 0.01, 100.0, 0, 0, - "Expected mean value of the distribution"); - break; - case ACT_RANDOM_FLOAT_CONST: - uiDefButF(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19, - &randAct->float_arg_1, 0.0, 1.0, 0, 0, - "Always return this number"); - break; - case ACT_RANDOM_FLOAT_UNIFORM: - uiDefButF(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19, - &randAct->float_arg_1, -10000.0, 10000.0, 0, 0, - "Choose a number from a range" - "Lower boundary of the range"); - uiDefButF(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, - &randAct->float_arg_2, -10000.0, 10000.0, 0, 0, - "Choose a number from a range" - "Upper boundary of the range"); - break; - case ACT_RANDOM_FLOAT_NORMAL: - uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20)/2, 19, - &randAct->float_arg_1, -10000.0, 10000.0, 0, 0, - "A normal distribution. Mean of the distribution"); - uiDefButF(block, NUM, 1, "SD: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, - &randAct->float_arg_2, 0.0, 10000.0, 0, 0, - "A normal distribution. Standard deviation of the " - "distribution"); - break; - case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL: - uiDefButF(block, NUM, 1, "Half-life time: ", (xco+10), yco-64, (width-20), 19, - &randAct->float_arg_1, 0.001, 10000.0, 0, 0, - "Negative exponential dropoff"); - break; - default: - ; /* don't know what this distro is... can be useful for testing */ - /* though :) */ - } - - yco-= ysize; - break; - case ACT_MESSAGE: - ma = act->data; - - ysize = 4 + (3 * 24); /* footer + number of lines * 24 pixels/line */ - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, - (float)xco+width, (float)yco, 1); - - myline=1; - - /* line 1: To */ - uiDefBut(block, TEX, 1, "To: ", - (xco+10), (yco-(myline++*24)), (width-20), 19, - &ma->toPropName, 0, MAX_NAME, 0, 0, - "Optional send message to objects with this name only, or empty to broadcast"); - - /* line 2: Message Subject */ - uiDefBut(block, TEX, 1, "Subject: ", - (xco+10), (yco-(myline++*24)), (width-20), 19, - &ma->subject, 0, MAX_NAME, 0, 0, - "Optional message subject. This is what can be filtered on"); - - /* line 3: Text/Property */ - uiDefButBitS(block, TOG, 1, B_REDR, "T/P", - (xco+10), (yco-(myline*24)), (0.20 * (width-20)), 19, - &ma->bodyType, 0.0, 0.0, 0, 0, - "Toggle message type: either Text or a PropertyName"); - - if (ma->bodyType == ACT_MESG_MESG) { - /* line 3: Message Body */ - uiDefBut(block, TEX, 1, "Body: ", - (xco+10+(0.20*(width-20))), (yco-(myline++*24)), (0.8*(width-20)), 19, - &ma->body, 0, MAX_NAME, 0, 0, - "Optional message body Text"); - } - else { - /* line 3: Property body (set by property) */ - uiDefBut(block, TEX, 1, "Propname: ", - (xco+10+(0.20*(width-20))), (yco-(myline++*24)), (0.8*(width-20)), 19, - &ma->body, 0, MAX_NAME, 0, 0, - "The message body will be set by the Property Value"); - } - - yco -= ysize; - break; - case ACT_2DFILTER: - tdfa = act->data; - - ysize = 50; - if (tdfa->type == ACT_2DFILTER_CUSTOMFILTER) { - ysize +=20; - } - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - switch (tdfa->type) { - case ACT_2DFILTER_MOTIONBLUR: - if (!tdfa->flag) { - uiDefButS(block, TOG, B_REDR, "D", xco+30, yco-44, 19, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Disable Motion Blur"); - uiDefButF(block, NUM, B_REDR, "Value:", xco+52, yco-44, width-82, 19, &tdfa->float_arg, 0.0, 1.0, 0.0, 0.0, "Set motion blur value"); - } - else { - uiDefButS(block, TOG, B_REDR, "Disabled", xco+30, yco-44, width-60, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Enable Motion Blur"); - } - break; - case ACT_2DFILTER_BLUR: - case ACT_2DFILTER_SHARPEN: - case ACT_2DFILTER_DILATION: - case ACT_2DFILTER_EROSION: - case ACT_2DFILTER_LAPLACIAN: - case ACT_2DFILTER_SOBEL: - case ACT_2DFILTER_PREWITT: - case ACT_2DFILTER_GRAYSCALE: - case ACT_2DFILTER_SEPIA: - case ACT_2DFILTER_INVERT: - case ACT_2DFILTER_NOFILTER: - case ACT_2DFILTER_DISABLED: - case ACT_2DFILTER_ENABLED: - uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30, yco-44, width-60, 19, &tdfa->int_arg, 0.0, MAX_RENDER_PASS-1, 0.0, 0.0, "Set filter order"); - break; - case ACT_2DFILTER_CUSTOMFILTER: - uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30, yco-44, width-60, 19, &tdfa->int_arg, 0.0, MAX_RENDER_PASS-1, 0.0, 0.0, "Set filter order"); - uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Script: ", xco+30, yco-64, width-60, 19, &tdfa->text, ""); - break; - } - - str= "2D Filter %t|Motion Blur %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|" - "Laplacian %x6|Sobel %x7|Prewitt %x8|Gray Scale %x9|Sepia %x10|Invert %x11|Custom Filter %x12|" - "Enable Filter %x-2|Disable Filter %x-1|Remove Filter %x0|"; - uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &tdfa->type, 0.0, 0.0, 0.0, 0.0, "2D filter type"); - - yco -= ysize; - break; - case ACT_PARENT: - parAct = act->data; - - if (parAct->type==ACT_PARENT_SET) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+95, yco-24, (width-100), 19, &(parAct->ob), "Set this object as parent"); - uiBlockBeginAlign(block); - uiDefButBitS(block, TOGN, ACT_PARENT_COMPOUND, B_REDR, - "Compound", - xco + 5, yco - 44, (width - 10)/2, 19, &parAct->flag, - 0.0, 0.0, 0, 0, - "Add this object shape to the parent shape (only if the parent shape is already compound)"); - uiDefButBitS(block, TOGN, ACT_PARENT_GHOST, B_REDR, - "Ghost", - xco + 5 + ((width - 10)/2), yco - 44, (width - 10)/2, 19, &parAct->flag, - 0.0, 0.0, 0, 0, - "Make this object ghost while parented (only if not compound)"); - uiBlockEndAlign(block); - } - else if (parAct->type==ACT_PARENT_REMOVE) { - - ysize= 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - - str= "Parent %t|Set Parent %x0|Remove Parent %x1"; - uiDefButI(block, MENU, B_REDR, str, xco+5, yco-24, parAct->type==1?(width-80):90, 19, &parAct->type, 0.0, 0.0, 0, 0, ""); - - yco-= ysize; - break; - case ACT_ARMATURE: - armAct = act->data; - - if (ob->type == OB_ARMATURE) { - str= "Constraint %t|Run armature %x0|Enable %x1|Disable %x2|Set target %x3|Set weight %x4"; - uiDefButI(block, MENU, B_REDR, str, xco+5, yco-24, (width-10)*0.35, 19, &armAct->type, 0.0, 0.0, 0, 0, ""); - - switch (armAct->type) { - case ACT_ARM_RUN: - ysize = 28; - break; - default: - uiBlockBeginAlign(block); - but = uiDefBut(block, TEX, 1, "Bone: ", - (xco+5), (yco-44), (width-10)/2, 19, - armAct->posechannel, 0, MAX_NAME, 0, 0, - "Bone on which the constraint is defined"); - uiButSetFunc(but, check_armature_actuator, but, armAct); - but = uiDefBut(block, TEX, 1, "Cons: ", - (xco+5)+(width-10)/2, (yco-44), (width-10)/2, 19, - armAct->constraint, 0, MAX_NAME, 0, 0, - "Name of the constraint you want to control"); - uiButSetFunc(but, check_armature_actuator, but, armAct); - uiBlockEndAlign(block); - ysize = 48; - switch (armAct->type) { - case ACT_ARM_SETTARGET: - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "Target: ", xco+5, yco-64, (width-10), 19, &(armAct->target), "Set this object as the target of the constraint"); - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "Secondary Target: ", xco+5, yco-84, (width-10), 19, &(armAct->subtarget), "Set this object as the secondary target of the constraint (only IK polar target at the moment)"); - ysize += 40; - break; - case ACT_ARM_SETWEIGHT: - uiDefButF(block, NUM, B_REDR, "Weight:", xco+5+(width-10)*0.35, yco-24, (width-10)*0.65, 19, &armAct->weight, 0.0, 1.0, 0.0, 0.0, "Set weight of this constraint"); - break; - } - } - } - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - yco-= ysize; - break; - - default: - ysize= 4; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - yco-= ysize; - break; - } - - uiBlockSetEmboss(block, UI_EMBOSS); - - return yco-4; -} static void do_sensor_menu(bContext *C, void *UNUSED(arg), int event) { @@ -3084,8 +878,6 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) return block; } - - static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, void *arg2_mask) { unsigned int *cont_mask = arg2_mask; @@ -3096,17 +888,6 @@ static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, voi but->retval = B_REDR; } -static int first_bit(unsigned int mask) -{ - int bit; - - for (bit=0; bit<32; bit++) { - if (mask & (1<<bit)) - return bit; - } - return -1; -} - static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_cont) { uiBlock *block; @@ -3139,44 +920,6 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c return block; } -static void do_object_state_menu(bContext *UNUSED(C), void *arg, int event) -{ - Object *ob = arg; - - switch (event) { - case 0: - ob->state = 0x3FFFFFFF; - break; - case 1: - ob->state = ob->init_state; - if (!ob->state) - ob->state = 1; - break; - case 2: - ob->init_state = ob->state; - break; - } -} - -static uiBlock *object_state_mask_menu(bContext *C, ARegion *ar, void *arg_obj) -{ - uiBlock *block; - short xco = 0; - - block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); - uiBlockSetButmFunc(block, do_object_state_menu, arg_obj); - - uiDefBut(block, BUTM, 1, "Set all bits", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefBut(block, BUTM, 1, "Recall init state", 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, "Store init state", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiBlockSetDirection(block, UI_TOP); - uiEndBlock(C, block); - - return block; -} - static int is_sensor_linked(uiBlock *block, bSensor *sens) { bController *cont; @@ -4458,14 +2201,13 @@ static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C) } } -static void logic_buttons_new(bContext *C, ARegion *ar) +void logic_buttons(bContext *C, ARegion *ar) { SpaceLogic *slogic= CTX_wm_space_logic(C); Object *ob= CTX_data_active_object(C); - Object *act_ob= ob; ID **idar; - PointerRNA logic_ptr, settings_ptr; + PointerRNA logic_ptr, settings_ptr, object_ptr; uiLayout *layout, *row, *box; uiBlock *block; @@ -4558,8 +2300,10 @@ static void logic_buttons_new(bContext *C, ARegion *ar) 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"); - if (ob == act_ob) - uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE); + + 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); if (RNA_boolean_get(&settings_ptr, "show_state_panel")) { @@ -4574,9 +2318,9 @@ static void logic_buttons_new(bContext *C, ARegion *ar) col = uiLayoutColumn(subsplit, FALSE); row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&settings_ptr, "use_all_states") == FALSE); - uiTemplateLayers(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0); + uiTemplateGameStates(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0); row = uiLayoutRow(col, FALSE); - uiTemplateLayers(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0); + uiTemplateGameStates(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0); col = uiLayoutColumn(subsplit, FALSE); uiItemR(col, &settings_ptr, "use_all_states", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -4653,8 +2397,10 @@ static void logic_buttons_new(bContext *C, ARegion *ar) 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"); - if (ob == act_ob) - uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE); + + 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); if ((ob->scaflag & OB_SHOWSENS) == 0) continue; @@ -4721,8 +2467,10 @@ static void logic_buttons_new(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"); - if (ob == act_ob) - uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE); + + 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); if ((ob->scaflag & OB_SHOWACT) == 0) continue; @@ -4773,377 +2521,3 @@ static void logic_buttons_new(bContext *C, ARegion *ar) if (idar) MEM_freeN(idar); } -void logic_buttons(bContext *C, ARegion *ar) -{ - Main *bmain= CTX_data_main(C); - SpaceLogic *slogic= CTX_wm_space_logic(C); - Object *ob= CTX_data_active_object(C); - ID **idar; - bSensor *sens; - bController *cont; - bActuator *act; - uiBlock *block; - uiBut *but; - PointerRNA logic_ptr; - int a, iact, stbit, offset; - int xco, yco, width, ycoo; - short count; - char numstr[32]; - /* pin is a bool used for actuator and sensor drawing with states - * pin so changing states dosnt hide the logic brick */ - char pin; - - if (G.debug_value == 0) { - logic_buttons_new(C, ar); - return; - } - - if (ob==NULL) return; -// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - - BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar); - block= uiBeginBlock(C, ar, numstr, UI_EMBOSS); - uiBlockSetHandleFunc(block, do_logic_buts, NULL); - - RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr); - - idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - - /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that - * we can determine which is actually linked/visible */ - for (a=0; a<count; a++) { - ob= (Object *)idar[a]; - act= ob->actuators.first; - while (act) { - act->flag &= ~(ACT_LINKED|ACT_VISIBLE); - act = act->next; - } - /* same for sensors */ - sens= ob->sensors.first; - while (sens) { - sens->flag &= ~(SENS_VISIBLE); - sens = sens->next; - } - } - - /* start with the controller because we need to know which one is visible */ - /* ******************************* */ - xco= 400; yco= 170; width= 300; - - uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, UI_UNIT_Y, ""); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, BUTS_CONT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects"); - uiDefButBitS(block, TOG, BUTS_CONT_ACT, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object"); - uiDefButBitS(block, TOG, BUTS_CONT_LINK, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator"); - uiBlockEndAlign(block); - - for (a=0; a<count; a++) { - unsigned int controller_state_mask = 0; /* store a bitmask for states that are used */ - - ob= (Object *)idar[a]; -// uiClearButLock(); -// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if ((ob->scavisflag & OB_VIS_CONT) == 0) { - continue; - } - - /* presume it is only objects for now */ - uiBlockBeginAlign(block); -// if (ob->controllers.first) uiSetCurFont(block, UI_HELVB); - uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Active Object name"); -// if (ob->controllers.first) uiSetCurFont(block, UI_HELV); - uiDefButBitS(block, TOG, OB_ADDCONT, B_ADD_CONT, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller"); - uiBlockEndAlign(block); - yco-=20; - - /* mark all actuators linked to these controllers */ - /* note that some of these actuators could be from objects that are not in the display list. - * It's ok because those actuators will not be displayed here */ - cont= ob->controllers.first; - while (cont) { - for (iact=0; iact<cont->totlinks; iact++) { - act = cont->links[iact]; - if (act) - act->flag |= ACT_LINKED; - } - controller_state_mask |= cont->state_mask; - cont = cont->next; - } - - if (ob->scaflag & OB_SHOWCONT) { - - /* first show the state */ - uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 36, UI_UNIT_Y, "Object state menu: store and retrieve initial state"); - - if (!ob->state) - ob->state = 1; - for (offset=0; offset<15; offset+=5) { - uiBlockBeginAlign(block); - for (stbit=0; stbit<5; stbit++) { - but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+31+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset))); - uiButSetFunc(but, check_state_mask, but, &(ob->state)); - } - for (stbit=0; stbit<5; stbit++) { - but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+31+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15))); - uiButSetFunc(but, check_state_mask, but, &(ob->state)); - } - } - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, OB_ALLSTATE, B_SET_STATE_BIT, "All", (short)(xco+226), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set all state bits"); - uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini", (short)(xco+248), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set the initial state"); - uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D", (short)(xco+270), yco-10, 15, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Print state debug info"); - uiBlockEndAlign(block); - - yco-=35; - - /* display only the controllers that match the current state */ - offset = 0; - for (stbit=0; stbit<32; stbit++) { - if (!(ob->state & (1<<stbit))) - continue; - /* add a separation between controllers of different states */ - if (offset) { - offset = 0; - yco -= 6; - } - cont= ob->controllers.first; - while (cont) { - if (cont->state_mask & (1<<stbit)) { - /* this controller is visible, mark all its actuator */ - for (iact=0; iact<cont->totlinks; iact++) { - act = cont->links[iact]; - if (act) - act->flag |= ACT_VISIBLE; - } - uiDefIconButBitS(block, TOG, CONT_DEL, B_DEL_CONT, ICON_X, xco, yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Delete Controller"); - uiDefIconButBitS(block, ICONTOG, CONT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Controller settings"); - uiDefIconButBitS(block, TOG, CONT_PRIO, B_REDR, ICON_BOOKMARKS, (short)(xco+width-66), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Mark controller for execution before all non-marked controllers (good for startup scripts)"); - - sprintf(numstr, "%d", first_bit(cont->state_mask)+1); - uiDefBlockBut(block, controller_state_mask_menu, cont, numstr, (short)(xco+width-44), yco, 22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); - - if (cont->flag & CONT_SHOW) { - cont->otype= cont->type; - uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(), (short)(xco+22), yco, 70, UI_UNIT_Y, &cont->type, 0, 0, 0, 0, "Controller type"); - but = uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont->name, 0, MAX_NAME, 0, 0, "Controller name"); - uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0); - - ycoo= yco; - yco= draw_controllerbuttons(cont, block, xco, yco, width); - if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; - } - else { - cpack(0x999999); - glRecti(xco+22, yco, xco+width-22, yco+19); - but = uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 70, UI_UNIT_Y, cont, 0, 0, 0, 0, "Controller type"); - //uiButSetFunc(but, old_sca_move_controller, cont, NULL); - but = uiDefBut(block, LABEL, 0, cont->name, (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont, 0, 0, 0, 0, "Controller name"); - //uiButSetFunc(but, old_sca_move_controller, cont, NULL); - - uiBlockBeginAlign(block); - but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(110+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up"); - uiButSetFunc(but, old_sca_move_controller, cont, (void *)TRUE); - but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(88+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down"); - uiButSetFunc(but, old_sca_move_controller, cont, (void *)FALSE); - uiBlockEndAlign(block); - - ycoo= yco; - } - - but = uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); - - uiDefIconBut(block, INLINK, 0, ICON_INLINK, (short)(xco-19), ycoo, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, ""); - /* offset is >0 if at least one controller was displayed */ - offset++; - yco-=20; - } - cont= cont->next; - } - - } - yco-= 6; - } - } - - /* ******************************* */ - xco= 10; yco= 170; width= 300; - - uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 70, UI_UNIT_Y, ""); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, BUTS_SENS_SEL, B_REDR, "Sel", xco+80, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects"); - uiDefButBitS(block, TOG, BUTS_SENS_ACT, B_REDR, "Act", xco+80+(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object"); - uiDefButBitS(block, TOG, BUTS_SENS_LINK, B_REDR, "Link", xco+80+2*(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); - uiDefButBitS(block, TOG, BUTS_SENS_STATE, B_REDR, "State", xco+80+3*(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show only sensors connected to active states"); - uiBlockEndAlign(block); - - for (a=0; a<count; a++) { - ob= (Object *)idar[a]; -// uiClearButLock(); -// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - - if ((ob->scavisflag & OB_VIS_SENS) == 0) { - continue; - } - - /* presume it is only objects for now */ - uiBlockBeginAlign(block); -// if (ob->sensors.first) uiSetCurFont(block, UI_HELVB); - 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"); -// if (ob->sensors.first) uiSetCurFont(block, UI_HELV); - uiDefButBitS(block, TOG, OB_ADDSENS, B_ADD_SENS, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor"); - uiBlockEndAlign(block); - yco-=20; - - if (ob->scaflag & OB_SHOWSENS) { - - sens= ob->sensors.first; - while (sens) { - if (!(slogic->scaflag & BUTS_SENS_STATE) || - (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */ - (sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */ - (is_sensor_linked(block, sens)) - ) { - /* should we draw the pin? - for now always draw when there is a state */ - pin = (slogic->scaflag & BUTS_SENS_STATE && (sens->flag & SENS_SHOW || sens->flag & SENS_PIN)) ? 1 : 0; - - sens->flag |= SENS_VISIBLE; - uiDefIconButBitS(block, TOG, SENS_DEL, B_DEL_SENS, ICON_X, xco, yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Delete Sensor"); - if (pin) - uiDefIconButBitS(block, ICONTOG, SENS_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller"); - - uiDefIconButBitS(block, ICONTOG, SENS_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Sensor settings"); - - ycoo= yco; - if (sens->flag & SENS_SHOW) { - uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 80, UI_UNIT_Y, &sens->type, 0, 0, 0, 0, "Sensor type"); - but = uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens->name, 0, MAX_NAME, 0, 0, "Sensor name"); - uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0); - - sens->otype= sens->type; - yco= draw_sensorbuttons(ob, sens, block, xco, yco, width); - if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; - } - else { - set_col_sensor(sens->type, 1); - glRecti(xco + 22, yco, xco + width - 22, yco + 19); - but = uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 80, UI_UNIT_Y, sens, 0, 0, 0, 0, ""); - //uiButSetFunc(but, old_sca_move_sensor, sens, NULL); - but = uiDefBut(block, LABEL, 0, sens->name, (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens, 0, MAX_NAME, 0, 0, ""); - //uiButSetFunc(but, old_sca_move_sensor, sens, NULL); - - uiBlockBeginAlign(block); - but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(66+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up"); - uiButSetFunc(but, old_sca_move_sensor, sens, (void *)TRUE); - but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(44+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down"); - uiButSetFunc(but, old_sca_move_sensor, sens, (void *)FALSE); - uiBlockEndAlign(block); - } - - but = uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); - - yco-=20; - } - sens= sens->next; - } - yco-= 6; - } - } - /* ******************************* */ - xco= 800; yco= 170; width= 300; - uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 90, UI_UNIT_Y, ""); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, BUTS_ACT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects"); - uiDefButBitS(block, TOG, BUTS_ACT_ACT, B_REDR, "Act", xco+110+(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object"); - uiDefButBitS(block, TOG, BUTS_ACT_LINK, B_REDR, "Link", xco+110+2*(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); - uiDefButBitS(block, TOG, BUTS_ACT_STATE, B_REDR, "State", xco+110+3*(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show only actuators connected to active states"); - uiBlockEndAlign(block); - for (a=0; a<count; a++) { - ob= (Object *)idar[a]; -// uiClearButLock(); -// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if ((ob->scavisflag & OB_VIS_ACT) == 0) { - continue; - } - - /* presume it is only objects for now */ - uiBlockBeginAlign(block); -// if (ob->actuators.first) uiSetCurFont(block, UI_HELVB); - 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"); -// if (ob->actuators.first) uiSetCurFont(block, UI_HELV); - uiDefButBitS(block, TOG, OB_ADDACT, B_ADD_ACT, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Actuator"); - uiBlockEndAlign(block); - yco-=20; - - if (ob->scaflag & OB_SHOWACT) { - - act= ob->actuators.first; - while (act) { - if (!(slogic->scaflag & BUTS_ACT_STATE) || - !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */ - (act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */ - (act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE)) - { - pin = (slogic->scaflag & BUTS_ACT_STATE && (act->flag & SENS_SHOW || act->flag & SENS_PIN)) ? 1 : 0; - - act->flag |= ACT_VISIBLE; /* mark the actuator as visible to help implementing the up/down action */ - uiDefIconButBitS(block, TOG, ACT_DEL, B_DEL_ACT, ICON_X, xco, yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Delete Actuator"); - if (pin) - uiDefIconButBitS(block, ICONTOG, ACT_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller"); - uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Display the actuator"); - - if (act->flag & ACT_SHOW) { - act->otype= act->type; - uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 90, UI_UNIT_Y, &act->type, 0, 0, 0, 0, "Actuator type"); - but = uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act->name, 0, MAX_NAME, 0, 0, "Actuator name"); - uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0); - - ycoo= yco; - yco= draw_actuatorbuttons(bmain, ob, act, block, xco, yco, width); - if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; - } - else { - set_col_actuator(act->type, 1); - glRecti((short)(xco+22), yco, (short)(xco+width-22), (short)(yco+19)); - /* but= */ uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 90, UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator type"); - // uiButSetFunc(but, old_sca_move_actuator, act, NULL); - /* but= */ uiDefBut(block, LABEL, 0, act->name, (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator name"); - // uiButSetFunc(but, old_sca_move_actuator, act, NULL); - - uiBlockBeginAlign(block); - but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(66+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up"); - uiButSetFunc(but, old_sca_move_actuator, act, (void *)TRUE); - but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(44+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down"); - uiButSetFunc(but, old_sca_move_actuator, act, (void *)FALSE); - uiBlockEndAlign(block); - - ycoo= yco; - } - - uiDefIconBut(block, INLINK, 0, ICON_INLINK, (short)(xco - 19), ycoo, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, ""); - - yco-=20; - } - act= act->next; - } - yco-= 6; - } - } - - uiComposeLinks(block); - - uiEndBlock(C, block); - uiDrawBlock(C, block); - - if (idar) MEM_freeN(idar); -} - - - - - - diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 9b0e342505b..badc4dbb533 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -67,9 +67,6 @@ /* ******************* nla editor space & buttons ************** */ -#define B_NOP 1 -#define B_REDR 2 - /* -------------- */ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event) diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 775dd5445c3..950060dde5f 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -304,13 +304,13 @@ static int nlaedit_viewall(bContext *C, const short onlySel) /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel); - extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur); + extra = 0.1f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; /* set vertical range */ v2d->cur.ymax = 0.0f; - v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask); + v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask); /* do View2D syncing */ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); @@ -1170,7 +1170,8 @@ static int nlaedit_bake_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void NLA_OT_bake(wmOperatorType *ot) +/* why isn't this used? */ +static void UNUSED_FUNCTION(NLA_OT_bake)(wmOperatorType *ot) { /* identifiers */ ot->name = "Bake Strips"; diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 222c2414fcb..79be0d0a194 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -309,7 +309,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... */ - if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect)) + if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect)) mode = NLA_BORDERSEL_FRAMERANGE; else mode = NLA_BORDERSEL_CHANNELS; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 5ebcef1d9a7..3bba02f4fc8 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -63,14 +63,12 @@ #include "UI_resources.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "node_intern.h" /* own include */ -/* XXX interface.h */ -extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select); - /* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */ static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v) @@ -199,25 +197,22 @@ static void node_draw_output_default(const bContext *C, uiBlock *block, const char *name, int UNUSED(x), int UNUSED(y), int UNUSED(width)) { SpaceNode *snode = CTX_wm_space_node(C); - float slen; - int ofs = 0; const char *ui_name = IFACE_(name); - int len = strlen(ui_name); + float slen; + UI_ThemeColor(TH_TEXT); slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt; - while (slen > node->width && ofs < len) { - ofs++; - slen = (UI_GetStringWidth(ui_name + ofs) + NODE_MARGIN_X) * snode->aspect_sqrt; + while (slen > node->width && *ui_name) { + ui_name = BLI_str_find_next_char_utf8(ui_name, NULL); + slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt; } - - if (ofs < len) { - uiDefBut(block, LABEL, 0, ui_name + ofs, - (int)(sock->locx - slen), (int)(sock->locy - 9.0f), - (short)(node->width - NODE_DY), (short)NODE_DY, - NULL, 0, 0, 0, 0, ""); + + if (*ui_name) { + uiDefBut(block, LABEL, 0, ui_name, + (int)(sock->locx - slen), (int)(sock->locy - 9.0f), + (short)slen, (short)NODE_DY, + NULL, 0, 0, 0, 0, ""); } - - (void)snode; } /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */ @@ -386,7 +381,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA * bt = uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "", (int)butr->xmin, (int)butr->xmin, - (short)BLI_RCT_SIZE_X(butr), (short)BLI_RCT_SIZE_X(butr), + (short)BLI_rctf_size_x(butr), (short)BLI_rctf_size_x(butr), nor, 0.0f, 1.0f, 0, 0, ""); uiButSetFunc(bt, node_normal_cb, ntree, node); } @@ -522,7 +517,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) rect->ymax += NODE_DY; /* input sockets */ - dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1)); + dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1)); gsock = ngroup->inputs.first; sock = gnode->inputs.first; while (gsock || sock) { @@ -570,7 +565,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) } /* output sockets */ - dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1)); + dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1)); gsock = ngroup->outputs.first; sock = gnode->outputs.first; while (gsock || sock) { @@ -645,13 +640,13 @@ static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), v } static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock, - int in_out, float xoffset, float yoffset) + int in_out, float xoffset, float yoffset, short width, short height) { if (sock->flag & SOCK_DYNAMIC) { bNodeTree *ngroup = (bNodeTree *)gnode->id; uiBut *but; but = uiDefBut(gnode->block, TEX, 0, "", - sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY, + sock->locx + xoffset, sock->locy + 1 + yoffset, width, height, sock->name, 0, sizeof(sock->name), 0, 0, ""); if (in_out == SOCK_IN) uiButSetFunc(but, update_group_input_cb, snode, ngroup); @@ -661,7 +656,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket * else { const char *ui_name = IFACE_(sock->name); uiDefBut(gnode->block, LABEL, 0, ui_name, - sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY, + sock->locx + xoffset, sock->locy + 1 + yoffset, width, height, NULL, 0, 0, 0, 0, ""); } } @@ -669,23 +664,26 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket * static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode, bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out) { + const float dpi_fac = U.dpi / 72.0f; bNodeTree *ngroup = (bNodeTree *)gnode->id; bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type); uiBut *bt; float offset; int draw_value; - float node_group_frame = U.dpi * NODE_GROUP_FRAME / 72; - float socket_size = NODE_SOCKSIZE * U.dpi / 72; - float arrowbutw = 0.8f * UI_UNIT_X; + const float node_group_frame = NODE_GROUP_FRAME * dpi_fac; + const float socket_size = NODE_SOCKSIZE * dpi_fac; + const float arrowbutw = 0.8f * UI_UNIT_X; + const short co_text_w = 72 * dpi_fac; + const float co_margin = 6.0f * dpi_fac; /* layout stuff for buttons on group left frame */ - float colw = 0.6f * node_group_frame; - float col1 = 6 - node_group_frame; - float col2 = col1 + colw + 6; - float col3 = -arrowbutw - 6; + const float colw = 0.6f * node_group_frame; + const float col1 = co_margin - node_group_frame; + const float col2 = col1 + colw + co_margin; + const float col3 = -arrowbutw - co_margin; /* layout stuff for buttons on group right frame */ - float cor1 = 6; - float cor2 = cor1 + arrowbutw + 6; - float cor3 = cor2 + arrowbutw + 6; + const float cor1 = co_margin; + const float cor2 = cor1 + arrowbutw; + const float cor3 = cor2 + arrowbutw + co_margin; /* node and group socket circles */ if (sock) @@ -715,13 +713,13 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt if (draw_value) { /* both name and value buttons */ if (gsock) { - draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0); + draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0, co_text_w, NODE_DY); if (stype->buttonfunc) stype->buttonfunc(C, gnode->block, ngroup, NULL, gsock, "", gsock->locx + offset, gsock->locy - NODE_DY, colw); } else { - draw_group_socket_name(snode, gnode, sock, in_out, offset, 0); + draw_group_socket_name(snode, gnode, sock, in_out, offset, 0, co_text_w, NODE_DY); if (stype->buttonfunc) stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "", sock->locx + offset, sock->locy - NODE_DY, colw); @@ -730,9 +728,9 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt else { /* only name, no value button */ if (gsock) - draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS); + draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS, co_text_w, NODE_DY); else - draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS); + draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS, co_text_w, NODE_DY); } if (gsock && (gsock->flag & SOCK_DYNAMIC)) { @@ -836,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_RCT_SIZE_X(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle()); + mini((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); @@ -892,7 +890,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN } } -void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL); } @@ -978,7 +976,7 @@ static void node_draw_frame_label(bNode *node, const float aspect) ascender = BLF_ascender(fontid); /* 'x' doesn't need aspect correction */ - x = BLI_RCT_CENTER_X(rct) - (0.5f * width); + x = BLI_rctf_cent_x(rct) - (0.5f * width); y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect)); BLF_position(fontid, x, y, 0); @@ -2023,7 +2021,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER); node_composit_buts_file_output(layout, C, ptr); - uiTemplateImageSettings(layout, &imfptr); + uiTemplateImageSettings(layout, &imfptr, TRUE); uiItemS(layout); @@ -2082,7 +2080,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE); - uiTemplateImageSettings(col, &imfptr); + uiTemplateImageSettings(col, &imfptr, TRUE); } } } @@ -2387,7 +2385,7 @@ static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C), uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE); } -void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y) +static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y) { // node_composit_backdrop_canvas(snode, backdrop, node, x, y); if (node->custom1 == 0) { @@ -2407,7 +2405,7 @@ void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *nod } } -void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y) +static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y) { NodeBoxMask *boxmask = node->storage; const float backdropWidth = backdrop->x; @@ -2448,7 +2446,7 @@ void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *no glEnd(); } -void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y) +static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y) { NodeEllipseMask *ellipsemask = node->storage; const float backdropWidth = backdrop->x; @@ -2608,7 +2606,7 @@ static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRN uiItemR(layout, ptr, "position", 0, NULL, ICON_NONE); if (node->custom1 == 2) { - uiItemR(layout, ptr, "relative_frame", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "frame_relative", 0, NULL, ICON_NONE); } } } @@ -3051,7 +3049,7 @@ void ED_node_init_butfuncs(void) /* ************** Generic drawing ************** */ -void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) +void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) { if ((snode->flag & SNODE_BACKDRAW) && snode->treetype == NTREE_COMPOSIT) { @@ -3059,7 +3057,10 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) void *lock; ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf) { + SpaceNode *snode = CTX_wm_space_node(C); float x, y; + unsigned char *display_buffer; + void *cache_handle; glMatrixMode(GL_PROJECTION); glPushMatrix(); @@ -3078,15 +3079,10 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof; y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof; - if (!ibuf->rect) { - if (color_manage) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - else - ibuf->profile = IB_PROFILE_NONE; - IMB_rect_from_float(ibuf); - } - if (ibuf->rect) { + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + + if (display_buffer) { if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) { int ofs; @@ -3104,7 +3100,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, - ((unsigned char *)ibuf->rect) + ofs); + display_buffer + ofs); glPixelZoom(1.0f, 1.0f); } @@ -3114,7 +3110,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) #ifdef __BIG_ENDIAN__ glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); #endif - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect); + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer); #ifdef __BIG_ENDIAN__ glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); @@ -3126,7 +3122,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); glPixelZoom(1.0f, 1.0f); glDisable(GL_BLEND); @@ -3134,12 +3130,14 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) else { glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); glPixelZoom(1.0f, 1.0f); } } + IMB_display_buffer_release(cache_handle); + /** @note draw selected info on backdrop */ if (snode->edittree) { bNode *node = snode->edittree->nodes.first; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index f1a91df6f53..379e9987c4c 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -62,10 +62,8 @@ #include "node_intern.h" /* own include */ #include "COM_compositor.h" -/* width of socket columns in group display */ -#define NODE_GROUP_FRAME 120 /* XXX interface.h */ -extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select); +extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select); /* XXX update functions for node editor are a mess, needs a clear concept */ void ED_node_tree_update(SpaceNode *snode, Scene *scene) @@ -343,7 +341,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin); } else { - float oldh = BLI_RCT_SIZE_Y(&node->prvr); + float oldh = BLI_rctf_size_y(&node->prvr); if (oldh == 0.0f) oldh = 0.6f * node->width - NODE_DY; dy -= NODE_DYS / 2; @@ -584,9 +582,9 @@ void node_socket_circle_draw(bNodeTree *UNUSED(ntree), bNodeSocket *sock, float /* not a callback */ static void node_draw_preview(bNodePreview *preview, rctf *prv) { - float xscale = BLI_RCT_SIZE_X(prv) / ((float)preview->xsize); - float yscale = BLI_RCT_SIZE_Y(prv) / ((float)preview->ysize); - float tile = BLI_RCT_SIZE_X(prv) / 10.0f; + float xscale = BLI_rctf_size_x(prv) / ((float)preview->xsize); + float yscale = BLI_rctf_size_y(prv) / ((float)preview->ysize); + float tile = BLI_rctf_size_x(prv) / 10.0f; float x, y; /* draw checkerboard backdrop to show alpha */ @@ -852,8 +850,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b { bNodeSocket *sock; rctf *rct = &node->totr; - float dx, centy = BLI_RCT_CENTER_Y(rct); - float hiddenrad = BLI_RCT_SIZE_Y(rct) / 2.0f; + float dx, centy = BLI_rctf_cent_y(rct); + float hiddenrad = BLI_rctf_size_y(rct) / 2.0f; float socket_size = NODE_SOCKSIZE * U.dpi / 72; int color_id = node_get_colorid(node); char showname[128]; /* 128 is used below */ @@ -932,7 +930,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b uiDefBut(node->block, LABEL, 0, showname, (int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10), - (short)(BLI_RCT_SIZE_X(rct) - 18.0f - 12.0f), (short)NODE_DY, + (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY, NULL, 0, 0, 0, 0, ""); } @@ -1091,8 +1089,6 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) { View2DScrollers *scrollers; SpaceNode *snode = CTX_wm_space_node(C); - Scene *scene = CTX_data_scene(C); - int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; bNodeLinkDrag *nldrag; LinkData *linkdata; @@ -1110,7 +1106,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) glEnable(GL_MAP1_VERTEX_3); /* aspect+font, set each time */ - snode->aspect = BLI_RCT_SIZE_X(&v2d->cur) / (float)ar->winx; + snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx; snode->aspect_sqrt = sqrtf(snode->aspect); // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); @@ -1118,7 +1114,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2); /* backdrop */ - draw_nodespace_back_pix(ar, snode, color_manage); + draw_nodespace_back_pix(C, ar, snode); /* nodes */ snode_set_context(snode, CTX_data_scene(C)); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 9e04bd36a1f..64a8d96a74f 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -148,8 +148,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog { CompoJob *cj = cjv; bNodeTree *ntree = cj->localtree; + Scene *scene = cj->scene; - if (cj->scene->use_nodes == FALSE) + if (scene->use_nodes == FALSE) return; cj->stop = stop; @@ -165,7 +166,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog // XXX BIF_store_spare(); - ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */ + ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1, &scene->view_settings, &scene->display_settings); /* 1 is do_previews */ ntree->test_break = NULL; ntree->stats_draw = NULL; @@ -2066,8 +2067,8 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) /* calculate "barycenter" for placing on mouse cursor */ zero_v2(center); for (node = clipboard_nodes_lb->first, num_nodes = 0; node; node = node->next, num_nodes++) { - center[0] += BLI_RCT_CENTER_X(&node->totr); - center[1] += BLI_RCT_CENTER_Y(&node->totr); + center[0] += BLI_rctf_cent_x(&node->totr); + center[1] += BLI_rctf_cent_y(&node->totr); } mul_v2_fl(center, 1.0 / num_nodes); diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index e17961b6c7c..5ab698cd415 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -100,7 +100,7 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp) /* once this is called from an operator, this should be removed */ if (node_new) { char undostr[BKE_UNDO_STR_MAX]; - BLI_snprintf(undostr, sizeof(BKE_UNDO_STR_MAX), "Add Node %s", nodeLabel(node_new)); + BLI_snprintf(undostr, sizeof(undostr), "Add Node %s", nodeLabel(node_new)); BKE_write_undo(C, undostr); } diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 2bb550d1a63..36ebddc8d22 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -125,7 +125,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link); void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3); int node_link_bezier_points(View2D * v2d, SpaceNode * snode, bNodeLink * link, float coord_array[][2], int resol); // void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 ); -void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage); +void draw_nodespace_back_pix(const struct bContext *C, ARegion *ar, SpaceNode *snode); /* node_add.c */ diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index a56d76a3ef7..f7757ce49b4 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -555,8 +555,8 @@ static int do_lasso_select_node(bContext *C, int mcords[][2], short moves, short /* do actual selection */ for (node = snode->edittree->nodes.first; node; node = node->next) { int screen_co[2]; - const float cent[2] = {BLI_RCT_CENTER_X(&node->totr), - BLI_RCT_CENTER_Y(&node->totr)}; + const float cent[2] = {BLI_rctf_cent_x(&node->totr), + BLI_rctf_cent_y(&node->totr)}; /* marker in screen coords */ UI_view2d_view_to_region(&ar->v2d, diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 7881014ed54..3d93a6c14a1 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -230,7 +230,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t /****************************** Node Link Menu *******************************/ -#define UI_NODE_LINK_ADD 0 +// #define UI_NODE_LINK_ADD 0 #define UI_NODE_LINK_DISCONNECT -1 #define UI_NODE_LINK_REMOVE -2 diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index e89e798a6fa..ccf5c4b540f 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -72,8 +72,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons int tot = 0; int has_frame = FALSE; - oldwidth = BLI_RCT_SIZE_X(&ar->v2d.cur); - oldheight = BLI_RCT_SIZE_Y(&ar->v2d.cur); + oldwidth = BLI_rctf_size_x(&ar->v2d.cur); + oldheight = BLI_rctf_size_y(&ar->v2d.cur); BLI_rctf_init_minmax(&cur_new); @@ -91,8 +91,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons } if (tot) { - width = BLI_RCT_SIZE_X(&cur_new); - height = BLI_RCT_SIZE_Y(&cur_new); + width = BLI_rctf_size_x(&cur_new); + height = BLI_rctf_size_y(&cur_new); /* for single non-frame nodes, don't zoom in, just pan view, * but do allow zooming out, this allows for big nodes to be zoomed out */ @@ -327,12 +327,12 @@ typedef struct ImageSampleInfo { void *draw_handle; int x, y; int channels; - int color_manage; unsigned char col[4]; float colf[4]; int draw; + int color_manage; } ImageSampleInfo; static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) @@ -341,7 +341,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) ImageSampleInfo *info = arg_info; if (info->draw) { - ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, + ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels, info->x, info->y, info->col, info->colf, NULL, NULL /* zbuf - unused for nodes */ ); @@ -358,6 +358,13 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float float fx, fy, bufx, bufy; int ret = FALSE; + if (snode->treetype != NTREE_COMPOSIT || (snode->flag & SNODE_BACKDRAW) == 0) { + /* use viewer image for color sampling only if we're in compositor tree + * with backdrop enabled + */ + return FALSE; + } + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (!ibuf) { @@ -381,12 +388,7 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); /* IB_PROFILE_NONE is default but infact its linear */ - if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) { - linearrgb_to_srgb_v3_v3(r_col, fp); - } - else { - copy_v3_v3(r_col, fp); - } + linearrgb_to_srgb_v3_v3(r_col, fp); ret = TRUE; } else if (ibuf->rect) { @@ -419,10 +421,6 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) } if (!ibuf->rect) { - if (info->color_manage) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - else - ibuf->profile = IB_PROFILE_NONE; IMB_rect_from_float(ibuf); } @@ -457,6 +455,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[1] = (float)cp[1] / 255.0f; info->colf[2] = (float)cp[2] / 255.0f; info->colf[3] = (float)cp[3] / 255.0f; + + info->color_manage = FALSE; } if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); @@ -465,6 +465,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[1] = fp[1]; info->colf[2] = fp[2]; info->colf[3] = fp[3]; + + info->color_manage = TRUE; } ED_node_sample_set(info->colf); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 1522528a8ac..0601d7c105f 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -44,6 +44,7 @@ #include "BKE_screen.h" #include "BKE_node.h" +#include "ED_space_api.h" #include "ED_render.h" #include "ED_screen.h" #include "ED_node.h" diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 0874ddcb279..d7e180f982b 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -579,11 +579,11 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) te = outliner_find_id(so, &so->tree, (ID *)OBACT); if (te) { /* make te->ys center of view */ - ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&v2d->mask) / 2); + ytop = (int)(te->ys + BLI_rcti_size_y(&v2d->mask) / 2); if (ytop > 0) ytop = 0; v2d->cur.ymax = (float)ytop; - v2d->cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&v2d->mask)); + v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - v2d->cur.xmin); @@ -615,7 +615,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) static int outliner_scroll_page_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); - int dy = BLI_RCT_SIZE_Y(&ar->v2d.mask); + int dy = BLI_rcti_size_y(&ar->v2d.mask); int up = 0; if (RNA_boolean_get(op->ptr, "up")) @@ -760,10 +760,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so tselem->flag |= TSE_SELECTED; /* make te->ys center of view */ - ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&ar->v2d.mask) / 2); + ytop = (int)(te->ys + BLI_rctf_size_y(&ar->v2d.mask) / 2); if (ytop > 0) ytop = 0; ar->v2d.cur.ymax = (float)ytop; - ar->v2d.cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&ar->v2d.mask)); + ar->v2d.cur.ymin = (float)(ytop - BLI_rctf_size_y(&ar->v2d.mask)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - ar->v2d.cur.xmin); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 8b7cf406642..823de61d044 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -433,8 +433,11 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, if (set) { if (!(bone->flag & BONE_HIDDEN_P)) { - if (set == 2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag - else ED_pose_deselectall(OBACT, 0); + Object *ob = OBACT; + if (ob) { + if (set == 2) ED_pose_deselectall(ob, 2); // 2 is clear active tag + else ED_pose_deselectall(ob, 0); + } if (set == 2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; @@ -444,7 +447,7 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, arm->act_bone = bone; } - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, OBACT); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob); } } else { diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 0c316450c29..f927e83cabe 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -52,6 +52,7 @@ #include "BKE_sound.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "BIF_gl.h" @@ -68,6 +69,9 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "WM_api.h" +#include "WM_types.h" + /* own include */ #include "sequencer_intern.h" @@ -428,7 +432,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - pixely = BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask); + pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); if (pixely <= 0) return; /* can happen when the view is split/resized */ @@ -721,7 +725,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline /* draw sound wave */ if (seq->type == SEQ_TYPE_SOUND_RAM) { - drawseqwave(scene, seq, x1, y1, x2, y2, BLI_RCT_SIZE_X(&ar->v2d.cur) / ar->winx); + drawseqwave(scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx); } /* draw lock */ @@ -846,6 +850,50 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int return ibuf; } +static void sequencer_check_scopes(SequencerScopes *scopes, ImBuf *ibuf) +{ + if (scopes->reference_ibuf != ibuf) { + if (scopes->zebra_ibuf) { + IMB_freeImBuf(scopes->zebra_ibuf); + scopes->zebra_ibuf = NULL; + } + + if (scopes->waveform_ibuf) { + IMB_freeImBuf(scopes->waveform_ibuf); + scopes->waveform_ibuf = NULL; + } + + if (scopes->sep_waveform_ibuf) { + IMB_freeImBuf(scopes->sep_waveform_ibuf); + scopes->sep_waveform_ibuf = NULL; + } + + if (scopes->vector_ibuf) { + IMB_freeImBuf(scopes->vector_ibuf); + scopes->vector_ibuf = NULL; + } + + if (scopes->histogram_ibuf) { + IMB_freeImBuf(scopes->histogram_ibuf); + scopes->histogram_ibuf = NULL; + } + } +} + +static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb) (ImBuf *ibuf)) +{ + ImBuf *display_ibuf = IMB_dupImBuf(ibuf); + ImBuf *scope; + + IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings); + + scope = make_scope_cb(display_ibuf); + + IMB_freeImBuf(display_ibuf); + + return scope; +} + void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay) { struct Main *bmain = CTX_data_main(C); @@ -859,6 +907,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq float col[3]; GLuint texid; GLuint last_texid; + unsigned char *display_buffer; + void *cache_handle = NULL; render_size = sseq->render_size; if (render_size == 0) { @@ -906,38 +956,64 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; - - switch (sseq->mainb) { - case SEQ_DRAW_IMG_IMBUF: - if (sseq->zebra != 0) { - scope = make_zebra_view_from_ibuf(ibuf, sseq->zebra); - } - break; - case SEQ_DRAW_IMG_WAVEFORM: - if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { - scope = make_sep_waveform_view_from_ibuf(ibuf); - } - else { - scope = make_waveform_view_from_ibuf(ibuf); - } - break; - case SEQ_DRAW_IMG_VECTORSCOPE: - scope = make_vectorscope_view_from_ibuf(ibuf); - break; - case SEQ_DRAW_IMG_HISTOGRAM: - scope = make_histogram_view_from_ibuf(ibuf); - break; + + if (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0) { + SequencerScopes *scopes = &sseq->scopes; + + sequencer_check_scopes(scopes, ibuf); + + switch (sseq->mainb) { + case SEQ_DRAW_IMG_IMBUF: + if (!scopes->zebra_ibuf) { + ImBuf *display_ibuf = IMB_dupImBuf(ibuf); + + IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings); + scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra); + IMB_freeImBuf(display_ibuf); + } + scope = scopes->zebra_ibuf; + break; + case SEQ_DRAW_IMG_WAVEFORM: + if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { + if (!scopes->sep_waveform_ibuf) + scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf); + scope = scopes->sep_waveform_ibuf; + } + else { + if (!scopes->waveform_ibuf) + scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf); + scope = scopes->waveform_ibuf; + } + break; + case SEQ_DRAW_IMG_VECTORSCOPE: + if (!scopes->vector_ibuf) + scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf); + scope = scopes->vector_ibuf; + break; + case SEQ_DRAW_IMG_HISTOGRAM: + if (!scopes->histogram_ibuf) + scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf); + scope = scopes->histogram_ibuf; + break; + } + + scopes->reference_ibuf = ibuf; } if (scope) { IMB_freeImBuf(ibuf); ibuf = scope; - } - if (ibuf->rect_float && ibuf->rect == NULL) { - IMB_rect_from_float(ibuf); + if (ibuf->rect_float && ibuf->rect == NULL) { + IMB_rect_from_float(ibuf); + } + + display_buffer = (unsigned char *)ibuf->rect; } - + else { + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + } + /* setting up the view - actual drawing starts here */ UI_view2d_view_ortho(v2d); @@ -950,16 +1026,16 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); glBegin(GL_QUADS); if (draw_overlay) { if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) { rctf tot_clip; - tot_clip.xmin = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmin); - tot_clip.ymin = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymin); - tot_clip.xmax = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmax); - tot_clip.ymax = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymax); + tot_clip.xmin = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin); + tot_clip.ymin = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin); + tot_clip.xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax); + tot_clip.ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax); glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin); glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax); @@ -1030,7 +1106,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq /* draw grease-pencil (image aligned) */ draw_gpencil_2dimage(C); - IMB_freeImBuf(ibuf); + if (!scope) + IMB_freeImBuf(ibuf); /* ortho at pixel level */ UI_view2d_view_restore(C); @@ -1065,6 +1142,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq } } + if (cache_handle) + IMB_display_buffer_release(cache_handle); } #if 0 @@ -1143,7 +1222,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) View2D *v2d = &ar->v2d; Sequence *last_seq = BKE_sequencer_active_get(scene); int sel = 0, j; - float pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); + float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); /* loop through twice, first unselected, then selected */ for (j = 0; j < 2; j++) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index f47eb339878..e7d964ba715 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -372,7 +372,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ if (ed == NULL) return NULL; - pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); + pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); @@ -2164,8 +2164,8 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op) float winx = (int)(rd->size * rd->xsch) / 100; float winy = (int)(rd->size * rd->ysch) / 100; - float facx = BLI_RCT_SIZE_X(&v2d->mask) / winx; - float facy = BLI_RCT_SIZE_Y(&v2d->mask) / winy; + float facx = BLI_rcti_size_x(&v2d->mask) / winx; + float facy = BLI_rcti_size_y(&v2d->mask) / winy; BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1); @@ -2268,7 +2268,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) ymax += ymargin; ymin -= ymargin; - orig_height = BLI_RCT_SIZE_Y(&cur_new); + orig_height = BLI_rctf_size_y(&cur_new); cur_new.xmin = xmin; cur_new.xmax = xmax; @@ -2277,8 +2277,8 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) cur_new.ymax = ymax; /* only zoom out vertically */ - if (orig_height > BLI_RCT_SIZE_Y(&cur_new)) { - ymid = BLI_RCT_CENTER_Y(&cur_new); + if (orig_height > BLI_rctf_size_y(&cur_new)) { + ymid = BLI_rctf_cent_y(&cur_new); cur_new.ymin = ymid - (orig_height / 2); cur_new.ymax = ymid + (orig_height / 2); @@ -2800,11 +2800,11 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op) if (ed == NULL) return OPERATOR_CANCELLED; - rect.xmin /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot))); - rect.ymin /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot))); + rect.xmin /= fabsf(BLI_rctf_size_x(&v2d->tot)); + rect.ymin /= fabsf(BLI_rctf_size_y(&v2d->tot)); - rect.xmax /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot))); - rect.ymax /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot))); + rect.xmax /= fabsf(BLI_rctf_size_x(&v2d->tot)); + rect.ymax /= fabsf(BLI_rctf_size_y(&v2d->tot)); rect.xmin += 0.5f; rect.xmax += 0.5f; diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index aa6bacf8836..70b288a59e6 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -43,6 +43,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_sequencer.h" #include "ED_markers.h" #include "ED_transform.h" /* transform keymap */ @@ -77,6 +78,9 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_swap_data); WM_operatortype_append(SEQUENCER_OT_rendersize); + WM_operatortype_append(SEQUENCER_OT_copy); + WM_operatortype_append(SEQUENCER_OT_paste); + WM_operatortype_append(SEQUENCER_OT_view_all); WM_operatortype_append(SEQUENCER_OT_view_selected); WM_operatortype_append(SEQUENCER_OT_view_all_preview); @@ -109,10 +113,9 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_sound_strip_add); WM_operatortype_append(SEQUENCER_OT_image_strip_add); WM_operatortype_append(SEQUENCER_OT_effect_strip_add); - WM_operatortype_append(SEQUENCER_OT_properties); - WM_operatortype_append(SEQUENCER_OT_copy); - WM_operatortype_append(SEQUENCER_OT_paste); + /* sequencer_buttons.c */ + WM_operatortype_append(SEQUENCER_OT_properties); /* sequencer_modifiers.c */ WM_operatortype_append(SEQUENCER_OT_strip_modifier_add); @@ -131,7 +134,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) /* Common items ------------------------------------------------------------------ */ keymap = WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0); - + + WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.show_overlay"); @@ -140,9 +145,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) /* Strips Region --------------------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0); - - WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); @@ -152,12 +155,12 @@ void sequencer_keymap(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "type", SEQ_CUT_SOFT); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", SEQ_CUT_HARD); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", FALSE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "unselected", TRUE); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "unselected", FALSE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); @@ -178,7 +181,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); @@ -209,7 +212,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_inputs", SKEY, KM_PRESS, KM_ALT, 0); @@ -244,7 +247,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "linked_left", TRUE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "linked_right", TRUE); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "linked_left", TRUE); RNA_boolean_set(kmi->ptr, "linked_right", TRUE); @@ -292,14 +295,14 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); @@ -307,33 +310,32 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_menu(keymap, "SEQUENCER_MT_change", CKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame"); RNA_int_set(kmi->ptr, "value", 0); transform_keymap_for_space(keyconf, keymap, SPACE_SEQ); - + /* special markers hotkeys for anim editors: see note in definition of this function */ ED_marker_keymap_animedit_conflictfree(keymap); - - + + /* Preview Region ----------------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_ghost_border", OKEY, KM_PRESS, 0, 0); /* would prefer to use numpad keys for job */ RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f); - + /* Setting zoom levels is not that useful, except for back to zoom level 1, removing keymap because of conflicts for now */ #if 0 RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f); - + RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f); diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 1655b3ec7bc..6ed34a79510 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -449,6 +449,8 @@ static void draw_histogram_bar(ImBuf *ibuf, int x, float val, int col) } } +#define HIS_STEPS 512 + static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) { ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect); @@ -456,22 +458,38 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) unsigned int n; unsigned char *src = (unsigned char *) ibuf->rect; - unsigned int bins[3][256]; + unsigned int bins[3][HIS_STEPS]; memset(bins, 0, sizeof(bins)); + #pragma omp parallel for shared(bins, src, ibuf) private(x, y) if (ibuf->y >= 256) for (y = 0; y < ibuf->y; y++) { + unsigned int cur_bins[3][HIS_STEPS]; + + memset(cur_bins, 0, sizeof(cur_bins)); + for (x = 0; x < ibuf->x; x++) { - bins[0][*src++]++; - bins[1][*src++]++; - bins[2][*src++]++; - src++; + unsigned char *pixel = src + (y * ibuf->x + x) * 4; + + cur_bins[0][pixel[0]]++; + cur_bins[1][pixel[1]]++; + cur_bins[2][pixel[2]]++; + } + + #pragma omp critical + { + int i; + for (i = 0; i < HIS_STEPS; i++) { + bins[0][i] += cur_bins[0][i]; + bins[1][i] += cur_bins[1][i]; + bins[2][i] += cur_bins[2][i]; + } } } n = 0; for (c = 0; c < 3; c++) { - for (x = 0; x < 256; x++) { + for (x = 0; x < HIS_STEPS; x++) { if (bins[c][x] > n) { n = bins[c][x]; } @@ -479,7 +497,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) } for (c = 0; c < 3; c++) { - for (x = 0; x < 256; x++) { + for (x = 0; x < HIS_STEPS; x++) { draw_histogram_bar(rval, x * 2 + 1, ((float) bins[c][x]) / n, c); draw_histogram_bar(rval, x * 2 + 2, ((float) bins[c][x]) / n, c); } @@ -490,7 +508,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) return rval; } -static int get_bin_float(float f) +BLI_INLINE int get_bin_float(float f) { if (f < -0.25f) { return 0; @@ -508,16 +526,32 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) int n, c, x, y; float *src = ibuf->rect_float; - unsigned int bins[3][512]; + unsigned int bins[3][HIS_STEPS]; memset(bins, 0, sizeof(bins)); + #pragma omp parallel for shared(bins, src, ibuf) private(x, y) if (ibuf->y >= 256) for (y = 0; y < ibuf->y; y++) { + unsigned int cur_bins[3][HIS_STEPS]; + + memset(cur_bins, 0, sizeof(cur_bins)); + for (x = 0; x < ibuf->x; x++) { - bins[0][get_bin_float(*src++)]++; - bins[1][get_bin_float(*src++)]++; - bins[2][get_bin_float(*src++)]++; - src++; + float *pixel = src + (y * ibuf->x + x) * 4; + + cur_bins[0][get_bin_float(pixel[0])]++; + cur_bins[1][get_bin_float(pixel[1])]++; + cur_bins[2][get_bin_float(pixel[2])]++; + } + + #pragma omp critical + { + int i; + for (i = 0; i < HIS_STEPS; i++) { + bins[0][i] += cur_bins[0][i]; + bins[1][i] += cur_bins[1][i]; + bins[2][i] += cur_bins[2][i]; + } } } @@ -526,14 +560,14 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) n = 0; for (c = 0; c < 3; c++) { - for (x = 0; x < 512; x++) { + for (x = 0; x < HIS_STEPS; x++) { if (bins[c][x] > n) { n = bins[c][x]; } } } for (c = 0; c < 3; c++) { - for (x = 0; x < 512; x++) { + for (x = 0; x < HIS_STEPS; x++) { draw_histogram_bar(rval, x + 1, (float) bins[c][x] / n, c); } } @@ -543,6 +577,8 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) return rval; } +#undef HIS_STEPS + ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf) { if (ibuf->rect_float) { diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index d500bef4f02..3c3489115a4 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -49,6 +49,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" #include "UI_view2d.h" @@ -70,6 +71,7 @@ typedef struct ImageSampleInfo { float *colfp; int draw; +int color_manage; } ImageSampleInfo; static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) @@ -78,8 +80,8 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) ImageSampleInfo *info = arg_info; if (info->draw) { - ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, - info->x, info->y, info->col, info->colf, NULL, NULL); + ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels, + info->x, info->y, info->colp, info->colfp, NULL, NULL); } } @@ -131,6 +133,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[2] = (float)cp[2] / 255.0f; info->colf[3] = (float)cp[3] / 255.0f; info->colfp = info->colf; + + info->color_manage = FALSE; } if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); @@ -140,6 +144,11 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[2] = fp[2]; info->colf[3] = fp[3]; info->colfp = info->colf; + + /* sequencer's image buffers are in non-linear space, need to make them linear */ + BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->colf); + + info->color_manage = TRUE; } } else { @@ -202,7 +211,7 @@ static int sample_cancel(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -int sample_poll(bContext *C) +static int sample_poll(bContext *C) { return BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL; } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index f7362aab7aa..8ac50a57b10 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -57,8 +57,19 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "IMB_imbuf.h" + #include "sequencer_intern.h" // own include +/**************************** common state *****************************/ + +static void sequencer_scopes_tag_refresh(ScrArea *sa) +{ + SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; + + sseq->scopes.reference_ibuf = NULL; +} + /* ******************** manage regions ********************* */ ARegion *sequencer_has_buttons_region(ScrArea *sa) @@ -183,12 +194,27 @@ static SpaceLink *sequencer_new(const bContext *C) } /* not spacelink itself */ -static void sequencer_free(SpaceLink *UNUSED(sl)) +static void sequencer_free(SpaceLink *sl) { -// SpaceSeq *sseq= (SpaceSequencer*) sl; - + SpaceSeq *sseq= (SpaceSeq *) sl; + SequencerScopes *scopes = &sseq->scopes; + // XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); + if (scopes->zebra_ibuf) + IMB_freeImBuf(scopes->zebra_ibuf); + + if (scopes->waveform_ibuf) + IMB_freeImBuf(scopes->waveform_ibuf); + + if (scopes->sep_waveform_ibuf) + IMB_freeImBuf(scopes->sep_waveform_ibuf); + + if (scopes->vector_ibuf) + IMB_freeImBuf(scopes->vector_ibuf); + + if (scopes->histogram_ibuf) + IMB_freeImBuf(scopes->histogram_ibuf); } @@ -290,7 +316,24 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl) return (SpaceLink *)sseqn; } - +static void sequencer_listener(ScrArea *sa, wmNotifier *wmn) +{ + /* context changes */ + switch (wmn->category) { + case NC_SCENE: + switch (wmn->data) { + case ND_FRAME: + case ND_SEQUENCER: + sequencer_scopes_tag_refresh(sa); + break; + } + break; + case NC_SPACE: + if (wmn->data == ND_SPACE_SEQUENCER) + sequencer_scopes_tag_refresh(sa); + break; + } +} /* *********************** sequencer (main) region ************************ */ /* add handlers, stuff you only do once or on area/region changes */ @@ -610,6 +653,7 @@ void ED_spacetype_sequencer(void) st->context = sequencer_context; st->dropboxes = sequencer_dropboxes; st->refresh = sequencer_refresh; + st->listener = sequencer_listener; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 97eb5b41db7..5111d20b8ee 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -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_RCT_SIZE_X(&st->txtscroll), BLI_RCT_SIZE_Y(&st->txtscroll)); + rad = 0.4f * mini(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll)); UI_GetThemeColor3ubv(TH_HILITE, col); col[3] = 48; glColor4ubv(col); diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index b0cd6aeaab4..7dc3ec1ac60 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -59,17 +59,12 @@ #include "WM_types.h" - - - #ifdef WITH_PYTHON // XXX #include "BPY_menus.h" #endif #include "text_intern.h" -#define HEADER_PATH_MAX 260 - /* ************************ header area region *********************** */ /************************** properties ******************************/ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 5af44f93d06..75b8e2f218d 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -602,9 +602,12 @@ static int text_run_script(bContext *C, ReportList *reports) /* Don't report error messages while live editing */ if (!is_live) { - if (text->curl != curl_prev || curc_prev != text->curc) { - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + /* text may have freed its self */ + if (CTX_data_edit_text(C) == text) { + if (text->curl != curl_prev || curc_prev != text->curc) { + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + } } BKE_report(reports, RPT_ERROR, "Python script fail, look in the console for now..."); @@ -2409,8 +2412,8 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event) /* jump scroll, works in v2d but needs to be added here too :S */ if (event->type == MIDDLEMOUSE) { - tsc->old[0] = ar->winrct.xmin + BLI_RCT_CENTER_X(&st->txtbar); - tsc->old[1] = ar->winrct.ymin + BLI_RCT_CENTER_Y(&st->txtbar); + tsc->old[0] = ar->winrct.xmin + BLI_rcti_cent_x(&st->txtbar); + tsc->old[1] = ar->winrct.ymin + BLI_rcti_cent_y(&st->txtbar); tsc->delta[0] = 0; tsc->delta[1] = 0; diff --git a/source/blender/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c index f980e19e9c8..966afe22e42 100644 --- a/source/blender/editors/space_text/text_python.c +++ b/source/blender/editors/space_text/text_python.c @@ -180,13 +180,9 @@ static void confirm_suggestion(Text *text, int skipleft) } // XXX -#define L_MOUSE 0 -#define M_MOUSE 0 -#define R_MOUSE 0 #define LR_SHIFTKEY 0 #define LR_ALTKEY 0 #define LR_CTRLKEY 0 -#define LR_OSKEY 0 // XXX static int doc_scroll = 0; diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 733fd27135b..9067fb6933f 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -151,7 +151,7 @@ static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op)) v2d->cur.xmax = (float)PEFRA; /* we need an extra "buffer" factor on either side so that the endpoints are visible */ - extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur); + extra = 0.01f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index da93e07748a..f05c78e8512 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -179,7 +179,7 @@ static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int i return DM_DRAW_OPTION_SKIP; } -void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) +static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) { drawMeshFaceSelect_userData data; @@ -372,7 +372,15 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O Gtexdraw.ob = ob; Gtexdraw.is_tex = is_tex; - Gtexdraw.color_profile = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; + + /* OCIO_TODO: for now assume OpenGL is always doing color management and working in sRGB space + * supporting for real display conversion could be nice here, but it's a bit challenging + * since all the shaders should be aware of such a transform + * perhaps this flag could be completely removed before release in separated commit and + * be re-implemented if real display transform would be needed + */ + Gtexdraw.color_profile = TRUE; + memcpy(Gtexdraw.obcol, obcol, sizeof(obcol)); set_draw_settings_cached(1, NULL, NULL, Gtexdraw); glShadeModel(GL_SMOOTH); @@ -507,7 +515,7 @@ static void update_tface_color_layer(DerivedMesh *dm) finalCol[i * 4 + j].r = 255; } } - else if (tface && mface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) { + else if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) { for (j = 0; j < 4; j++) { finalCol[i * 4 + j].b = 255; finalCol[i * 4 + j].g = 0; @@ -630,7 +638,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) MLoopCol *mloopcol = me->mloopcol; /* why does mcol exist? */ MLoopCol *lcol; - bProperty *prop = get_ob_property(ob, "Text"); + bProperty *prop = BKE_bproperty_object_get(ob, "Text"); GPUVertexAttribs gattribs; int a, totpoly = me->totpoly; @@ -706,7 +714,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) unsigned int j; lcol = &mloopcol[mp->loopstart]; - for (j = 0; j <= totloop_clamp; j++, lcol++) { + for (j = 0; j < totloop_clamp; j++, lcol++) { MESH_MLOOPCOL_TO_MCOL(lcol, &tmp_mcol[j]); } } @@ -724,7 +732,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) /* The BM_FONT handling is in the gpu module, shared with the * game engine, was duplicated previously */ - set_property_valstr(prop, string); + BKE_bproperty_set_valstr(prop, string); characters = strlen(string); if (!BKE_image_get_ibuf(mtpoly->tpage, NULL)) @@ -772,8 +780,8 @@ static int compareDrawOptionsEm(void *userData, int cur_index, int next_index) return 1; } -void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, - Object *ob, DerivedMesh *dm, const int draw_flags) +static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, + Object *ob, DerivedMesh *dm, const int draw_flags) { Mesh *me = ob->data; @@ -824,7 +832,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, } /* draw game engine text hack */ - if (get_ob_property(ob, "Text")) + if (BKE_bproperty_object_get(ob, "Text")) draw_mesh_text(scene, ob, 0); draw_textured_end(); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 83bc094270b..8d58530765a 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2092,7 +2092,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const flo else { float co2[2]; mul_v3_m4v3(co2, data->vc.obedit->obmat, co); - project_short_noclip(data->vc.ar, co2, s); + ED_view3d_project_short_noclip(data->vc.ar, co2, s); } if (s[0] != IS_CLIPPED) @@ -2169,8 +2169,8 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const flo mul_v3_m4v3(v1_co, data->vc.obedit->obmat, v0co); mul_v3_m4v3(v2_co, data->vc.obedit->obmat, v1co); - project_short_noclip(data->vc.ar, v1_co, s[0]); - project_short_noclip(data->vc.ar, v2_co, s[1]); + ED_view3d_project_short_noclip(data->vc.ar, v1_co, s[0]); + ED_view3d_project_short_noclip(data->vc.ar, v2_co, s[1]); if (data->clipVerts == V3D_CLIP_TEST_REGION) { /* make an int copy */ @@ -2225,7 +2225,7 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const flo short s[2]; mul_v3_m4v3(cent2, data->vc.obedit->obmat, cent); - project_short(data->vc.ar, cent2, s); + ED_view3d_project_short(data->vc.ar, cent2, s); if (s[0] != IS_CLIPPED) { data->func(data->userData, efa, s[0], s[1], index); @@ -3335,7 +3335,8 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act); } - if (em) { + + { draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d); if (me->drawflag & ME_DRAWNORMALS) { @@ -3461,7 +3462,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); dm->drawFacesGLSL(dm, GPU_enable_material); -// if (get_ob_property(ob, "Text")) +// if (BKE_bproperty_object_get(ob, "Text")) // XXX draw_mesh_text(ob, 1); GPU_disable_material(); @@ -3649,7 +3650,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } if (obedit && ob != obedit && ob->data == obedit->data) { - if (ob_get_key(ob) || ob_get_key(obedit)) {} + if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {} else if (ob->modifiers.first || obedit->modifiers.first) {} else drawlinked = 1; } @@ -6643,7 +6644,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short /* which wire color */ if ((dflag & DRAW_CONSTCOLOR) == 0) { - project_short(ar, ob->obmat[3], &base->sx); + ED_view3d_project_short(ar, ob->obmat[3], &base->sx); draw_object_wire_color(scene, base, _ob_wire_col, warning_recursive); ob_wire_col = _ob_wire_col; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index c819637fd04..c8aca5674a4 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -83,7 +83,6 @@ /* ******************* view3d space & buttons ************** */ -#define B_NOP 1 #define B_REDR 2 #define B_OBJECTPANELMEDIAN 1008 diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 8a334423ab0..c0ea4173392 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -69,6 +69,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -558,7 +559,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) /* we don't want the clipping for cursor */ flag = v3d->flag; v3d->flag = 0; - project_int(ar, give_cursor(scene, v3d), co); + ED_view3d_project_int(ar, give_cursor(scene, v3d), co); v3d->flag = flag; mx = co[0]; @@ -900,7 +901,7 @@ static void draw_selected_name(Scene *scene, Object *ob) /* try to display active shapekey too */ shapes[0] = '\0'; - key = ob_get_key(ob); + key = BKE_key_from_object(ob); if (key) { kb = BLI_findlink(&key->block, ob->shapenr - 1); if (kb) { @@ -972,10 +973,10 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV rect_camera = params.viewplane; /* get camera border within viewport */ - viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx; - viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx; - viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy; - viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy; + viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * ar->winx; + viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * ar->winx; + viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * ar->winy; + viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * ar->winy; } void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2]) @@ -983,8 +984,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R rctf viewborder; view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE); - size_r[0] = BLI_RCT_SIZE_X(&viewborder); - size_r[1] = BLI_RCT_SIZE_Y(&viewborder); + size_r[0] = BLI_rctf_size_x(&viewborder); + size_r[1] = BLI_rctf_size_y(&viewborder); } void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, @@ -1340,7 +1341,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) glDisable(GL_MULTISAMPLE_ARB); region_scissor_winrct(ar, &winrct); - glScissor(winrct.xmin, winrct.ymin, BLI_RCT_SIZE_X(&winrct), BLI_RCT_SIZE_Y(&winrct)); + glScissor(winrct.xmin, winrct.ymin, BLI_rcti_size_x(&winrct), BLI_rcti_size_y(&winrct)); glClearColor(0.0, 0.0, 0.0, 0.0); if (v3d->zbuf) { @@ -1542,11 +1543,6 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, { RegionView3D *rv3d = ar->regiondata; BGpic *bgpic; - Image *ima; - MovieClip *clip; - ImBuf *ibuf = NULL, *freeibuf; - float vec[4], fac, asp, zoomx, zoomy; - float x1, y1, x2, y2, cx, cy; int fg_flag = do_foreground ? V3D_BGPIC_FOREGROUND : 0; for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) { @@ -1559,6 +1555,13 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, (rv3d->persp == RV3D_CAMOB && bgpic->view == (1 << RV3D_VIEW_CAMERA))) { float image_aspect[2]; + float fac, asp, zoomx, zoomy; + float x1, y1, x2, y2; + + ImBuf *ibuf = NULL, *freeibuf; + + Image *ima; + MovieClip *clip; /* disable individual images */ if ((bgpic->flag & V3D_BGPIC_DISABLED)) @@ -1686,26 +1689,25 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, } } else { + float tvec[3]; float sco[2]; const float mval_f[2] = {1.0f, 0.0f}; /* calc window coord */ initgrabz(rv3d, 0.0, 0.0, 0.0); - ED_view3d_win_to_delta(ar, mval_f, vec); - fac = maxf(fabsf(vec[0]), maxf(fabsf(vec[1]), fabsf(vec[2]))); /* largest abs axis */ + 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 = 1.0f / fac; - asp = ( (float)ibuf->y) / (float)ibuf->x; + asp = (float)ibuf->y / (float)ibuf->x; - zero_v3(vec); - ED_view3d_project_float_v2(ar, vec, sco, rv3d->persmat); - cx = sco[0]; - cy = sco[1]; + zero_v3(tvec); + ED_view3d_project_float_v2_m4(ar, tvec, sco, rv3d->persmat); - x1 = cx + fac * (bgpic->xof - bgpic->size); - y1 = cy + asp * fac * (bgpic->yof - bgpic->size); - x2 = cx + fac * (bgpic->xof + bgpic->size); - y2 = cy + asp * fac * (bgpic->yof + bgpic->size); + x1 = sco[0] + fac * (bgpic->xof - bgpic->size); + y1 = sco[1] + asp * fac * (bgpic->yof - bgpic->size); + x2 = sco[0] + fac * (bgpic->xof + bgpic->size); + y2 = sco[1] + asp * fac * (bgpic->yof + bgpic->size); } /* complete clip? */ @@ -1771,8 +1773,9 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, glDepthMask(1); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); - if (freeibuf) + if (freeibuf) { IMB_freeImBuf(freeibuf); + } } } } @@ -2044,8 +2047,8 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) x = rect->xmin; y = rect->ymin; - w = BLI_RCT_SIZE_X(rect); - h = BLI_RCT_SIZE_Y(rect); + w = BLI_rcti_size_x(rect); + h = BLI_rcti_size_y(rect); if (w <= 0 || h <= 0) { if (d->depths) @@ -2375,7 +2378,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); - ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE); + ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE, FALSE); GPU_lamp_shadow_buffer_unbind(shadow->lamp); v3d->drawtype = drawtype; @@ -2514,7 +2517,7 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, 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 do_bgpic, int colormanage_background) { RegionView3D *rv3d = ar->regiondata; Base *base; @@ -2553,10 +2556,25 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, /* 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) */ if (scene->world) { - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + /* NOTE: currently OpenGL is supposed to always work in sRGB space and do not + * apply any tonemaps since it's really tricky to support for all features (GLSL, textures, etc) + * but due to compatibility issues background is being affected display transform, so we can + * emulate behavior of disabled colro management + * but this function is also used for sequencer's scene strips which shouldn't be affected by + * tonemaps now and should be purely sRGB, that's why we've got this colormanage_background + * we can drop this flag in cost of some compatibility loss -- background wouldn't be + * color managed in 3d viewport + * same goes to opengl rendering, where color profile should be applied as very final step + */ + + if (colormanage_background) { + IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings, + &scene->display_settings); + } + else { linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr); - else - copy_v3_v3(backcol, &scene->world->horr); + } + glClearColor(backcol[0], backcol[1], backcol[2], 0.0); } else { @@ -2661,7 +2679,8 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, /* utility func for ED_view3d_draw_offscreen */ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, - int sizex, int sizey, unsigned int flag, int draw_background, char err_out[256]) + int sizex, int sizey, unsigned int flag, int draw_background, + int colormanage_background, char err_out[256]) { RegionView3D *rv3d = ar->regiondata; ImBuf *ibuf; @@ -2686,10 +2705,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, BKE_camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp); BKE_camera_params_compute_matrix(¶ms); - ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, params.winmat, draw_background); + ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, params.winmat, draw_background, colormanage_background); } else { - ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL, draw_background); + ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL, draw_background, colormanage_background); } /* read in pixels & stamp */ @@ -2714,7 +2733,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, /* creates own 3d views, used by the sequencer */ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height, - unsigned int flag, int drawtype, int draw_background, char err_out[256]) + unsigned int flag, int drawtype, int draw_background, + int colormanage_background, char err_out[256]) { View3D v3d = {NULL}; ARegion ar = {NULL}; @@ -2753,7 +2773,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat); invert_m4_m4(rv3d.persinv, rv3d.viewinv); - return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag, draw_background, err_out); + return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag, + draw_background, colormanage_background, err_out); // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); } @@ -2860,10 +2881,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE); - cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_RCT_SIZE_X(&viewborder); - cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_RCT_SIZE_Y(&viewborder); - cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_RCT_SIZE_X(&viewborder); - cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_RCT_SIZE_Y(&viewborder); + cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder); + cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder); + cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder); + cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder); cliprct.xmin += ar->winrct.xmin; cliprct.xmax += ar->winrct.xmin; @@ -2877,7 +2898,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) { glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor(cliprct.xmin, cliprct.ymin, BLI_RCT_SIZE_X(&cliprct), BLI_RCT_SIZE_Y(&cliprct)); + glScissor(cliprct.xmin, cliprct.ymin, BLI_rcti_size_x(&cliprct), BLI_rcti_size_y(&cliprct)); } else return 0; @@ -2936,10 +2957,9 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const /* clear background */ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) { - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) - linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr); - else - copy_v3_v3(backcol, &scene->world->horr); + IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings, + &scene->display_settings); + glClearColor(backcol[0], backcol[1], backcol[2], 0.0); } else diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 7accdb0c0e4..744ce6f6209 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -375,17 +375,17 @@ typedef struct ViewOpsData { #define TRACKBALLSIZE (1.1) -static void calctrackballvec(rcti *rect, int mx, int my, float vec[3]) +static void calctrackballvec(const rcti *rect, int mx, int my, float vec[3]) { float x, y, radius, d, z, t; radius = TRACKBALLSIZE; /* normalize x and y */ - x = BLI_RCT_CENTER_X(rect) - mx; - x /= (float)(BLI_RCT_SIZE_X(rect) / 4); - y = BLI_RCT_CENTER_Y(rect) - my; - y /= (float)(BLI_RCT_SIZE_Y(rect) / 2); + x = BLI_rcti_cent_x(rect) - mx; + x /= (float)(BLI_rcti_size_x(rect) / 4); + y = BLI_rcti_cent_y(rect) - my; + y /= (float)(BLI_rcti_size_y(rect) / 2); d = sqrt(x * x + y * y); if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */ @@ -1637,7 +1637,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, if (use_cam_zoom) { float delta; delta = (x - vod->origx + y - vod->origy) / 10.0f; - vod->rv3d->camzoom = vod->camzoom0 - delta; + vod->rv3d->camzoom = vod->camzoom0 + (zoom_invert ? delta : -delta); CLAMP(vod->rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); } @@ -1666,8 +1666,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, int ctr[2], len1, len2; /* method which zooms based on how far you move the mouse */ - ctr[0] = BLI_RCT_CENTER_X(&vod->ar->winrct); - ctr[1] = BLI_RCT_CENTER_Y(&vod->ar->winrct); + ctr[0] = BLI_rcti_cent_x(&vod->ar->winrct); + ctr[1] = BLI_rcti_cent_y(&vod->ar->winrct); len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5; len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5; @@ -2619,10 +2619,10 @@ static int render_border_exec(bContext *C, wmOperator *op) /* calculate range */ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE); - scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_RCT_SIZE_X(&vb); - scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_RCT_SIZE_Y(&vb); - scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_RCT_SIZE_X(&vb); - scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_RCT_SIZE_Y(&vb); + scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_rctf_size_x(&vb); + scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_rctf_size_y(&vb); + scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_rctf_size_x(&vb); + scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_rctf_size_y(&vb); /* actually set border */ CLAMP(scene->r.border.xmin, 0.0f, 1.0f); @@ -2786,8 +2786,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) } /* work out the ratios, so that everything selected fits when we zoom */ - xscale = (BLI_RCT_SIZE_X(&rect) / vb[0]); - yscale = (BLI_RCT_SIZE_Y(&rect) / vb[1]); + xscale = (BLI_rcti_size_x(&rect) / vb[0]); + yscale = (BLI_rcti_size_y(&rect) / vb[1]); new_dist *= maxf(xscale, yscale); /* zoom in as required, or as far as we can go */ @@ -3465,7 +3465,7 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op) view3d_set_viewcontext(C, &vc); view3d_get_transformation(vc.ar, vc.rv3d, NULL, &mats); /* NULL because we don't want it in object space */ - ED_view3d_calc_clipping(rv3d->clipbb, rv3d->clip, &mats, &rect); + ED_view3d_clipping_calc(rv3d->clipbb, rv3d->clip, &mats, &rect); return OPERATOR_FINISHED; } @@ -3529,7 +3529,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve // if (obedit && ctrl) lr_click= 1; copy_v3_v3(oldcurs, fp); - project_int_noclip(ar, fp, mval); + ED_view3d_project_int_noclip(ar, fp, mval); flip = initgrabz(rv3d, fp[0], fp[1], fp[2]); /* reset the depth based on the view offset */ @@ -3537,7 +3537,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve negate_v3_v3(fp, rv3d->ofs); /* re initialize */ - project_int_noclip(ar, fp, mval); + ED_view3d_project_int_noclip(ar, fp, mval); flip = initgrabz(rv3d, fp[0], fp[1], fp[2]); (void)flip; } @@ -3837,10 +3837,12 @@ int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int m } /** - * Gets the view transformation from a camera - * currently dosnt take camzoom into account + * Set the view transformation from a 4x4 matrix. * - * The dist is not modified for this function, if NULL its assumed zero + * \param mat The view 4x4 transformation matrix to assign. + * \param ofs The view offset, normally from RegionView3D.ofs. + * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. + * \param dist The view distance from ofs, normally from RegionView3D.dist. */ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) { @@ -3871,6 +3873,14 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) } } +/** + * Calculate the view transformation matrix from RegionView3D input. + * The resulting matrix is equivalent to RegionView3D.viewinv + * \param mat The view 4x4 transformation matrix to calculate. + * \param ofs The view offset, normally from RegionView3D.ofs. + * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. + * \param dist The view distance from ofs, normally from RegionView3D.dist. + */ void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist) { float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]}; @@ -3881,8 +3891,14 @@ void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], co sub_v3_v3v3(mat[3], dvec, ofs); } - -/* object -> view */ +/** + * Set the RegionView3D members from an objects transformation and optionally lens. + * \param ob The object to set the view to. + * \param ofs The view offset to be set, normally from RegionView3D.ofs. + * \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat. + * \param dist The view distance from ofs to be set, normally from RegionView3D.dist. + * \param lens The view lens angle set for cameras and lamps, normally from View3D.lens. + */ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens) { ED_view3d_from_m4(ob->obmat, ofs, quat, dist); @@ -3896,7 +3912,13 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, } } -/* view -> object */ +/** + * Set the object transformation from RegionView3D members. + * \param ob The object which has the transformation assigned. + * \param ofs The view offset, normally from RegionView3D.ofs. + * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. + * \param dist The view distance from ofs, normally from RegionView3D.dist. + */ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], const float dist) { float mat[4][4]; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 855771b17a2..c743b88e889 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -346,7 +346,6 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event /* check for flying ortho camera - which we cant support well * we _could_ also check for an ortho camera but this is easier */ if ((fly->rv3d->persp == RV3D_CAMOB) && - (fly->v3d->camera != NULL) && (fly->rv3d->is_persp == FALSE)) { ((Camera *)fly->v3d->camera->data)->type = CAM_PERSP; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index fd43333acfe..b2ae63df662 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -84,25 +84,10 @@ * This can be cleaned when I make some new 'mode' icons. */ -/* view3d handler codes */ -#define VIEW3D_HANDLER_BACKGROUND 1 -#define VIEW3D_HANDLER_PROPERTIES 2 -#define VIEW3D_HANDLER_OBJECT 3 -#define VIEW3D_HANDLER_PREVIEW 4 -#define VIEW3D_HANDLER_MULTIRES 5 -#define VIEW3D_HANDLER_TRANSFORM 6 -#define VIEW3D_HANDLER_GREASEPENCIL 7 -#define VIEW3D_HANDLER_BONESKETCH 8 - /* end XXX ************* */ static void do_view3d_header_buttons(bContext *C, void *arg, int event); -#define B_SCENELOCK 101 -#define B_FULL 102 -#define B_HOME 103 -#define B_VIEWBUT 104 -#define B_PERSP 105 #define B_MODESELECT 108 #define B_SEL_VERT 110 #define B_SEL_EDGE 111 @@ -110,10 +95,7 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event); #define B_MAN_TRANS 116 #define B_MAN_ROT 117 #define B_MAN_SCALE 118 -#define B_NDOF 119 #define B_MAN_MODE 120 -#define B_REDR 122 -#define B_NOP 123 /* XXX quickly ported across */ static void handle_view3d_lock(bContext *C) @@ -346,10 +328,6 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event) /* watch it: if sa->win does not exist, check that when calling direct drawing routines */ switch (event) { - case B_REDR: - ED_area_tag_redraw(sa); - break; - case B_MODESELECT: WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set"); RNA_enum_set(&props_ptr, "mode", v3d->modeselect); @@ -416,9 +394,6 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event) } ED_area_tag_redraw(sa); break; - case B_NDOF: - ED_area_tag_redraw(sa); - break; case B_MAN_MODE: ED_area_tag_redraw(sa); break; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 5712144caf1..e409ad4e81e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -114,7 +114,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m mval_cpy[0] = mval[0]; mval_cpy[1] = mval[1]; - project_int_noclip(vc->ar, fp, mval_cpy); + ED_view3d_project_int_noclip(vc->ar, fp, mval_cpy); initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); @@ -319,11 +319,6 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) return 1; } - -#define MOVES_GESTURE 50 -#define MOVES_LASSO 500 - - /* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN) * and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK */ @@ -339,9 +334,9 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], s for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) { mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); - project_int(vc->ar, vec, sco1); + ED_view3d_project_int(vc->ar, vec, sco1); mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); - project_int(vc->ar, vec, sco2); + ED_view3d_project_int(vc->ar, vec, sco2); if (BLI_lasso_is_edge_inside(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1], IS_CLIPPED)) { if (select) pchan->bone->flag |= BONE_SELECTED; @@ -376,7 +371,7 @@ static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short move for (base = vc->scene->base.first; base; base = base->next) { if (BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */ - project_short(vc->ar, base->object->obmat[3], &base->sx); + ED_view3d_project_short(vc->ar, base->object->obmat[3], &base->sx); if (BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)) { if (select) ED_base_object_select(base, BA_SELECT); @@ -583,9 +578,9 @@ static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short mov for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) { mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head); - project_short(vc->ar, vec, sco1); + ED_view3d_project_short(vc->ar, vec, sco1); mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail); - project_short(vc->ar, vec, sco2); + ED_view3d_project_short(vc->ar, vec, sco2); didpoint = 0; if (BLI_lasso_is_point_inside(mcords, moves, sco1[0], sco1[1], IS_CLIPPED)) { @@ -637,7 +632,7 @@ static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves, for (ml = mb->editelems->first; ml; ml = ml->next) { mul_v3_m4v3(vec, vc->obedit->obmat, &ml->x); - project_short(vc->ar, vec, sco); + ED_view3d_project_short(vc->ar, vec, sco); if (BLI_lasso_is_point_inside(mcords, moves, sco[0], sco[1], IS_CLIPPED)) { if (select) ml->flag |= SELECT; @@ -646,7 +641,7 @@ static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves, } } -int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) +static int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) { Mesh *me; MVert *mvert; @@ -654,8 +649,8 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) unsigned int *rt; int a, index; char *selar; - int sx = BLI_RCT_SIZE_X(rect) + 1; - int sy = BLI_RCT_SIZE_Y(rect) + 1; + int sx = BLI_rcti_size_x(rect) + 1; + int sy = BLI_rcti_size_y(rect) + 1; me = vc->obact->data; @@ -1065,7 +1060,7 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int else { int temp, dist = 15; - project_short(vc->ar, base->object->obmat[3], &base->sx); + ED_view3d_project_short(vc->ar, base->object->obmat[3], &base->sx); temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]); if (temp < dist) @@ -1346,7 +1341,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese base = startbase; while (base) { if (BASE_SELECTABLE(v3d, base)) { - project_short(ar, base->object->obmat[3], &base->sx); + ED_view3d_project_short(ar, base->object->obmat[3], &base->sx); temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]); if (base == BASACT) temp += 10; @@ -2383,11 +2378,11 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f /* project head location to screenspace */ mul_v3_m4v3(vec, vc->obact->obmat, pchan->pose_head); - project_short(vc->ar, vec, sco1); + ED_view3d_project_short(vc->ar, vec, sco1); /* project tail location to screenspace */ mul_v3_m4v3(vec, vc->obact->obmat, pchan->pose_tail); - project_short(vc->ar, vec, sco2); + ED_view3d_project_short(vc->ar, vec, sco2); /* check if the head and/or tail is in the circle * - the call to check also does the selection already @@ -2451,11 +2446,11 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 /* project head location to screenspace */ mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head); - project_short(vc->ar, vec, sco1); + ED_view3d_project_short(vc->ar, vec, sco1); /* project tail location to screenspace */ mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail); - project_short(vc->ar, vec, sco2); + ED_view3d_project_short(vc->ar, vec, sco2); /* check if the head and/or tail is in the circle * - the call to check also does the selection already @@ -2561,7 +2556,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) select = select ? BA_SELECT : BA_DESELECT; for (base = FIRSTBASE; base; base = base->next) { if (BASE_SELECTABLE(v3d, base)) { - project_short(ar, base->object->obmat[3], &base->sx); + ED_view3d_project_short(ar, base->object->obmat[3], &base->sx); if (base->sx != IS_CLIPPED) { int dx = base->sx - x; int dy = base->sy - y; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c25bb80bfde..ff518e6ce5b 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -520,7 +520,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) /* ********************************** */ -void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect) +void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect) { float modelview[4][4]; double xs, ys, p[3]; @@ -569,7 +569,18 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co } } -/* create intersection coordinates in view Z direction at mouse coordinates */ +/** + * Calculate a 3d segment from 2d window coordinates. + * This ray_start is located at the viewpoint, ray_end is a far point. + * ray_start and ray_end are clipped by the view near and far limits + * so points along this line are always in view. + * In orthographic view all resulting segments will be parallel. + * \param ar The region (used for the window width and height). + * \param v3d The 3d viewport (used for near and far clipping range). + * \param mval The area relative 2d location (such as event->mval, converted into float[2]). + * \param ray_start The world-space starting point of the segment. + * \param ray_end The world-space end point of the segment. + */ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) { RegionView3D *rv3d = ar->regiondata; @@ -604,7 +615,17 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2] } } -/* create intersection ray in view Z direction at mouse coordinates */ +/** + * Calculate a 3d viewpoint and direction vector from 2d window coordinates. + * This ray_start is located at the viewpoint, ray_normal is the direction towards mval. + * ray_start is clipped by the view near limit so points in front of it are always in view. + * In orthographic view the resulting ray_normal will match the view vector. + * \param ar The region (used for the window width and height). + * \param v3d The 3d viewport (used for near clipping value). + * \param mval The area relative 2d location (such as event->mval, converted into float[2]). + * \param ray_start The world-space starting point of the segment. + * \param ray_normal The normalized world-space direction of towards mval. + */ void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]) { float ray_end[3]; @@ -614,6 +635,13 @@ void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float r normalize_v3(ray_normal); } +/** + * Calculate a normalized 3d direction vector from the viewpoint towards a global location. + * In orthographic view the resulting vector will match the view vector. + * \param rv3d The region (used for the window width and height). + * \param coord The world-space location. + * \param vec The resulting normalized vector. + */ void ED_view3d_global_to_vector(RegionView3D *rv3d, const float coord[3], float vec[3]) { if (rv3d->is_persp) { @@ -660,6 +688,13 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z) return flip; } +/** + * Calculate a 3d location from 2d window coordinates. + * \param ar The region (used for the window width and height). + * \param depth_pt The reference location used to calculate the Z depth. + * \param mval The area relative location (such as event->mval converted to floats). + * \param out The resulting world-space location. + */ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]) { RegionView3D *rv3d = ar->regiondata; @@ -690,8 +725,14 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[ } } -/* always call initgrabz */ -/* only to detect delta motion */ +/** + * Calculate a 3d difference vector from 2d window offset. + * note that initgrabz() must be called first to determine + * the depth used to calculate the delta. + * \param ar The region (used for the window width and height). + * \param mval The area relative 2d difference (such as event->mval[0] - other_x). + * \param out The resulting world-space delta. + */ void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3]) { RegionView3D *rv3d = ar->regiondata; @@ -705,9 +746,19 @@ void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3]) out[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy); } -/* doesn't rely on initgrabz */ -/* for perspective view, get the vector direction to - * the mouse cursor as a normalized vector */ +/** + * Calculate a 3d direction vector from 2d window coordinates. + * This direction vector starts and the view in the direction of the 2d window coordinates. + * In orthographic view all window coordinates yield the same vector. + * + * \note doesn't rely on initgrabz + * for perspective view, get the vector direction to + * the mouse cursor as a normalized vector. + * + * \param ar The region (used for the window width and height). + * \param mval The area relative 2d location (such as event->mval converted to floats). + * \param out The resulting normalized world-space direction vector. + */ void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3]) { RegionView3D *rv3d = ar->regiondata; @@ -754,7 +805,7 @@ void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][ /* Uses window coordinates (x,y) and depth component z to find a point in * modelspace */ -void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, const float z) +void ED_view3d_unproject(bglMats *mats, float out[3], const float x, const float y, const float z) { double ux, uy, uz; @@ -766,44 +817,44 @@ void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, out[2] = uz; } -/* use view3d_get_object_project_mat to get projecting mat */ -void ED_view3d_project_float_v2(const ARegion *ar, const float vec[3], float adr[2], float mat[4][4]) +/* use #ED_view3d_ob_project_mat_get to get projecting mat */ +void ED_view3d_project_float_v2_m4(const ARegion *ar, const float co[3], float r_co[2], float mat[4][4]) { float vec4[4]; - copy_v3_v3(vec4, vec); + copy_v3_v3(vec4, co); vec4[3] = 1.0; - /* adr[0]= IS_CLIPPED; */ /* always overwritten */ + /* r_co[0] = IS_CLIPPED; */ /* always overwritten */ mul_m4_v4(mat, vec4); if (vec4[3] > FLT_EPSILON) { - adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; - adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; + r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; + r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; } else { - adr[0] = adr[1] = 0.0f; + zero_v2(r_co); } } -/* use view3d_get_object_project_mat to get projecting mat */ -void ED_view3d_project_float_v3(ARegion *ar, const float vec[3], float adr[3], float mat[4][4]) +/* use #ED_view3d_ob_project_mat_get to get projecting mat */ +void ED_view3d_project_float_v3_m4(ARegion *ar, const float vec[3], float r_co[3], float mat[4][4]) { float vec4[4]; copy_v3_v3(vec4, vec); vec4[3] = 1.0; - /* adr[0]= IS_CLIPPED; */ /* always overwritten */ + /* r_co[0] = IS_CLIPPED; */ /* always overwritten */ mul_m4_v4(mat, vec4); if (vec4[3] > FLT_EPSILON) { - adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; - adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; - adr[2] = vec4[2] / vec4[3]; + r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; + r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; + r_co[2] = vec4[2] / vec4[3]; } else { - zero_v3(adr); + zero_v3(r_co); } } @@ -842,24 +893,24 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb) return 0; } -void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */ +void ED_view3d_project_short(ARegion *ar, const float co[3], short r_co[2]) /* clips */ { RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; - adr[0] = IS_CLIPPED; + r_co[0] = IS_CLIPPED; if (rv3d->rflag & RV3D_CLIPPING) { - if (ED_view3d_clipping_test(rv3d, vec, FALSE)) { + if (ED_view3d_clipping_test(rv3d, co, FALSE)) { return; } } - copy_v3_v3(vec4, vec); + copy_v3_v3(vec4, co); vec4[3] = 1.0; mul_m4_v4(rv3d->persmat, vec4); - if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */ + if (vec4[3] > (float)BL_NEAR_CLIP) { fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); if (fx > 0 && fx < ar->winx) { @@ -867,44 +918,44 @@ void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */ fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); if (fy > 0.0f && fy < (float)ar->winy) { - adr[0] = (short)floor(fx); - adr[1] = (short)floor(fy); + r_co[0] = (short)floor(fx); + r_co[1] = (short)floor(fy); } } } } -void project_int(ARegion *ar, const float vec[3], int adr[2]) +void ED_view3d_project_int(ARegion *ar, const float co[3], int r_co[2]) { RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; - copy_v3_v3(vec4, vec); + copy_v3_v3(vec4, co); vec4[3] = 1.0; - adr[0] = (int)2140000000.0f; + r_co[0] = (int)2140000000.0f; mul_m4_v4(rv3d->persmat, vec4); - if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */ + if (vec4[3] > (float)BL_NEAR_CLIP) { fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); if (fx > -2140000000.0f && fx < 2140000000.0f) { fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); if (fy > -2140000000.0f && fy < 2140000000.0f) { - adr[0] = (int)floor(fx); - adr[1] = (int)floor(fy); + r_co[0] = (int)floor(fx); + r_co[1] = (int)floor(fy); } } } } -void project_int_noclip(ARegion *ar, const float vec[3], int adr[2]) +void ED_view3d_project_int_noclip(ARegion *ar, const float co[3], int r_co[2]) { RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; - copy_v3_v3(vec4, vec); + copy_v3_v3(vec4, co); vec4[3] = 1.0; mul_m4_v4(rv3d->persmat, vec4); @@ -913,27 +964,27 @@ void project_int_noclip(ARegion *ar, const float vec[3], int adr[2]) fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); - adr[0] = (int)floor(fx); - adr[1] = (int)floor(fy); + r_co[0] = (int)floor(fx); + r_co[1] = (int)floor(fy); } else { - adr[0] = ar->winx / 2; - adr[1] = ar->winy / 2; + r_co[0] = ar->winx / 2; + r_co[1] = ar->winy / 2; } } -void project_short_noclip(ARegion *ar, const float vec[3], short adr[2]) +void ED_view3d_project_short_noclip(ARegion *ar, const float co[3], short r_co[2]) { RegionView3D *rv3d = ar->regiondata; float fx, fy, vec4[4]; - copy_v3_v3(vec4, vec); + copy_v3_v3(vec4, co); vec4[3] = 1.0; - adr[0] = IS_CLIPPED; + r_co[0] = IS_CLIPPED; mul_m4_v4(rv3d->persmat, vec4); - if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */ + if (vec4[3] > (float)BL_NEAR_CLIP) { fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]); if (fx > -32700 && fx < 32700) { @@ -941,53 +992,48 @@ void project_short_noclip(ARegion *ar, const float vec[3], short adr[2]) fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]); if (fy > -32700.0f && fy < 32700.0f) { - adr[0] = (short)floor(fx); - adr[1] = (short)floor(fy); + r_co[0] = (short)floor(fx); + r_co[1] = (short)floor(fy); } } } } -void apply_project_float(float persmat[4][4], int winx, int winy, const float vec[3], float adr[2]) +void ED_view3d_project_float(ARegion *ar, const float co[3], float r_co[2]) { + RegionView3D *rv3d = ar->regiondata; + float vec4[4]; - copy_v3_v3(vec4, vec); + copy_v3_v3(vec4, co); vec4[3] = 1.0; - adr[0] = IS_CLIPPED; + r_co[0] = IS_CLIPPED; - mul_m4_v4(persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); if (vec4[3] > (float)BL_NEAR_CLIP) { - adr[0] = (float)(winx / 2.0f) + (winx / 2.0f) * vec4[0] / vec4[3]; - adr[1] = (float)(winy / 2.0f) + (winy / 2.0f) * vec4[1] / vec4[3]; + r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; + r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; } } -void project_float(ARegion *ar, const float vec[3], float adr[2]) -{ - RegionView3D *rv3d = ar->regiondata; - - apply_project_float(rv3d->persmat, ar->winx, ar->winy, vec, adr); -} - -void project_float_noclip(ARegion *ar, const float vec[3], float adr[2]) +void ED_view3d_project_float_noclip(ARegion *ar, const float co[3], float r_co[2]) { RegionView3D *rv3d = ar->regiondata; float vec4[4]; - copy_v3_v3(vec4, vec); + copy_v3_v3(vec4, co); vec4[3] = 1.0; mul_m4_v4(rv3d->persmat, vec4); if (fabs(vec4[3]) > BL_NEAR_CLIP) { - adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; - adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; + r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; + r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; } else { - adr[0] = ar->winx / 2.0f; - adr[1] = ar->winy / 2.0f; + r_co[0] = ar->winx / 2.0f; + r_co[1] = ar->winy / 2.0f; } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index dccd0c27234..ee5d50c7aba 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -126,11 +126,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy) { float divx, divy; - divx = BLI_RCT_SIZE_X(&v2d->mask); - divy = BLI_RCT_SIZE_Y(&v2d->mask); + divx = BLI_rcti_size_x(&v2d->mask); + divy = BLI_rcti_size_y(&v2d->mask); - r_vec[0] = BLI_RCT_SIZE_X(&v2d->cur) * dx / divx; - r_vec[1] = BLI_RCT_SIZE_Y(&v2d->cur) * dy / divy; + r_vec[0] = BLI_rctf_size_x(&v2d->cur) * dx / divx; + r_vec[1] = BLI_rctf_size_y(&v2d->cur) * dy / divy; r_vec[2] = 0.0f; } @@ -139,11 +139,11 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy) float divx, divy; float mulx, muly; - divx = BLI_RCT_SIZE_X(&v2d->mask); - divy = BLI_RCT_SIZE_Y(&v2d->mask); + divx = BLI_rcti_size_x(&v2d->mask); + divy = BLI_rcti_size_y(&v2d->mask); - mulx = BLI_RCT_SIZE_X(&v2d->cur); - muly = BLI_RCT_SIZE_Y(&v2d->cur); + mulx = BLI_rctf_size_x(&v2d->cur); + muly = BLI_rctf_size_y(&v2d->cur); /* difference with convertViewVec2D */ /* clamp w/h, mask only */ @@ -226,7 +226,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) { if (t->spacetype == SPACE_VIEW3D) { if (t->ar->regiontype == RGN_TYPE_WINDOW) - project_int_noclip(t->ar, vec, adr); + ED_view3d_project_int_noclip(t->ar, vec, adr); } else if (t->spacetype == SPACE_IMAGE) { SpaceImage *sima = t->sa->spacedata.first; @@ -344,7 +344,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) case SPACE_VIEW3D: { if (t->ar->regiontype == RGN_TYPE_WINDOW) { - project_float_noclip(t->ar, vec, adr); + ED_view3d_project_float_noclip(t->ar, vec, adr); return; } break; @@ -2195,7 +2195,6 @@ static void constraintTransLim(TransInfo *t, TransData *td) for (con = td->con; con; con = con->next) { bConstraintTypeInfo *cti = NULL; ListBase targets = {NULL, NULL}; - float tmat[4][4]; /* only consider constraint if enabled */ if (con->flag & CONSTRAINT_DISABLE) continue; @@ -2221,8 +2220,7 @@ static void constraintTransLim(TransInfo *t, TransData *td) /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->mtx, tmat); + mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix); } else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) { /* skip... incompatable spacetype */ @@ -2237,9 +2235,8 @@ static void constraintTransLim(TransInfo *t, TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { - /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->smtx, tmat); + /* just multiply by td->smtx (this should be ok) */ + mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix); } /* free targets list */ @@ -2287,18 +2284,17 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) bConstraintOb cob; bConstraint *con; int do_limit = FALSE; - + /* Evaluate valid constraints */ for (con = td->con; con; con = con->next) { /* only consider constraint if enabled */ if (con->flag & CONSTRAINT_DISABLE) continue; if (con->enforce == 0.0f) continue; - + /* we're only interested in Limit-Rotation constraints */ if (con->type == CONSTRAINT_TYPE_ROTLIMIT) { bRotLimitConstraint *data = con->data; - float tmat[4][4]; - + /* only use it if it's tagged for this purpose */ if ((data->flag2 & LIMIT_TRANSFORM) == 0) continue; @@ -2312,12 +2308,11 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) constraintob_from_transdata(&cob, td); do_limit = TRUE; } - + /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->mtx, tmat); + mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix); } /* do constraint */ @@ -2325,9 +2320,8 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { - /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->smtx, tmat); + /* just multiply by td->smtx (this should be ok) */ + mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix); } } } @@ -2382,7 +2376,6 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* we're only interested in Limit-Scale constraints */ if (con->type == CONSTRAINT_TYPE_SIZELIMIT) { bSizeLimitConstraint *data = con->data; - float tmat[4][4]; /* only use it if it's tagged for this purpose */ if ((data->flag2 & LIMIT_TRANSFORM) == 0) @@ -2391,11 +2384,10 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->mtx, tmat); + mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix); } else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) { - /* skip... incompatable spacetype */ + /* skip... incompatible spacetype */ continue; } @@ -2404,13 +2396,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { - /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->smtx, tmat); + /* just multiply by td->smtx (this should be ok) */ + mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix); } } } - + /* copy results from cob->matrix */ if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) { /* scale val and reset size */ @@ -2420,7 +2411,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* Reset val if SINGLESIZE but using a constraint */ if (td->flag & TD_SINGLESIZE) return; - + mat4_to_size(td->ext->size, cob.matrix); } } @@ -2852,11 +2843,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) { float obsizemat[3][3]; - // Reorient the size mat to fit the oriented object. + /* Reorient the size mat to fit the oriented object. */ mul_m3_m3m3(obsizemat, tmat, td->axismtx); - //print_m3("obsizemat", obsizemat); + /* print_m3("obsizemat", obsizemat); */ TransMat3ToSize(obsizemat, td->axismtx, fsize); - //print_v3("fsize", fsize); + /* print_v3("fsize", fsize); */ } else { mat3_to_size(fsize, tmat); @@ -2864,7 +2855,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) protectedSizeBits(td->protectflag, fsize); - if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't resize objects itself + if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't resize objects itself */ if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) { /* scale val and reset size */ *td->val = td->ival * (1 + (fsize[0] - 1) * td->factor); @@ -4100,9 +4091,9 @@ void initMaskShrinkFatten(TransInfo *t) int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { - TransData *td = t->data; + TransData *td; float ratio; - int i; + int i, initial_feather = FALSE; char str[50]; ratio = t->values[0]; @@ -4116,13 +4107,30 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c); - sprintf(str, "Shrink/Fatten: %s", c); + sprintf(str, "Feather Shrink/Fatten: %s", c); } else { - sprintf(str, "Shrink/Fatten: %3f", ratio); + sprintf(str, "Feather Shrink/Fatten: %3f", ratio); } - for (i = 0; i < t->total; i++, td++) { + /* detect if no points have feather yet */ + if (ratio > 1.0f) { + initial_feather = TRUE; + + for (td = t->data, i = 0; i < t->total; i++, td++) { + if (td->flag & TD_NOACTION) + break; + + if (td->flag & TD_SKIP) + continue; + + if (td->ival >= 0.001f) + initial_feather = FALSE; + } + } + + /* apply shrink/fatten */ + for (td = t->data, i = 0; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -4130,7 +4138,11 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) continue; if (td->val) { - *td->val = td->ival * ratio; + if (initial_feather) + *td->val = td->ival + (ratio - 1.0f) * 0.01f; + else + *td->val = td->ival * ratio; + /* apply PET */ *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); if (*td->val <= 0.0f) *td->val = 0.001f; @@ -4774,7 +4786,7 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo sv->edge_len = len_v3v3(dw_p, up_p); mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co); - project_float_noclip(t->ar, v_proj, v_proj); + ED_view3d_project_float_noclip(t->ar, v_proj, v_proj); dist = len_squared_v2v2(mval, v_proj); if (dist < min_dist) { @@ -5040,19 +5052,19 @@ static int createSlideVerts(TransInfo *t) j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v)); if (sv_array[j].down) { - ED_view3d_project_float_v3(ar, sv_array[j].down->co, vec1, projectMat); + ED_view3d_project_float_v3_m4(ar, sv_array[j].down->co, vec1, projectMat); } else { add_v3_v3v3(vec1, v->co, sv_array[j].downvec); - ED_view3d_project_float_v3(ar, vec1, vec1, projectMat); + ED_view3d_project_float_v3_m4(ar, vec1, vec1, projectMat); } if (sv_array[j].up) { - ED_view3d_project_float_v3(ar, sv_array[j].up->co, vec2, projectMat); + ED_view3d_project_float_v3_m4(ar, sv_array[j].up->co, vec2, projectMat); } else { add_v3_v3v3(vec2, v->co, sv_array[j].upvec); - ED_view3d_project_float_v3(ar, vec2, vec2, projectMat); + ED_view3d_project_float_v3_m4(ar, vec2, vec2, projectMat); } /* global direction */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 181f9fe6036..022e9177a4a 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1773,9 +1773,6 @@ void flushTransParticles(TransInfo *t) /* ********************* mesh ****************** */ -/* proportional distance based on connectivity */ -#define THRESHOLDFACTOR (1.0f - 0.0001f) - /* I did this wrong, it should be a breadth-first search * but instead it's a depth-first search, fudged * to report shortest distances. I have no idea how fast @@ -5170,7 +5167,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* Depending on the lock status, draw necessary views */ // fixme... some of this stuff is not good if (ob) { - if (ob->pose || ob_get_key(ob)) + if (ob->pose || BKE_key_from_object(ob)) DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); else DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -5554,8 +5551,8 @@ static void createTransObject(bContext *C, TransInfo *t) static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) { /* hold original location */ - float locxy[2] = {BLI_RCT_CENTER_X(&node->totr), - BLI_RCT_CENTER_Y(&node->totr)}; + float locxy[2] = {BLI_rctf_cent_x(&node->totr), + BLI_rctf_cent_y(&node->totr)}; copy_v2_v2(td2d->loc, locxy); td2d->loc[2] = 0.0f; @@ -5722,10 +5719,9 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra unit_m3(td->smtx); } -static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d, +static void trackToTransData(const int framenr, TransData *td, TransData2D *td2d, TransDataTracking *tdt, MovieTrackingTrack *track, float aspx, float aspy) { - int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr); tdt->flag = marker->flag; @@ -5777,7 +5773,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - MovieTrackingMarker *marker; TransDataTracking *tdt; int framenr = ED_space_clip_get_clip_frame_number(sc); float aspx, aspy; @@ -5788,8 +5783,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { - marker = BKE_tracking_marker_get(track, framenr); - t->total++; /* offset */ if (track->flag & SELECT) @@ -5820,9 +5813,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { - marker = BKE_tracking_marker_get(track, framenr); - - trackToTransData(sc, td, td2d, tdt, track, aspx, aspy); + trackToTransData(framenr, td, td2d, tdt, track, aspx, aspy); /* offset */ td++; @@ -5845,12 +5836,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) td += 2; td2d += 2; tdt += 2; - - if (marker->flag & MARKER_DISABLED) { - td += 3; - td2d += 3; - tdt += 3; - }; } } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index b88ae68e00b..1d75be05534 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -315,7 +315,7 @@ void applyProject(TransInfo *t) copy_v3_v3(iloc, td->ob->obmat[3]); } - project_float(t->ar, iloc, mval); + ED_view3d_project_float(t->ar, iloc, mval); if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) { // if (t->flag & (T_EDIT|T_POSE)) { @@ -601,7 +601,7 @@ int updateSelectedSnapPoint(TransInfo *t) int dx, dy; int dist; - project_int(t->ar, p->co, screen_loc); + ED_view3d_project_int(t->ar, p->co, screen_loc); dx = t->mval[0] - screen_loc[0]; dy = t->mval[1] - screen_loc[1]; @@ -960,8 +960,8 @@ static void TargetSnapOffset(TransInfo *t, TransData *td) if (t->spacetype == SPACE_NODE && td != NULL) { bNode *node = td->extra; char border = t->tsnap.snapNodeBorder; - float width = BLI_RCT_SIZE_X(&node->totr); - float height = BLI_RCT_SIZE_Y(&node->totr); + float width = BLI_rctf_size_x(&node->totr); + float height = BLI_rctf_size_y(&node->totr); if (border & NODE_LEFT) t->tsnap.snapTarget[0] -= 0.5f * width; @@ -1164,7 +1164,7 @@ static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], fl new_depth = len_v3v3(location, ray_start); - project_int(ar, location, screen_loc); + ED_view3d_project_int(ar, location, screen_loc); new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); if (new_dist <= *dist && new_depth < *depth) { @@ -1232,7 +1232,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh new_depth = len_v3v3(location, ray_start); - project_int(ar, location, screen_loc); + ED_view3d_project_int(ar, location, screen_loc); new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); /* 10% threshold if edge is closer but a bit further @@ -1289,7 +1289,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4], new_depth = len_v3v3(location, ray_start); - project_int(ar, location, screen_loc); + ED_view3d_project_int(ar, location, screen_loc); new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); if (new_dist <= *r_dist && new_depth < *r_depth) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 5008c35e46a..06da1c8bfea 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2836,7 +2836,7 @@ static int uv_lasso_select_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; } -void UV_OT_select_lasso(wmOperatorType *ot) +static void UV_OT_select_lasso(wmOperatorType *ot) { ot->name = "Lasso Select UV"; ot->description = "Select UVs using lasso selection"; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index c95b2e85248..7c06fbd2a9d 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -242,7 +242,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, key = (ParamKey)efa; - tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); + // tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); // UNUSED if (efa->len == 3 || efa->len == 4) { /* for quads let parametrize split, it can make better decisions diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp index a342fed27e3..321dd5fe41f 100755 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp @@ -203,7 +203,8 @@ namespace StrokeShaders { ifstream ifs(j->c_str()); if (ifs.is_open()) { //soc image.load(j->c_str()); - image = IMB_loadiffname(j->c_str(), 0); + /* OCIO_TODO: support different input color space */ + image = IMB_loadiffname(j->c_str(), 0, NULL); break; } } @@ -350,7 +351,8 @@ namespace StrokeShaders { for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); j++) { ifstream ifs(j->c_str()); if (ifs.is_open()) { - image = IMB_loadiffname(j->c_str(), 0); //soc + /* OCIO_TODO: support different input color space */ + image = IMB_loadiffname(j->c_str(), 0, NULL); //soc break; } } diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp index d67f05ddb92..f2cfe6a855f 100755 --- a/source/blender/freestyle/intern/stroke/Canvas.cpp +++ b/source/blender/freestyle/intern/stroke/Canvas.cpp @@ -333,7 +333,8 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i // return; // } // qimg = &newMap; - ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0);; + /* OCIO_TODO: support different input color space */ + ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0, NULL); if( qimg == 0 ){ cout << "Could not load image file " << filePath << endl; return; diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index 1729ac06f5a..745ca1ef2ac 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -162,8 +162,9 @@ 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, struct MFace *mface, int *face_indices, int totface, + struct MVert *mvert, int *vert_indices, int totvert, + int (*face_vert_indices)[4], const float *vmask); GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, unsigned int **grid_hidden, int gridsize); diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 467adbe10b8..7d829bd57bf 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); @@ -119,7 +121,7 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap); /* Image updates and free * - these deal with images bound as opengl textures */ -void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int 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); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index c44a181841e..930573ec750 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, @@ -1280,6 +1281,8 @@ typedef struct { char pad[2]; unsigned char color[3]; + float accum_color[3]; + int tot_color; } VertexBufferFormat; struct GPU_Buffers { @@ -1327,24 +1330,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; } -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, @@ -1360,29 +1363,32 @@ 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) +void GPU_update_mesh_buffers(GPU_Buffers *buffers, MFace *mface, int *face_indices, int totface, + MVert *mvert, int *vert_indices, int totvert, + int (*face_vert_indices)[4], const float *vmask) { VertexBufferFormat *vert_data; int i; @@ -1404,8 +1410,40 @@ 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); - gpu_color_from_mask_copy(vmask[vert_indices[i]], - out->color); + zero_v3(out->accum_color); + out->tot_color = 0; + } + +#define UPDATE_VERTEX(face, vertex, index, diffuse_color) \ + { \ + VertexBufferFormat *out = vert_data + face_vert_indices[face][index]; \ + add_v3_v3(out->accum_color, diffuse_color); \ + out->tot_color++; \ + } (void)0 + + for (i = 0; i < totface; ++i) { + MFace *f = mface + face_indices[i]; + float diffuse_color[4]; + + GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color); + + 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 + + for (i = 0; i < totvert; ++i) { + VertexBufferFormat *out = vert_data + i; + if (out->tot_color) { + float diffuse_color[4]; + + mul_v3_v3fl(diffuse_color, out->accum_color, 1.0f / out->tot_color); + + gpu_color_from_mask_copy(vmask[vert_indices[i]], diffuse_color, out->color); + } } glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); @@ -1517,6 +1555,10 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, for (i = 0; i < totgrid; ++i) { VertexBufferFormat *vd = vert_data; CCGElem *grid = grids[grid_indices[i]]; + const DMFlagMat *flags = &grid_flag_mats[grid_indices[i]]; + float diffuse_color[4]; + + GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color); for (y = 0; y < key->grid_size; y++) { for (x = 0; x < key->grid_size; x++) { @@ -1524,11 +1566,9 @@ 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)); - gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), - vd->color); + gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), diffuse_color, vd->color); } vd++; } @@ -1561,6 +1601,7 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, elems[1], elems[2], elems[3], + diffuse_color, vd->color); } } @@ -1769,6 +1810,9 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) { const MVert *mvert = buffers->mvert; int i, j; + float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; + + glGetMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse_color); gpu_colors_enable(VBO_DISABLED); @@ -1784,7 +1828,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) if (smooth) { for (j = 0; j < S; j++) { - 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); } @@ -1809,7 +1853,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) 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++) glVertex3fv(mvert[fv[j]].co); @@ -1825,6 +1869,9 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) { const CCGKey *key = &buffers->gridkey; int i, j, x, y, gridsize = buffers->gridkey.grid_size; + float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; + + glGetMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse_color); gpu_colors_enable(VBO_DISABLED); @@ -1853,7 +1900,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) if (smooth) { for (j = 0; j < 4; j++) { - 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])); } @@ -1866,7 +1913,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) CCG_elem_co(key, e[2]), CCG_elem_co(key, e[3])); glNormal3fv(fno); - 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++) glVertex3fv(CCG_elem_co(key, e[j])); @@ -1883,10 +1930,10 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) CCGElem *a = CCG_grid_elem(key, grid, x, y); CCGElem *b = CCG_grid_elem(key, grid, x, y + 1); - 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)); - 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)); } @@ -1912,7 +1959,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) CCG_elem_co(key, c)); glNormal3fv(fno); - gpu_color_from_mask_quad_set(key, a, b, c, d); + gpu_color_from_mask_quad_set(key, a, b, c, d, diffuse_color); } glVertex3fv(CCG_elem_co(key, a)); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 4314a784511..60e3c19a419 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -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 && ibuf->profile == IB_PROFILE_LINEAR_RGB) + if (!ncd) do_color_management = TRUE; if (ibuf->rect==NULL) @@ -535,7 +535,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (do_color_management) { srgb_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(float)*4, "floar_buf_col_cor"); IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float, - ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0, + ibuf->channels, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, 0, ibuf->x, ibuf->y, ibuf->x, ibuf->x); /* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */ IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y); @@ -560,7 +560,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (do_color_management) { frect = srgb_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(*srgb_frect)*4, "floar_buf_col_cor"); IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float, - ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0, + ibuf->channels, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, 0, ibuf->x, ibuf->y, ibuf->x, ibuf->x); /* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */ IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y); @@ -709,7 +709,7 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float * frect, int */ int GPU_upload_dxt_texture(ImBuf *ibuf) { -#if WITH_DDS +#ifdef WITH_DDS GLint format = 0; int blocksize, height, width, i, size, offset = 0; @@ -878,13 +878,13 @@ void GPU_paint_set_mipmap(int mipmap) } } -void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) +void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) { ImBuf *ibuf; ibuf = BKE_image_get_ibuf(ima, NULL); - if (ima->repbind || (GPU_get_mipmap() && mipmap) || !ima->bindcode || !ibuf || + if (ima->repbind || (GPU_get_mipmap() && !GTS.gpu_mipmap) || !ima->bindcode || !ibuf || (!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) || (w == 0) || (h == 0)) { @@ -901,7 +901,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows); /* if color correction is needed, we must update the part that needs updating. */ - if (ibuf->rect_float && (!U.use_16bit_textures || (ibuf->profile == IB_PROFILE_LINEAR_RGB))) { + 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); @@ -911,8 +911,14 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) MEM_freeN(buffer); - if (ima->tpageflag & IMA_MIPMAP_COMPLETE) + /* we have already accounted for the case where GTS.gpu_mipmap is false + * so we will be using GPU mipmap generation here */ + if (GPU_get_mipmap()) { + glGenerateMipmapEXT(GL_TEXTURE_2D); + } + else { ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; + } return; } @@ -934,8 +940,13 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); - if (ima->tpageflag & IMA_MIPMAP_COMPLETE) + /* see comment above as to why we are using gpu mipmap generation here */ + if (GPU_get_mipmap()) { + glGenerateMipmapEXT(GL_TEXTURE_2D); + } + else { ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; + } } } @@ -1197,7 +1208,12 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O GPUMaterial *gpumat; GPUBlendMode alphablend; int a; - int gamma = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; + + /* OCIO_TODO: assume color management is always enabled. could be nice to support real display transform here, + * but that's not so important and could be done later + */ + int gamma = TRUE; + int new_shading_nodes = BKE_scene_use_new_shading_nodes(scene); /* initialize state */ @@ -1221,7 +1237,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O * - object transparency off: for glsl we draw both in a single pass, and * for solid we don't use transparency at all. */ GMS.use_alpha_pass = (do_alpha_after != NULL); - GMS.is_alpha_pass = (v3d && v3d->transp); + GMS.is_alpha_pass = (v3d->transp != FALSE); if (GMS.use_alpha_pass) *do_alpha_after = FALSE; @@ -1424,6 +1440,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(); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 61be4057843..dd92b561235 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -389,8 +389,12 @@ void gpu_material_add_node(GPUMaterial *material, GPUNode *node) int GPU_material_do_color_management(GPUMaterial *mat) { - return ((mat->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) && - !((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT))); + /* OCIO_TODO: for now assume scene always does color management. probably could be + * improved in the future to support real display transform + * also probably we'll need to get rid ofgame engine's color management flag + */ + + return !((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT)); } static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **lv, GPUNodeLink **dist) diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index c5722995d32..d88f954345f 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -393,7 +393,7 @@ static bool constraint_valid(bConstraint *con) return true; } -int initialize_scene(Object *ob, bPoseChannel *pchan_tip) +static int initialize_scene(Object *ob, bPoseChannel *pchan_tip) { bConstraint *con; int treecount; diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index aa4454562b4..bbe70a7d73f 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -30,6 +30,7 @@ set(INC ../blenlib ../blenloader ../makesdna + ../makesrna ../../../intern/guardedalloc ../../../intern/memutil ) @@ -45,6 +46,7 @@ set(SRC intern/anim_movie.c intern/bmp.c intern/cache.c + intern/colormanagement.c intern/divers.c intern/filetype.c intern/filter.c @@ -67,16 +69,19 @@ set(SRC intern/util.c intern/writeimage.c + IMB_colormanagement.h IMB_imbuf.h IMB_imbuf_types.h IMB_moviecache.h IMB_thumbs.h intern/IMB_allocimbuf.h intern/IMB_anim.h + intern/IMB_colormanagement_intern.h intern/IMB_filetype.h intern/IMB_filter.h 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 @@ -94,7 +99,6 @@ set(SRC intern/dds/PixelFormat.h intern/dds/Stream.h intern/dds/dds_api.h - intern/imbuf.h intern/openexr/openexr_api.h intern/openexr/openexr_multi.h @@ -180,6 +184,10 @@ if(WITH_IMAGE_HDR) add_definitions(-DWITH_HDR) endif() +list(APPEND INC + ../../../intern/opencolorio +) + if(WIN32) list(APPEND INC ../../../intern/utfconv diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h new file mode 100644 index 00000000000..5d0ab5e57d4 --- /dev/null +++ b/source/blender/imbuf/IMB_colormanagement.h @@ -0,0 +1,156 @@ +/* + * ***** 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) 2012 by Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Xavier Thomas, + * Lukas Toenne, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#ifndef IMB_COLORMANAGEMENT_H +#define IMB_COLORMANAGEMENT_H + +#define BCM_CONFIG_FILE "config.ocio" + +struct bContext; +struct ColorManagedColorspaceSettings; +struct ColorManagedDisplaySettings; +struct ColorManagedViewSettings; +struct ColormanageProcessor; +struct EnumPropertyItem; +struct ImBuf; +struct Main; +struct rcti; +struct PartialBufferUpdateContext; +struct wmWindow; +struct Scene; + +struct ColorSpace; +struct ColorManagedDisplay; + +/* ** Initialization / De-initialization ** */ + +void IMB_colormanagement_init(void); +void IMB_colormanagement_exit(void); + +/* ** Generic functions ** */ + +void IMB_colormanagement_check_file_config(struct Main *bmain); + +void IMB_colormanagement_validate_settings(struct ColorManagedDisplaySettings *display_settings, + struct ColorManagedViewSettings *view_settings); + +const char *IMB_colormanagement_role_colorspace_name_get(int role); +void IMB_colormanagement_assign_rect_colorspace(struct ImBuf *ibuf, const char *name); + +/* ** Color space transformation functions ** */ +void IMB_colormanagement_transform(float *buffer, int width, int height, int channels, + const char *from_colorspace, const char *to_colorspace, int predivide); +void IMB_colormanagement_transform_threaded(float *buffer, int width, int height, int channels, + const char *from_colorspace, const char *to_colorspace, int predivide); +void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace); + +void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace); +void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], struct ColorSpace *colorspace); + +void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, int predivide); + +void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], struct ColorManagedDisplay *display); +void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], struct ColorManagedDisplay *display); + +void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4], const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); + +void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3], const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); + +void IMB_colormanagement_imbuf_assign_float_space(struct ImBuf *ibuf, struct ColorManagedColorspaceSettings *colorspace_settings); + +void IMB_colormanagement_imbuf_make_display_space(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); + +/* ** Public display buffers interfaces ** */ + +unsigned char *IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings, void **cache_handle); +unsigned char *IMB_display_buffer_acquire_ctx(const struct bContext *C, struct ImBuf *ibuf, void **cache_handle); + +void IMB_display_buffer_to_imbuf_rect(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); + +void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height, + int channels, const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings, int predivide); + +void IMB_display_buffer_release(void *cache_handle); + +/* ** Display funcrions ** */ +int IMB_colormanagement_display_get_named_index(const char *name); +const char *IMB_colormanagement_display_get_indexed_name(int index); +const char *IMB_colormanagement_display_get_default_name(void); +struct ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name); + +/* ** View funcrions ** */ +int IMB_colormanagement_view_get_named_index(const char *name); +const char *IMB_colormanagement_view_get_indexed_name(int index); + +/* ** Color space functions ** */ +int IMB_colormanagement_colorspace_get_named_index(const char *name); +const char *IMB_colormanagement_colorspace_get_indexed_name(int index); +const char *IMB_colormanagement_view_get_default_name(const char *display_name); + +void IMB_colormanagment_colorspace_from_ibuf_ftype(struct ColorManagedColorspaceSettings *colorspace_settings, struct ImBuf *ibuf); + +/* ** RNA helper functions ** */ +void IMB_colormanagement_display_items_add(struct EnumPropertyItem **items, int *totitem); +void IMB_colormanagement_view_items_add(struct EnumPropertyItem **items, int *totitem, const char *display_name); +void IMB_colormanagement_colorspace_items_add(struct EnumPropertyItem **items, int *totitem); + +/* ** Tile-based buffer management ** */ +void IMB_partial_display_buffer_update(struct ImBuf *ibuf, const float *linear_buffer, const unsigned char *buffer_byte, + int stride, int offset_x, int offset_y, const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings, + int xmin, int ymin, int xmax, int ymax); + +/* ** Pixel processor functions ** */ +struct ColormanageProcessor *IMB_colormanagement_display_processor_new(const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); +struct ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace); +void IMB_colormanagement_processor_apply_v4(struct ColormanageProcessor *cm_processor, float pixel[4]); +void IMB_colormanagement_processor_apply_v3(struct ColormanageProcessor *cm_processor, float pixel[3]); +void IMB_colormanagement_processor_apply(struct ColormanageProcessor *cm_processor, float *buffer, int width, int height, + int channels, int predivide); +void IMB_colormanagement_processor_free(struct ColormanageProcessor *cm_processor); + +/* Roles */ +enum { + COLOR_ROLE_SCENE_LINEAR = 0, + COLOR_ROLE_COLOR_PICKING, + COLOR_ROLE_TEXTURE_PAINTING, + COLOR_ROLE_DEFAULT_SEQUENCER, + COLOR_ROLE_DEFAULT_BYTE, + COLOR_ROLE_DEFAULT_FLOAT, +}; + +#endif /* IMB_COLORMANAGEMENT_H */ diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index d23d42ddd0c..1503b9f6f67 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -70,6 +70,8 @@ #ifndef __IMB_IMBUF_H__ #define __IMB_IMBUF_H__ +#define IM_MAX_SPACE 64 + /** * * \attention defined in ??? @@ -82,6 +84,8 @@ struct ImBuf; */ struct anim; +struct ColorManagedDisplay; + /** * * \attention Defined in allocimbuf.c @@ -93,20 +97,19 @@ void IMB_exit(void); * * \attention Defined in readimage.c */ -struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, - int flags, const char *descr); +struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr); /** * * \attention Defined in readimage.c */ -struct ImBuf *IMB_testiffname(const char *filepath, int flags); +struct ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]); /** * * \attention Defined in readimage.c */ -struct ImBuf *IMB_loadiffname(const char *filepath, int flags); +struct ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]); /** * @@ -245,7 +248,7 @@ int IMB_anim_get_fps(struct anim * anim, * * \attention Defined in anim_movie.c */ -struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex); +struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE]); void IMB_close_anim(struct anim *anim); void IMB_close_anim_proxies(struct anim *anim); @@ -372,7 +375,6 @@ void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y 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 */ -void IMB_convert_profile(struct ImBuf *ibuf, int profile); float *IMB_float_profile_ensure(struct ImBuf *ibuf, int profile, int *alloc); void IMB_color_to_bw(struct ImBuf *ibuf); void IMB_saturation(struct ImBuf *ibuf, float sat); @@ -417,7 +419,7 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, flo * * \attention defined in readimage.c */ -struct ImBuf *IMB_loadifffile(int file, int flags, const char *descr); +struct ImBuf *IMB_loadifffile(int file, int flags, char colorspace[IM_MAX_SPACE], const char *descr); /** * @@ -478,12 +480,12 @@ void IMB_freezbuffloatImBuf(struct ImBuf *ibuf); * \attention Defined in rectop.c */ void IMB_rectfill(struct ImBuf *drect, const float col[4]); -void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2); +void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2, struct ColorManagedDisplay *display); void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value); /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, - const float col[4], const int do_color_management, + const float col[4], struct ColorManagedDisplay *display, int x1, int y1, int x2, int y2); /* defined in metadata.c */ diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index be93d51d7d7..f03f709f13f 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -101,7 +101,6 @@ typedef struct ImBuf { /* parameters used by conversion between byte and float */ float dither; /* random dither value, for conversion from float -> byte rect */ - short profile; /* color space/profile preset that the byte rect buffer represents */ /* mipmapping */ struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /* MipMap levels, a series of halved images */ @@ -127,6 +126,13 @@ typedef struct ImBuf { unsigned int encodedsize; /* Size of data written to encodedbuffer */ unsigned int encodedbuffersize; /* Size of encodedbuffer */ + /* color management */ + struct ColorSpace *rect_colorspace; /* color space of byte buffer */ + struct ColorSpace *float_colorspace; /* color space of float buffer, used by sequencer only */ + unsigned int *display_buffer_flags; /* array of per-display display buffers dirty flags */ + struct ColormanageCache *colormanage_cache; /* cache used by color management */ + int colormanage_flag; + /* information for compressed textures */ struct DDSData dds_data; } ImBuf; @@ -136,10 +142,11 @@ typedef struct ImBuf { * \brief userflags: Flags used internally by blender for imagebuffers */ -#define IB_BITMAPFONT (1 << 0) /* this image is a font */ -#define IB_BITMAPDIRTY (1 << 1) /* image needs to be saved is not the same as filename */ -#define IB_MIPMAP_INVALID (1 << 2) /* image mipmaps are invalid, need recreate */ -#define IB_RECT_INVALID (1 << 3) /* float buffer changed, needs recreation of byte rect */ +#define IB_BITMAPFONT (1 << 0) /* this image is a font */ +#define IB_BITMAPDIRTY (1 << 1) /* image needs to be saved is not the same as filename */ +#define IB_MIPMAP_INVALID (1 << 2) /* image mipmaps are invalid, need recreate */ +#define IB_RECT_INVALID (1 << 3) /* float buffer changed, needs recreation of byte rect */ +#define IB_DISPLAY_BUFFER_INVALID (1 << 4) /* either float or byte buffer changed, need to re-calculate display buffers */ /** * \name Imbuf Component flags @@ -254,4 +261,8 @@ extern const char *imb_ext_image_qt[]; extern const char *imb_ext_movie[]; extern const char *imb_ext_audio[]; +enum { + IMB_COLORMANAGE_IS_DATA = (1 << 0) +}; + #endif diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript index a1030112f4b..976108cd84e 100644 --- a/source/blender/imbuf/SConscript +++ b/source/blender/imbuf/SConscript @@ -4,9 +4,9 @@ Import ('env') sources = env.Glob('intern/*.c') -incs = '. ../makesdna #/intern/guardedalloc #/intern/memutil ../blenlib' +incs = '. ../makesdna ../makesrna #/intern/guardedalloc #/intern/memutil ../blenlib' incs += ' ../avi ../blenkernel ../blenloader' -incs += ' #/intern/ffmpeg' +incs += ' #/intern/ffmpeg #intern/opencolorio' incs += ' ' + env['BF_JPEG_INC'] incs += ' ' + env['BF_PNG_INC'] diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 571c54b9cb3..d5cc4929aed 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -191,6 +191,7 @@ struct anim { struct anim *proxy_anim[IMB_PROXY_MAX_SLOT]; struct anim_index *curr_idx[IMB_TC_MAX_SLOT]; + char colorspace[64]; }; #endif diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h new file mode 100644 index 00000000000..059bdee00eb --- /dev/null +++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h @@ -0,0 +1,93 @@ +/* + * ***** 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) 2012 by Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Xavier Thomas, + * Lukas Toenne, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#ifndef IMB_COLORMANAGEMENT_INTERN_H +#define IMB_COLORMANAGEMENT_INTERN_H + +#include "DNA_listBase.h" + +#define BCM_CONFIG_FILE "config.ocio" + +struct ConstProcessorRcPtr; +struct ImBuf; + +typedef struct ColorSpace { + struct ColorSpace *next, *prev; + int index; + char name[64]; + char description[64]; + + struct ConstProcessorRcPtr *to_scene_linear; + struct ConstProcessorRcPtr *from_scene_linear; + + int is_invertible; + int is_data; +} ColorSpace; + +typedef struct ColorManagedDisplay { + struct ColorManagedDisplay *next, *prev; + int index; + char name[64]; + ListBase views; + + struct ConstProcessorRcPtr *to_scene_linear; + struct ConstProcessorRcPtr *from_scene_linear; +} ColorManagedDisplay; + +typedef struct ColorManagedView { + struct ColorManagedView *next, *prev; + int index; + char name[64]; +} ColorManagedView; + +void colormanage_cache_free(struct ImBuf *ibuf); + +struct ColorManagedDisplay *colormanage_display_get_default(void); +struct ColorManagedDisplay *colormanage_display_add(const char *name); +struct ColorManagedDisplay *colormanage_display_get_named(const char *name); +struct ColorManagedDisplay *colormanage_display_get_indexed(int index); + +const char *colormanage_view_get_default_name(const ColorManagedDisplay *display); +struct ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *display); +struct ColorManagedView *colormanage_view_add(const char *name); +struct ColorManagedView *colormanage_view_get_indexed(int index); +struct ColorManagedView *colormanage_view_get_named(const char *name); + +struct ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible, int is_data); +struct ColorSpace *colormanage_colorspace_get_named(const char *name); +struct ColorSpace *colormanage_colorspace_get_roled(int role); +struct ColorSpace *colormanage_colorspace_get_indexed(int index); + +void colorspace_set_default_role(char *colorspace, int size, int role); + +void colormanage_imbuf_set_default_spaces(struct ImBuf *ibuf); +void colormanage_imbuf_make_linear(struct ImBuf *ibuf, const char *from_colorspace); + +#endif /* IMB_COLORMANAGEMENT_INTERN_H */ diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 74d0a92f26b..56a03121409 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -40,12 +40,13 @@ typedef struct ImFileType { int (*is_a)(unsigned char *buf); int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf); - struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags); + struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int (*save)(struct ImBuf *ibuf, const char *name, int flags); void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect); int flag; int filetype; + int default_save_role; } ImFileType; extern ImFileType IMB_FILE_TYPES[]; @@ -63,57 +64,57 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty); /* png */ int imb_is_a_png(unsigned char *buf); -struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_savepng(struct ImBuf *ibuf, const char *name, int flags); /* targa */ int imb_is_a_targa(unsigned char *buf); -struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags); /* iris */ int imb_is_a_iris(unsigned char *mem); -struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_saveiris(struct ImBuf * ibuf, const char *name, int flags); /* jp2 */ int imb_is_a_jp2(unsigned char *buf); -struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags); /* jpeg */ int imb_is_a_jpeg(unsigned char *mem); int imb_savejpeg(struct ImBuf *ibuf, const char *name, int flags); -struct ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags); +struct ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE]); /* bmp */ int imb_is_a_bmp(unsigned char *buf); -struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags); /* cocoa */ -struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); 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); +struct ImBuf *imb_loadcineon(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); +struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_is_dpx(unsigned char *buf); /* hdr */ int imb_is_a_hdr(unsigned char *buf); -struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_savehdr(struct ImBuf * ibuf, const char *name, int flags); /* tiff */ void imb_inittiff(void); int imb_is_a_tiff(unsigned char *buf); -struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect); int imb_savetiff(struct ImBuf *ibuf, const char *name, int flags); diff --git a/source/blender/imbuf/intern/IMB_metadata.h b/source/blender/imbuf/intern/IMB_metadata.h index 4f512e04ef8..a68d7a7813e 100644 --- a/source/blender/imbuf/intern/IMB_metadata.h +++ b/source/blender/imbuf/intern/IMB_metadata.h @@ -62,7 +62,7 @@ void IMB_metadata_free(struct ImBuf *img); * \param len - length of value buffer allocated by user. * \return - 1 (true) if ImageInfo present and value for the key found, 0 (false) otherwise */ -int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, int len); +int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, const size_t len); /** set user data in the ImMetaData struct, which has to be allocated with IMB_metadata_create * before calling this function. diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 7724f444b2c..69048274104 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -41,6 +41,7 @@ #include "IMB_allocimbuf.h" #include "IMB_filetype.h" #include "IMB_metadata.h" +#include "IMB_colormanagement_intern.h" #include "imbuf.h" @@ -162,8 +163,11 @@ void IMB_freeImBuf(ImBuf *ibuf) IMB_freezbuffloatImBuf(ibuf); freeencodedbufferImBuf(ibuf); IMB_metadata_free(ibuf); - if (ibuf->dds_data.data != NULL) + colormanage_cache_free(ibuf); + + if (ibuf->dds_data.data != NULL) { free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */ + } MEM_freeN(ibuf); } } @@ -354,7 +358,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int ibuf->ftype = TGA; ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */ ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254; /* IMB_DPI_DEFAULT -> pixels-per-meter */ - + if (flags & IB_rect) { if (imb_addrectImBuf(ibuf) == FALSE) { IMB_freeImBuf(ibuf); @@ -382,6 +386,9 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int return NULL; } } + + /* assign default spaces */ + colormanage_imbuf_set_default_spaces(ibuf); } return (ibuf); } @@ -442,8 +449,11 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) /* for now don't duplicate metadata */ tbuf.metadata = NULL; + tbuf.display_buffer_flags = NULL; + tbuf.colormanage_cache = NULL; + *ibuf2 = tbuf; - + return(ibuf2); } diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 16dbd0823da..394f5169046 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -113,6 +113,9 @@ #endif #endif +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + int ismovie(const char *UNUSED(filepath)) { return 0; @@ -263,12 +266,20 @@ void IMB_close_anim_proxies(struct anim *anim) IMB_free_indices(anim); } -struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex) +struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE]) { struct anim *anim; anim = (struct anim *)MEM_callocN(sizeof(struct anim), "anim struct"); if (anim != NULL) { + if (colorspace) { + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + BLI_strncpy(anim->colorspace, colorspace, sizeof(anim->colorspace)); + } + else { + colorspace_set_default_role(anim->colorspace, sizeof(anim->colorspace), COLOR_ROLE_DEFAULT_BYTE); + } + BLI_strncpy(anim->name, name, sizeof(anim->name)); anim->ib_flags = ib_flags; anim->streamindex = streamindex; @@ -404,7 +415,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position) if (anim->pgf) { lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo])); if (lpbi) { - ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect, "<avi_fetchibuf>"); + ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>"); //Oh brother... } } @@ -432,8 +443,8 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position) MEM_freeN(tmp); } - ibuf->profile = IB_PROFILE_SRGB; - + ibuf->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace); + return ibuf; } @@ -634,8 +645,6 @@ static void ffmpeg_postprocess(struct anim *anim) ImBuf *ibuf = anim->last_frame; int filter_y = 0; - ibuf->profile = IB_PROFILE_SRGB; - if (!anim->pFrameComplete) { return; } @@ -1090,6 +1099,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_freeImBuf(anim->last_frame); anim->last_frame = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect); + anim->last_frame->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace); ffmpeg_postprocess(anim); @@ -1213,7 +1223,7 @@ static ImBuf *anim_getnew(struct anim *anim) switch (anim->curtype) { case ANIM_SEQUENCE: - ibuf = IMB_loadiffname(anim->name, anim->ib_flags); + ibuf = IMB_loadiffname(anim->name, anim->ib_flags, anim->colorspace); if (ibuf) { BLI_strncpy(anim->first, anim->name, sizeof(anim->first)); anim->duration = 1; @@ -1309,7 +1319,7 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position, pic = an_stringdec(anim->first, head, tail, &digits); pic += position; an_stringenc(anim->name, head, tail, digits, pic); - ibuf = IMB_loadiffname(anim->name, IB_rect); + ibuf = IMB_loadiffname(anim->name, IB_rect, anim->colorspace); if (ibuf) { anim->curposition = position; } @@ -1319,7 +1329,6 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position, if (ibuf) { anim->curposition = position; IMB_convert_rgba_to_abgr(ibuf); - ibuf->profile = IB_PROFILE_SRGB; } break; case ANIM_AVI: @@ -1330,8 +1339,16 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position, #ifdef WITH_QUICKTIME case ANIM_QTIME: ibuf = qtime_fetchibuf(anim, position); - if (ibuf) + if (ibuf) { + if (ibuf->rect) { + /* OCIO_TODO: should happen in quicktime module, but it currently doesn't have access + * to color management's internals + */ + ibuf->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace); + } + anim->curposition = position; + } break; #endif #ifdef WITH_FFMPEG diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index 8fa468949e7..df12f0b703e 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -38,6 +38,9 @@ #include "IMB_allocimbuf.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + /* some code copied from article on microsoft.com, copied * here for enhanced BMP support in the future * http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0197/mfcp1/mfcp1.htm&nav=/msj/0197/newnav.htm @@ -115,7 +118,7 @@ int imb_is_a_bmp(unsigned char *buf) return checkbmp(buf); } -struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags) +struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf = NULL; BMPINFOHEADER bmi; @@ -127,6 +130,8 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags) if (checkbmp(mem) == 0) return(NULL); + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + if ((mem[0] == 'B') && (mem[1] == 'M')) { /* skip fileheader */ mem += BMP_FILEHEADER_SIZE; @@ -195,7 +200,6 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags) if (ibuf) { ibuf->ftype = BMP; - ibuf->profile = IB_PROFILE_SRGB; } return(ibuf); diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 182e0a7e29d..7705af13b1e 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -44,6 +44,9 @@ #include "IMB_imbuf.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + #include "BKE_global.h" #include "MEM_guardedalloc.h" @@ -63,7 +66,7 @@ static void cineon_conversion_parameters(LogImageByteConversionParameters *param } #endif -static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags) +static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags, char colorspace[IM_MAX_SPACE]) { ImBuf *ibuf; LogImageFile *image; @@ -72,6 +75,8 @@ static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, 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); @@ -202,10 +207,10 @@ int imb_is_cineon(unsigned char *buf) return cineonIsMemFileCineon(buf); } -ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags) +ImBuf *imb_loadcineon(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); + return imb_load_dpx_cineon(mem, 1, size, flags, colorspace); return NULL; } @@ -219,9 +224,9 @@ int imb_is_dpx(unsigned char *buf) return dpxIsMemFileCineon(buf); } -ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags) +ImBuf *imb_loaddpx(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); + return imb_load_dpx_cineon(mem, 0, size, flags, colorspace); return NULL; } diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c new file mode 100644 index 00000000000..11dce3087c6 --- /dev/null +++ b/source/blender/imbuf/intern/colormanagement.c @@ -0,0 +1,2436 @@ +/* + * ***** 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) 2012 by Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Xavier Thomas, + * Lukas Toenne, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + +#include <string.h> +#include <math.h> + +#include "DNA_color_types.h" +#include "DNA_image_types.h" +#include "DNA_movieclip_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_windowmanager_types.h" + +#include "IMB_filter.h" +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "IMB_filetype.h" +#include "IMB_moviecache.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_math_color.h" +#include "BLI_path_util.h" +#include "BLI_string.h" +#include "BLI_threads.h" + +#include "BKE_colortools.h" +#include "BKE_context.h" +#include "BKE_utildefines.h" +#include "BKE_main.h" + +#include "RNA_define.h" + +#include <ocio_capi.h> + +/*********************** Global declarations *************************/ + +#define MAX_COLORSPACE_NAME 64 +#define DISPLAY_BUFFER_CHANNELS 4 + +/* ** list of all supported color spaces, displays and views */ +static char global_role_scene_linear[MAX_COLORSPACE_NAME]; +static char global_role_color_picking[MAX_COLORSPACE_NAME]; +static char global_role_texture_painting[MAX_COLORSPACE_NAME]; +static char global_role_default_byte[MAX_COLORSPACE_NAME]; +static char global_role_default_float[MAX_COLORSPACE_NAME]; +static char global_role_default_sequencer[MAX_COLORSPACE_NAME]; + +static ListBase global_colorspaces = {NULL}; +static ListBase global_displays = {NULL}; +static ListBase global_views = {NULL}; + +static int global_tot_colorspace = 0; +static int global_tot_display = 0; +static int global_tot_view = 0; + +typedef struct ColormanageProcessor { + ConstProcessorRcPtr *processor; + CurveMapping *curve_mapping; +} ColormanageProcessor; + +/*********************** Color managed cache *************************/ + +/* Cache Implementation Notes + * ========================== + * + * All color management cache stuff is stored in two properties of + * image buffers: + * + * 1. display_buffer_flags + * + * This is a bit field which used to mark calculated transformations + * for particular image buffer. Index inside of this array means index + * of a color managed display. Element with given index matches view + * transformations applied for a given display. So if bit B of array + * element B is set to 1, this means display buffer with display index + * of A and view transform of B was ever calculated for this imbuf. + * + * In contrast with indices in global lists of displays and views this + * indices are 0-based, not 1-based. This is needed to save some bytes + * of memory. + * + * 2. colormanage_cache + * + * This is a pointer to a structure which holds all data which is + * needed for color management cache to work. + * + * It contains two parts: + * - data + * - moviecache + * + * Data field is used to store additional information about cached + * buffers which affects on whether cached buffer could be used. + * This data can't go to cache key because changes in this data + * shouldn't lead extra buffers adding to cache, it shall + * invalidate cached images. + * + * Currently such a data contains only exposure and gamma, but + * would likely extended further. + * + * data field is not null only for elements of cache, not used for + * original image buffers. + * + * Color management cache is using generic MovieCache implementation + * to make it easier to deal with memory limitation. + * + * Currently color management is using the same memory limitation + * pool as sequencer and clip editor are using which means color + * managed buffers would be removed from the cache as soon as new + * frames are loading for the movie clip and there's no space in + * cache. + * + * Every image buffer has got own movie cache instance, which + * means keys for color managed buffers could be really simple + * and look up in this cache would be fast and independent from + * overall amount of color managed images. + */ + +/* NOTE: ColormanageCacheViewSettings and ColormanageCacheDisplaySettings are + * quite the same as ColorManagedViewSettings and ColorManageDisplaySettings + * but they holds indexes of all transformations and color spaces, not + * their names. + * + * This helps avoid extra colorsmace / display / view lookup without + * requiring to pass all variables which affects on display buffer + * to color management cache system and keeps calls small and nice. + */ +typedef struct ColormanageCacheViewSettings { + int flag; + int view; + float exposure; + float gamma; + CurveMapping *curve_mapping; +} ColormanageCacheViewSettings; + +typedef struct ColormanageCacheDisplaySettings { + int display; +} ColormanageCacheDisplaySettings; + +typedef struct ColormanageCacheKey { + int view; /* view transformation used for display buffer */ + int display; /* display device name */ +} ColormanageCacheKey; + +typedef struct ColormnaageCacheData { + int flag; /* view flags of cached buffer */ + float exposure; /* exposure value cached buffer is calculated with */ + float gamma; /* gamma value cached buffer is calculated with */ + int predivide; /* predivide flag of cached buffer */ + CurveMapping *curve_mapping; /* curve mapping used for cached buffer */ + int curve_mapping_timestamp; /* time stamp of curve mapping used for cached buffer */ +} ColormnaageCacheData; + +typedef struct ColormanageCache { + struct MovieCache *moviecache; + + ColormnaageCacheData *data; +} ColormanageCache; + +static struct MovieCache *colormanage_moviecache_get(const ImBuf *ibuf) +{ + if (!ibuf->colormanage_cache) + return NULL; + + return ibuf->colormanage_cache->moviecache; +} + +static ColormnaageCacheData *colormanage_cachedata_get(const ImBuf *ibuf) +{ + if (!ibuf->colormanage_cache) + return NULL; + + return ibuf->colormanage_cache->data; +} + +static unsigned int colormanage_hashhash(const void *key_v) +{ + ColormanageCacheKey *key = (ColormanageCacheKey *)key_v; + + unsigned int rval = (key->display << 16) | (key->view % 0xffff); + + return rval; +} + +static int colormanage_hashcmp(const void *av, const void *bv) +{ + const ColormanageCacheKey *a = (ColormanageCacheKey *) av; + const ColormanageCacheKey *b = (ColormanageCacheKey *) bv; + + if (a->view < b->view) + return -1; + else if (a->view > b->view) + return 1; + + if (a->display < b->display) + return -1; + else if (a->display > b->display) + return 1; + + return 0; +} + +static struct MovieCache *colormanage_moviecache_ensure(ImBuf *ibuf) +{ + if (!ibuf->colormanage_cache) + ibuf->colormanage_cache = MEM_callocN(sizeof(ColormanageCache), "imbuf colormanage cache"); + + if (!ibuf->colormanage_cache->moviecache) { + struct MovieCache *moviecache; + + moviecache = IMB_moviecache_create("colormanage cache", sizeof(ColormanageCacheKey), + colormanage_hashhash, colormanage_hashcmp); + + ibuf->colormanage_cache->moviecache = moviecache; + } + + return ibuf->colormanage_cache->moviecache; +} + +static void colormanage_cachedata_set(ImBuf *ibuf, ColormnaageCacheData *data) +{ + if (!ibuf->colormanage_cache) + ibuf->colormanage_cache = MEM_callocN(sizeof(ColormanageCache), "imbuf colormanage cache"); + + ibuf->colormanage_cache->data = data; +} + +static void colormanage_view_settings_to_cache(ColormanageCacheViewSettings *cache_view_settings, + const ColorManagedViewSettings *view_settings) +{ + int view = IMB_colormanagement_view_get_named_index(view_settings->view_transform); + + cache_view_settings->view = view; + cache_view_settings->exposure = view_settings->exposure; + cache_view_settings->gamma = view_settings->gamma; + cache_view_settings->flag = view_settings->flag; + cache_view_settings->curve_mapping = view_settings->curve_mapping; +} + +static void colormanage_display_settings_to_cache(ColormanageCacheDisplaySettings *cache_display_settings, + const ColorManagedDisplaySettings *display_settings) +{ + int display = IMB_colormanagement_display_get_named_index(display_settings->display_device); + + cache_display_settings->display = display; +} + +static void colormanage_settings_to_key(ColormanageCacheKey *key, + const ColormanageCacheViewSettings *view_settings, + const ColormanageCacheDisplaySettings *display_settings) +{ + key->view = view_settings->view; + key->display = display_settings->display; +} + +static ImBuf *colormanage_cache_get_ibuf(ImBuf *ibuf, ColormanageCacheKey *key, void **cache_handle) +{ + ImBuf *cache_ibuf; + struct MovieCache *moviecache = colormanage_moviecache_get(ibuf); + + if (!moviecache) { + /* if there's no moviecache it means no color management was applied on given image buffer before */ + + return NULL; + } + + *cache_handle = NULL; + + cache_ibuf = IMB_moviecache_get(moviecache, key); + + *cache_handle = cache_ibuf; + + return cache_ibuf; +} + +static unsigned char *colormanage_cache_get(ImBuf *ibuf, const ColormanageCacheViewSettings *view_settings, + const ColormanageCacheDisplaySettings *display_settings, + void **cache_handle) +{ + ColormanageCacheKey key; + ImBuf *cache_ibuf; + int view_flag = 1 << (view_settings->view - 1); + int predivide = ibuf->flags & IB_cm_predivide; + CurveMapping *curve_mapping = view_settings->curve_mapping; + int curve_mapping_timestamp = curve_mapping ? curve_mapping->changed_timestamp : 0; + + colormanage_settings_to_key(&key, view_settings, display_settings); + + /* check whether image was marked as dirty for requested transform */ + if ((ibuf->display_buffer_flags[display_settings->display - 1] & view_flag) == 0) { + return NULL; + } + + cache_ibuf = colormanage_cache_get_ibuf(ibuf, &key, cache_handle); + + if (cache_ibuf) { + ColormnaageCacheData *cache_data; + + BLI_assert(cache_ibuf->x == ibuf->x && + cache_ibuf->y == ibuf->y); + + /* only buffers with different color space conversions are being stored + * in cache separately. buffer which were used only different exposure/gamma + * are re-suing the same cached buffer + * + * check here which exposure/gamma/curve was used for cached buffer and if they're + * different from requested buffer should be re-generated + */ + cache_data = colormanage_cachedata_get(cache_ibuf); + + if (cache_data->exposure != view_settings->exposure || + cache_data->gamma != view_settings->gamma || + cache_data->predivide != predivide || + cache_data->flag != view_settings->flag || + cache_data->curve_mapping != curve_mapping || + cache_data->curve_mapping_timestamp != curve_mapping_timestamp) + { + *cache_handle = NULL; + + IMB_freeImBuf(cache_ibuf); + + return NULL; + } + + return (unsigned char *) cache_ibuf->rect; + } + + return NULL; +} + +static void colormanage_cache_put(ImBuf *ibuf, const ColormanageCacheViewSettings *view_settings, + const ColormanageCacheDisplaySettings *display_settings, + unsigned char *display_buffer, void **cache_handle) +{ + ColormanageCacheKey key; + ImBuf *cache_ibuf; + ColormnaageCacheData *cache_data; + int view_flag = 1 << (view_settings->view - 1); + int predivide = ibuf->flags & IB_cm_predivide; + struct MovieCache *moviecache = colormanage_moviecache_ensure(ibuf); + CurveMapping *curve_mapping = view_settings->curve_mapping; + int curve_mapping_timestamp = curve_mapping ? curve_mapping->changed_timestamp : 0; + + colormanage_settings_to_key(&key, view_settings, display_settings); + + /* mark display buffer as valid */ + ibuf->display_buffer_flags[display_settings->display - 1] |= view_flag; + + /* buffer itself */ + cache_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0); + cache_ibuf->rect = (unsigned int *) display_buffer; + + cache_ibuf->mall |= IB_rect; + cache_ibuf->flags |= IB_rect; + + /* store data which is needed to check whether cached buffer could be used for color managed display settings */ + cache_data = MEM_callocN(sizeof(ColormnaageCacheData), "color manage cache imbuf data"); + cache_data->exposure = view_settings->exposure; + cache_data->gamma = view_settings->gamma; + cache_data->predivide = predivide; + cache_data->flag = view_settings->flag; + cache_data->curve_mapping = curve_mapping; + cache_data->curve_mapping_timestamp = curve_mapping_timestamp; + + colormanage_cachedata_set(cache_ibuf, cache_data); + + *cache_handle = cache_ibuf; + + IMB_moviecache_put(moviecache, &key, cache_ibuf); +} + +static void colormanage_cache_handle_release(void *cache_handle) +{ + ImBuf *cache_ibuf = cache_handle; + + IMB_freeImBuf(cache_ibuf); +} + +/*********************** Initialization / De-initialization *************************/ + +static void colormanage_role_color_space_name_get(ConstConfigRcPtr *config, char *colorspace_name, const char *role, const char *backup_role) +{ + ConstColorSpaceRcPtr *ociocs; + + ociocs = OCIO_configGetColorSpace(config, role); + + if (!ociocs && backup_role) + ociocs = OCIO_configGetColorSpace(config, backup_role); + + if (ociocs) { + const char *name = OCIO_colorSpaceGetName(ociocs); + + /* assume function was called with buffer properly allocated to MAX_COLORSPACE_NAME chars */ + BLI_strncpy(colorspace_name, name, MAX_COLORSPACE_NAME); + OCIO_colorSpaceRelease(ociocs); + } + else { + printf("Color management: Error could not find role %s role.\n", role); + } +} + +static void colormanage_load_config(ConstConfigRcPtr *config) +{ + int tot_colorspace, tot_display, tot_display_view, index, viewindex, viewindex2; + const char *name; + + /* get roles */ + colormanage_role_color_space_name_get(config, global_role_scene_linear, OCIO_ROLE_SCENE_LINEAR, NULL); + colormanage_role_color_space_name_get(config, global_role_color_picking, OCIO_ROLE_COLOR_PICKING, NULL); + colormanage_role_color_space_name_get(config, global_role_texture_painting, OCIO_ROLE_TEXTURE_PAINT, NULL); + colormanage_role_color_space_name_get(config, global_role_default_sequencer, OCIO_ROLE_DEFAULT_SEQUENCER, OCIO_ROLE_SCENE_LINEAR); + colormanage_role_color_space_name_get(config, global_role_default_byte, OCIO_ROLE_DEFAULT_BYTE, OCIO_ROLE_TEXTURE_PAINT); + colormanage_role_color_space_name_get(config, global_role_default_float, OCIO_ROLE_DEFAULT_FLOAT, OCIO_ROLE_SCENE_LINEAR); + + /* load colorspaces */ + tot_colorspace = OCIO_configGetNumColorSpaces(config); + for (index = 0 ; index < tot_colorspace; index++) { + ConstColorSpaceRcPtr *ocio_colorspace; + const char *description; + int is_invertible, is_data; + + name = OCIO_configGetColorSpaceNameByIndex(config, index); + + ocio_colorspace = OCIO_configGetColorSpace(config, name); + description = OCIO_colorSpaceGetDescription(ocio_colorspace); + is_invertible = OCIO_colorSpaceIsInvertible(ocio_colorspace); + is_data = OCIO_colorSpaceIsData(ocio_colorspace); + + colormanage_colorspace_add(name, description, is_invertible, is_data); + + OCIO_colorSpaceRelease(ocio_colorspace); + } + + /* load displays */ + viewindex2 = 0; + tot_display = OCIO_configGetNumDisplays(config); + + for (index = 0 ; index < tot_display; index++) { + const char *displayname; + ColorManagedDisplay *display; + + displayname = OCIO_configGetDisplay(config, index); + + display = colormanage_display_add(displayname); + + /* load views */ + tot_display_view = OCIO_configGetNumViews(config, displayname); + for (viewindex = 0 ; viewindex < tot_display_view; viewindex++, viewindex2++) { + const char *viewname; + ColorManagedView *view; + LinkData *display_view; + + viewname = OCIO_configGetView(config, displayname, viewindex); + + /* first check if view transform with given name was already loaded */ + view = colormanage_view_get_named(viewname); + + if (!view) { + view = colormanage_view_add(viewname); + } + + display_view = BLI_genericNodeN(view); + + BLI_addtail(&display->views, display_view); + } + } + + global_tot_display = tot_display; +} + +static void colormanage_free_config(void) +{ + ColorSpace *colorspace; + ColorManagedDisplay *display; + + /* free color spaces */ + colorspace = global_colorspaces.first; + while (colorspace) { + ColorSpace *colorspace_next = colorspace->next; + + /* free precomputer processors */ + if (colorspace->to_scene_linear) + OCIO_processorRelease((ConstProcessorRcPtr *) colorspace->to_scene_linear); + + if (colorspace->from_scene_linear) + OCIO_processorRelease((ConstProcessorRcPtr *) colorspace->from_scene_linear); + + /* free color space itself */ + MEM_freeN(colorspace); + + colorspace = colorspace_next; + } + + /* free displays */ + display = global_displays.first; + while (display) { + ColorManagedDisplay *display_next = display->next; + + /* free precomputer processors */ + if (display->to_scene_linear) + OCIO_processorRelease((ConstProcessorRcPtr *) display->to_scene_linear); + + if (display->from_scene_linear) + OCIO_processorRelease((ConstProcessorRcPtr *) display->from_scene_linear); + + /* free list of views */ + BLI_freelistN(&display->views); + + MEM_freeN(display); + display = display_next; + } + + /* free views */ + BLI_freelistN(&global_views); +} + +void IMB_colormanagement_init(void) +{ + const char *ocio_env; + const char *configdir; + char configfile[FILE_MAX]; + ConstConfigRcPtr *config = NULL; + + ocio_env = getenv("OCIO"); + + if (ocio_env && ocio_env[0] != '\0') + config = OCIO_configCreateFromEnv(); + + if (config == NULL) { + configdir = BLI_get_folder(BLENDER_DATAFILES, "colormanagement"); + + if (configdir) { + BLI_join_dirfile(configfile, sizeof(configfile), configdir, BCM_CONFIG_FILE); + + config = OCIO_configCreateFromFile(configfile); + } + } + + if (config == NULL) { + config = OCIO_getDefaultConfig(); + } + + if (config) { + OCIO_setCurrentConfig(config); + + colormanage_load_config(config); + + OCIO_configRelease(config); + } + + BLI_init_srgb_conversion(); +} + +void IMB_colormanagement_exit(void) +{ + colormanage_free_config(); +} + +/*********************** Internal functions *************************/ + +void colormanage_cache_free(ImBuf *ibuf) +{ + if (ibuf->display_buffer_flags) { + MEM_freeN(ibuf->display_buffer_flags); + + ibuf->display_buffer_flags = NULL; + } + + if (ibuf->colormanage_cache) { + ColormnaageCacheData *cache_data = colormanage_cachedata_get(ibuf); + struct MovieCache *moviecache = colormanage_moviecache_get(ibuf); + + if (cache_data) { + MEM_freeN(cache_data); + } + + if (moviecache) { + IMB_moviecache_free(moviecache); + } + + MEM_freeN(ibuf->colormanage_cache); + + ibuf->colormanage_cache = NULL; + } +} + +static void display_transform_get_from_ctx(const bContext *C, ColorManagedViewSettings **view_settings_r, + ColorManagedDisplaySettings **display_settings_r) +{ + Scene *scene = CTX_data_scene(C); + SpaceImage *sima = CTX_wm_space_image(C); + + *view_settings_r = &scene->view_settings; + *display_settings_r = &scene->display_settings; + + if (sima) { + if ((sima->image->flag & IMA_VIEW_AS_RENDER) == 0) + *view_settings_r = NULL; + } +} + +static ConstProcessorRcPtr *create_display_buffer_processor(const char *view_transform, const char *display, + float exposure, float gamma) +{ + ConstConfigRcPtr *config = OCIO_getCurrentConfig(); + DisplayTransformRcPtr *dt; + ConstProcessorRcPtr *processor; + + if (!config) { + /* there's no valid OCIO configuration, can't create processor */ + + return NULL; + } + + dt = OCIO_createDisplayTransform(); + + /* assuming handling buffer was already converted to scene linear space */ + OCIO_displayTransformSetInputColorSpaceName(dt, global_role_scene_linear); + OCIO_displayTransformSetView(dt, view_transform); + OCIO_displayTransformSetDisplay(dt, display); + + /* fstop exposure control */ + if (exposure != 0.0f) { + MatrixTransformRcPtr *mt; + float gain = powf(2.0f, exposure); + const float scale4f[] = {gain, gain, gain, gain}; + float m44[16], offset4[4]; + + OCIO_matrixTransformScale(m44, offset4, scale4f); + mt = OCIO_createMatrixTransform(); + OCIO_matrixTransformSetValue(mt, m44, offset4); + OCIO_displayTransformSetLinearCC(dt, (ConstTransformRcPtr *) mt); + + OCIO_matrixTransformRelease(mt); + } + + /* post-display gamma transform */ + if (gamma != 1.0f) { + ExponentTransformRcPtr *et; + float exponent = 1.0f / MAX2(FLT_EPSILON, gamma); + const float exponent4f[] = {exponent, exponent, exponent, exponent}; + + et = OCIO_createExponentTransform(); + OCIO_exponentTransformSetValue(et, exponent4f); + OCIO_displayTransformSetDisplayCC(dt, (ConstTransformRcPtr *) et); + + OCIO_exponentTransformRelease(et); + } + + processor = OCIO_configGetProcessor(config, (ConstTransformRcPtr *) dt); + + OCIO_displayTransformRelease(dt); + OCIO_configRelease(config); + + return processor; +} + +static ConstProcessorRcPtr *create_colorspace_transform_processor(const char *from_colorspace, + const char *to_colorspace) +{ + ConstConfigRcPtr *config = OCIO_getCurrentConfig(); + ConstProcessorRcPtr *processor; + + if (!config) { + /* there's no valid OCIO configuration, can't create processor */ + + return NULL; + } + + processor = OCIO_configGetProcessorWithNames(config, from_colorspace, to_colorspace); + + OCIO_configRelease(config); + + return processor; +} + +static ConstProcessorRcPtr *colorspace_to_scene_linear_processor(ColorSpace *colorspace) +{ + if (colorspace->to_scene_linear == NULL) { + BLI_lock_thread(LOCK_COLORMANAGE); + + if (colorspace->to_scene_linear == NULL) { + ConstProcessorRcPtr *to_scene_linear; + to_scene_linear = create_colorspace_transform_processor(colorspace->name, global_role_scene_linear); + colorspace->to_scene_linear = (struct ConstProcessorRcPtr *) to_scene_linear; + } + + BLI_unlock_thread(LOCK_COLORMANAGE); + } + + return (ConstProcessorRcPtr *) colorspace->to_scene_linear; +} + +static ConstProcessorRcPtr *colorspace_from_scene_linear_processor(ColorSpace *colorspace) +{ + if (colorspace->from_scene_linear == NULL) { + BLI_lock_thread(LOCK_COLORMANAGE); + + if (colorspace->from_scene_linear == NULL) { + ConstProcessorRcPtr *from_scene_linear; + from_scene_linear = create_colorspace_transform_processor(global_role_scene_linear, colorspace->name); + colorspace->from_scene_linear = (struct ConstProcessorRcPtr *) from_scene_linear; + } + + BLI_unlock_thread(LOCK_COLORMANAGE); + } + + return (ConstProcessorRcPtr *) colorspace->from_scene_linear; +} + +static ConstProcessorRcPtr *display_from_scene_linear_processor(ColorManagedDisplay *display) +{ + if (display->from_scene_linear == NULL) { + BLI_lock_thread(LOCK_COLORMANAGE); + + if (display->from_scene_linear == NULL) { + const char *view_name = colormanage_view_get_default_name(display); + ConstConfigRcPtr *config = OCIO_getCurrentConfig(); + ConstProcessorRcPtr *processor = NULL; + + if (view_name && config) { + const char *view_colorspace = OCIO_configGetDisplayColorSpaceName(config, display->name, view_name); + processor = OCIO_configGetProcessorWithNames(config, global_role_scene_linear, view_colorspace); + + OCIO_configRelease(config); + } + + display->from_scene_linear = (struct ConstProcessorRcPtr *) processor; + } + + BLI_unlock_thread(LOCK_COLORMANAGE); + } + + return (ConstProcessorRcPtr *) display->from_scene_linear; +} + +static ConstProcessorRcPtr *display_to_scene_linear_processor(ColorManagedDisplay *display) +{ + if (display->to_scene_linear == NULL) { + BLI_lock_thread(LOCK_COLORMANAGE); + + if (display->to_scene_linear == NULL) { + const char *view_name = colormanage_view_get_default_name(display); + ConstConfigRcPtr *config = OCIO_getCurrentConfig(); + ConstProcessorRcPtr *processor = NULL; + + if (view_name && config) { + const char *view_colorspace = OCIO_configGetDisplayColorSpaceName(config, display->name, view_name); + processor = OCIO_configGetProcessorWithNames(config, view_colorspace, global_role_scene_linear); + + OCIO_configRelease(config); + } + + display->to_scene_linear = (struct ConstProcessorRcPtr *) processor; + } + + BLI_unlock_thread(LOCK_COLORMANAGE); + } + + return (ConstProcessorRcPtr *) display->to_scene_linear; +} + +static void init_default_view_settings(const ColorManagedDisplaySettings *display_settings, + ColorManagedViewSettings *view_settings) +{ + ColorManagedDisplay *display; + ColorManagedView *default_view = NULL; + + display = colormanage_display_get_named(display_settings->display_device); + + if (display) + default_view = colormanage_view_get_default(display); + + if (default_view) + BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform)); + else + view_settings->view_transform[0] = '\0'; + + view_settings->flag = 0; + view_settings->gamma = 1.0f; + view_settings->exposure = 0.0f; + view_settings->curve_mapping = NULL; +} + +static void curve_mapping_apply_pixel(CurveMapping *curve_mapping, float *pixel, int channels) +{ + if (channels == 1) { + pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]); + } + else if (channels == 2) { + pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]); + pixel[1] = curvemap_evaluateF(curve_mapping->cm, pixel[1]); + } + else { + curvemapping_evaluate_premulRGBF(curve_mapping, pixel, pixel); + } +} + +void colorspace_set_default_role(char *colorspace, int size, int role) +{ + if (colorspace && colorspace[0] == '\0') { + const char *role_colorspace; + + role_colorspace = IMB_colormanagement_role_colorspace_name_get(role); + + BLI_strncpy(colorspace, role_colorspace, size); + } +} + +void colormanage_imbuf_set_default_spaces(ImBuf *ibuf) +{ + ibuf->rect_colorspace = colormanage_colorspace_get_named(global_role_default_byte); +} + +void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace) +{ + ColorSpace *colorspace = colormanage_colorspace_get_named(from_colorspace); + + if (colorspace->is_data) { + ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA; + return; + } + + if (ibuf->rect_float) { + const char *to_colorspace = global_role_scene_linear; + int predivide = ibuf->flags & IB_cm_predivide; + + if (ibuf->rect) + imb_freerectImBuf(ibuf); + + IMB_colormanagement_transform(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, + from_colorspace, to_colorspace, predivide); + } +} + +/*********************** Generic functions *************************/ + +static void colormanage_check_display_settings(ColorManagedDisplaySettings *display_settings, const char *what, + const ColorManagedDisplay *default_display) +{ + if (display_settings->display_device[0] == '\0') { + BLI_strncpy(display_settings->display_device, default_display->name, sizeof(display_settings->display_device)); + } + else { + ColorManagedDisplay *display = colormanage_display_get_named(display_settings->display_device); + + if (!display) { + printf("Color management: display \"%s\" used by %s not found, setting to default (\"%s\").\n", + display_settings->display_device, what, default_display->name); + + BLI_strncpy(display_settings->display_device, default_display->name, + sizeof(display_settings->display_device)); + } + } +} + +static void colormanage_check_view_settings(ColorManagedDisplaySettings *display_settings, + ColorManagedViewSettings *view_settings, const char *what) +{ + ColorManagedDisplay *display; + ColorManagedView *default_view = NULL; + + if (view_settings->view_transform[0] == '\0') { + display = colormanage_display_get_named(display_settings->display_device); + + if (display) + default_view = colormanage_view_get_default(display); + + if (default_view) + BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform)); + } + else { + ColorManagedView *view = colormanage_view_get_named(view_settings->view_transform); + + if (!view) { + display = colormanage_display_get_named(display_settings->display_device); + + if (display) + default_view = colormanage_view_get_default(display); + + if (default_view) { + printf("Color management: %s view \"%s\" not found, setting default \"%s\".\n", + what, view_settings->view_transform, default_view->name); + + BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform)); + } + } + } + + /* OCIO_TODO: move to do_versions() */ + if (view_settings->exposure == 0.0f && view_settings->gamma == 0.0f) { + view_settings->exposure = 0.0f; + view_settings->gamma = 1.0f; + } +} + +static void colormanage_check_colorspace_settings(ColorManagedColorspaceSettings *colorspace_settings, const char *what) +{ + if (colorspace_settings->name[0] == '\0') { + /* pass */ + } + else { + ColorSpace *colorspace = colormanage_colorspace_get_named(colorspace_settings->name); + + if (!colorspace) { + printf("Color management: %s colorspace \"%s\" not found, will use default instead.\n", + what, colorspace_settings->name); + + BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name)); + } + } + + (void) what; +} + +void IMB_colormanagement_check_file_config(Main *bmain) +{ + Scene *scene; + Image *image; + MovieClip *clip; + + ColorManagedDisplay *default_display; + + default_display = colormanage_display_get_default(); + + if (!default_display) { + /* happens when OCIO configuration is incorrect */ + return; + } + + for (scene = bmain->scene.first; scene; scene = scene->id.next) { + ColorManagedColorspaceSettings *sequencer_colorspace_settings; + + colormanage_check_display_settings(&scene->display_settings, "scene", default_display); + colormanage_check_view_settings(&scene->display_settings, &scene->view_settings, "scene"); + + sequencer_colorspace_settings = &scene->sequencer_colorspace_settings; + + colormanage_check_colorspace_settings(sequencer_colorspace_settings, "sequencer"); + + if (sequencer_colorspace_settings->name[0] == '\0') { + BLI_strncpy(sequencer_colorspace_settings->name, global_role_default_sequencer, MAX_COLORSPACE_NAME); + } + } + + /* ** check input color space settings ** */ + + for (image = bmain->image.first; image; image = image->id.next) { + colormanage_check_colorspace_settings(&image->colorspace_settings, "image"); + } + + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { + colormanage_check_colorspace_settings(&clip->colorspace_settings, "clip"); + } +} + +void IMB_colormanagement_validate_settings(ColorManagedDisplaySettings *display_settings, + ColorManagedViewSettings *view_settings) +{ + ColorManagedDisplay *display; + ColorManagedView *default_view = NULL; + LinkData *view_link; + + display = colormanage_display_get_named(display_settings->display_device); + + if (display) + default_view = colormanage_view_get_default(display); + + for (view_link = display->views.first; view_link; view_link = view_link->next) { + ColorManagedView *view = view_link->data; + + if (!strcmp(view->name, view_settings->view_transform)) + break; + } + + if (view_link == NULL && default_view) + BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform)); +} + +const char *IMB_colormanagement_role_colorspace_name_get(int role) +{ + switch (role) { + case COLOR_ROLE_SCENE_LINEAR: + return global_role_scene_linear; + break; + case COLOR_ROLE_COLOR_PICKING: + return global_role_color_picking; + break; + case COLOR_ROLE_TEXTURE_PAINTING: + return global_role_texture_painting; + break; + case COLOR_ROLE_DEFAULT_SEQUENCER: + return global_role_default_sequencer; + break; + case COLOR_ROLE_DEFAULT_FLOAT: + return global_role_default_float; + break; + case COLOR_ROLE_DEFAULT_BYTE: + return global_role_default_byte; + break; + default: + printf("Unknown role was passed to %s\n", __func__); + BLI_assert(0); + } + + return NULL; +} + +void IMB_colormanagement_assign_rect_colorspace(ImBuf *ibuf, const char *name) +{ + ColorSpace *colorspace = colormanage_colorspace_get_named(name); + if (colorspace) { + ibuf->rect_colorspace = colorspace; + + if (colorspace->is_data) + ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA; + else + ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA; + } +} + +/*********************** Threaded display buffer transform routines *************************/ + +typedef struct DisplayBufferThread { + ColormanageProcessor *cm_processor; + + float *buffer; + unsigned char *byte_buffer; + + float *display_buffer; + unsigned char *display_buffer_byte; + + int width; + int start_line; + int tot_line; + + int channels; + float dither; + int predivide; + int is_data; + + const char *byte_colorspace; + const char *float_colorspace; +} DisplayBufferThread; + +typedef struct DisplayBufferInitData { + ImBuf *ibuf; + ColormanageProcessor *cm_processor; + float *buffer; + unsigned char *byte_buffer; + + float *display_buffer; + unsigned char *display_buffer_byte; + + int width; + + const char *byte_colorspace; + const char *float_colorspace; +} DisplayBufferInitData; + +static void display_buffer_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v) +{ + DisplayBufferThread *handle = (DisplayBufferThread *) handle_v; + DisplayBufferInitData *init_data = (DisplayBufferInitData *) init_data_v; + ImBuf *ibuf = init_data->ibuf; + + int predivide = ibuf->flags & IB_cm_predivide; + int channels = ibuf->channels; + float dither = ibuf->dither; + int is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA; + + int offset = channels * start_line * ibuf->x; + int display_buffer_byte_offset = DISPLAY_BUFFER_CHANNELS * start_line * ibuf->x; + + memset(handle, 0, sizeof(DisplayBufferThread)); + + handle->cm_processor = init_data->cm_processor; + + if (init_data->buffer) + handle->buffer = init_data->buffer + offset; + + if (init_data->byte_buffer) + handle->byte_buffer = init_data->byte_buffer + offset; + + if (init_data->display_buffer) + handle->display_buffer = init_data->display_buffer + offset; + + if (init_data->display_buffer_byte) + handle->display_buffer_byte = init_data->display_buffer_byte + display_buffer_byte_offset; + + handle->width = ibuf->x; + + handle->start_line = start_line; + handle->tot_line = tot_line; + + handle->channels = channels; + handle->dither = dither; + handle->predivide = predivide; + handle->is_data = is_data; + + handle->byte_colorspace = init_data->byte_colorspace; + handle->float_colorspace = init_data->float_colorspace; +} + +static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle) +{ + float *linear_buffer = NULL; + + int channels = handle->channels; + int width = handle->width; + int height = handle->tot_line; + + int buffer_size = channels * width * height; + + int predivide = handle->predivide; + int is_data = handle->is_data; + + linear_buffer = MEM_callocN(buffer_size * sizeof(float), "color conversion linear buffer"); + + if (!handle->buffer) { + unsigned char *byte_buffer = handle->byte_buffer; + + const char *from_colorspace = handle->byte_colorspace; + const char *to_colorspace = global_role_scene_linear; + + float *fp; + unsigned char *cp; + int i; + + /* first convert byte buffer to float, keep in image space */ + for (i = 0, fp = linear_buffer, cp = byte_buffer; + i < channels * width * height; + i++, fp++, cp++) + { + *fp = (float)(*cp) / 255.0f; + } + + if (!is_data) { + /* convert float buffer to scene linear space */ + IMB_colormanagement_transform(linear_buffer, width, height, channels, + from_colorspace, to_colorspace, predivide); + } + } + else if (handle->float_colorspace) { + /* currently float is non-linear only in sequencer, which is working + * in it's own color space even to handle float buffers. + * This color space is the same for byte and float images. + * Need to convert float buffer to linear space before applying display transform + */ + + const char *from_colorspace = handle->float_colorspace; + const char *to_colorspace = global_role_scene_linear; + + memcpy(linear_buffer, handle->buffer, buffer_size * sizeof(float)); + + IMB_colormanagement_transform(linear_buffer, width, height, channels, + from_colorspace, to_colorspace, predivide); + } + else { + /* some processors would want to modify float original buffer + * before converting it into display byte buffer, so we need to + * make sure original's ImBuf buffers wouldn't be modified by + * using duplicated buffer here + * + * NOTE: MEM_dupallocN can't be used because buffer could be + * specified as an offset inside allocated buffer + */ + + memcpy(linear_buffer, handle->buffer, buffer_size * sizeof(float)); + } + + return linear_buffer; +} + +static void *do_display_buffer_apply_thread(void *handle_v) +{ + DisplayBufferThread *handle = (DisplayBufferThread *) handle_v; + ColormanageProcessor *cm_processor = handle->cm_processor; + float *display_buffer = handle->display_buffer; + unsigned char *display_buffer_byte = handle->display_buffer_byte; + int channels = handle->channels; + int width = handle->width; + int height = handle->tot_line; + float dither = handle->dither; + int predivide = handle->predivide; + int is_data = handle->is_data; + + if (cm_processor == NULL) { + if (display_buffer_byte) { + IMB_buffer_byte_from_byte(display_buffer_byte, handle->byte_buffer, IB_PROFILE_SRGB, IB_PROFILE_SRGB, + FALSE, width, height, width, width); + } + + if (display_buffer) { + IMB_buffer_float_from_byte(display_buffer, handle->byte_buffer, IB_PROFILE_SRGB, IB_PROFILE_SRGB, + FALSE, width, height, width, width); + } + } + else { + float *linear_buffer = display_buffer_apply_get_linear_buffer(handle); + + if (is_data) { + /* special case for data buffers - no color space conversions, + * only generate byte buffers + */ + } + else { + /* apply processor */ + IMB_colormanagement_processor_apply(cm_processor, linear_buffer, width, height, channels, predivide); + } + + /* copy result to output buffers */ + if (display_buffer_byte) { + /* do conversion */ + IMB_buffer_byte_from_float(display_buffer_byte, linear_buffer, + channels, dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, + predivide, width, height, width, width); + } + + if (display_buffer) + memcpy(display_buffer, linear_buffer, width * height * channels * sizeof(float)); + + MEM_freeN(linear_buffer); + } + + return NULL; +} + +static void display_buffer_apply_threaded(ImBuf *ibuf, float *buffer, unsigned char *byte_buffer, float *display_buffer, + unsigned char *display_buffer_byte, ColormanageProcessor *cm_processor) +{ + DisplayBufferInitData init_data; + + init_data.ibuf = ibuf; + init_data.cm_processor = cm_processor; + init_data.buffer = buffer; + init_data.byte_buffer = byte_buffer; + init_data.display_buffer = display_buffer; + init_data.display_buffer_byte = display_buffer_byte; + + if (ibuf->rect_colorspace != NULL) { + init_data.byte_colorspace = ibuf->rect_colorspace->name; + } + else { + /* happens for viewer images, which are not so simple to determine where to + * set image buffer's color spaces + */ + init_data.byte_colorspace = global_role_default_byte; + } + + if (ibuf->float_colorspace != NULL) { + /* sequencer stores float buffers in non-linear space */ + init_data.float_colorspace = ibuf->float_colorspace->name; + } + else { + init_data.float_colorspace = NULL; + } + + IMB_processor_apply_threaded(ibuf->y, sizeof(DisplayBufferThread), &init_data, + display_buffer_init_handle, do_display_buffer_apply_thread); +} + +static void colormanage_display_buffer_process_ex(ImBuf *ibuf, float *display_buffer, unsigned char *display_buffer_byte, + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) +{ + ColormanageProcessor *cm_processor = NULL; + int skip_transform = FALSE; + + /* if we're going to transform byte buffer, check whether transformation would + * happen to the same color space as byte buffer itself is + * this would save byte -> float -> byte conversions making display buffer + * computation noticeable faster + */ + if (ibuf->rect_float == NULL && ibuf->rect_colorspace) { + if ((view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) == 0 && + view_settings->exposure == 0.0f && + view_settings->gamma == 1.0f) + { + ConstConfigRcPtr *config = OCIO_getCurrentConfig(); + + if (config) { + const char *display = display_settings->display_device; + const char *view = view_settings->view_transform; + const char *from_colorspace = ibuf->rect_colorspace->name; + const char *to_colorspace = OCIO_configGetDisplayColorSpaceName(config, display, view); + + if (!strcmp(from_colorspace, to_colorspace)) + skip_transform = TRUE; + + OCIO_configRelease(config); + } + } + } + + if (skip_transform == FALSE) + cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + + display_buffer_apply_threaded(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect, + display_buffer, display_buffer_byte, cm_processor); + + if (cm_processor) + IMB_colormanagement_processor_free(cm_processor); +} + +static void colormanage_display_buffer_process(ImBuf *ibuf, unsigned char *display_buffer, + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) +{ + colormanage_display_buffer_process_ex(ibuf, NULL, display_buffer, view_settings, display_settings); +} + +/*********************** Threaded processor transform routines *************************/ + +typedef struct ProcessorTransformThread { + ColormanageProcessor *cm_processor; + float *buffer; + int width; + int start_line; + int tot_line; + int channels; + int predivide; +} ProcessorTransformThread; + +typedef struct ProcessorTransformInit { + ColormanageProcessor *cm_processor; + float *buffer; + int width; + int height; + int channels; + int predivide; +} ProcessorTransformInitData; + +static void processor_transform_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v) +{ + ProcessorTransformThread *handle = (ProcessorTransformThread *) handle_v; + ProcessorTransformInitData *init_data = (ProcessorTransformInitData *) init_data_v; + + int channels = init_data->channels; + int width = init_data->width; + int predivide = init_data->predivide; + + int offset = channels * start_line * width; + + memset(handle, 0, sizeof(ProcessorTransformThread)); + + handle->cm_processor = init_data->cm_processor; + + handle->buffer = init_data->buffer + offset; + + handle->width = width; + + handle->start_line = start_line; + handle->tot_line = tot_line; + + handle->channels = channels; + handle->predivide = predivide; +} + +static void *do_processor_transform_thread(void *handle_v) +{ + ProcessorTransformThread *handle = (ProcessorTransformThread *) handle_v; + float *buffer = handle->buffer; + int channels = handle->channels; + int width = handle->width; + int height = handle->tot_line; + int predivide = handle->predivide; + + IMB_colormanagement_processor_apply(handle->cm_processor, buffer, width, height, channels, predivide); + + return NULL; +} + +static void processor_transform_apply_threaded(float *buffer, int width, int height, int channels, + ColormanageProcessor *cm_processor, int predivide) +{ + ProcessorTransformInitData init_data; + + init_data.cm_processor = cm_processor; + init_data.buffer = buffer; + init_data.width = width; + init_data.height = height; + init_data.channels = channels; + init_data.predivide = predivide; + + IMB_processor_apply_threaded(height, sizeof(ProcessorTransformThread), &init_data, + processor_transform_init_handle, do_processor_transform_thread); +} + +/*********************** Color space transformation functions *************************/ + +/* convert the whole buffer from specified by name color space to another - internal implementation */ +static void colormanagement_transform_ex(float *buffer, int width, int height, int channels, const char *from_colorspace, + const char *to_colorspace, int predivide, int do_threaded) +{ + ColormanageProcessor *cm_processor; + + if (from_colorspace[0] == '\0') { + return; + } + + if (!strcmp(from_colorspace, to_colorspace)) { + /* if source and destination color spaces are identical, skip + * threading overhead and simply do nothing + */ + return; + } + + cm_processor = IMB_colormanagement_colorspace_processor_new(from_colorspace, to_colorspace); + + if (do_threaded) + processor_transform_apply_threaded(buffer, width, height, channels, cm_processor, predivide); + else + IMB_colormanagement_processor_apply(cm_processor, buffer, width, height, channels, predivide); + + IMB_colormanagement_processor_free(cm_processor); +} + +/* convert the whole buffer from specified by name color space to another */ +void IMB_colormanagement_transform(float *buffer, int width, int height, int channels, + const char *from_colorspace, const char *to_colorspace, int predivide) +{ + colormanagement_transform_ex(buffer, width, height, channels, from_colorspace, to_colorspace, predivide, FALSE); +} + +/* convert the whole buffer from specified by name color space to another + * will do threaded conversion + */ +void IMB_colormanagement_transform_threaded(float *buffer, int width, int height, int channels, + const char *from_colorspace, const char *to_colorspace, int predivide) +{ + colormanagement_transform_ex(buffer, width, height, channels, from_colorspace, to_colorspace, predivide, TRUE); +} + +void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace) +{ + ColormanageProcessor *cm_processor; + + if (from_colorspace[0] == '\0') { + return; + } + + if (!strcmp(from_colorspace, to_colorspace)) { + /* if source and destination color spaces are identical, skip + * threading overhead and simply do nothing + */ + return; + } + + cm_processor = IMB_colormanagement_colorspace_processor_new(from_colorspace, to_colorspace); + + IMB_colormanagement_processor_apply_v4(cm_processor, pixel); + + IMB_colormanagement_processor_free(cm_processor); +} + +/* convert pixel from specified by descriptor color space to scene linear + * used by performance-critical areas such as renderer and baker + */ +void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpace *colorspace) +{ + ConstProcessorRcPtr *processor; + + if (!colorspace) { + /* OCIO_TODO: make sure it never happens */ + + printf("%s: perform conversion from unknown color space\n", __func__); + + return; + } + + processor = colorspace_to_scene_linear_processor(colorspace); + + if (processor) + OCIO_processorApplyRGB(processor, pixel); +} + +/* same as above, but converts colors in opposite direction */ +void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], ColorSpace *colorspace) +{ + ConstProcessorRcPtr *processor; + + if (!colorspace) { + /* OCIO_TODO: make sure it never happens */ + + printf("%s: perform conversion from unknown color space\n", __func__); + + return; + } + + processor = colorspace_from_scene_linear_processor(colorspace); + + if (processor) + OCIO_processorApplyRGB(processor, pixel); +} + +void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, int predivide) +{ + ConstProcessorRcPtr *processor; + + if (!colorspace) { + /* OCIO_TODO: make sure it never happens */ + + printf("%s: perform conversion from unknown color space\n", __func__); + + return; + } + + processor = colorspace_to_scene_linear_processor(colorspace); + + if (processor) { + PackedImageDesc *img; + + img = OCIO_createPackedImageDesc(buffer, width, height, channels, sizeof(float), + channels * sizeof(float), channels * sizeof(float) * width); + + if (predivide) + OCIO_processorApply_predivide(processor, img); + else + OCIO_processorApply(processor, img); + + OCIO_packedImageDescRelease(img); + } +} + +/* convert pixel from scene linear to display space using default view + * used by performance-critical areas such as color-related widgets where we want to reduce + * amount of per-widget allocations + */ +void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManagedDisplay *display) +{ + ConstProcessorRcPtr *processor; + + processor = display_from_scene_linear_processor(display); + + if (processor) + OCIO_processorApplyRGB(processor, pixel); +} + +/* same as above, but converts color in opposite direction */ +void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManagedDisplay *display) +{ + ConstProcessorRcPtr *processor; + + processor = display_to_scene_linear_processor(display); + + if (processor) + OCIO_processorApplyRGB(processor, pixel); +} + +void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4], + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) +{ + ColormanageProcessor *cm_processor; + + copy_v4_v4(result, pixel); + + cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + IMB_colormanagement_processor_apply_v4(cm_processor, result); + IMB_colormanagement_processor_free(cm_processor); +} + +void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3], + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) +{ + ColormanageProcessor *cm_processor; + + copy_v3_v3(result, pixel); + + cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + IMB_colormanagement_processor_apply_v3(cm_processor, result); + IMB_colormanagement_processor_free(cm_processor); +} + +void IMB_colormanagement_imbuf_assign_float_space(ImBuf *ibuf, ColorManagedColorspaceSettings *colorspace_settings) +{ + ibuf->float_colorspace = colormanage_colorspace_get_named(colorspace_settings->name); +} + +void IMB_colormanagement_imbuf_make_display_space(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) +{ + /* OCIO_TODO: byte buffer management is not supported here yet */ + if (!ibuf->rect_float) + return; + + if (global_tot_display == 0 || global_tot_view == 0) { + IMB_buffer_float_from_float(ibuf->rect_float, ibuf->rect_float, ibuf->channels, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, + ibuf->flags & IB_cm_predivide, ibuf->x, ibuf->y, ibuf->x, ibuf->x); + } + else { + colormanage_display_buffer_process_ex(ibuf, ibuf->rect_float, NULL, view_settings, display_settings); + } +} + +static void imbuf_verify_float(ImBuf *ibuf) +{ + /* multiple threads could request for display buffer at once and in case + * view transform is not used it'll lead to display buffer calculated + * several times + * it is harmless, but would take much more time (assuming thread lock + * happens faster than running float->byte conversion for average image) + */ + BLI_lock_thread(LOCK_COLORMANAGE); + + if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID))) { + IMB_rect_from_float(ibuf); + + ibuf->userflags &= ~IB_RECT_INVALID; + } + + BLI_unlock_thread(LOCK_COLORMANAGE); +} + +/*********************** Public display buffers interfaces *************************/ + +/* acquire display buffer for given image buffer using specified view and display settings */ +unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings, void **cache_handle) +{ + *cache_handle = NULL; + + if (!ibuf->x || !ibuf->y) + return NULL; + + if (global_tot_display == 0 || global_tot_view == 0) { + /* if there's no view transform or display transforms, fallback to standard sRGB/linear conversion + * the same logic would be used if OCIO is disabled + */ + + imbuf_verify_float(ibuf); + + return (unsigned char *) ibuf->rect; + } + else { + unsigned char *display_buffer; + int buffer_size; + ColormanageCacheViewSettings cache_view_settings; + ColormanageCacheDisplaySettings cache_display_settings; + ColorManagedViewSettings default_view_settings; + const ColorManagedViewSettings *applied_view_settings; + + if (view_settings) { + applied_view_settings = view_settings; + } + else { + /* if no view settings were specified, use default display transformation + * this happens for images which don't want to be displayed with render settings + */ + + init_default_view_settings(display_settings, &default_view_settings); + applied_view_settings = &default_view_settings; + } + + colormanage_view_settings_to_cache(&cache_view_settings, applied_view_settings); + colormanage_display_settings_to_cache(&cache_display_settings, display_settings); + + BLI_lock_thread(LOCK_COLORMANAGE); + + /* ensure color management bit fields exists */ + if (!ibuf->display_buffer_flags) { + if (global_tot_display) + ibuf->display_buffer_flags = MEM_callocN(sizeof(unsigned int) * global_tot_display, "imbuf display_buffer_flags"); + } + else if (ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) { + /* all display buffers were marked as invalid from other areas, + * now propagate this flag to internal color management routines + */ + memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(unsigned int)); + + ibuf->userflags &= ~IB_DISPLAY_BUFFER_INVALID; + } + + display_buffer = colormanage_cache_get(ibuf, &cache_view_settings, &cache_display_settings, cache_handle); + + if (display_buffer) { + BLI_unlock_thread(LOCK_COLORMANAGE); + return display_buffer; + } + + buffer_size = DISPLAY_BUFFER_CHANNELS * ibuf->x * ibuf->y * sizeof(float); + display_buffer = MEM_callocN(buffer_size, "imbuf display buffer"); + + colormanage_display_buffer_process(ibuf, display_buffer, applied_view_settings, display_settings); + + colormanage_cache_put(ibuf, &cache_view_settings, &cache_display_settings, display_buffer, cache_handle); + + BLI_unlock_thread(LOCK_COLORMANAGE); + + return display_buffer; + } +} + +/* same as IMB_display_buffer_acquire but gets view and display settings from context */ +unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, void **cache_handle) +{ + ColorManagedViewSettings *view_settings; + ColorManagedDisplaySettings *display_settings; + + display_transform_get_from_ctx(C, &view_settings, &display_settings); + + return IMB_display_buffer_acquire(ibuf, view_settings, display_settings, cache_handle); +} + +/* covert float buffer to display space and store it in image buffer's byte array */ +void IMB_display_buffer_to_imbuf_rect(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) +{ + if (global_tot_display == 0 || global_tot_view == 0) { + imbuf_verify_float(ibuf); + } + else { + if (!ibuf->rect) { + imb_addrectImBuf(ibuf); + } + + colormanage_display_buffer_process(ibuf, (unsigned char *) ibuf->rect, view_settings, display_settings); + } +} + +void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height, + int channels, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings, int predivide) +{ + if (global_tot_display == 0 || global_tot_view == 0) { + IMB_buffer_byte_from_float(display_buffer, linear_buffer, channels, 0.0f, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, FALSE, + width, height, width, width); + } + else { + float *buffer; + ColormanageProcessor *cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + + buffer = MEM_callocN(channels * width * height * sizeof(float), "display transform temp buffer"); + memcpy(buffer, linear_buffer, channels * width * height * sizeof(float)); + + IMB_colormanagement_processor_apply(cm_processor, buffer, width, height, channels, predivide); + + IMB_colormanagement_processor_free(cm_processor); + + IMB_buffer_byte_from_float(display_buffer, buffer, channels, 0.0f, IB_PROFILE_SRGB, IB_PROFILE_SRGB, + FALSE, width, height, width, width); + + MEM_freeN(buffer); + } +} + +void IMB_display_buffer_release(void *cache_handle) +{ + if (cache_handle) { + BLI_lock_thread(LOCK_COLORMANAGE); + + colormanage_cache_handle_release(cache_handle); + + BLI_unlock_thread(LOCK_COLORMANAGE); + } +} + +/*********************** Display functions *************************/ + +ColorManagedDisplay *colormanage_display_get_default(void) +{ + ConstConfigRcPtr *config = OCIO_getCurrentConfig(); + const char *display; + + if (!config) { + /* no valid OCIO configuration, can't get default display */ + + return NULL; + } + + display = OCIO_configGetDefaultDisplay(config); + + OCIO_configRelease(config); + + if (display[0] == '\0') + return NULL; + + return colormanage_display_get_named(display); +} + +ColorManagedDisplay *colormanage_display_add(const char *name) +{ + ColorManagedDisplay *display; + int index = 0; + + if (global_displays.last) { + ColorManagedDisplay *last_display = global_displays.last; + + index = last_display->index; + } + + display = MEM_callocN(sizeof(ColorManagedDisplay), "ColorManagedDisplay"); + + display->index = index + 1; + + BLI_strncpy(display->name, name, sizeof(display->name)); + + BLI_addtail(&global_displays, display); + + return display; +} + +ColorManagedDisplay *colormanage_display_get_named(const char *name) +{ + ColorManagedDisplay *display; + + for (display = global_displays.first; display; display = display->next) { + if (!strcmp(display->name, name)) + return display; + } + + return NULL; +} + +ColorManagedDisplay *colormanage_display_get_indexed(int index) +{ + /* display indices are 1-based */ + return BLI_findlink(&global_displays, index - 1); +} + +int IMB_colormanagement_display_get_named_index(const char *name) +{ + ColorManagedDisplay *display; + + display = colormanage_display_get_named(name); + + if (display) { + return display->index; + } + + return 0; +} + +const char *IMB_colormanagement_display_get_indexed_name(int index) +{ + ColorManagedDisplay *display; + + display = colormanage_display_get_indexed(index); + + if (display) { + return display->name; + } + + return NULL; +} + +const char *IMB_colormanagement_display_get_default_name(void) +{ + ColorManagedDisplay *display = colormanage_display_get_default(); + + return display->name; +} + +/* used by performance-critical pixel processing areas, such as color widgets */ +ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name) +{ + return colormanage_display_get_named(name); +} + +/*********************** View functions *************************/ + +const char *colormanage_view_get_default_name(const ColorManagedDisplay *display) +{ + ConstConfigRcPtr *config = OCIO_getCurrentConfig(); + const char *name; + + if (!config) { + /* no valid OCIO configuration, can't get default view */ + + return NULL; + } + + name = OCIO_configGetDefaultView(config, display->name); + + OCIO_configRelease(config); + + return name; +} + +ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *display) +{ + const char *name = colormanage_view_get_default_name(display); + + if (!name || name[0] == '\0') + return NULL; + + return colormanage_view_get_named(name); +} + +ColorManagedView *colormanage_view_add(const char *name) +{ + ColorManagedView *view; + int index = global_tot_view; + + view = MEM_callocN(sizeof(ColorManagedView), "ColorManagedView"); + view->index = index + 1; + BLI_strncpy(view->name, name, sizeof(view->name)); + + BLI_addtail(&global_views, view); + + global_tot_view++; + + return view; +} + +ColorManagedView *colormanage_view_get_named(const char *name) +{ + ColorManagedView *view; + + for (view = global_views.first; view; view = view->next) { + if (!strcmp(view->name, name)) + return view; + } + + return NULL; +} + +ColorManagedView *colormanage_view_get_indexed(int index) +{ + /* view transform indices are 1-based */ + return BLI_findlink(&global_views, index - 1); +} + +int IMB_colormanagement_view_get_named_index(const char *name) +{ + ColorManagedView *view = colormanage_view_get_named(name); + + if (view) { + return view->index; + } + + return 0; +} + +const char *IMB_colormanagement_view_get_indexed_name(int index) +{ + ColorManagedView *view = colormanage_view_get_indexed(index); + + if (view) { + return view->name; + } + + return NULL; +} + +const char *IMB_colormanagement_view_get_default_name(const char *display_name) +{ + ColorManagedDisplay *display = colormanage_display_get_named(display_name); + ColorManagedView *view = NULL; + + if (display) + view = colormanage_view_get_default(display); + + if (view) + return view->name; + + return NULL; +} + +/*********************** Color space functions *************************/ + +static void colormanage_description_strip(char *description) +{ + int i, n; + + for (i = strlen(description) - 1; i >= 0; i--) { + if (ELEM(description[i], '\r', '\n')) { + description[i] = '\0'; + } + else { + break; + } + } + + for (i = 0, n = strlen(description); i < n; i++) { + if (ELEM(description[i], '\r', '\n')) { + description[i] = ' '; + } + } +} + +ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible, int is_data) +{ + ColorSpace *colorspace, *prev_space; + int counter = 1; + + colorspace = MEM_callocN(sizeof(ColorSpace), "ColorSpace"); + + BLI_strncpy(colorspace->name, name, sizeof(colorspace->name)); + + if (description) { + BLI_strncpy(colorspace->description, description, sizeof(colorspace->description)); + + colormanage_description_strip(colorspace->description); + } + + colorspace->is_invertible = is_invertible; + colorspace->is_data = is_data; + + for (prev_space = global_colorspaces.first; prev_space; prev_space = prev_space->next) { + if (BLI_strcasecmp(prev_space->name, colorspace->name) > 0) + break; + + prev_space->index = counter++; + } + + if (!prev_space) + BLI_addtail(&global_colorspaces, colorspace); + else + BLI_insertlinkbefore(&global_colorspaces, prev_space, colorspace); + + colorspace->index = counter++; + for (; prev_space; prev_space = prev_space->next) { + prev_space->index = counter++; + } + + global_tot_colorspace++; + + return colorspace; +} + +ColorSpace *colormanage_colorspace_get_named(const char *name) +{ + ColorSpace *colorspace; + + for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) { + if (!strcmp(colorspace->name, name)) + return colorspace; + } + + return NULL; +} + +ColorSpace *colormanage_colorspace_get_roled(int role) +{ + const char *role_colorspace = IMB_colormanagement_role_colorspace_name_get(role); + + return colormanage_colorspace_get_named(role_colorspace); +} + +ColorSpace *colormanage_colorspace_get_indexed(int index) +{ + /* display indices are 1-based */ + return BLI_findlink(&global_colorspaces, index - 1); +} + +int IMB_colormanagement_colorspace_get_named_index(const char *name) +{ + ColorSpace *colorspace; + + colorspace = colormanage_colorspace_get_named(name); + + if (colorspace) { + return colorspace->index; + } + + return 0; +} + +const char *IMB_colormanagement_colorspace_get_indexed_name(int index) +{ + ColorSpace *colorspace; + + colorspace = colormanage_colorspace_get_indexed(index); + + if (colorspace) { + return colorspace->name; + } + + return ""; +} + +void IMB_colormanagment_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf) +{ + ImFileType *type; + + for (type = IMB_FILE_TYPES; type->is_a; type++) { + if (type->save && type->ftype(type, ibuf)) { + const char *role_colorspace; + + role_colorspace = IMB_colormanagement_role_colorspace_name_get(type->default_save_role); + + BLI_strncpy(colorspace_settings->name, role_colorspace, sizeof(colorspace_settings->name)); + } + } +} + +/*********************** RNA helper functions *************************/ + +void IMB_colormanagement_display_items_add(EnumPropertyItem **items, int *totitem) +{ + ColorManagedDisplay *display; + + for (display = global_displays.first; display; display = display->next) { + EnumPropertyItem item; + + item.value = display->index; + item.name = display->name; + item.identifier = display->name; + item.icon = 0; + item.description = ""; + + RNA_enum_item_add(items, totitem, &item); + } +} + +static void colormanagement_view_item_add(EnumPropertyItem **items, int *totitem, ColorManagedView *view) +{ + EnumPropertyItem item; + + item.value = view->index; + item.name = view->name; + item.identifier = view->name; + item.icon = 0; + item.description = ""; + + RNA_enum_item_add(items, totitem, &item); +} + +void IMB_colormanagement_view_items_add(EnumPropertyItem **items, int *totitem, const char *display_name) +{ + ColorManagedDisplay *display = colormanage_display_get_named(display_name); + ColorManagedView *view; + + if (display) { + LinkData *display_view; + + for (display_view = display->views.first; display_view; display_view = display_view->next) { + view = display_view->data; + + colormanagement_view_item_add(items, totitem, view); + } + } +} + +void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *totitem) +{ + ColorSpace *colorspace; + + for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) { + EnumPropertyItem item; + + if (!colorspace->is_invertible) + continue; + + item.value = colorspace->index; + item.name = colorspace->name; + item.identifier = colorspace->name; + item.icon = 0; + + if (colorspace->description) + item.description = colorspace->description; + else + item.description = ""; + + RNA_enum_item_add(items, totitem, &item); + } +} + +/*********************** Partial display buffer update *************************/ + +/* + * Partial display update is supposed to be used by such areas as + * compositor and renderer, This areas are calculating tiles of the + * images and because of performance reasons only this tiles should + * be color managed. + * This gives nice visual feedback without slowing things down. + * + * Updating happens for active display transformation only, all + * the rest buffers would be marked as dirty + */ + +static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffer, const float *linear_buffer, + const unsigned char *byte_buffer, int display_stride, int linear_stride, + int linear_offset_x, int linear_offset_y, ColormanageProcessor *cm_processor, + int xmin, int ymin, int xmax, int ymax) +{ + int x, y; + int channels = ibuf->channels; + int predivide = ibuf->flags & IB_cm_predivide; + float dither = ibuf->dither; + ColorSpace *rect_colorspace = ibuf->rect_colorspace; + float *display_buffer_float = NULL; + int width = xmax - xmin; + int height = ymax - ymin; + int is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA; + + if (dither != 0.0f) { + display_buffer_float = MEM_callocN(channels * width * height * sizeof(float), "display buffer for dither"); + } + + for (y = ymin; y < ymax; y++) { + for (x = xmin; x < xmax; x++) { + int display_index = (y * display_stride + x) * channels; + int linear_index = ((y - linear_offset_y) * linear_stride + (x - linear_offset_x)) * channels; + float pixel[4]; + + if (linear_buffer) { + copy_v4_v4(pixel, (float *) linear_buffer + linear_index); + } + else if (byte_buffer) { + rgba_uchar_to_float(pixel, byte_buffer + linear_index); + + IMB_colormanagement_colorspace_to_scene_linear_v3(pixel, rect_colorspace); + } + + if (!is_data) { + if (predivide) + IMB_colormanagement_processor_apply_v4(cm_processor, pixel); + else + IMB_colormanagement_processor_apply_v4(cm_processor, pixel); + } + + if (display_buffer_float) { + int index = ((y - ymin) * width + (x - xmin)) * channels; + + copy_v4_v4(display_buffer_float + index, pixel); + } + else { + rgba_float_to_uchar(display_buffer + display_index, pixel); + } + } + } + + if (display_buffer_float) { + int display_index = (ymin * display_stride + xmin) * channels; + + IMB_buffer_byte_from_float(display_buffer + display_index, display_buffer_float, channels, dither, + IB_PROFILE_SRGB, IB_PROFILE_SRGB, FALSE, width, height, display_stride, width); + + MEM_freeN(display_buffer_float); + } +} + +void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer, const unsigned char *byte_buffer, + int stride, int offset_x, int offset_y, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings, + int xmin, int ymin, int xmax, int ymax) +{ + if (ibuf->rect && ibuf->rect_float) { + /* update byte buffer created by legacy color management */ + + unsigned char *rect = (unsigned char *) ibuf->rect; + int predivide = ibuf->flags & IB_cm_predivide; + int channels = ibuf->channels; + int width = xmax - xmin; + int height = ymax - ymin; + int rect_index = (ymin * ibuf->x + xmin) * channels; + int linear_index = ((ymin - offset_y) * stride + (xmin - offset_x)) * channels; + + IMB_buffer_byte_from_float(rect + rect_index, linear_buffer + linear_index, channels, ibuf->dither, + IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, predivide, width, height, ibuf->x, stride); + } + + if (ibuf->display_buffer_flags) { + ColormanageCacheViewSettings cache_view_settings; + ColormanageCacheDisplaySettings cache_display_settings; + void *cache_handle = NULL; + unsigned char *display_buffer = NULL; + int view_flag, display_index, buffer_width; + + colormanage_view_settings_to_cache(&cache_view_settings, view_settings); + colormanage_display_settings_to_cache(&cache_display_settings, display_settings); + + view_flag = 1 << (cache_view_settings.view - 1); + display_index = cache_display_settings.display - 1; + + BLI_lock_thread(LOCK_COLORMANAGE); + if ((ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) == 0) + display_buffer = colormanage_cache_get(ibuf, &cache_view_settings, &cache_display_settings, &cache_handle); + + /* in some rare cases buffer's dimension could be changing directly from + * different thread + * this i.e. happens when image editor acquires render result + */ + buffer_width = ibuf->x; + + /* mark all other buffers as invalid */ + memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(unsigned int)); + ibuf->display_buffer_flags[display_index] |= view_flag; + + BLI_unlock_thread(LOCK_COLORMANAGE); + + if (display_buffer) { + ColormanageProcessor *cm_processor; + + cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + + partial_buffer_update_rect(ibuf, display_buffer, linear_buffer, byte_buffer, buffer_width, stride, + offset_x, offset_y, cm_processor, xmin, ymin, xmax, ymax); + + IMB_colormanagement_processor_free(cm_processor); + + IMB_display_buffer_release(cache_handle); + } + } +} + +/*********************** Pixel processor functions *************************/ + +ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) +{ + ColormanageProcessor *cm_processor; + + cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor"); + + { + ColorManagedViewSettings default_view_settings; + const ColorManagedViewSettings *applied_view_settings; + + if (view_settings) { + applied_view_settings = view_settings; + } + else { + init_default_view_settings(display_settings, &default_view_settings); + applied_view_settings = &default_view_settings; + } + + cm_processor->processor = create_display_buffer_processor(applied_view_settings->view_transform, display_settings->display_device, + applied_view_settings->exposure, applied_view_settings->gamma); + + if (applied_view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) { + cm_processor->curve_mapping = curvemapping_copy(applied_view_settings->curve_mapping); + curvemapping_premultiply(cm_processor->curve_mapping, FALSE); + } + } + + return cm_processor; +} + +ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace) +{ + ColormanageProcessor *cm_processor; + + cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor"); + + cm_processor->processor = create_colorspace_transform_processor(from_colorspace, to_colorspace); + + return cm_processor; +} + +void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4]) +{ + if (cm_processor->curve_mapping) + curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); + + if (cm_processor->processor) + OCIO_processorApplyRGBA(cm_processor->processor, pixel); +} + +void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3]) +{ + if (cm_processor->curve_mapping) + curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); + + if (cm_processor->processor) + OCIO_processorApplyRGB(cm_processor->processor, pixel); +} + +void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, float *buffer, int width, int height, + int channels, int predivide) +{ + /* apply curve mapping */ + if (cm_processor->curve_mapping) { + int x, y; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + float *pixel = buffer + channels * (y * width + x); + + curve_mapping_apply_pixel(cm_processor->curve_mapping, pixel, channels); + } + } + } + + if (cm_processor->processor && channels >= 3) { + PackedImageDesc *img; + + /* apply OCIO processor */ + img = OCIO_createPackedImageDesc(buffer, width, height, channels, sizeof(float), + channels * sizeof(float), channels * sizeof(float) * width); + + if (predivide) + OCIO_processorApply_predivide(cm_processor->processor, img); + else + OCIO_processorApply(cm_processor->processor, img); + + OCIO_packedImageDescRelease(img); + } +} + +void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor) +{ + if (cm_processor->curve_mapping) + curvemapping_free(cm_processor->curve_mapping); + if (cm_processor->processor) + OCIO_processorRelease(cm_processor->processor); + + MEM_freeN(cm_processor); +} diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index 82f355e1bb2..d9d0cb86ee0 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -305,7 +305,7 @@ static const uint DDPF_SRGB = 0x40000000U; }; - const char * getDxgiFormatString(DXGI_FORMAT dxgiFormat) + static const char * getDxgiFormatString(DXGI_FORMAT dxgiFormat) { #define CASE(format) case DXGI_FORMAT_##format: return #format switch (dxgiFormat) @@ -429,7 +429,7 @@ static const uint DDPF_SRGB = 0x40000000U; #undef CASE } - const char * getD3d10ResourceDimensionString(D3D10_RESOURCE_DIMENSION resourceDimension) + static const char * getD3d10ResourceDimensionString(D3D10_RESOURCE_DIMENSION resourceDimension) { switch (resourceDimension) { @@ -534,7 +534,7 @@ namespace } // namespace -uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) +static uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) { for (int i = 0; i < s_d3dFormatCount; i++) { diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 71313d4438f..7aacbf20bae 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -43,6 +43,9 @@ extern "C" { #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + int imb_save_dds(struct ImBuf * ibuf, const char *name, int flags) { return(0); /* todo: finish this function */ @@ -79,7 +82,7 @@ int imb_is_a_dds(unsigned char *mem) // note: use at most first 32 bytes return(1); } -struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) +struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf * ibuf = 0; DirectDrawSurface dds(mem, size); /* reads header */ @@ -92,6 +95,12 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) Color32 pixel; Color32 *pixels = 0; + /* OCIO_TODO: never was able to save DDS, so can'ttest loading + * but profile used to be set to sRGB and can't see rect_float here, so + * default byte space should work fine + */ + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + if (!imb_is_a_dds(mem)) return (0); @@ -133,7 +142,6 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) if (ibuf == 0) return(0); /* memory allocation failed */ ibuf->ftype = DDS; - ibuf->profile = IB_PROFILE_SRGB; ibuf->dds_data.fourcc = dds.fourCC(); ibuf->dds_data.nummipmaps = dds.mipmapCount(); diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h index 589257816e0..2316fefce69 100644 --- a/source/blender/imbuf/intern/dds/dds_api.h +++ b/source/blender/imbuf/intern/dds/dds_api.h @@ -32,9 +32,11 @@ extern "C" { #endif +#include "../../IMB_imbuf.h" + int imb_save_dds(struct ImBuf *ibuf, const char *name, int flags); int imb_is_a_dds(unsigned char *mem); /* use only first 32 bytes of mem */ -struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); #ifdef __cplusplus } diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 5ba08f1dd73..9ce5d0e30da 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -40,6 +40,9 @@ #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + #include "MEM_guardedalloc.h" /**************************** Interlace/Deinterlace **************************/ @@ -106,7 +109,7 @@ typedef struct DitherContext { float f; } DitherContext; -DitherContext *create_dither_context(int w, float factor) +static DitherContext *create_dither_context(int w, float factor) { DitherContext *di; int i; @@ -522,32 +525,34 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from, void IMB_rect_from_float(ImBuf *ibuf) { int predivide = (ibuf->flags & IB_cm_predivide); - int profile_from; + float *buffer; + const char *from_colorspace; /* verify we have a float buffer */ if (ibuf->rect_float == NULL) return; /* create byte rect if it didn't exist yet */ - if (ibuf->rect == NULL) - imb_addrectImBuf(ibuf); - - /* determine profiles */ - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - profile_from = IB_PROFILE_LINEAR_RGB; - } - else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) { - profile_from = IB_PROFILE_SRGB; - } - else { - profile_from = IB_PROFILE_SRGB; /* should never happen */ - BLI_assert(0); + if (ibuf->rect == NULL) { + if (imb_addrectImBuf(ibuf) == 0) + return; } - /* do conversion */ - IMB_buffer_byte_from_float((uchar *)ibuf->rect, ibuf->rect_float, - ibuf->channels, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide, - ibuf->x, ibuf->y, ibuf->x, ibuf->x); + if (ibuf->float_colorspace == NULL) + from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR); + else + from_colorspace = ibuf->float_colorspace->name; + + buffer = MEM_dupallocN(ibuf->rect_float); + + /* first make float buffer in byte space */ + IMB_colormanagement_transform(buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, ibuf->rect_colorspace->name, predivide); + + /* convert float to byte */ + IMB_buffer_byte_from_float((unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, + FALSE, ibuf->x, ibuf->y, ibuf->x, ibuf->x); + + MEM_freeN(buffer); /* ensure user flag is reset */ ibuf->userflags &= ~IB_RECT_INVALID; @@ -559,7 +564,7 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w float *rect_float; uchar *rect_byte; int predivide = (ibuf->flags & IB_cm_predivide); - int profile_from; + int profile_from = IB_PROFILE_LINEAR_RGB; /* verify we have a float buffer */ if (ibuf->rect_float == NULL || buffer == NULL) @@ -569,18 +574,6 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w if (ibuf->rect == NULL) imb_addrectImBuf(ibuf); - /* determine profiles */ - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - profile_from = IB_PROFILE_LINEAR_RGB; - } - else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) { - profile_from = IB_PROFILE_SRGB; - } - else { - profile_from = IB_PROFILE_SRGB; /* should never happen */ - BLI_assert(0); - } - /* do conversion */ rect_float = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels; rect_byte = (uchar *)ibuf->rect + (x + y * ibuf->x) * 4; @@ -589,6 +582,7 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w 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); @@ -600,26 +594,23 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w void IMB_float_from_rect(ImBuf *ibuf) { int predivide = (ibuf->flags & IB_cm_predivide); - int profile_from; /* verify if we byte and float buffers */ if (ibuf->rect == NULL) return; - if (ibuf->rect_float == NULL) + if (ibuf->rect_float == NULL) { if (imb_addrectfloatImBuf(ibuf) == 0) return; - - /* determine profiles */ - if (ibuf->profile == IB_PROFILE_NONE) - profile_from = IB_PROFILE_LINEAR_RGB; - else - profile_from = IB_PROFILE_SRGB; - - /* do conversion */ - IMB_buffer_float_from_byte(ibuf->rect_float, (uchar *)ibuf->rect, - IB_PROFILE_LINEAR_RGB, profile_from, predivide, - ibuf->x, ibuf->y, ibuf->x, ibuf->x); + } + + /* first, create float buffer in non-linear space */ + IMB_buffer_float_from_byte(ibuf->rect_float, (unsigned char *) ibuf->rect, IB_PROFILE_SRGB, IB_PROFILE_SRGB, + FALSE, ibuf->x, ibuf->y, ibuf->x, ibuf->x); + + /* then make float be in linear space */ + IMB_colormanagement_colorspace_to_scene_linear(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, + ibuf->rect_colorspace, predivide); } /* no profile conversion */ @@ -635,63 +626,19 @@ void IMB_float_from_rect_simple(ImBuf *ibuf) ibuf->x, ibuf->y, ibuf->x, ibuf->x); } -void IMB_convert_profile(ImBuf *ibuf, int profile) -{ - int predivide = (ibuf->flags & IB_cm_predivide); - int profile_from, profile_to; - - if (ibuf->profile == profile) - return; - - /* determine profiles */ - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) - profile_from = IB_PROFILE_LINEAR_RGB; - else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) - profile_from = IB_PROFILE_SRGB; - else { - BLI_assert(0); - profile_from = IB_PROFILE_SRGB; /* dummy, should never happen */ - } - - if (profile == IB_PROFILE_LINEAR_RGB) - profile_to = IB_PROFILE_LINEAR_RGB; - else if (ELEM(profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) - profile_to = IB_PROFILE_SRGB; - else { - BLI_assert(0); - profile_to = IB_PROFILE_SRGB; /* dummy, should never happen */ - } - - /* do conversion */ - if (ibuf->rect_float) { - IMB_buffer_float_from_float(ibuf->rect_float, ibuf->rect_float, - 4, profile_to, profile_from, predivide, - ibuf->x, ibuf->y, ibuf->x, ibuf->x); - } - - if (ibuf->rect) { - IMB_buffer_byte_from_byte((uchar *)ibuf->rect, (uchar *)ibuf->rect, - profile_to, profile_from, predivide, - ibuf->x, ibuf->y, ibuf->x, ibuf->x); - } - - /* set new profile */ - ibuf->profile = profile; -} - /* use when you need to get a buffer with a certain profile * if the return */ + +/* OCIO_TODO: used only by Cineon/DPX exporter which is still broken, so can not guarantee + * this function is working properly + */ float *IMB_float_profile_ensure(ImBuf *ibuf, int profile, int *alloc) { int predivide = (ibuf->flags & IB_cm_predivide); - int profile_from, profile_to; - - /* determine profiles */ - if (ibuf->profile == IB_PROFILE_NONE) - profile_from = IB_PROFILE_LINEAR_RGB; - else - profile_from = IB_PROFILE_SRGB; + int profile_from = IB_PROFILE_LINEAR_RGB; + int profile_to; + /* determine profile */ if (profile == IB_PROFILE_NONE) profile_to = IB_PROFILE_LINEAR_RGB; else diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index d67de3be68b..ed4db50035d 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -30,6 +30,8 @@ #include "IMB_imbuf_types.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" + #ifdef WITH_OPENEXR #include "openexr/openexr_api.h" #endif @@ -66,34 +68,34 @@ void quicktime_exit(void); #endif ImFileType IMB_FILE_TYPES[] = { - {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, 0, JPG}, - {NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, 0, PNG}, - {NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, 0, BMP}, - {NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA}, - {NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, 0, IMAGIC}, + {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, 0, JPG, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, 0, PNG, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, 0, BMP, COLOR_ROLE_DEFAULT_BYTE}, + {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}, - {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, 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}, #endif #ifdef WITH_TIFF - {imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF}, + {imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF, COLOR_ROLE_DEFAULT_BYTE}, #endif #ifdef WITH_HDR - {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR}, + {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR, COLOR_ROLE_DEFAULT_FLOAT}, #endif #ifdef WITH_OPENEXR - {imb_initopenexr, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR}, + {imb_initopenexr, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR, COLOR_ROLE_DEFAULT_FLOAT}, #endif #ifdef WITH_OPENJPEG - {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2}, + {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2, COLOR_ROLE_DEFAULT_BYTE}, #endif #ifdef WITH_DDS - {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS}, + {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS, COLOR_ROLE_DEFAULT_BYTE}, #endif #ifdef WITH_QUICKTIME - {quicktime_init, quicktime_exit, imb_is_a_quicktime, imb_ftype_quicktime, imb_quicktime_decode, NULL, NULL, 0, QUICKTIME}, + {quicktime_init, quicktime_exit, imb_is_a_quicktime, imb_ftype_quicktime, imb_quicktime_decode, NULL, NULL, 0, QUICKTIME, COLOR_ROLE_DEFAULT_BYTE}, #endif - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0} + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0} }; void imb_filetypes_init(void) diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index ea493e277f3..97316c48621 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -1254,7 +1254,8 @@ struct anim *IMB_anim_open_proxy( get_proxy_filename(anim, preview_size, fname, FALSE); - anim->proxy_anim[i] = IMB_open_anim(fname, 0, 0); + /* proxies are generated in default color space */ + anim->proxy_anim[i] = IMB_open_anim(fname, 0, 0, NULL); anim->proxies_tried |= preview_size; diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c index 6b960a18277..7a8f8fcc752 100644 --- a/source/blender/imbuf/intern/indexer_dv.c +++ b/source/blender/imbuf/intern/indexer_dv.c @@ -385,7 +385,7 @@ static void indexer_dv_delete(anim_index_builder *idx) MEM_freeN(This); } -void IMB_indexer_dv_new(anim_index_builder *idx) +static void UNUSED_FUNCTION(IMB_indexer_dv_new)(anim_index_builder *idx) { indexer_dv_context *rv = MEM_callocN( sizeof(indexer_dv_context), "index_dv builder context"); diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index 13b0fc1b55a..549a28a0453 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -42,6 +42,9 @@ #include "IMB_allocimbuf.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + typedef struct { unsigned short imagic; /* stuff saved on disk . . */ unsigned short type; @@ -80,21 +83,21 @@ typedef struct { #define OFFSET_R 0 /* this is byte order dependent */ #define OFFSET_G 1 #define OFFSET_B 2 -#define OFFSET_A 3 +// #define OFFSET_A 3 #define CHANOFFSET(z) (3 - (z)) /* this is byte order dependent */ -#define TYPEMASK 0xff00 +// #define TYPEMASK 0xff00 #define BPPMASK 0x00ff -#define ITYPE_VERBATIM 0x0000 +// #define ITYPE_VERBATIM 0x0000 // UNUSED #define ITYPE_RLE 0x0100 #define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE) -#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM) +// #define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM) #define BPP(type) ((type) & BPPMASK) #define RLE(bpp) (ITYPE_RLE | (bpp)) -#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) -#define IBUFSIZE(pixels) ((pixels + (pixels >> 6)) << 2) -#define RLE_NOP 0x00 +// #define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) // UNUSED +// #define IBUFSIZE(pixels) ((pixels + (pixels >> 6)) << 2) // UNUSED +// #define RLE_NOP 0x00 /* funcs */ static void readheader(FILE *inf, IMAGE *image); @@ -247,7 +250,7 @@ int imb_is_a_iris(unsigned char *mem) * */ -struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) +struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { unsigned int *base, *lptr = NULL; float *fbase, *fptr = NULL; @@ -265,6 +268,9 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) if (!imb_is_a_iris(mem)) return NULL; + /* OCIO_TODO: only tested with 1 byte per pixel, not sure how to test with other settings */ + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + /*printf("new iris\n");*/ file_data = mem; @@ -523,7 +529,6 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) } ibuf->ftype = IMAGIC; - ibuf->profile = IB_PROFILE_SRGB; test_endian_zbuf(ibuf); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 1fe9a5ab522..dd559c55402 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -36,6 +36,9 @@ #include "IMB_allocimbuf.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + #include "openjpeg.h" #define JP2_FILEHEADER_SIZE 14 @@ -109,7 +112,7 @@ static void info_callback(const char *msg, void *client_data) } \ } (void)0 \ -struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) +struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf = NULL; int use_float = FALSE; /* for precision higher then 8 use float */ @@ -137,6 +140,9 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) if (!is_jp2 && !is_j2k) return(NULL); + /* both 8, 12 and 16 bit JP2Ks are default to standard byte colorspace */ + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + /* configure the event callbacks (not required) */ memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); event_mgr.error_handler = error_callback; @@ -641,136 +647,67 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) switch (prec) { case 8: /* Convert blenders float color channels to 8, 12 or 16bit ints */ if (numcomps == 4) { - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0])); - g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1])); - b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2])); - a[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]); - } - PIXEL_LOOPER_END; - } - else { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[0]); - g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[1]); - b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[2]); - a[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]); - } - PIXEL_LOOPER_END; + PIXEL_LOOPER_BEGIN(rect_float) + { + r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0])); + g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1])); + b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2])); + a[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[3]); } + PIXEL_LOOPER_END; } else { - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0])); - g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1])); - b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2])); - } - PIXEL_LOOPER_END; - } - else { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[0]); - g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[1]); - b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(rect_float[2]); - } - PIXEL_LOOPER_END; + PIXEL_LOOPER_BEGIN(rect_float) + { + r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[0])); + g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[1])); + b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(linearrgb_to_srgb(rect_float[2])); } + PIXEL_LOOPER_END; } break; case 12: if (numcomps == 4) { - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0])); - g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1])); - b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2])); - a[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]); - } - PIXEL_LOOPER_END; - } - else { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[0]); - g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[1]); - b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[2]); - a[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]); - } - PIXEL_LOOPER_END; + PIXEL_LOOPER_BEGIN(rect_float) + { + r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0])); + g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1])); + b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2])); + a[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[3]); } + PIXEL_LOOPER_END; } else { - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0])); - g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1])); - b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2])); - } - PIXEL_LOOPER_END; - } - else { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[0]); - g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[1]); - b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(rect_float[2]); - } - PIXEL_LOOPER_END; + PIXEL_LOOPER_BEGIN(rect_float) + { + r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[0])); + g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[1])); + b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(linearrgb_to_srgb(rect_float[2])); } + PIXEL_LOOPER_END; } break; case 16: if (numcomps == 4) { - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0])); - g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1])); - b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2])); - a[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]); - } - PIXEL_LOOPER_END; - } - else { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[0]); - g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[1]); - b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[2]); - a[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]); - } - PIXEL_LOOPER_END; + PIXEL_LOOPER_BEGIN(rect_float) + { + r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0])); + g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1])); + b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2])); + a[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[3]); } + PIXEL_LOOPER_END; } else { - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0])); - g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1])); - b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2])); - } - PIXEL_LOOPER_END; - } - else { - PIXEL_LOOPER_BEGIN(rect_float) - { - r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[0]); - g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[1]); - b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(rect_float[2]); - } - PIXEL_LOOPER_END; + PIXEL_LOOPER_BEGIN(rect_float) + { + r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[0])); + g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[1])); + b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(linearrgb_to_srgb(rect_float[2])); } + PIXEL_LOOPER_END; } break; } diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 364950b99cb..61275a8937c 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -48,9 +48,12 @@ #include "jpeglib.h" #include "jerror.h" -#define IS_jpg(x) (x->ftype & JPG) +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + +// #define IS_jpg(x) (x->ftype & JPG) // UNUSED #define IS_stdjpg(x) ((x->ftype & JPG_MSK) == JPG_STD) -#define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID) +// #define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID) // UNUSED #define IS_jstjpg(x) ((x->ftype & JPG_MSK) == JPG_JST) #define IS_maxjpg(x) ((x->ftype & JPG_MSK) == JPG_MAX) @@ -435,21 +438,22 @@ next_stamp_marker: jpeg_destroy((j_common_ptr) cinfo); if (ibuf) { ibuf->ftype = ibuf_ftype; - ibuf->profile = IB_PROFILE_SRGB; } } return(ibuf); } -ImBuf *imb_load_jpeg(unsigned char *buffer, size_t size, int flags) +ImBuf *imb_load_jpeg(unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo; struct my_error_mgr jerr; ImBuf *ibuf; if (!imb_is_a_jpeg(buffer)) return NULL; - + + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + cinfo->err = jpeg_std_error(&jerr.pub); jerr.pub.error_exit = jpeg_error; diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c index 1ce2053fde5..fed55c05eea 100644 --- a/source/blender/imbuf/intern/metadata.c +++ b/source/blender/imbuf/intern/metadata.c @@ -63,7 +63,7 @@ void IMB_metadata_free(struct ImBuf *img) } } -int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, int len) +int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, const size_t len) { ImMetaData *info; int retval = 0; diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 78a989ad48f..d5aa635f548 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -386,7 +386,7 @@ ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey) void IMB_moviecache_free(MovieCache *cache) { - PRINT("%s: create '%s' free\n", __func__, cache->name); + PRINT("%s: cache '%s' free\n", __func__, cache->name); BLI_ghash_free(cache->hash, moviecache_keyfree, moviecache_valfree); diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 26aab29b8dd..13078921d1c 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -64,6 +64,9 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include "IMB_allocimbuf.h" #include "IMB_metadata.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + #include "openexr_multi.h" } @@ -379,30 +382,15 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags else { unsigned char *from; - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { - for (int i = ibuf->y - 1; i >= 0; i--) { - from = (unsigned char *)ibuf->rect + channels * i * width; + for (int i = ibuf->y - 1; i >= 0; i--) { + from = (unsigned char *)ibuf->rect + channels * i * width; - for (int j = ibuf->x; j > 0; j--) { - to->r = (float)(from[0]) / 255.0f; - to->g = (float)(from[1]) / 255.0f; - to->b = (float)(from[2]) / 255.0f; - to->a = (float)(channels >= 4) ? from[3] / 255.0f : 1.0f; - to++; from += 4; - } - } - } - else { - for (int i = ibuf->y - 1; i >= 0; i--) { - from = (unsigned char *)ibuf->rect + channels * i * width; - - for (int j = ibuf->x; j > 0; j--) { - to->r = srgb_to_linearrgb((float)from[0] / 255.0f); - to->g = srgb_to_linearrgb((float)from[1] / 255.0f); - to->b = srgb_to_linearrgb((float)from[2] / 255.0f); - to->a = channels >= 4 ? (float)from[3] / 255.0f : 1.0f; - to++; from += 4; - } + for (int j = ibuf->x; j > 0; j--) { + to->r = srgb_to_linearrgb((float)from[0] / 255.0f); + to->g = srgb_to_linearrgb((float)from[1] / 255.0f); + to->b = srgb_to_linearrgb((float)from[2] / 255.0f); + to->a = channels >= 4 ? (float)from[3] / 255.0f : 1.0f; + to++; from += 4; } } } @@ -1129,13 +1117,15 @@ static int exr_is_multilayer(InputFile *file) return 0; } -struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags) +struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf = NULL; InputFile *file = NULL; if (imb_is_a_openexr(mem) == 0) return(NULL); + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT); + try { Mem_IStream *membuf = new Mem_IStream(mem, size); @@ -1164,9 +1154,6 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags) ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0); ibuf->ftype = OPENEXR; - /* openEXR is linear as per EXR spec */ - ibuf->profile = IB_PROFILE_LINEAR_RGB; - if (!(flags & IB_test)) { if (is_multi) { /* only enters with IB_multilayer flag set */ /* constructs channels for reading, allocates memory in channels */ diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h index d12fe2fc49f..3135795fb3f 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.h +++ b/source/blender/imbuf/intern/openexr/openexr_api.h @@ -50,7 +50,7 @@ int imb_is_a_openexr (unsigned char *mem); int imb_save_openexr (struct ImBuf *ibuf, const char *name, int flags); -struct ImBuf *imb_load_openexr (unsigned char *mem, size_t size, int flags); +struct ImBuf *imb_load_openexr (unsigned char *mem, size_t size, int flags, char *colorspace); #ifdef __cplusplus } diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 92cd9622849..6310d8e105f 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -47,6 +47,9 @@ #include "IMB_metadata.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + typedef struct PNGReadStruct { unsigned char *data; unsigned int size; @@ -302,7 +305,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return(1); } -ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) +ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf = NULL; png_structp png_ptr; @@ -317,11 +320,13 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) unsigned char *from, *to; unsigned short *from16; float *to_float; - float tmp[4]; int i, bytesperpixel; if (imb_is_a_png(mem) == 0) return(NULL); + /* both 8 and 16 bit PNGs are default to standard byte colorspace */ + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { @@ -389,10 +394,6 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) if (ibuf) { ibuf->ftype = PNG; - if (bit_depth == 16) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - else - ibuf->profile = IB_PROFILE_SRGB; if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs)) { int unit_type; @@ -443,37 +444,33 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) switch (bytesperpixel) { case 4: for (i = ibuf->x * ibuf->y; i > 0; i--) { - tmp[0] = from16[0] / 65535.0; - tmp[1] = from16[1] / 65535.0; - tmp[2] = from16[2] / 65535.0; - tmp[3] = from16[3] / 65535.0; - srgb_to_linearrgb_v4(to_float, tmp); + to_float[0] = from16[0] / 65535.0; + to_float[1] = from16[1] / 65535.0; + to_float[2] = from16[2] / 65535.0; + to_float[3] = from16[3] / 65535.0; to_float += 4; from16 += 4; } break; case 3: for (i = ibuf->x * ibuf->y; i > 0; i--) { - tmp[0] = from16[0] / 65535.0; - tmp[1] = from16[1] / 65535.0; - tmp[2] = from16[2] / 65535.0; - tmp[3] = 1.0; - srgb_to_linearrgb_v4(to_float, tmp); + to_float[0] = from16[0] / 65535.0; + to_float[1] = from16[1] / 65535.0; + to_float[2] = from16[2] / 65535.0; + to_float[3] = 1.0; to_float += 4; from16 += 3; } break; case 2: for (i = ibuf->x * ibuf->y; i > 0; i--) { - tmp[0] = tmp[1] = tmp[2] = from16[0] / 65535.0; - tmp[3] = from16[1] / 65535.0; - srgb_to_linearrgb_v4(to_float, tmp); + to_float[0] = to_float[1] = to_float[2] = from16[0] / 65535.0; + to_float[3] = from16[1] / 65535.0; to_float += 4; from16 += 2; } break; case 1: for (i = ibuf->x * ibuf->y; i > 0; i--) { - tmp[0] = tmp[1] = tmp[2] = from16[0] / 65535.0; - tmp[3] = 1.0; - srgb_to_linearrgb_v4(to_float, tmp); + to_float[0] = to_float[1] = to_float[2] = from16[0] / 65535.0; + to_float[3] = 1.0; to_float += 4; from16++; } break; diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 4cd50484a64..5add372cd4e 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -53,6 +53,9 @@ #include "IMB_allocimbuf.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + /* needed constants */ #define MINELEN 8 #define MAXELEN 0x7fff @@ -171,7 +174,7 @@ int imb_is_a_hdr(unsigned char *buf) return 0; } -struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags) +struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf; RGBE *sline; @@ -184,6 +187,8 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags) char oriY[80], oriX[80]; if (imb_is_a_hdr((void *)mem)) { + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT); + /* find empty line, next line is resolution info */ for (x = 1; x < size; x++) { if ((mem[x - 1] == '\n') && (mem[x] == '\n')) { @@ -207,7 +212,6 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags) if (ibuf == NULL) return NULL; ibuf->ftype = RADHDR; - ibuf->profile = IB_PROFILE_LINEAR_RGB; if (flags & IB_test) return ibuf; diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 4bde71588b7..a1fa05d1098 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -54,20 +54,42 @@ #include "IMB_imbuf.h" #include "IMB_filetype.h" -ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, const char *descr) +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + +ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr) { ImBuf *ibuf; ImFileType *type; + char effective_colorspace[IM_MAX_SPACE] = ""; if (mem == NULL) { fprintf(stderr, "%s: NULL pointer\n", __func__); return NULL; } + if (colorspace) + BLI_strncpy(effective_colorspace, colorspace, sizeof(effective_colorspace)); + for (type = IMB_FILE_TYPES; type->is_a; type++) { if (type->load) { - ibuf = type->load(mem, size, flags); + ibuf = type->load(mem, size, flags, effective_colorspace); if (ibuf) { + if (colorspace) { + if (ibuf->rect) { + /* byte buffer is never internally converted to some standard space, + * store pointer to it's color space descriptor instead + */ + ibuf->rect_colorspace = colormanage_colorspace_get_named(effective_colorspace); + } + + BLI_strncpy(colorspace, effective_colorspace, IM_MAX_SPACE); + } + + /* OCIO_TODO: in some cases it's faster to do threaded conversion, + * but how to distinguish such cases */ + colormanage_imbuf_make_linear(ibuf, effective_colorspace); + if (flags & IB_premul) { IMB_premultiply_alpha(ibuf); ibuf->flags |= IB_premul; @@ -83,7 +105,7 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, const c return NULL; } -ImBuf *IMB_loadifffile(int file, int flags, const char *descr) +ImBuf *IMB_loadifffile(int file, int flags, char colorspace[IM_MAX_SPACE], const char *descr) { ImBuf *ibuf; unsigned char *mem; @@ -99,7 +121,7 @@ ImBuf *IMB_loadifffile(int file, int flags, const char *descr) return NULL; } - ibuf = IMB_ibImageFromMemory(mem, size, flags, descr); + ibuf = IMB_ibImageFromMemory(mem, size, flags, colorspace, descr); if (munmap(mem, size)) fprintf(stderr, "%s: couldn't unmap file %s\n", __func__, descr); @@ -122,7 +144,7 @@ static void imb_cache_filename(char *filename, const char *name, int flags) BLI_strncpy(filename, name, IB_FILENAME_SIZE); } -ImBuf *IMB_loadiffname(const char *filepath, int flags) +ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]) { ImBuf *ibuf; int file, a; @@ -133,7 +155,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags) file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0); if (file < 0) return NULL; - ibuf = IMB_loadifffile(file, flags, filepath_tx); + ibuf = IMB_loadifffile(file, flags, colorspace, filepath_tx); if (ibuf) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); @@ -148,7 +170,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags) return ibuf; } -ImBuf *IMB_testiffname(const char *filepath, int flags) +ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]) { ImBuf *ibuf; int file; @@ -159,7 +181,7 @@ ImBuf *IMB_testiffname(const char *filepath, int flags) file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0); if (file < 0) return NULL; - ibuf = IMB_loadifffile(file, flags | IB_test | IB_multilayer, filepath_tx); + ibuf = IMB_loadifffile(file, flags | IB_test | IB_multilayer, colorspace, filepath_tx); if (ibuf) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index c3e23246638..a11f16d5669 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -42,6 +42,7 @@ #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" +#include "IMB_colormanagement.h" /* blend modes */ @@ -486,7 +487,7 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4]) void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, - const float col[4], const int do_color_management, + const float col[4], struct ColorManagedDisplay *display, int x1, int y1, int x2, int y2) { int i, j; @@ -553,11 +554,12 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float col_conv[4]; float *pixel; - if (do_color_management) { - srgb_to_linearrgb_v4(col_conv, col); + if (display) { + copy_v4_v4(col_conv, col); + IMB_colormanagement_display_to_scene_linear_v3(col_conv, display); } else { - copy_v4_v4(col_conv, col); + srgb_to_linearrgb_v4(col_conv, col); } for (j = 0; j < y2 - y1; j++) { @@ -581,12 +583,10 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, } } -void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2) +void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2, struct ColorManagedDisplay *display) { - int do_color_management; if (!ibuf) return; - do_color_management = (ibuf->profile == IB_PROFILE_LINEAR_RGB); - buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, do_color_management, + buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, display, x1, y1, x2, y2); } diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 389c3c42b6d..527f334d6a4 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1051,7 +1051,7 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) sample -= 1.0f; } - } + } if (do_rect) { // printf("%ld %ld\n", (uchar *)rect - ((uchar *)ibuf->rect), rect_size); diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 4df49386ce1..253680e4bea 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -46,6 +46,8 @@ #include "IMB_allocimbuf.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" /* this one is only def-ed once, strangely... related to GS? */ #define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0]) @@ -546,22 +548,23 @@ partial_load: } -ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) +ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags, char colorspace[IM_MAX_SPACE]) { TARGA tga; struct ImBuf *ibuf; int col, count, size; unsigned int *rect, *cmap = NULL /*, mincol = 0*/, maxcol = 0; uchar *cp = (uchar *) &col; - + if (checktarga(&tga, mem) == 0) return(NULL); + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + if (flags & IB_test) ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, tga.pixsize, 0); else ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, (tga.pixsize + 0x7) & ~0x7, IB_rect); if (ibuf == NULL) return(NULL); ibuf->ftype = TGA; - ibuf->profile = IB_PROFILE_SRGB; mem = mem + 18 + tga.numid; cp[0] = 0xff; @@ -682,9 +685,11 @@ ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) } } - if (tga.imgdes & 0x20) IMB_flipy(ibuf); + if (tga.imgdes & 0x20) { + IMB_flipy(ibuf); + } - if (ibuf && ibuf->rect) + if (ibuf->rect) IMB_convert_rgba_to_abgr(ibuf); return(ibuf); diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 2a2aedb49ff..ff7218d649c 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -313,7 +313,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im img = IMB_loadblend_thumb(path); } else { - img = IMB_loadiffname(path, IB_rect | IB_metadata); + img = IMB_loadiffname(path, IB_rect | IB_metadata, NULL); } } @@ -326,7 +326,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im } else if (THB_SOURCE_MOVIE == source) { struct anim *anim = NULL; - anim = IMB_open_anim(path, IB_rect | IB_metadata, 0); + anim = IMB_open_anim(path, IB_rect | IB_metadata, 0, NULL); if (anim != NULL) { img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); if (img == NULL) { @@ -376,6 +376,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im } img->ftype = PNG; img->planes = 32; + if (IMB_saveiff(img, temp, IB_rect | IB_metadata)) { #ifndef WIN32 chmod(temp, S_IRUSR | S_IWUSR); @@ -401,7 +402,7 @@ ImBuf *IMB_thumb_read(const char *path, ThumbSize size) return NULL; } if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { - img = IMB_loadiffname(thumb, IB_rect | IB_metadata); + img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL); } return img; @@ -456,10 +457,10 @@ ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source) if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) { - img = IMB_loadiffname(path, IB_rect); + img = IMB_loadiffname(path, IB_rect, NULL); } else { - img = IMB_loadiffname(thumb, IB_rect | IB_metadata); + img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL); if (img) { char mtime[40]; if (!IMB_metadata_get_field(img, "Thumb::MTime", mtime, 40)) { diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index ac5f5da8a67..932a4941a0a 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -57,6 +57,9 @@ #include "IMB_filetype.h" #include "IMB_filter.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + #include "tiffio.h" #ifdef WIN32 @@ -464,8 +467,6 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) _TIFFfree(sbuf); if (success) { - ibuf->profile = (bitspersample == 32) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB; - /* Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) */ if (bitspersample < 16) if (ENDIAN_ORDER == B_ENDIAN) @@ -508,7 +509,7 @@ void imb_inittiff(void) * * \return: A newly allocated ImBuf structure if successful, otherwise NULL. */ -ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) +ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { TIFF *image = NULL; ImBuf *ibuf = NULL, *hbuf; @@ -527,6 +528,9 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) if (imb_is_a_tiff(mem) == 0) return NULL; + /* both 8 and 16 bit PNGs are default to standard byte colorspace */ + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + image = imb_tiff_client_open(&memFile, mem, size); if (image == NULL) { @@ -786,10 +790,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) /* convert from float source */ float rgb[4]; - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) - linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]); - else - copy_v3_v3(rgb, &fromf[from_i]); + linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]); rgb[3] = fromf[from_i + 3]; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 6d1e3c16631..833671e3f2f 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -225,7 +225,7 @@ static int isqtime(const char *name) static char ffmpeg_last_error[1024]; -void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg) +static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg) { if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) { size_t n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, arg); diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index 1c182e9784e..5d785e08212 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -38,8 +38,28 @@ #include "IMB_imbuf.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + #include "imbuf.h" +static ImBuf *prepare_write_imbuf(ImFileType *type, ImBuf *ibuf) +{ + ImBuf *write_ibuf = ibuf; + + if (type->flag & IM_FTYPE_FLOAT) { + /* pass */ + } + else { + if (ibuf->rect == NULL && ibuf->rect_float) { + ibuf->rect_colorspace = colormanage_colorspace_get_roled(COLOR_ROLE_DEFAULT_BYTE); + IMB_rect_from_float(ibuf); + } + } + + return write_ibuf; +} + short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) { ImFileType *type; @@ -49,11 +69,17 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) for (type = IMB_FILE_TYPES; type->is_a; type++) { if (type->save && type->ftype(type, ibuf)) { - if (!(type->flag & IM_FTYPE_FLOAT)) { - if (ibuf->rect == NULL && ibuf->rect_float) - IMB_rect_from_float(ibuf); - } - return type->save(ibuf, name, flags); + ImBuf *write_ibuf; + short result = FALSE; + + write_ibuf = prepare_write_imbuf(type, ibuf); + + result = type->save(write_ibuf, name, flags); + + if (write_ibuf != ibuf) + IMB_freeImBuf(write_ibuf); + + return result; } } diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index 4ead26c04f3..32a0629c338 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -160,6 +160,26 @@ typedef struct Scopes { #define SCOPES_WAVEFRM_YCC_709 3 #define SCOPES_WAVEFRM_YCC_JPEG 4 +typedef struct ColorManagedViewSettings { + int flag, pad; + char view_transform[64]; /* view transform which is being applied when displaying buffer on the screen */ + float exposure; /* fstop exposure */ + float gamma; /* post-display gamma transform */ + struct CurveMapping *curve_mapping; /* pre-display RGB curves transform */ + void *pad2; +} ColorManagedViewSettings; + +typedef struct ColorManagedDisplaySettings { + char display_device[64]; +} ColorManagedDisplaySettings; + +typedef struct ColorManagedColorspaceSettings { + char name[64]; /* MAX_COLORSPACE_NAME */ +} ColorManagedColorspaceSettings; + +/* ColorManagedViewSettings->flag */ +enum { + COLORMANAGE_VIEW_USE_CURVES = (1 << 0) +}; #endif - diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 377af042922..c22de3cb7eb 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -74,7 +74,7 @@ typedef struct CustomData { /* CustomData.type */ #define CD_MVERT 0 -#define CD_MSTICKY 1 +#define CD_MSTICKY 1 /* DEPRECATED */ #define CD_MDEFORMVERT 2 #define CD_MEDGE 3 #define CD_MFACE 4 @@ -118,7 +118,7 @@ typedef struct CustomData { /* Bits for CustomDataMask */ #define CD_MASK_MVERT (1 << CD_MVERT) -#define CD_MASK_MSTICKY (1 << CD_MSTICKY) +#define CD_MASK_MSTICKY (1 << CD_MSTICKY) /* DEPRECATED */ #define CD_MASK_MDEFORMVERT (1 << CD_MDEFORMVERT) #define CD_MASK_MEDGE (1 << CD_MEDGE) #define CD_MASK_MFACE (1 << CD_MFACE) diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index 4a4b21017db..38058dbb699 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -33,6 +33,7 @@ #define __DNA_IMAGE_TYPES_H__ #include "DNA_ID.h" +#include "DNA_color_types.h" /* for color management */ struct PackedFile; struct Scene; @@ -107,6 +108,9 @@ typedef struct Image { /* display aspect - for UV editing images resized for faster openGL display */ float aspx, aspy; + + /* color management */ + ColorManagedColorspaceSettings colorspace_settings; } Image; @@ -123,6 +127,7 @@ typedef struct Image { #define IMA_CM_PREDIVIDE 256 #define IMA_USED_FOR_RENDER 512 #define IMA_USER_FRAME_IN_RANGE 1024 /* for image user, but these flags are mixed */ +#define IMA_VIEW_AS_RENDER 2048 /* Image.tpageflag */ #define IMA_TILES 1 diff --git a/source/blender/makesdna/DNA_key_types.h b/source/blender/makesdna/DNA_key_types.h index 8494e663fbe..6e5861043c1 100644 --- a/source/blender/makesdna/DNA_key_types.h +++ b/source/blender/makesdna/DNA_key_types.h @@ -105,7 +105,7 @@ typedef struct Key { /* Key->type: KeyBlocks are interpreted as... */ enum { - /* Sequencial positions over time (using KeyBlock->pos and Key->ctime) */ + /* Sequential positions over time (using KeyBlock->pos and Key->ctime) */ KEY_NORMAL = 0, /* States to blend between (default) */ diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 1f185731e91..f3c527b6531 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -130,8 +130,11 @@ typedef struct Material { /* for buttons and render*/ char rgbsel, texact, pr_type, use_nodes; - short pr_back, pr_lamp, pr_texture, ml_flag; /* ml_flag is for disable base material */ + short pr_lamp, pr_texture, ml_flag; /* ml_flag is for disable base material */ + /* mapping */ + char mapflag, pad; + /* shaders */ short diff_shader, spec_shader; float roughness, refrac; @@ -140,6 +143,8 @@ typedef struct Material { float param[4]; /* size, smooth, size, smooth, for toonshader, 0 (fac) and 1 (fresnel) also for fresnel shader */ float rms; float darkness; + + /* runtime - OR'd from 'mtex' */ short texco, mapto; /* ramp colors */ @@ -173,7 +178,7 @@ typedef struct Material { short index; /* custom index for render passes */ short vcol_alpha; - short pad[3]; + short pad4[3]; ListBase gpumaterial; /* runtime */ } Material; @@ -274,6 +279,9 @@ typedef struct Material { #define MA_MODE_MASK 0x6fffffff /* all valid mode bits */ +/* mapflag */ +#define MA_MAPFLAG_UVPROJECT (1 << 0) + /* ray mirror fadeout */ #define MA_RAYMIR_FADETOSKY 0 #define MA_RAYMIR_FADETOMAT 1 @@ -340,7 +348,7 @@ typedef struct Material { #define TEXCO_OBJECT 32 #define TEXCO_LAVECTOR 64 #define TEXCO_VIEW 128 -#define TEXCO_STICKY 256 +#define TEXCO_STICKY_ 256 // DEPRECATED #define TEXCO_OSA 512 #define TEXCO_WINDOW 1024 #define NEED_UV 2048 diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 5408e865ab2..1196ce20a6b 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -89,8 +89,7 @@ typedef struct Mesh { /* array of colors for the tessellated faces, must be number of tessellated * faces * 4 in length */ - struct MCol *mcol; - struct MSticky *msticky; + struct MCol *mcol; struct Mesh *texcomesh; /* When the object is available, the preferred access method is: BMEdit_FromObject(ob) */ diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 3c89e069ea0..f28c0328acc 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -119,7 +119,8 @@ typedef struct MLoopUV { #define MLOOPUV_PINNED 4 /* at the moment alpha is abused for vertex painting - * and not used for transparency, note that red and blue are swapped */ + * and not used for transparency, + * note that red and blue are _not_ swapped, as they are with #MCol */ typedef struct MLoopCol { char r, g, b, a; } MLoopCol; @@ -145,13 +146,9 @@ typedef struct MLoopCol { mcol__tmp->a = mloopcol__tmp->a; \ } (void)0 -typedef struct MSticky { - float co[2]; -} MSticky; - typedef struct MSelect { int index; - int type; /* EDITVERT/EDITEDGE/EDITFACE */ + int type; /* ME_VSEL/ME_ESEL/ME_FSEL */ } MSelect; /*tessellation uv face data*/ diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h index d8bba4a3bf5..cda51779528 100644 --- a/source/blender/makesdna/DNA_movieclip_types.h +++ b/source/blender/makesdna/DNA_movieclip_types.h @@ -37,6 +37,7 @@ #include "DNA_ID.h" #include "DNA_tracking_types.h" +#include "DNA_color_types.h" /* for color management */ struct anim; struct AnimData; @@ -94,6 +95,9 @@ typedef struct MovieClip { /* from a file. affects only a way how scene frame is mapping */ /* to a file name and not touches other data associated with */ /* a clip */ + + /* color management */ + ColorManagedColorspaceSettings colorspace_settings; } MovieClip; typedef struct MovieClipScopes { diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 9b347a71140..3f8f043efad 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -41,6 +41,7 @@ extern "C" { #endif +#include "DNA_color_types.h" /* color management */ #include "DNA_vec_types.h" #include "DNA_listBase.h" #include "DNA_ID.h" @@ -278,6 +279,9 @@ typedef struct ImageFormatData { char pad[7]; + /* color management */ + ColorManagedViewSettings view_settings; + ColorManagedDisplaySettings display_settings; } ImageFormatData; @@ -834,14 +838,15 @@ typedef struct VPaint { void *paintcursor; /* wm handle */ } VPaint; -/* VPaint flag */ -#define VP_COLINDEX 1 -#define VP_AREA 2 /* vertex paint only */ - -#define VP_NORMALS 8 -#define VP_SPRAY 16 -// #define VP_MIRROR_X 32 // deprecated in 2.5x use (me->editflag & ME_EDIT_MIRROR_X) -#define VP_ONLYVGROUP 128 /* weight paint only */ +/* VPaint.flag */ +enum { + // VP_COLINDEX = (1 << 0), /* only paint onto active material*/ /* deprecated since before 2.49 */ + VP_AREA = (1 << 1), + VP_NORMALS = (1 << 3), + VP_SPRAY = (1 << 4), + // VP_MIRROR_X = (1 << 5), /* deprecated in 2.5x use (me->editflag & ME_EDIT_MIRROR_X) */ + VP_ONLYVGROUP = (1 << 7) /* weight paint only */ +}; /* *************************************************************** */ /* Transform Orientations */ @@ -1142,6 +1147,11 @@ typedef struct Scene { uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by BKE_object_handle_update() */ uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ + + /* Color Management */ + ColorManagedViewSettings view_settings; + ColorManagedDisplaySettings display_settings; + ColorManagedColorspaceSettings sequencer_colorspace_settings; } Scene; @@ -1264,7 +1274,7 @@ typedef struct Scene { #define R_ALPHAKEY 2 /* color_mgt_flag */ -#define R_COLOR_MANAGEMENT (1 << 0) +#define R_COLOR_MANAGEMENT (1 << 0) /* deprecated, should only be used in versioning code only */ #define R_COLOR_MANAGEMENT_PREDIVIDE (1 << 1) /* subimtype, flag options for imtype */ diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index d094c1d6255..4d259fad246 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -275,6 +275,18 @@ typedef struct BrightContrastModifierData { float contrast; } BrightContrastModifierData; +/* ***************** Scopes ****************** */ + +typedef struct SequencerScopes { + struct ImBuf *reference_ibuf; + + struct ImBuf *zebra_ibuf; + struct ImBuf *waveform_ibuf; + struct ImBuf *sep_waveform_ibuf; + struct ImBuf *vector_ibuf; + struct ImBuf *histogram_ibuf; +} SequencerScopes; + #define MAXSEQ 32 #define SELECT 1 @@ -317,6 +329,7 @@ typedef struct BrightContrastModifierData { #define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21) #define SEQ_USE_EFFECT_DEFAULT_FADE (1 << 22) +#define SEQ_USE_LINEAR_MODIFIERS (1 << 23) // flags for whether those properties are animated or not #define SEQ_AUDIO_VOLUME_ANIMATED (1 << 24) diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index b828247c816..6cc4541f19e 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -40,6 +40,7 @@ #include "DNA_outliner_types.h" /* for TreeStoreElem */ #include "DNA_image_types.h" /* ImageUser */ #include "DNA_movieclip_types.h" /* MovieClipUser */ +#include "DNA_sequence_types.h" /* SequencerScopes */ /* Hum ... Not really nice... but needed for spacebuts. */ #include "DNA_view2d_types.h" @@ -473,6 +474,8 @@ typedef struct SpaceSeq { int overlay_type; struct bGPdata *gpd; /* grease-pencil data */ + + struct SequencerScopes scopes; /* different scoped displayed in space */ } SpaceSeq; @@ -685,8 +688,9 @@ typedef struct SpaceImage { struct Image *image; struct ImageUser iuser; - struct CurveMapping *cumap; - + + struct CurveMapping *cumap DNA_DEPRECATED; /* was switched to scene's color management settings */ + struct Scopes scopes; /* histogram waveform and vectorscope */ struct Histogram sample_line_hist; /* sample line histogram */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index ac7a5a748e9..fe3fd10b680 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -104,6 +104,9 @@ extern StructRNA RNA_CollectionProperty; extern StructRNA RNA_CollisionModifier; extern StructRNA RNA_CollisionSensor; extern StructRNA RNA_CollisionSettings; +extern StructRNA RNA_ColorManagedColorspaceSettings; +extern StructRNA RNA_ColorManagedDisplaySettings; +extern StructRNA RNA_ColorManagedViewSettings; extern StructRNA RNA_ColorRamp; extern StructRNA RNA_ColorRampElement; extern StructRNA RNA_ColorSequence; diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 4a27761b8d2..2c3bc0360fc 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -259,7 +259,7 @@ StructRNA *rna_PropertyGroup_refine(PointerRNA *ptr) return ptr->type; } -ID *rna_ID_copy(ID *id) +static ID *rna_ID_copy(ID *id) { ID *newid; @@ -312,7 +312,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) DAG_id_tag_update(id, flag); } -void rna_ID_user_clear(ID *id) +static void rna_ID_user_clear(ID *id) { id->us = 0; /* don't save */ id->flag &= ~LIB_FAKEUSER; @@ -344,7 +344,7 @@ int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assig } } -void rna_IDMaterials_append_id(ID *id, Material *ma) +static void rna_IDMaterials_append_id(ID *id, Material *ma) { material_append_id(id, ma); @@ -352,7 +352,7 @@ void rna_IDMaterials_append_id(ID *id, Material *ma) WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id); } -Material *rna_IDMaterials_pop_id(ID *id, int index_i, int remove_material_slot) +static Material *rna_IDMaterials_pop_id(ID *id, int index_i, int remove_material_slot) { Material *ma = material_pop_id(id, index_i, remove_material_slot); @@ -363,7 +363,7 @@ Material *rna_IDMaterials_pop_id(ID *id, int index_i, int remove_material_slot) return ma; } -void rna_Library_filepath_set(PointerRNA *ptr, const char *value) +static void rna_Library_filepath_set(PointerRNA *ptr, const char *value) { Library *lib = (Library *)ptr->data; BKE_library_filepath_set(lib, value); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 4c1c377cb9f..c88944b4584 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -233,7 +233,7 @@ static void rna_idproperty_touch(IDProperty *idprop) } /* return a UI local ID prop definition for this prop */ -IDProperty *rna_idproperty_ui(PropertyRNA *prop) +static IDProperty *rna_idproperty_ui(PropertyRNA *prop) { IDProperty *idprop; @@ -618,7 +618,7 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier) } /* Find the property which uses the given nested struct */ -PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna) +static PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna) { PropertyRNA *prop = NULL; diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index bb714043002..12a41f213b7 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -29,6 +29,7 @@ #include "RNA_define.h" #include "RNA_access.h" +#include "RNA_enum_types.h" #include "rna_internal.h" #include "DNA_constraint_types.h" @@ -110,7 +111,7 @@ static StructRNA *rna_Actuator_refine(struct PointerRNA *ptr) } } -void rna_Actuator_name_set(PointerRNA *ptr, const char *value) +static void rna_Actuator_name_set(PointerRNA *ptr, const char *value) { bActuator *act = (bActuator *)ptr->data; @@ -530,7 +531,7 @@ static void rna_Actuator_action_action_set(PointerRNA *ptr, PointerRNA value) #else -void rna_def_actuator(BlenderRNA *brna) +static void rna_def_actuator(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 69f785c32de..d50cb663b97 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -829,7 +829,7 @@ void rna_def_animdata_common(StructRNA *srna) RNA_def_property_ui_text(prop, "Animation Data", "Animation data for this datablock"); } -void rna_def_animdata(BlenderRNA *brna) +static void rna_def_animdata(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c index 32472c8d415..39128b48cd8 100644 --- a/source/blender/makesrna/intern/rna_animation_api.c +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -39,6 +39,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "rna_internal.h" /* own include */ #ifdef RNA_RUNTIME diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index be70405d165..a645930f09a 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -100,7 +100,7 @@ static void rna_Armature_act_edit_bone_set(PointerRNA *ptr, PointerRNA value) } } -EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, const char *name) +static EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, const char *name) { if (arm->edbo == NULL) { BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant add an editbone", arm->id.name + 2); @@ -109,7 +109,7 @@ EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, const return ED_armature_edit_bone_add(arm, name); } -void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone *ebone) +static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone *ebone) { if (arm->edbo == NULL) { BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant remove an editbone", arm->id.name + 2); diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c index 29dc23b7bef..96c5350e5b7 100644 --- a/source/blender/makesrna/intern/rna_armature_api.c +++ b/source/blender/makesrna/intern/rna_armature_api.c @@ -36,18 +36,20 @@ #include "RNA_define.h" +#include "rna_internal.h" /* own include */ + #ifdef RNA_RUNTIME #include <stddef.h> #include "BKE_armature.h" -void rna_EditBone_align_roll(EditBone *ebo, float no[3]) +static void rna_EditBone_align_roll(EditBone *ebo, float no[3]) { ebo->roll = ED_rollBoneToVector(ebo, no, FALSE); } -float rna_Bone_do_envelope(Bone *bone, float *vec) +static float rna_Bone_do_envelope(Bone *bone, float *vec) { float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f; return distfactor_to_bone(vec, bone->arm_head, bone->arm_tail, bone->rad_head * scale, diff --git a/source/blender/makesrna/intern/rna_camera_api.c b/source/blender/makesrna/intern/rna_camera_api.c index 75941fa224f..bf916806e40 100644 --- a/source/blender/makesrna/intern/rna_camera_api.c +++ b/source/blender/makesrna/intern/rna_camera_api.c @@ -31,6 +31,8 @@ #include "RNA_define.h" +#include "rna_internal.h" /* own include */ + #ifdef RNA_RUNTIME #include "DNA_scene_types.h" @@ -39,8 +41,8 @@ #include "BKE_context.h" #include "BKE_object.h" -void rna_camera_view_frame(struct Camera *camera, struct Scene *scene, - float vec1_r[3], float vec2_r[3], float vec3_r[3], float vec4_r[3]) +static void rna_camera_view_frame(struct Camera *camera, struct Scene *scene, + float vec1_r[3], float vec2_r[3], float vec3_r[3], float vec4_r[3]) { float vec[4][3]; diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index a0690047754..bf8b687139b 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -34,26 +34,32 @@ #include "DNA_color_types.h" #include "DNA_texture_types.h" +#include "WM_api.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME #include "RNA_access.h" +#include "DNA_image_types.h" #include "DNA_material_types.h" +#include "DNA_movieclip_types.h" #include "DNA_node_types.h" #include "MEM_guardedalloc.h" #include "BKE_colortools.h" #include "BKE_depsgraph.h" +#include "BKE_image.h" +#include "BKE_movieclip.h" #include "BKE_node.h" #include "BKE_texture.h" #include "BKE_linestyle.h" -#include "WM_api.h" -#include "WM_types.h" - #include "ED_node.h" +#include "IMB_colormanagement.h" + static int rna_CurveMapping_curves_length(PointerRNA *ptr) { CurveMapping *cumap = (CurveMapping *)ptr->data; @@ -367,8 +373,162 @@ static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointer s->ok = 0; } +static int rna_ColorManagedDisplaySettings_display_device_get(struct PointerRNA *ptr) +{ + ColorManagedDisplaySettings *display = (ColorManagedDisplaySettings *) ptr->data; + + return IMB_colormanagement_display_get_named_index(display->display_device); +} + +static void rna_ColorManagedDisplaySettings_display_device_set(struct PointerRNA *ptr, int value) +{ + ColorManagedDisplaySettings *display = (ColorManagedDisplaySettings *) ptr->data; + const char *name = IMB_colormanagement_display_get_indexed_name(value); + + if (name) { + BLI_strncpy(display->display_device, name, sizeof(display->display_device)); + } +} + +static EnumPropertyItem *rna_ColorManagedDisplaySettings_display_device_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) +{ + EnumPropertyItem *items = NULL; + int totitem = 0; + + IMB_colormanagement_display_items_add(&items, &totitem); + RNA_enum_item_end(&items, &totitem); + + *free = TRUE; + + return items; +} + +static void rna_ColorManagedDisplaySettings_display_device_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + ID *id = ptr->id.data; + + if (!id) + return; + + if (GS(id->name) == ID_SCE) { + Scene *scene = (Scene *) id; + + IMB_colormanagement_validate_settings(&scene->display_settings, &scene->view_settings); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); + } +} + +static int rna_ColorManagedViewSettings_view_transform_get(PointerRNA *ptr) +{ + ColorManagedViewSettings *view = (ColorManagedViewSettings *) ptr->data; + + return IMB_colormanagement_view_get_named_index(view->view_transform); +} + +static void rna_ColorManagedViewSettings_view_transform_set(PointerRNA *ptr, int value) +{ + ColorManagedViewSettings *view = (ColorManagedViewSettings *) ptr->data; + + const char *name = IMB_colormanagement_view_get_indexed_name(value); + + if (name) { + BLI_strncpy(view->view_transform, name, sizeof(view->view_transform)); + } +} + +static EnumPropertyItem* rna_ColorManagedViewSettings_view_transform_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) +{ + Scene *scene = CTX_data_scene(C); + EnumPropertyItem *items = NULL; + ColorManagedDisplaySettings *display_settings = &scene->display_settings; + int totitem = 0; + + IMB_colormanagement_view_items_add(&items, &totitem, display_settings->display_device); + RNA_enum_item_end(&items, &totitem); + + *free = TRUE; + return items; +} + +static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, int value) +{ + ColorManagedViewSettings *view_settings = (ColorManagedViewSettings *) ptr->data; + + if (value) { + view_settings->flag |= COLORMANAGE_VIEW_USE_CURVES; + + if (view_settings->curve_mapping == NULL) { + view_settings->curve_mapping = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + } + } + else { + view_settings->flag &= ~COLORMANAGE_VIEW_USE_CURVES; + } +} + +static int rna_ColorManagedColorspaceSettings_colorspace_get(struct PointerRNA *ptr) +{ + ColorManagedColorspaceSettings *colorspace = (ColorManagedColorspaceSettings *) ptr->data; + + return IMB_colormanagement_colorspace_get_named_index(colorspace->name); +} + +static void rna_ColorManagedColorspaceSettings_colorspace_set(struct PointerRNA *ptr, int value) +{ + ColorManagedColorspaceSettings *colorspace = (ColorManagedColorspaceSettings *) ptr->data; + const char *name = IMB_colormanagement_colorspace_get_indexed_name(value); + + if (name) { + BLI_strncpy(colorspace->name, name, sizeof(colorspace->name)); + } +} + +static EnumPropertyItem *rna_ColorManagedColorspaceSettings_colorspace_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) +{ + EnumPropertyItem *items = NULL; + int totitem = 0; + + IMB_colormanagement_colorspace_items_add(&items, &totitem); + RNA_enum_item_end(&items, &totitem); + + *free = TRUE; + + return items; +} + +static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + ID *id = ptr->id.data; + + if (GS(id->name) == ID_IM) { + Image *ima = (Image *) id; + + BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); + WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id); + } + else if (GS(id->name) == ID_MC) { + MovieClip *clip = (MovieClip *) id; + + BKE_movieclip_reload(clip); + WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id); + } +} + +static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + ID *id = ptr->id.data; + + if (!id) + return; + + if (GS(id->name) == ID_SCE) { + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); + } +} + /* this function only exists because #curvemap_evaluateF uses a 'const' qualifier */ -float rna_CurveMap_evaluateF(struct CurveMap *cuma, float value) +static float rna_CurveMap_evaluateF(struct CurveMap *cuma, float value) { return curvemap_evaluateF(cuma, value); } @@ -712,6 +872,87 @@ static void rna_def_scopes(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vectorscope Opacity", "Opacity of the points"); } +static void rna_def_colormanage(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem display_device_items[] = { + {0, "DEFAULT", 0, "Default", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem view_transform_items[] = { + {0, "NONE", 0, "None", "Do not perform any color transform on display, use old non-color managed technique for display"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem color_space_items[] = { + {0, "NONE", 0, "None", "Do not perform any color transform on load, treat colors as in scene linear space already"}, + {0, NULL, 0, NULL, NULL} + }; + + /* ** Display Settings ** */ + srna = RNA_def_struct(brna, "ColorManagedDisplaySettings", NULL); + RNA_def_struct_ui_text(srna, "ColorManagedDisplaySettings", "Color management specific to display device"); + + prop= RNA_def_property(srna, "display_device", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, display_device_items); + RNA_def_property_enum_funcs(prop, "rna_ColorManagedDisplaySettings_display_device_get", + "rna_ColorManagedDisplaySettings_display_device_set", + "rna_ColorManagedDisplaySettings_display_device_itemf"); + RNA_def_property_ui_text(prop, "Display Device", "Display device name"); + RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedDisplaySettings_display_device_update"); + + /* ** View Settings ** */ + srna = RNA_def_struct(brna, "ColorManagedViewSettings", NULL); + RNA_def_struct_ui_text(srna, "ColorManagedViewSettings", "Color management settings used for displaying images on the display"); + + prop= RNA_def_property(srna, "view_transform", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, view_transform_items); + RNA_def_property_enum_funcs(prop, "rna_ColorManagedViewSettings_view_transform_get", + "rna_ColorManagedViewSettings_view_transform_set", + "rna_ColorManagedViewSettings_view_transform_itemf"); + RNA_def_property_ui_text(prop, "View Transform", "View used "); + RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update"); + + prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "exposure"); + RNA_def_property_range(prop, -10.0f, 10.0f); + RNA_def_property_float_default(prop, 0.0f); + RNA_def_property_ui_text(prop, "Exposure", "Exposure (stops) applied before display transform"); + RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update"); + + prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "gamma"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.0f, 5.0f); + RNA_def_property_ui_text(prop, "Gamma", "Amount of gamma modification applied after display transform"); + RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update"); + + prop = RNA_def_property(srna, "curve_mapping", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "curve_mapping"); + RNA_def_property_ui_text(prop, "Curve", "Color curve mapping applied before display transform"); + RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update"); + + prop = RNA_def_property(srna, "use_curve_mapping", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", COLORMANAGE_VIEW_USE_CURVES); + RNA_def_property_boolean_funcs(prop, NULL, "rna_ColorManagedViewSettings_use_curves_set"); + RNA_def_property_ui_text(prop, "Use Curves", "Use RGB curved for pre-display transformation"); + RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update"); + + /* ** Colorspace ** */ + srna = RNA_def_struct(brna, "ColorManagedColorspaceSettings", NULL); + RNA_def_struct_ui_text(srna, "ColorManagedColorspaceSettings", "Input color space settings"); + + prop= RNA_def_property(srna, "name", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_enum_funcs(prop, "rna_ColorManagedColorspaceSettings_colorspace_get", + "rna_ColorManagedColorspaceSettings_colorspace_set", + "rna_ColorManagedColorspaceSettings_colorspace_itemf"); + RNA_def_property_ui_text(prop, "Color Space", "Input color space name"); + RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedColorspaceSettings_reload_update"); +} void RNA_def_color(BlenderRNA *brna) { @@ -722,6 +963,7 @@ void RNA_def_color(BlenderRNA *brna) rna_def_color_ramp(brna); rna_def_histogram(brna); rna_def_scopes(brna); + rna_def_colormanage(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index 44c8a2b412b..aef1f765fe2 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -77,7 +77,7 @@ static StructRNA *rna_Controller_refine(struct PointerRNA *ptr) } } -void rna_Constroller_name_set(PointerRNA *ptr, const char *value) +static void rna_Constroller_name_set(PointerRNA *ptr, const char *value) { bController *cont = (bController *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_controller_api.c b/source/blender/makesrna/intern/rna_controller_api.c index 6fe90e1721b..639d6a330a5 100644 --- a/source/blender/makesrna/intern/rna_controller_api.c +++ b/source/blender/makesrna/intern/rna_controller_api.c @@ -35,6 +35,8 @@ #include "WM_types.h" #include "RNA_define.h" +#include "rna_internal.h" /* own include */ + #ifdef RNA_RUNTIME #include "BKE_sca.h" diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index b2a2bab0f4b..c47cb8ef2af 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -432,20 +432,20 @@ static void rna_Curve_offset_set(PointerRNA *ptr, float value) } /* name functions that ignore the first two ID characters */ -void rna_Curve_body_get(PointerRNA *ptr, char *value) +static void rna_Curve_body_get(PointerRNA *ptr, char *value) { Curve *cu = (Curve *)ptr->id.data; BLI_strncpy(value, cu->str, cu->len + 1); } -int rna_Curve_body_length(PointerRNA *ptr) +static int rna_Curve_body_length(PointerRNA *ptr) { Curve *cu = (Curve *)ptr->id.data; return cu->len; } /* TODO - check UTF & python play nice */ -void rna_Curve_body_set(PointerRNA *ptr, const char *value) +static void rna_Curve_body_set(PointerRNA *ptr, const char *value) { int len = strlen(value); Curve *cu = (Curve *)ptr->id.data; diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index a0d64723a5c..24b14fdb884 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -403,13 +403,13 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value) } } -DriverVar *rna_Driver_new_variable(ChannelDriver *driver) +static DriverVar *rna_Driver_new_variable(ChannelDriver *driver) { /* call the API function for this */ return driver_add_new_variable(driver); } -void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar) +static void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar) { if (BLI_findindex(&driver->variables, dvar) == -1) { BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver"); diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index eb12a02aa99..131611d3002 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -90,7 +90,7 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value) } } -void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) +static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) { bGPdata *gpd = ptr->id.data; bGPDlayer *gpl = ptr->data; diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 62a06888613..fdab874cf01 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -147,7 +147,7 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA * } -char *rna_ImageUser_path(PointerRNA *ptr) +static char *rna_ImageUser_path(PointerRNA *ptr) { if (ptr->id.data) { /* ImageUser *iuser= ptr->data; */ @@ -513,6 +513,11 @@ static void rna_def_image(BlenderRNA *brna) "to avoid fringing for images with light backgrounds"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_free_update"); + prop = RNA_def_property(srna, "view_as_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER); + RNA_def_property_ui_text(prop, "View as Render", "Apply render part of display transformation when displaying this image on the screen"); + RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -652,6 +657,11 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length"); RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", NULL); + prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "colorspace_settings"); + RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings"); + RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings"); + RNA_api_image(srna); } diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index fa3f8d69c47..c66c0085763 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -50,6 +50,7 @@ #include "BKE_global.h" /* grr: G.main->name */ #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" #include "BIF_gl.h" #include "GPU_draw.h" @@ -80,16 +81,17 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports BKE_reportf(reports, RPT_ERROR, "Couldn't acquire buffer from image"); } else { - /* temp swap out the color */ - const unsigned char imb_planes_back = ibuf->planes; - const float dither_back = ibuf->dither; - ibuf->planes = scene->r.im_format.planes; - ibuf->dither = scene->r.dither_intensity; - if (!BKE_imbuf_write(ibuf, path, &scene->r.im_format)) { + ImBuf *write_ibuf = IMB_dupImBuf(ibuf); + + IMB_display_buffer_to_imbuf_rect(write_ibuf, &scene->view_settings, &scene->display_settings); + + write_ibuf->planes = scene->r.im_format.planes; + 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); } - ibuf->planes = imb_planes_back; - ibuf->dither = dither_back; + IMB_freeImBuf(write_ibuf); } BKE_image_release_ibuf(image, lock); @@ -118,6 +120,8 @@ static void rna_Image_save(Image *image, ReportList *reports) if (image->source == IMA_SRC_GENERATED) image->source = IMA_SRC_FILE; + IMB_colormanagment_colorspace_from_ibuf_ftype(&image->colorspace_settings, ibuf); + ibuf->userflags &= ~IB_BITMAPDIRTY; } else { diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index a4582406c10..b85688e156c 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -34,8 +34,14 @@ #define RNA_MAGIC ((int)~0) +struct ColorBand; struct ID; struct IDProperty; +struct Main; +struct Mesh; +struct Object; +struct RenderEngine; +struct ReportList; struct SDNA; struct Sequence; @@ -400,6 +406,22 @@ void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct Re int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct PointerRNA *assign_ptr); + +/* 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); +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_key.c b/source/blender/makesrna/intern/rna_key.c index 5334c10c4c6..33bbaeec282 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -61,12 +61,12 @@ static Key *rna_ShapeKey_find_key(ID *id) case ID_KE: return (Key *)id; case ID_LT: return ((Lattice *)id)->key; case ID_ME: return ((Mesh *)id)->key; - case ID_OB: return ob_get_key((Object *)id); + case ID_OB: return BKE_key_from_object((Object *)id); default: return NULL; } } -void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value) +static void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value) { KeyBlock *kb = ptr->data; char oldname[sizeof(kb->name)]; @@ -360,7 +360,7 @@ static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *p Object *ob; for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (ob_get_key(ob) == key) { + if (BKE_key_from_object(ob) == key) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 2d26fec0d50..100485dd714 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -96,13 +96,13 @@ #include "ED_screen.h" -Camera *rna_Main_cameras_new(Main *UNUSED(bmain), const char *name) +static Camera *rna_Main_cameras_new(Main *UNUSED(bmain), const char *name) { ID *id = BKE_camera_add(name); id_us_min(id); return (Camera *)id; } -void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) +static void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) { if (ID_REAL_USERS(camera) <= 0) BKE_libblock_free(&bmain->camera, camera); @@ -113,11 +113,11 @@ void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *ca /* XXX python now has invalid pointer? */ } -Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name) +static Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name) { return BKE_scene_add(name); } -void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene) +static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene) { /* don't call BKE_libblock_free(...) directly */ Scene *newscene; @@ -137,7 +137,7 @@ void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struc BKE_scene_unlink(bmain, scene, newscene); } -Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data) +static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data) { Object *ob; int type = OB_EMPTY; @@ -191,7 +191,7 @@ Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const cha return ob; } -void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) +static void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) { if (ID_REAL_USERS(object) <= 0) { BKE_object_unlink(object); /* needed or ID pointers to this are not cleared */ @@ -203,13 +203,13 @@ void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *ob } } -Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name) +static Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name) { ID *id = (ID *)BKE_material_add(name); id_us_min(id); return (Material *)id; } -void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) +static void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) { if (ID_REAL_USERS(material) <= 0) BKE_libblock_free(&bmain->mat, material); @@ -220,14 +220,14 @@ void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material /* XXX python now has invalid pointer? */ } -bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, int type) +static bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, int type) { bNodeTree *tree = ntreeAddTree(name, type, NODE_GROUP); id_us_min(&tree->id); return tree; } -void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree) +static void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree) { if (ID_REAL_USERS(tree) <= 0) BKE_libblock_free(&bmain->nodetree, tree); @@ -238,7 +238,7 @@ void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree /* XXX python now has invalid pointer? */ } -Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name) +static Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name) { Mesh *me = BKE_mesh_add(name); id_us_min(&me->id); @@ -255,14 +255,14 @@ void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) /* XXX python now has invalid pointer? */ } -Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type) +static Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type) { Lamp *lamp = BKE_lamp_add(name); lamp->type = type; id_us_min(&lamp->id); return lamp; } -void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) +static void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) { if (ID_REAL_USERS(lamp) <= 0) BKE_libblock_free(&bmain->lamp, lamp); @@ -273,14 +273,14 @@ void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) /* XXX python now has invalid pointer? */ } -Image *rna_Main_images_new(Main *UNUSED(bmain), const char *name, int width, int height, int alpha, int float_buffer) +static Image *rna_Main_images_new(Main *UNUSED(bmain), const char *name, int width, int height, int alpha, int float_buffer) { float color[4] = {0.0, 0.0, 0.0, 1.0}; Image *image = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, float_buffer, 0, color); id_us_min(&image->id); return image; } -Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath) +static Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath) { Image *ima; @@ -293,7 +293,7 @@ Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char return ima; } -void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) +static void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) { if (ID_REAL_USERS(image) <= 0) BKE_libblock_free(&bmain->image, image); @@ -304,13 +304,13 @@ void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) /* XXX python now has invalid pointer? */ } -Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name) +static Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name) { Lattice *lt = BKE_lattice_add(name); id_us_min(<->id); return lt; } -void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt) +static void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt) { if (ID_REAL_USERS(lt) <= 0) BKE_libblock_free(&bmain->latt, lt); @@ -319,13 +319,13 @@ void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice * lt->id.name + 2, ID_REAL_USERS(lt)); } -Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int type) +static Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int type) { Curve *cu = BKE_curve_add(name, type); id_us_min(&cu->id); return cu; } -void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) +static void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) { if (ID_REAL_USERS(cu) <= 0) BKE_libblock_free(&bmain->curve, cu); @@ -334,13 +334,13 @@ void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) cu->id.name + 2, ID_REAL_USERS(cu)); } -MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name) +static MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name) { MetaBall *mb = BKE_mball_add(name); id_us_min(&mb->id); return mb; } -void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb) +static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb) { if (ID_REAL_USERS(mb) <= 0) BKE_libblock_free(&bmain->mball, mb); @@ -349,7 +349,7 @@ void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall mb->id.name + 2, ID_REAL_USERS(mb)); } -VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath) +static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath) { VFont *font; @@ -363,7 +363,7 @@ VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepat return font; } -void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont) +static void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont) { if (ID_REAL_USERS(vfont) <= 0) BKE_libblock_free(&bmain->vfont, vfont); @@ -374,14 +374,14 @@ void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont) /* XXX python now has invalid pointer? */ } -Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int type) +static Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int type) { Tex *tex = add_texture(name); tex_set_type(tex, type); id_us_min(&tex->id); return tex; } -void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) +static void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) { if (ID_REAL_USERS(tex) <= 0) BKE_libblock_free(&bmain->tex, tex); @@ -390,13 +390,13 @@ void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) tex->id.name + 2, ID_REAL_USERS(tex)); } -Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name) +static Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name) { Brush *brush = BKE_brush_add(name); id_us_min(&brush->id); return brush; } -void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush) +static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush) { if (ID_REAL_USERS(brush) <= 0) BKE_libblock_free(&bmain->brush, brush); @@ -405,13 +405,13 @@ void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *bru brush->id.name + 2, ID_REAL_USERS(brush)); } -World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name) +static World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name) { World *world = add_world(name); id_us_min(&world->id); return world; } -void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world) +static void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world) { if (ID_REAL_USERS(world) <= 0) BKE_libblock_free(&bmain->world, world); @@ -420,24 +420,24 @@ void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *worl world->id.name + 2, ID_REAL_USERS(world)); } -Group *rna_Main_groups_new(Main *UNUSED(bmain), const char *name) +static Group *rna_Main_groups_new(Main *UNUSED(bmain), const char *name) { return add_group(name); } -void rna_Main_groups_remove(Main *bmain, Group *group) +static void rna_Main_groups_remove(Main *bmain, Group *group) { BKE_group_unlink(group); BKE_libblock_free(&bmain->group, group); /* XXX python now has invalid pointer? */ } -Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name) +static Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name) { Speaker *speaker = BKE_speaker_add(name); id_us_min(&speaker->id); return speaker; } -void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker) +static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker) { if (ID_REAL_USERS(speaker) <= 0) BKE_libblock_free(&bmain->speaker, speaker); @@ -448,18 +448,18 @@ void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker /* XXX python now has invalid pointer? */ } -Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name) +static Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name) { return BKE_text_add(name); } -void rna_Main_texts_remove(Main *bmain, Text *text) +static void rna_Main_texts_remove(Main *bmain, Text *text) { BKE_text_unlink(bmain, text); BKE_libblock_free(&bmain->text, text); /* XXX python now has invalid pointer? */ } -Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath) +static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath) { Text *txt; @@ -473,13 +473,13 @@ Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath return txt; } -bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name) +static bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name) { bArmature *arm = BKE_armature_add(name); id_us_min(&arm->id); return arm; } -void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) +static void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) { if (ID_REAL_USERS(arm) <= 0) BKE_libblock_free(&bmain->armature, arm); @@ -490,14 +490,14 @@ void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) /* XXX python now has invalid pointer? */ } -bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name) +static bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name) { bAction *act = add_empty_action(name); id_us_min(&act->id); act->id.flag &= ~LIB_FAKEUSER; return act; } -void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) +static void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) { if (ID_REAL_USERS(act) <= 0) BKE_libblock_free(&bmain->action, act); @@ -508,13 +508,13 @@ void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) /* XXX python now has invalid pointer? */ } -ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name) +static ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name) { ParticleSettings *part = psys_new_settings(name, bmain); id_us_min(&part->id); return part; } -void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part) +static void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part) { if (ID_REAL_USERS(part) <= 0) BKE_libblock_free(&bmain->particle, part); @@ -525,7 +525,7 @@ void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSetting /* XXX python now has invalid pointer? */ } -MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath) +static MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath) { MovieClip *clip; @@ -539,14 +539,14 @@ MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, con return clip; } -void rna_Main_movieclips_remove(Main *bmain, MovieClip *clip) +static void rna_Main_movieclips_remove(Main *bmain, MovieClip *clip) { BKE_movieclip_unlink(bmain, clip); BKE_libblock_free(&bmain->movieclip, clip); /* XXX python now has invalid pointer? */ } -Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name) +static Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name) { Mask *mask; @@ -555,7 +555,7 @@ Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name) return mask; } -void rna_Main_masks_remove(Main *bmain, Mask *mask) +static void rna_Main_masks_remove(Main *bmain, Mask *mask) { BKE_mask_free(bmain, mask); BKE_libblock_free(&bmain->mask, mask); @@ -580,36 +580,36 @@ void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineS } /* tag functions, all the same */ -void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); } -void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); } -void rna_Main_objects_tag(Main *bmain, int value) { tag_main_lb(&bmain->object, value); } -void rna_Main_materials_tag(Main *bmain, int value) { tag_main_lb(&bmain->mat, value); } -void rna_Main_node_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->nodetree, value); } -void rna_Main_meshes_tag(Main *bmain, int value) { tag_main_lb(&bmain->mesh, value); } -void rna_Main_lamps_tag(Main *bmain, int value) { tag_main_lb(&bmain->lamp, value); } -void rna_Main_libraries_tag(Main *bmain, int value) { tag_main_lb(&bmain->library, value); } -void rna_Main_screens_tag(Main *bmain, int value) { tag_main_lb(&bmain->screen, value); } -void rna_Main_window_managers_tag(Main *bmain, int value) { tag_main_lb(&bmain->wm, value); } -void rna_Main_images_tag(Main *bmain, int value) { tag_main_lb(&bmain->image, value); } -void rna_Main_lattices_tag(Main *bmain, int value) { tag_main_lb(&bmain->latt, value); } -void rna_Main_curves_tag(Main *bmain, int value) { tag_main_lb(&bmain->curve, value); } -void rna_Main_metaballs_tag(Main *bmain, int value) { tag_main_lb(&bmain->mball, value); } -void rna_Main_fonts_tag(Main *bmain, int value) { tag_main_lb(&bmain->vfont, value); } -void rna_Main_textures_tag(Main *bmain, int value) { tag_main_lb(&bmain->tex, value); } -void rna_Main_brushes_tag(Main *bmain, int value) { tag_main_lb(&bmain->brush, value); } -void rna_Main_worlds_tag(Main *bmain, int value) { tag_main_lb(&bmain->world, value); } -void rna_Main_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->group, value); } -void rna_Main_shape_keys_tag(Main *bmain, int value) { tag_main_lb(&bmain->key, value); } -void rna_Main_scripts_tag(Main *bmain, int value) { tag_main_lb(&bmain->script, value); } -void rna_Main_texts_tag(Main *bmain, int value) { tag_main_lb(&bmain->text, value); } -void rna_Main_speakers_tag(Main *bmain, int value) { tag_main_lb(&bmain->speaker, value); } -void rna_Main_sounds_tag(Main *bmain, int value) { tag_main_lb(&bmain->sound, value); } -void rna_Main_armatures_tag(Main *bmain, int value) { tag_main_lb(&bmain->armature, value); } -void rna_Main_actions_tag(Main *bmain, int value) { tag_main_lb(&bmain->action, value); } -void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); } -void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); } -void rna_Main_movieclips_tag(Main *bmain, int value) { tag_main_lb(&bmain->movieclip, value); } -void rna_Main_masks_tag(Main *bmain, int value) { tag_main_lb(&bmain->mask, value); } +static void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); } +static void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); } +static void rna_Main_objects_tag(Main *bmain, int value) { tag_main_lb(&bmain->object, value); } +static void rna_Main_materials_tag(Main *bmain, int value) { tag_main_lb(&bmain->mat, value); } +static void rna_Main_node_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->nodetree, value); } +static void rna_Main_meshes_tag(Main *bmain, int value) { tag_main_lb(&bmain->mesh, value); } +static void rna_Main_lamps_tag(Main *bmain, int value) { tag_main_lb(&bmain->lamp, value); } +static void rna_Main_libraries_tag(Main *bmain, int value) { tag_main_lb(&bmain->library, value); } +static void rna_Main_screens_tag(Main *bmain, int value) { tag_main_lb(&bmain->screen, value); } +static void rna_Main_window_managers_tag(Main *bmain, int value) { tag_main_lb(&bmain->wm, value); } +static void rna_Main_images_tag(Main *bmain, int value) { tag_main_lb(&bmain->image, value); } +static void rna_Main_lattices_tag(Main *bmain, int value) { tag_main_lb(&bmain->latt, value); } +static void rna_Main_curves_tag(Main *bmain, int value) { tag_main_lb(&bmain->curve, value); } +static void rna_Main_metaballs_tag(Main *bmain, int value) { tag_main_lb(&bmain->mball, value); } +static void rna_Main_fonts_tag(Main *bmain, int value) { tag_main_lb(&bmain->vfont, value); } +static void rna_Main_textures_tag(Main *bmain, int value) { tag_main_lb(&bmain->tex, value); } +static void rna_Main_brushes_tag(Main *bmain, int value) { tag_main_lb(&bmain->brush, value); } +static void rna_Main_worlds_tag(Main *bmain, int value) { tag_main_lb(&bmain->world, value); } +static void rna_Main_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->group, value); } +static void rna_Main_shape_keys_tag(Main *bmain, int value) { tag_main_lb(&bmain->key, value); } +static void rna_Main_scripts_tag(Main *bmain, int value) { tag_main_lb(&bmain->script, value); } +static void rna_Main_texts_tag(Main *bmain, int value) { tag_main_lb(&bmain->text, value); } +static void rna_Main_speakers_tag(Main *bmain, int value) { tag_main_lb(&bmain->speaker, value); } +static void rna_Main_sounds_tag(Main *bmain, int value) { tag_main_lb(&bmain->sound, value); } +static void rna_Main_armatures_tag(Main *bmain, int value) { tag_main_lb(&bmain->armature, value); } +static void rna_Main_actions_tag(Main *bmain, int value) { tag_main_lb(&bmain->action, value); } +static void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); } +static void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); } +static void rna_Main_movieclips_tag(Main *bmain, int value) { tag_main_lb(&bmain->movieclip, value); } +static void rna_Main_masks_tag(Main *bmain, int value) { tag_main_lb(&bmain->mask, value); } void rna_Main_linestyle_tag(Main *bmain, int value) { tag_main_lb(&bmain->linestyle, value); } static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA); } @@ -654,6 +654,8 @@ void RNA_api_main(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_pointer(func, "image", "Image", "", "New image"); RNA_def_function_return(func, parm); +#else + (void)srna; #endif } diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 719baed8edb..97d9cc961ef 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -193,7 +193,7 @@ static void rna_MaskLayer_splines_begin(CollectionPropertyIterator *iter, Pointe rna_iterator_listbase_begin(iter, &masklay->splines, NULL); } -void rna_MaskLayer_name_set(PointerRNA *ptr, const char *value) +static void rna_MaskLayer_name_set(PointerRNA *ptr, const char *value) { Mask *mask = (Mask *)ptr->id.data; MaskLayer *masklay = (MaskLayer *)ptr->data; @@ -315,7 +315,7 @@ static MaskLayer *rna_Mask_layers_new(Mask *mask, const char *name) return masklay; } -void rna_Mask_layers_remove(Mask *mask, ReportList *reports, MaskLayer *masklay) +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); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 4523858d639..96529de074b 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -45,7 +45,6 @@ static EnumPropertyItem prop_texture_coordinates_items[] = { {TEXCO_ORCO, "ORCO", 0, "Generated", "Use the original undeformed coordinates of the object"}, {TEXCO_STRAND, "STRAND", 0, "Strand / Particle", "Use normalized strand texture coordinate (1D) or particle age (X) and trail position (Y)"}, - {TEXCO_STICKY, "STICKY", 0, "Sticky", "Use mesh's sticky coordinates for the texture coordinates"}, {TEXCO_WINDOW, "WINDOW", 0, "Window", "Use screen coordinates as texture coordinates"}, {TEXCO_NORM, "NORMAL", 0, "Normal", "Use normal vector as texture coordinates"}, {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Use reflection vector as texture coordinates"}, @@ -303,7 +302,6 @@ static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *UNUSED else if (ELEM3(ma->material_type, MA_TYPE_SURFACE, MA_TYPE_HALO, MA_TYPE_WIRE)) { RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_UV); RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRAND); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STICKY); RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_WINDOW); RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_NORM); RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_REFL); @@ -1939,6 +1937,12 @@ void RNA_def_material(BlenderRNA *brna) "- for anisotropic shading effects"); RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "use_uv_project", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapflag", MA_MAPFLAG_UVPROJECT); + RNA_def_property_ui_text(prop, "UV Project", + "Use to ensure UV interpolation is correct for camera projections (use with UV project modifier)"); + RNA_def_property_update(prop, 0, "rna_Material_update"); + /* nested structs */ prop = RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index dbb46c9c291..ce86f90f018 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -149,7 +149,7 @@ void rna_Mesh_update_draw(Main *bmain, Scene *scene, PointerRNA *ptr) } -void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr) { Mesh *me = ptr->data; if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) { @@ -158,7 +158,7 @@ void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Mesh_update_draw(bmain, scene, ptr); } -void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr) { Mesh *me = ptr->data; if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) { @@ -1204,11 +1204,6 @@ static char *rna_MeshColor_path(PointerRNA *ptr) return rna_LoopCustomData_data_path(ptr, "vertex_colors", CD_MLOOPCOL); } -static char *rna_MeshSticky_path(PointerRNA *ptr) -{ - return BLI_sprintfN("sticky[%d]", (int)((MSticky *)ptr->data - rna_mesh(ptr)->msticky)); -} - static char *rna_MeshIntPropertyLayer_path(PointerRNA *ptr) { return BLI_sprintfN("int_layers[\"%s\"]", ((CustomDataLayer *)ptr->data)->name); @@ -1972,21 +1967,6 @@ static void rna_def_mtexpoly(BlenderRNA *brna) #endif } -static void rna_def_msticky(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "MeshSticky", NULL); - RNA_def_struct_sdna(srna, "MSticky"); - RNA_def_struct_ui_text(srna, "Mesh Vertex Sticky Texture Coordinate", "Sticky texture coordinate"); - RNA_def_struct_path_func(srna, "rna_MeshSticky_path"); - - prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ); - RNA_def_property_ui_text(prop, "Location", "Sticky texture coordinate location"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); -} - static void rna_def_mcol(BlenderRNA *brna) { StructRNA *srna; @@ -2624,7 +2604,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); } -static void rna_def_skin_vertices(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_skin_vertices(BlenderRNA *brna, PropertyRNA *UNUSED(cprop)) { StructRNA *srna; PropertyRNA *prop; @@ -2711,11 +2691,6 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Polygons", "Polygons of the mesh"); rna_def_mesh_polygons(brna, prop); - prop = RNA_def_property(srna, "sticky", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "msticky", "totvert"); - RNA_def_property_struct_type(prop, "MeshSticky"); - RNA_def_property_ui_text(prop, "Sticky", "Sticky texture coordinates"); - /* TODO, should this be allowed to be its self? */ prop = RNA_def_property(srna, "texture_mesh", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "texcomesh"); @@ -3061,7 +3036,6 @@ void RNA_def_mesh(BlenderRNA *brna) rna_def_mloopuv(brna); rna_def_mtface(brna); rna_def_mtexpoly(brna); - rna_def_msticky(brna); rna_def_mcol(brna); rna_def_mloopcol(brna); rna_def_mproperties(brna); diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index fe18e6254d0..b63390c65ed 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -41,8 +41,10 @@ #include "BKE_mesh.h" #include "ED_mesh.h" +#include "rna_internal.h" /* own include */ + #ifdef RNA_RUNTIME -const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, struct Mesh *mesh2) +static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, struct Mesh *mesh2) { const char *ret = BKE_mesh_cmp(mesh, mesh2, FLT_EPSILON * 60); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 084cda87507..eb4660c18e8 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -215,7 +215,7 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) } } -void rna_Modifier_name_set(PointerRNA *ptr, const char *value) +static void rna_Modifier_name_set(PointerRNA *ptr, const char *value) { ModifierData *md = ptr->data; char oldname[sizeof(md->name)]; @@ -2658,7 +2658,7 @@ static void rna_def_modifier_screw(BlenderRNA *brna) #endif } -static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna) +static void rna_def_modifier_weightvg_mask(BlenderRNA *UNUSED(brna), StructRNA *srna) { static EnumPropertyItem weightvg_mask_tex_map_items[] = { {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Local", "Use local generated coordinates"}, diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index 8b2b741b83e..c221d1175df 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -187,8 +187,7 @@ static void rna_def_moviecliUser(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Movie Clip User", "Parameters defining how a MovieClip datablock is used by another datablock"); - prop = RNA_def_property(srna, "current_frame", PROP_INT, PROP_TIME); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "framenr"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Current Frame", "Current frame number in movie or image sequence"); @@ -299,6 +298,12 @@ static void rna_def_movieclip(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Frame Offset", "Offset of footage first frame relative to it's file name " "(affects only how footage is loading, does not change data associated with a clip)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update"); + + /* color management */ + prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "colorspace_settings"); + RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings"); + RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings"); } void RNA_def_movieclip(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 16753961852..6e0f9f37d17 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -360,7 +360,7 @@ static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *report /* Set the 'solo' setting for the given NLA-track, making sure that it is the only one * that has this status in its AnimData block. */ -void rna_NlaTrack_solo_set(PointerRNA *ptr, int value) +static void rna_NlaTrack_solo_set(PointerRNA *ptr, int value) { NlaTrack *data = (NlaTrack *)ptr->data; AnimData *adt = BKE_animdata_from_id(ptr->id.data); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 55dda3fc315..6b543f9f576 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3839,7 +3839,7 @@ static void def_cmp_trackpos(StructRNA *srna) RNA_def_property_ui_text(prop, "Position", "Which marker position to use for output"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "relative_frame", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "frame_relative", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "custom2"); RNA_def_property_ui_text(prop, "Frame", "Frame to be used for relative position"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -4036,7 +4036,7 @@ static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop) } /* shared between all note tree types*/ -static void rna_def_nodetree_active_api(StructRNA *srna, PropertyRNA *cprop) +static void rna_def_nodetree_active_api(StructRNA *srna, PropertyRNA *UNUSED(cprop)) { PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index e69d313b23b..a10c153515a 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -231,7 +231,7 @@ void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data); } -void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Object *ob = ptr->id.data; @@ -496,7 +496,7 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle"); } -void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value) +static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value) { Object *ob = (Object *)ptr->id.data; bDeformGroup *dg = (bDeformGroup *)ptr->data; @@ -1101,7 +1101,7 @@ static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values) static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) { Object *ob = (Object *)ptr->id.data; - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); *min = 0; if (key) { @@ -1130,7 +1130,7 @@ static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value) static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); KeyBlock *kb; PointerRNA keyptr; diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 5bf1cc281ad..1263e7716dd 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -39,6 +39,8 @@ #include "DNA_object_types.h" #include "DNA_modifier_types.h" +#include "rna_internal.h" /* own include */ + #ifdef RNA_RUNTIME #include "BLI_math.h" @@ -385,7 +387,7 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList * } } -int rna_Object_is_visible(Object *ob, Scene *sce) +static int rna_Object_is_visible(Object *ob, Scene *sce) { return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay); } @@ -428,8 +430,8 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int #endif /* BMESH_TODO, return polygon index, not tessface */ -void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3], - float r_location[3], float r_normal[3], int *index) +static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3], + float r_location[3], float r_normal[3], int *index) { BVHTreeFromMesh treeData = {NULL}; @@ -470,8 +472,8 @@ void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], fl *index = -1; } -void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist, - float n_location[3], float n_normal[3], int *index) +static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist, + float n_location[3], float n_normal[3], int *index) { BVHTreeFromMesh treeData = {NULL}; @@ -510,7 +512,7 @@ void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float poi /* ObjectBase */ -void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) +static void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) { base->lay = base->object->lay = v3d->lay; } diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index fc3dfafe133..89638389fd2 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -502,7 +502,7 @@ static int rna_PartSettings_is_fluid_get(PointerRNA *ptr) return part->type == PART_FLUID; } -void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value) +static void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value) { Object *ob = ptr->id.data; ParticleSystem *part = (ParticleSystem *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 739f302fcbe..2b6fd2cb263 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -148,7 +148,7 @@ void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value) } } -void rna_BoneGroup_name_set(PointerRNA *ptr, const char *value) +static void rna_BoneGroup_name_set(PointerRNA *ptr, const char *value) { Object *ob = ptr->id.data; bActionGroup *agrp = ptr->data; @@ -257,7 +257,7 @@ static int rna_PoseChannel_has_ik_get(PointerRNA *ptr) return ED_pose_channel_in_IK_chain(ob, pchan); } -StructRNA *rna_IKParam_refine(PointerRNA *ptr) +static StructRNA *rna_IKParam_refine(PointerRNA *ptr) { bIKParam *param = (bIKParam *)ptr->data; @@ -269,7 +269,7 @@ StructRNA *rna_IKParam_refine(PointerRNA *ptr) } } -PointerRNA rna_Pose_ikparam_get(struct PointerRNA *ptr) +static PointerRNA rna_Pose_ikparam_get(struct PointerRNA *ptr) { bPose *pose = (bPose *)ptr->data; return rna_pointer_inherit_refine(ptr, &RNA_IKParam, pose->ikparam); @@ -593,7 +593,7 @@ static int rna_PoseChannel_rotation_4d_editable(PointerRNA *ptr, int index) } /* not essential, but much faster then the default lookup function */ -int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) +static int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { bPose *pose = (bPose *)ptr->data; bPoseChannel *pchan = BKE_pose_channel_find_name(pose, key); @@ -788,8 +788,6 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_editable_array_func(prop, "rna_PoseChannel_location_editable"); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); - /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */ - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); @@ -797,8 +795,6 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_editable_array_func(prop, "rna_PoseChannel_scale_editable"); RNA_def_property_float_array_default(prop, default_scale); RNA_def_property_ui_text(prop, "Scale", ""); - /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */ - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); @@ -806,8 +802,6 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable"); RNA_def_property_float_array_default(prop, default_quat); RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions"); - /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */ - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but @@ -820,15 +814,11 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable"); RNA_def_property_float_array_default(prop, default_axisAngle); RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation"); - /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */ - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "eul"); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_euler_editable"); - /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */ - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c index bf9f924489b..fc3697633a4 100644 --- a/source/blender/makesrna/intern/rna_property.c +++ b/source/blender/makesrna/intern/rna_property.c @@ -89,7 +89,7 @@ static void rna_GameProperty_type_set(PointerRNA *ptr, int value) if (prop->type != value) { prop->type = value; - init_property(prop); + BKE_bproperty_init(prop); } } @@ -97,7 +97,7 @@ static void rna_GameProperty_name_set(PointerRNA *ptr, const char *value) { bProperty *prop = (bProperty *)(ptr->data); BLI_strncpy_utf8(prop->name, value, sizeof(prop->name)); - unique_property(NULL, prop, 1); + BKE_bproperty_unique(NULL, prop, 1); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index bd4d3e84883..1c7f0b00caf 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -160,12 +160,13 @@ EnumPropertyItem snap_node_element_items[] = { #define R_IMF_ENUM_TAGA_RAW {R_IMF_IMTYPE_RAWTGA, "TARGA_RAW", ICON_FILE_IMAGE, "Targa Raw", \ "Output image in uncompressed Targa format"}, - +#if 0 /* UNUSED (so far) */ #ifdef WITH_DDS # define R_IMF_ENUM_DDS {R_IMF_IMTYPE_DDS, "DDS", ICON_FILE_IMAGE, "DDS", "Output image in DDS format"}, #else # define R_IMF_ENUM_DDS #endif +#endif #ifdef WITH_OPENJPEG # define R_IMF_ENUM_JPEG2K {R_IMF_IMTYPE_JP2, "JPEG2000", ICON_FILE_IMAGE, "JPEG 2000", \ @@ -501,7 +502,7 @@ static void rna_Scene_framelen_update(Main *UNUSED(bmain), Scene *scene, Pointer } -static void rna_Scene_current_frame_set(PointerRNA *ptr, int value) +static void rna_Scene_frame_current_set(PointerRNA *ptr, int value) { Scene *data = (Scene *)ptr->data; @@ -1096,34 +1097,6 @@ static void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi DAG_id_tag_update(&scene->id, 0); } -static void rna_RenderSettings_color_management_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) -{ - /* reset image nodes */ - Scene *scene = (Scene *)ptr->id.data; - bNodeTree *ntree = scene->nodetree; - bNode *node; - - if (ntree && scene->use_nodes) { - /* images are freed here, stop render and preview threads, until - * Image is threadsafe. when we are changing this property from a - * python script in the render thread, don't stop own thread */ - if (BLI_thread_is_main()) - WM_jobs_stop_all(bmain->wm.first); - - for (node = ntree->nodes.first; node; node = node->next) { - if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_IMAGE)) { - ED_node_changed_update(&scene->id, node); - WM_main_add_notifier(NC_NODE | NA_EDITED, node); - - if (node->type == CMP_NODE_IMAGE) - BKE_image_signal((Image *)node->id, NULL, IMA_SIGNAL_FREE); - } - } - } - - rna_Scene_glsl_update(bmain, scene, ptr); -} - static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value) { Scene *scene = (Scene *)ptr->id.data; @@ -3390,6 +3363,17 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "G", "Log conversion gamma"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + /* color management */ + prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "view_settings"); + RNA_def_property_struct_type(prop, "ColorManagedViewSettings"); + RNA_def_property_ui_text(prop, "View Settings", "Color management settings applied on image before saving"); + + prop = RNA_def_property(srna, "display_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "display_settings"); + RNA_def_property_struct_type(prop, "ColorManagedDisplaySettings"); + RNA_def_property_ui_text(prop, "Display Settings", "Settings of device saved image would be displayed on"); } static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) @@ -4140,11 +4124,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) "editor pipeline, if sequencer strips exist"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_color_management", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "color_mgt_flag", R_COLOR_MANAGEMENT); - RNA_def_property_ui_text(prop, "Color Management", "Use linear workflow - gamma corrected imaging pipeline"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_RenderSettings_color_management_update"); - prop = RNA_def_property(srna, "use_color_unpremultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "color_mgt_flag", R_COLOR_MANAGEMENT_PREDIVIDE); RNA_def_property_ui_text(prop, "Color Unpremultiply", @@ -4426,6 +4405,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_enum_items(prop, engine_items); RNA_def_property_enum_funcs(prop, "rna_RenderSettings_engine_get", "rna_RenderSettings_engine_set", "rna_RenderSettings_engine_itemf"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering"); RNA_def_property_update(prop, NC_WINDOW, "rna_RenderSettings_engine_update"); @@ -4774,7 +4754,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_sdna(prop, NULL, "r.cfra"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); - RNA_def_property_int_funcs(prop, NULL, "rna_Scene_current_frame_set", NULL); + RNA_def_property_int_funcs(prop, NULL, "rna_Scene_frame_current_set", NULL); RNA_def_property_ui_text(prop, "Current Frame", "Current Frame, to update animation data from python frame_set() instead"); RNA_def_property_update(prop, NC_SCENE | ND_FRAME, "rna_Scene_frame_update"); @@ -5027,6 +5007,22 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active Movie Clip", "Active movie clip used for constraints and viewport drawing"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + /* color management */ + prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "view_settings"); + RNA_def_property_struct_type(prop, "ColorManagedViewSettings"); + RNA_def_property_ui_text(prop, "View Settings", "Color management settings applied on image before saving"); + + prop = RNA_def_property(srna, "display_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "display_settings"); + RNA_def_property_struct_type(prop, "ColorManagedDisplaySettings"); + RNA_def_property_ui_text(prop, "Display Settings", "Settings of device saved image would be displayed on"); + + prop = RNA_def_property(srna, "sequencer_colorspace_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "sequencer_colorspace_settings"); + RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings"); + RNA_def_property_ui_text(prop, "Sequencer Color Space Settings", "Settings of color space sequencer is working in"); + /* Nestled Data */ rna_def_tool_settings(brna); rna_def_unified_paint_settings(brna); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 69b61b47d8a..cdf7ac5e68f 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -40,6 +40,8 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "rna_internal.h" /* own include */ + #ifdef RNA_RUNTIME #include "BKE_animsys.h" diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index a6d4e473df4..32e388598f5 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -140,12 +140,12 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr) } } -void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float result[2]) +static void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float result[2]) { UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]); } -void rna_View2D_view_to_region(struct View2D *v2d, float x, float y, int clip, int result[2]) +static void rna_View2D_view_to_region(struct View2D *v2d, float x, float y, int clip, int result[2]) { if (clip) UI_view2d_view_to_region(v2d, x, y, &result[0], &result[1]); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 314082dfd02..6097fa2ae96 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -104,7 +104,7 @@ static StructRNA *rna_Sensor_refine(struct PointerRNA *ptr) } } -void rna_Sensor_name_set(PointerRNA *ptr, const char *value) +static void rna_Sensor_name_set(PointerRNA *ptr, const char *value) { bSensor *sens = (bSensor *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index e3e467a9abb..b27148e964d 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1433,6 +1433,11 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_channel_set", NULL); /* overlap test */ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); + prop = RNA_def_property(srna, "use_linear_modifiers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_LINEAR_MODIFIERS); + RNA_def_property_ui_text(prop, "Use Linear Modifiers", "Calculate modifiers in linear space instead of sequencer's space"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); + /* blending */ prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 549868e5ed0..c7c4b0817f6 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -37,8 +37,6 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" -extern EnumPropertyItem blend_mode_items[]; - #ifdef RNA_RUNTIME //#include "DNA_anim_types.h" @@ -188,7 +186,8 @@ static Sequence *rna_Sequences_new_movie(ID *id, Editing *ed, ReportList *report Scene *scene = (Scene *)id; Sequence *seq; - struct anim *an = openanim(file, IB_rect, 0); + /* OCIO_TODO: support configurable color spaces for strips */ + struct anim *an = openanim(file, IB_rect, 0, NULL); if (an == NULL) { BKE_report(reports, RPT_ERROR, "Sequences.new_movie: unable to open movie file"); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index a00e8bfea2d..ff5f4988cc1 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -478,7 +478,7 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value } /* api call */ -void rna_RegionView3D_update(ID *id, RegionView3D *rv3d) +static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d) { bScreen *sc = (bScreen *)id; @@ -658,20 +658,6 @@ static void rna_SpaceImageEditor_cursor_location_set(PointerRNA *ptr, const floa } } -static void rna_SpaceImageEditor_curves_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - SpaceImage *sima = (SpaceImage *)ptr->data; - ImBuf *ibuf; - void *lock; - - ibuf = ED_space_image_acquire_buffer(sima, &lock); - if (ibuf->rect_float) - curvemapping_do_ibuf(sima->cumap, ibuf); - ED_space_image_release_buffer(sima, lock); - - WM_main_add_notifier(NC_IMAGE, sima->image); -} - static void rna_SpaceImageEditor_scopes_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)ptr->data; @@ -680,7 +666,7 @@ static void rna_SpaceImageEditor_scopes_update(Main *UNUSED(bmain), Scene *scene ibuf = ED_space_image_acquire_buffer(sima, &lock); if (ibuf) { - scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT); + scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); WM_main_add_notifier(NC_IMAGE, sima->image); } ED_space_image_release_buffer(sima, lock); @@ -863,7 +849,7 @@ static void rna_SpaceDopeSheetEditor_action_update(Main *UNUSED(bmain), Scene *s adt = BKE_id_add_animdata(&obact->id); /* this only adds if non-existant */ } else if (saction->mode == SACTCONT_SHAPEKEY) { - Key *key = ob_get_key(obact); + Key *key = BKE_key_from_object(obact); if (key) adt = BKE_id_add_animdata(&key->id); /* this only adds if non-existant */ } @@ -890,7 +876,7 @@ static void rna_SpaceDopeSheetEditor_mode_update(Main *UNUSED(bmain), Scene *sce /* special exceptions for ShapeKey Editor mode */ if (saction->mode == SACTCONT_SHAPEKEY) { - Key *key = ob_get_key(obact); + Key *key = BKE_key_from_object(obact); /* 1) update the action stored for the editor */ if (key) @@ -1116,7 +1102,7 @@ static void rna_def_space(BlenderRNA *brna) } /* for all spaces that use a mask */ -void rna_def_space_mask_info(StructRNA *srna, int noteflag, const char *mask_set_func) +static void rna_def_space_mask_info(StructRNA *srna, int noteflag, const char *mask_set_func) { PropertyRNA *prop; @@ -1980,11 +1966,6 @@ static void rna_def_space_image(BlenderRNA *brna) "Parameters defining which layer, pass and frame of the image is displayed"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "cumap"); - RNA_def_property_ui_text(prop, "Curve", "Color curve mapping to use for displaying the image"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_curves_update"); - prop = RNA_def_property(srna, "scopes", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "scopes"); RNA_def_property_struct_type(prop, "Scopes"); diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c index e62b3ecd804..a2880510958 100644 --- a/source/blender/makesrna/intern/rna_texture_api.c +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -32,6 +32,8 @@ #include "RNA_define.h" +#include "rna_internal.h" /* own include */ + #ifdef RNA_RUNTIME #include "IMB_imbuf.h" @@ -42,8 +44,8 @@ #include "RE_pipeline.h" #include "RE_shader_ext.h" -void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char *filepath, - struct Scene *scene, float layout[12]) +static void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char *filepath, + struct Scene *scene, float layout[12]) { if (scene == NULL) { scene = CTX_data_scene(C); @@ -52,7 +54,7 @@ void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const cha RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.im_format.imtype, layout); } -void clear_envmap(struct EnvMap *env, bContext *C) +static void clear_envmap(struct EnvMap *env, bContext *C) { Main *bmain = CTX_data_main(C); Tex *tex; @@ -66,7 +68,7 @@ void clear_envmap(struct EnvMap *env, bContext *C) } } -void texture_evaluate(struct Tex *tex, float value[3], float color_r[4]) +static void texture_evaluate(struct Tex *tex, float value[3], float color_r[4]) { TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; multitex_ext(tex, value, NULL, NULL, 1, &texres); diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 172a79970b5..0c62a280935 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -144,7 +144,7 @@ static void rna_tracking_active_track_set(PointerRNA *ptr, PointerRNA value) clip->tracking.act_track = NULL; } -void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value) +static void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value) { MovieClip *clip = (MovieClip *)ptr->id.data; MovieTracking *tracking = &clip->tracking; @@ -325,7 +325,7 @@ static void rna_tracking_active_object_set(PointerRNA *ptr, PointerRNA value) else clip->tracking.objectnr = 0; } -void rna_trackingObject_name_set(PointerRNA *ptr, const char *value) +static void rna_trackingObject_name_set(PointerRNA *ptr, const char *value) { MovieClip *clip = (MovieClip *)ptr->id.data; MovieTrackingObject *object = (MovieTrackingObject *)ptr->data; @@ -447,7 +447,7 @@ static MovieTrackingObject *rna_trackingObject_new(MovieTracking *tracking, cons return object; } -void rna_trackingObject_remove(MovieTracking *tracking, MovieTrackingObject *object) +static void rna_trackingObject_remove(MovieTracking *tracking, MovieTrackingObject *object) { BKE_tracking_object_delete(tracking, object); @@ -477,7 +477,7 @@ static MovieTrackingMarker *rna_trackingMarkers_insert_frame(MovieTrackingTrack return new_marker; } -void rna_trackingMarkers_delete_frame(MovieTrackingTrack *track, int framenr) +static void rna_trackingMarkers_delete_frame(MovieTrackingTrack *track, int framenr) { if (track->markersnr == 1) return; diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index cf43bd74d72..006e1ad3903 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -36,6 +36,8 @@ #include "UI_resources.h" +#include "rna_internal.h" + #ifdef RNA_RUNTIME static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, int icon, @@ -415,6 +417,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_ui_description(func, "User interface for setting image format options"); parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL); + RNA_def_boolean(func, "color_management", 0, "", "Show color management settings"); func = RNA_def_function(srna, "template_movieclip", "uiTemplateMovieClip"); RNA_def_function_ui_description(func, "Item(s). User interface for selecting movie clips and their source paths"); @@ -497,6 +500,17 @@ void RNA_api_ui_layout(StructRNA *srna) func = RNA_def_function(srna, "introspect", "uiLayoutIntrospect"); parm = RNA_def_string(func, "string", "", 1024 * 1024, "Descr", "DESCR"); RNA_def_function_return(func, parm); + + /* color management templates */ + func = RNA_def_function(srna, "template_colorspace_settings", "uiTemplateColorspaceSettings"); + RNA_def_function_ui_description(func, "Item. A widget to control input color space settings."); + api_ui_item_rna_common(func); + + func = RNA_def_function(srna, "template_colormanaged_view_settings", "uiTemplateColormanagedViewSettings"); + RNA_def_function_ui_description(func, "Item. A widget to control color managed view settings settings."); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + /* RNA_def_boolean(func, "show_global_settings", 0, "", "Show widgets to control global color management settings"); */ } #endif diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 018022fdde9..eada607ed97 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2994,8 +2994,9 @@ static void rna_def_userdef_system(BlenderRNA *brna) /* Note: As this list is in alphabetical order, and not defined order, * here is the highest define currently in use: 33 (Hebrew). */ static EnumPropertyItem language_items[] = { - { 0, "", 0, N_("Nearly done"), ""}, + { 0, "", 0, N_("Nearly Done"), ""}, { 0, "DEFAULT", 0, "Default (Default)", ""}, + /* using the utf8 flipped form of Arabic (العربية) */ {21, "ARABIC", 0, "Arabic (ﺔﻴﺑﺮﻌﻟﺍ)", "ar_EG"}, {32, "BRAZILIANPORTUGUESE", 0, "Brazilian Portuguese (Português do Brasil)", "pt_BR"}, { 1, "ENGLISH", 0, "English (English)", "en_US"}, @@ -3008,8 +3009,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) { 9, "SPANISH", 0, "Spanish (Español)", "es"}, {14, "TRADITIONAL_CHINESE", 0, "Traditional Chinese (繁體中文)", "zh_TW"}, {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, - { 0, "", 0, N_("In progress"), ""}, - /* using the utf8 flipped form of Arabic (العربية) */ + { 0, "", 0, N_("In Progress"), ""}, {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"}, {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"}, {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"}, @@ -3018,8 +3018,9 @@ static void rna_def_userdef_system(BlenderRNA *brna) { 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"}, { 5, "GERMAN", 0, "German (Deutsch)", "de_DE"}, {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"}, - {33, "HEBREW", 0, "Hebrew (עִבְרִית)", "he_IL"}, - {31, "HUNGARIAN", 0, "Hungarian (magyar)", "hu_HU"}, + /* using the utf8 flipped form of Hebrew (עִבְרִית)) */ + {33, "HEBREW", 0, "Hebrew (תירִבְעִ)", "he_IL"}, + {31, "HUNGARIAN", 0, "Hungarian (Magyar)", "hu_HU"}, {27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"}, {29, "KYRGYZ", 0, "Kyrgyz (Кыргыз тили)", "ky_KG"}, /* {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, */ /* XXX No po's yet. */ @@ -3029,7 +3030,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) {19, "POLISH", 0, "Polish (Polski)", "pl_PL"}, /* {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, */ /* XXX No po's yet. */ {17, "SERBIAN", 0, "Serbian (Српски)", "sr_RS"}, - {28, "SERBIAN_LATIN", 0, "Serbian latin (Srpski latinica)", "sr_RS@latin"}, + {28, "SERBIAN_LATIN", 0, "Serbian Latin (Srpski latinica)", "sr_RS@latin"}, { 7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"}, {30, "TURKISH", 0, "Turkish (Türkçe)", "tr_TR"}, { 0, NULL, 0, NULL, NULL} @@ -3602,7 +3603,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) "Enables automatic saving of preview images in the .blend file"); } -void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 61c75e306cb..d8753f4ff43 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -765,14 +765,14 @@ static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value) { wmKeyMapItem *kmi = ptr->data; wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1); - strcpy(value, ot ? ot->name : kmi->idname); + strcpy(value, ot ? RNA_struct_ui_name(ot->srna) : kmi->idname); } static int rna_wmKeyMapItem_name_length(PointerRNA *ptr) { wmKeyMapItem *kmi = ptr->data; wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1); - return strlen(ot ? ot->name : kmi->idname); + return strlen(ot ? RNA_struct_ui_name(ot->srna) : kmi->idname); } static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr) @@ -1136,7 +1136,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void * return dummyot.ext.srna; } -void **rna_Operator_instance(PointerRNA *ptr) +static void **rna_Operator_instance(PointerRNA *ptr) { wmOperator *op = ptr->data; return &op->py_instance; @@ -1793,7 +1793,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) * fallback on the operator ID */ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Name", "Name of operator to call on input event"); + RNA_def_property_ui_text(prop, "Name", "Name of operator (translated) to call on input event"); RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", NULL); prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index ae4d5dc493e..cb4e00a042e 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -39,6 +39,8 @@ #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" +#include "rna_internal.h" /* own include */ + #ifdef RNA_RUNTIME #include "BKE_context.h" @@ -72,12 +74,12 @@ static int rna_event_modal_handler_add(struct bContext *C, struct wmOperator *op } /* XXX, need a way for python to know event types, 0x0110 is hard coded */ -wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, wmWindow *win) +static wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, wmWindow *win) { return WM_event_add_timer(wm, win, 0x0110, time_step); } -void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer) +static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer) { WM_event_remove_timer(wm, timer->win, timer); } diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index cdb200ff180..638e91e22f1 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -88,10 +88,10 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -#define EDGE_MARK 1 - #ifdef USE_BM_BEVEL_OP_AS_MOD +#define EDGE_MARK 1 + /* BMESH_TODO * * this bevel calls the operator which is missing many of the options diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 890e45f7e80..254c02b7672 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -188,11 +188,9 @@ static void deformVerts(ModifierData *md, Object *ob, psmd->totdmface = psmd->dm->getNumTessFaces(psmd->dm); } - if (psys) { - psmd->flag &= ~eParticleSystemFlag_psys_updated; - particle_system_update(md->scene, ob, psys); - psmd->flag |= eParticleSystemFlag_psys_updated; - } + psmd->flag &= ~eParticleSystemFlag_psys_updated; + particle_system_update(md->scene, ob, psys); + psmd->flag |= eParticleSystemFlag_psys_updated; } /* disabled particles in editmode for now, until support for proper derivedmesh diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 4fd2c658380..a94b4834d18 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -393,7 +393,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mul_m4_v3(mtx_tx, vc->co); /* length in 2d, don't sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + + vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + vc->co[other_axis_2] * vc->co[other_axis_2]; /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ @@ -410,7 +410,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vc->v[0] = vc->v[1] = -1; /* length in 2d, don't sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + + vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + vc->co[other_axis_2] * vc->co[other_axis_2]; /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ @@ -430,7 +430,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vc->e[1] = med_new; } else { - vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */ + vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */ } vc = &vert_connect[med_new->v2]; @@ -445,7 +445,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vc->e[1] = med_new; } else { - vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */ + vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */ } } diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index 3353382fa3d..8ef86362edd 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -54,7 +54,7 @@ static void deformVerts(ModifierData *md, Object *ob, int numVerts, ModifierApplyFlag UNUSED(flag)) { - KeyBlock *kb = ob_get_keyblock(ob); + KeyBlock *kb = BKE_keyblock_from_object(ob); float (*deformedVerts)[3]; if (kb && kb->totelem == numVerts) { @@ -69,8 +69,8 @@ static void deformVerts(ModifierData *md, Object *ob, static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { - Key *key = ob_get_key(ob); - KeyBlock *kb = ob_get_keyblock(ob); + Key *key = BKE_key_from_object(ob); + KeyBlock *kb = BKE_keyblock_from_object(ob); float scale[3][3]; (void)vertexCos; /* unused */ @@ -94,7 +94,7 @@ static void deformVertsEM(ModifierData *md, Object *ob, float (*vertexCos)[3], int numVerts) { - Key *key = ob_get_key(ob); + Key *key = BKE_key_from_object(ob); if (key && key->type == KEY_RELATIVE) deformVerts(md, ob, derivedData, vertexCos, numVerts, 0); @@ -107,8 +107,8 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob, float (*defMats)[3][3], int numVerts) { - Key *key = ob_get_key(ob); - KeyBlock *kb = ob_get_keyblock(ob); + Key *key = BKE_key_from_object(ob); + KeyBlock *kb = BKE_keyblock_from_object(ob); float scale[3][3]; (void)vertexCos; /* unused */ diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index eb5a74f0dcc..88951919272 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -157,7 +157,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, int override_image = ((umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0); Projector projectors[MOD_UVPROJECT_MAXPROJECTORS]; int num_projectors = 0; - float aspect; char uvname[MAX_CUSTOMDATA_LAYER_NAME]; float aspx = umd->aspectx ? umd->aspectx : 1.0f; float aspy = umd->aspecty ? umd->aspecty : 1.0f; @@ -165,8 +164,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, float scay = umd->scaley ? umd->scaley : 1.0f; int free_uci = 0; - aspect = aspx / aspy; - for (i = 0; i < umd->num_projectors; ++i) if (umd->projectors[i]) projectors[num_projectors++].ob = umd->projectors[i]; @@ -199,39 +196,23 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, free_uci = 1; } else { - float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); - int sensor_fit = BKE_camera_sensor_fit(cam->sensor_fit, aspx, aspy); - float scale = (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale; - float xmax, xmin, ymax, ymin; - - if (sensor_fit == CAMERA_SENSOR_FIT_HOR) { - xmax = 0.5f * scale; - ymax = xmax / aspect; - } - else { - ymax = 0.5f * scale; - xmax = ymax * aspect; - } + CameraParams params; - xmin = -xmax; - ymin = -ymax; + /* setup parameters */ + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, projectors[i].ob); - /* scale the matrix */ - xmin *= scax; - xmax *= scax; - ymin *= scay; - ymax *= scay; + /* compute matrix, viewplane, .. */ + BKE_camera_params_compute_viewplane(¶ms, 1, 1, aspx, aspy); - if (cam->type == CAM_PERSP) { - float perspmat[4][4]; - perspective_m4(perspmat, xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend); - mult_m4_m4m4(tmpmat, perspmat, projectors[i].projmat); - } - else { /* if (cam->type == CAM_ORTHO) */ - float orthomat[4][4]; - orthographic_m4(orthomat, xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend); - mult_m4_m4m4(tmpmat, orthomat, projectors[i].projmat); - } + /* scale the view-plane */ + params.viewplane.xmin *= scax; + params.viewplane.xmax *= scax; + params.viewplane.ymin *= scay; + params.viewplane.ymax *= scay; + + BKE_camera_params_compute_matrix(¶ms); + mult_m4_m4m4(tmpmat, params.winmat, projectors[i].projmat); } } else { @@ -241,22 +222,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, unit_m4(offsetmat); mul_mat3_m4_fl(offsetmat, 0.5); offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5; - - if (cam) { - if (aspx == aspy) { - offsetmat[3][0] -= cam->shiftx; - offsetmat[3][1] -= cam->shifty; - } - else if (aspx < aspy) { - offsetmat[3][0] -= (cam->shiftx * aspy / aspx); - offsetmat[3][1] -= cam->shifty; - } - else { - offsetmat[3][0] -= cam->shiftx; - offsetmat[3][1] -= (cam->shifty * aspx / aspy); - } - } - + mult_m4_m4m4(projectors[i].projmat, offsetmat, tmpmat); /* calculate worldspace projector normal (for best projector test) */ diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 22b1e33e2a6..25a2a61d8e3 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -185,7 +185,7 @@ static float get_ob2ob_distance(const Object *ob, const Object *obr) /** * Maps distances to weights, with an optional "smoothing" mapping. */ -void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode) +static void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode) { const float range_inv = 1.0f / (max_d - min_d); /* invert since multiplication is faster */ unsigned int i = nidx; diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index e1510f9f813..c9960df1345 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -33,6 +33,7 @@ #include <stdio.h> #include "DNA_anim_types.h" +#include "DNA_color_types.h" #include "DNA_scene_types.h" #include "DNA_node_types.h" @@ -693,7 +694,9 @@ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_pr void *COM_linker_hack = NULL; -void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview) +void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview, + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) { #ifdef WITH_COMPOSITOR #ifdef WITH_COMPOSITOR_LEGACY @@ -704,10 +707,11 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int else #endif { - COM_execute(rd, ntree, rendering); + COM_execute(rd, ntree, rendering, view_settings, display_settings); } #else (void)ntree, (void)rd, (void)rendering, (void)do_preview; + (void)view_settings, (void)display_settings; #endif (void)do_preview; diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 2277c5a2836..8f01408d8c7 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -146,7 +146,7 @@ CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, in if (disprect.xmin>= disprect.xmax) return NULL; if (disprect.ymin>= disprect.ymax) return NULL; - cbuf= alloc_compbuf(BLI_RCT_SIZE_X(&disprect), BLI_RCT_SIZE_Y(&disprect), type, 1); + cbuf= alloc_compbuf(BLI_rcti_size_x(&disprect), BLI_rcti_size_y(&disprect), type, 1); outfp= cbuf->rect; rectf += type*(disprect.ymin*rectx + disprect.xmin); dx= type*cbuf->x; @@ -606,6 +606,9 @@ static CompBuf *generate_procedural_preview(CompBuf *cbuf, int newx, int newy) return outbuf; } +/* OCIO_TODO: this function is only used by legacy compositor system only, which would likely be removed soon, + * keep check for old color management flag for now + */ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) { RenderData *rd= data; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 96a92055ca9..9f3874560ac 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -282,6 +282,8 @@ static void cmp_node_image_update(bNodeTree *ntree, bNode *node) cmp_node_image_verify_outputs(ntree, node); } +#ifdef WITH_COMPOSITOR_LEGACY + /* float buffer from the image with matching color management */ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) { @@ -290,40 +292,25 @@ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) *alloc= FALSE; + /* OCIO_TODO: this is a part of legacy compositor system, don't bother with porting this code + * to new color management system since this code would likely be simply removed soon + */ if (rd->color_mgt_flag & R_COLOR_MANAGEMENT) { - if (ibuf->profile != IB_PROFILE_NONE) { - rect= ibuf->rect_float; - } - else { - rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); - - IMB_buffer_float_from_float(rect, ibuf->rect_float, - 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide, - ibuf->x, ibuf->y, ibuf->x, ibuf->x); - - *alloc= TRUE; - } + rect= ibuf->rect_float; } else { - if (ibuf->profile == IB_PROFILE_NONE) { - rect= ibuf->rect_float; - } - else { - rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); + rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); - IMB_buffer_float_from_float(rect, ibuf->rect_float, - 4, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, predivide, - ibuf->x, ibuf->y, ibuf->x, ibuf->x); + IMB_buffer_float_from_float(rect, ibuf->rect_float, + 4, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, predivide, + ibuf->x, ibuf->y, ibuf->x, ibuf->x); *alloc= TRUE; - } } return rect; } -#ifdef WITH_COMPOSITOR_LEGACY - /* note: this function is used for multilayer too, to ensure uniform * handling with BKE_image_get_ibuf() */ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *iuser) diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index 2d9b9348668..656e2a72c03 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -267,9 +267,6 @@ static void exec_output_file_singlelayer(RenderData *rd, bNode *node, bNodeStack ibuf->rect_float = cbuf->rect; ibuf->dither = rd->dither_intensity; - if (rd->color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - /* get full path */ BLI_join_dirfile(path, FILE_MAX, nimf->base_path, sockdata->path); BKE_makepicstring(filename, path, bmain->name, rd->cfra, format->imtype, (rd->scemode & R_EXTENSION), TRUE); diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index fdbe82efeda..59a4d6818c8 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -349,7 +349,7 @@ void node_group_edit_clear(bNode *node) nodeGroupEditClear(inode); } -void node_group_link(bNodeTree *ntree, bNodeSocket *sock, int in_out) +static void UNUSED_FUNCTION(node_group_link)(bNodeTree *ntree, bNodeSocket *sock, int in_out) { node_group_expose_socket(ntree, sock, in_out); } diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h index 9f9caef14e2..95104df5fed 100644 --- a/source/blender/nodes/intern/node_util.h +++ b/source/blender/nodes/intern/node_util.h @@ -67,7 +67,7 @@ ListBase node_internal_connect_default(struct bNodeTree *ntree, struct bNode *no #endif // this is needed for inlining behavior -#if defined _WIN32 +#if defined _MSC_VER # define DO_INLINE __inline #elif defined (__sun) || defined (__sun__) # define DO_INLINE diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index 53f1aa82f60..5e58b74ac3a 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -49,8 +49,6 @@ #include <assert.h> #include "node_texture_util.h" -#define PREV_RES 128 /* default preview resolution */ - static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread) { if (dg->node->need_exec) { diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h index 7d8c4ce232c..e938e6fc419 100644 --- a/source/blender/nodes/texture/node_texture_util.h +++ b/source/blender/nodes/texture/node_texture_util.h @@ -61,6 +61,8 @@ #include "node_util.h" +#include "NOD_texture.h" + #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c index c16b1fb901f..fb5b94249e6 100644 --- a/source/blender/python/bmesh/bmesh_py_ops.c +++ b/source/blender/python/bmesh/bmesh_py_ops.c @@ -42,6 +42,8 @@ #include "bmesh.h" +#include "bmesh_py_ops.h" /* own include */ + #include "bmesh_py_types.h" #include "bmesh_py_utils.h" /* own include */ @@ -69,7 +71,7 @@ typedef struct { const char *opname; } BPy_BMeshOpFunc; -PyObject *bpy_bmesh_op_CreatePyObject(const char *opname) +static PyObject *bpy_bmesh_op_CreatePyObject(const char *opname) { BPy_BMeshOpFunc *self = PyObject_New(BPy_BMeshOpFunc, &bmesh_op_Type); diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index 4b397ee1870..15aa5164c86 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -72,6 +72,7 @@ set(SRC bpy_app_handlers.h bpy_driver.h bpy_intern_string.h + bpy_library.h bpy_operator.h bpy_operator_wrap.h bpy_props.h diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 38d082346d8..360e041270f 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -37,6 +37,7 @@ #include "bpy_rna.h" #include "bpy_app.h" #include "bpy_props.h" +#include "bpy_library.h" #include "bpy_operator.h" #include "BLI_path_util.h" @@ -240,7 +241,6 @@ static PyObject *bpy_import_test(const char *modname) void BPy_init_modules(void) { extern BPy_StructRNA *bpy_context_module; - extern int bpy_lib_init(PyObject *); PointerRNA ctx_ptr; PyObject *mod; @@ -276,7 +276,7 @@ void BPy_init_modules(void) PyModule_AddObject(mod, "StructMetaPropGroup", (PyObject *)&pyrna_struct_meta_idprop_Type); /* needs to be first so bpy_types can run */ - bpy_lib_init(mod); + BPY_library_module(mod); bpy_import_test("bpy_types"); PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */ diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h index 2412d65aa21..fe877d161ff 100644 --- a/source/blender/python/intern/bpy.h +++ b/source/blender/python/intern/bpy.h @@ -23,10 +23,13 @@ * \ingroup pythonintern */ - +#ifndef __BPY_H__ + void BPy_init_modules(void); extern PyObject *bpy_package_py; /* bpy_interface_atexit.c */ void BPY_atexit_register(void); void BPY_atexit_unregister(void); + +#endif /* __BPY_H__ */ diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.c index 44bba4c098f..5ae2a11710a 100644 --- a/source/blender/python/intern/bpy_app_ffmpeg.c +++ b/source/blender/python/intern/bpy_app_ffmpeg.c @@ -26,11 +26,8 @@ #include <Python.h> #include "BLI_utildefines.h" -#include "BLI_callbacks.h" -#include "RNA_types.h" -#include "RNA_access.h" -#include "bpy_rna.h" +#include "bpy_app_ffmpeg.h" #ifdef WITH_FFMPEG #include <libavcodec/avcodec.h> @@ -80,8 +77,10 @@ static PyObject *make_ffmpeg_info(void) return NULL; } +#if 0 // UNUSED #define SetIntItem(flag) \ PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyLong_FromLong(flag)) +#endif #define SetStrItem(str) \ PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyUnicode_FromString(str)) #define SetObjItem(obj) \ @@ -121,7 +120,7 @@ static PyObject *make_ffmpeg_info(void) return NULL; } -#undef SetIntItem +// #undef SetIntItem #undef SetStrItem #undef SetObjItem diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index bab5a83a6ed..4d7f2080bbc 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -37,6 +37,8 @@ #include "bpy_rna.h" #include "bpy_app_handlers.h" +#include "BPY_extern.h" + void bpy_app_generic_callback(struct Main *main, struct ID *id, void *arg); static PyTypeObject BlenderAppCbType; diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 9cd0bdd090a..85f6163c721 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -53,6 +53,7 @@ #include "BLI_path_util.h" #include "BLI_fileops.h" +#include "BLI_listbase.h" #include "BLI_math_base.h" #include "BLI_string.h" #include "BLI_string_utf8.h" @@ -383,6 +384,7 @@ typedef struct { static int python_script_exec(bContext *C, const char *fn, struct Text *text, struct ReportList *reports, const short do_jump) { + Main *bmain_old = CTX_data_main(C); PyObject *main_mod = NULL; PyObject *py_dict = NULL, *py_result = NULL; PyGILState_STATE gilstate; @@ -461,7 +463,11 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, if (!py_result) { if (text) { if (do_jump) { - python_script_error_jump_text(text); + /* ensure text is valid before use, the script may have freed its self */ + Main *bmain_new = CTX_data_main(C); + if ((bmain_old == bmain_new) && (BLI_findindex(&bmain_new->text, text) != -1)) { + python_script_error_jump_text(text); + } } } BPy_errors_to_report(reports); @@ -680,11 +686,20 @@ void BPY_modules_load_user(bContext *C) int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result) { - PyObject *pyctx = (PyObject *)CTX_py_dict_get(C); - PyObject *item = PyDict_GetItemString(pyctx, member); + PyGILState_STATE gilstate; + int use_gil = !PYC_INTERPRETER_ACTIVE; + + PyObject *pyctx; + PyObject *item; PointerRNA *ptr = NULL; int done = FALSE; + if (use_gil) + gilstate = PyGILState_Ensure(); + + pyctx = (PyObject *)CTX_py_dict_get(C); + item = PyDict_GetItemString(pyctx, member); + if (item == NULL) { /* pass */ } @@ -720,7 +735,8 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data); } else { - printf("List item not a valid type\n"); + printf("PyContext: '%s' list item not a valid type in sequece type '%s'\n", + member, Py_TYPE(item)->tp_name); } } @@ -740,6 +756,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * } } + if (use_gil) + PyGILState_Release(gilstate); + return done; } diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c index db97d361c73..13d8cedf907 100644 --- a/source/blender/python/intern/bpy_interface_atexit.c +++ b/source/blender/python/intern/bpy_interface_atexit.c @@ -32,6 +32,7 @@ #include <Python.h> #include "bpy_util.h" +#include "bpy.h" /* own include */ #include "WM_api.h" diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index 40ec8136eb7..7571fe0f75e 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -55,6 +55,7 @@ #include "DNA_space_types.h" /* FILE_LINK, FILE_RELPATH */ #include "bpy_util.h" +#include "bpy_library.h" #ifdef USE_RNA_DATABLOCKS # include "bpy_rna.h" @@ -426,7 +427,7 @@ static PyObject *bpy_lib_dir(BPy_Library *self) } -int bpy_lib_init(PyObject *mod_par) +int BPY_library_module(PyObject *mod_par) { static PyMethodDef load_meth = {"load", (PyCFunction)bpy_lib_load, METH_STATIC | METH_VARARGS | METH_KEYWORDS, diff --git a/source/blender/python/intern/bpy_library.h b/source/blender/python/intern/bpy_library.h new file mode 100644 index 00000000000..1b68007b704 --- /dev/null +++ b/source/blender/python/intern/bpy_library.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. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_library.h + * \ingroup pythonintern + */ + +#ifndef __BPY_LIBRARY_H__ +#define __BPY_LIBRARY_H__ + +int BPY_library_module(PyObject *); + +#endif /* __BPY_LIBRARY_H__ */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4ae8e821298..8ec8c4c41ba 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -37,6 +37,8 @@ #include "RNA_types.h" +#include "BPY_extern.h" + #include "bpy_rna.h" #include "bpy_rna_anim.h" #include "bpy_props.h" @@ -45,7 +47,7 @@ #include "bpy_intern_string.h" #ifdef USE_PYRNA_INVALIDATE_WEAKREF -#include "MEM_guardedalloc.h" +# include "MEM_guardedalloc.h" #endif #include "BLI_dynstr.h" @@ -55,7 +57,7 @@ #include "BLI_utildefines.h" #ifdef USE_PYRNA_INVALIDATE_WEAKREF -#include "BLI_ghash.h" +# include "BLI_ghash.h" #endif #include "RNA_enum_types.h" @@ -78,7 +80,7 @@ #include "../generic/py_capi_utils.h" #ifdef WITH_INTERNATIONAL -#include "BLF_translation.h" +# include "BLF_translation.h" #endif #define USE_PEDANTIC_WRITE @@ -2150,10 +2152,10 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons * -1: exception set * 0: not found * 1: found */ -int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyObject *key, - const char *err_prefix, const short err_not_found, - PointerRNA *r_ptr - ) +static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyObject *key, + const char *err_prefix, const short err_not_found, + PointerRNA *r_ptr + ) { char *keyname; @@ -5908,7 +5910,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = { NULL }; -PyObject *pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop) +static PyObject *pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop) { BPy_PropertyCollectionIterRNA *self = PyObject_New(BPy_PropertyCollectionIterRNA, &pyrna_prop_collection_iter_Type); diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 113367788b6..1fb4b116872 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -175,6 +175,10 @@ PyObject *BPY_rna_types(void); PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr); PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop); +/* extern'd by other modules which don't deal closely with RNA */ +PyObject *pyrna_id_CreatePyObject(struct ID *id); +int pyrna_id_FromPyObject(PyObject *obj, struct ID **id); + /* operators also need this to set args */ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const char *error_prefix); PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop); diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index b7a45897668..69839514a12 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -52,9 +52,6 @@ #include "bpy_util.h" #include "bpy_rna_anim.h" -#define TRUE 1 -#define FALSE 0 - /* for keyframes and drivers */ static int pyrna_struct_anim_args_parse( PointerRNA *ptr, const char *error_prefix, const char *path, diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index 7e2da5b1818..69fe0c48a41 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -74,8 +74,7 @@ static struct PyModuleDef gpumodule = { NULL, NULL, NULL, NULL, NULL }; -PyMODINIT_FUNC -PyInit_gpu(void) +static PyObject *PyInit_gpu(void) { PyObject *m; diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c index 50d2e88f210..e0508359e13 100644 --- a/source/blender/python/intern/stubs.c +++ b/source/blender/python/intern/stubs.c @@ -28,12 +28,15 @@ * \ingroup pythonintern */ +#include "BLI_utildefines.h" + +#include "BPY_extern.h" /* python, will come back */ //void BPY_script_exec(void) {} //void BPY_python_start(void) {} //void BPY_text_free_code(void) {} -void BPY_pyconstraint_exec(void) {} -void BPY_pyconstraint_target(void) {} -int BPY_is_pyconstraint(void) { return 0;} -void BPY_pyconstraint_update(void) {} +void BPY_pyconstraint_exec(struct bPythonConstraint *UNUSED(con), struct bConstraintOb *UNUSED(cob), struct ListBase *UNUSED(targets)) {} +void BPY_pyconstraint_target(struct bPythonConstraint *UNUSED(con), struct bConstraintTarget *UNUSED(ct)) {} +int BPY_is_pyconstraint(struct Text *UNUSED(text)) { return 0;} +void BPY_pyconstraint_update(struct Object *UNUSED(owner), struct bConstraint *UNUSED(con)) {} diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 19f9aa2dc88..818f30ec284 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -46,8 +46,6 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#define SWAP_FLOAT(a, b, tmp) tmp = a; a = b; b = tmp - /*-------------------------DOC STRINGS ---------------------------*/ PyDoc_STRVAR(M_Geometry_doc, "The Blender geometry module" diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m index e30b8331fc0..75b9056de1b 100644 --- a/source/blender/quicktime/apple/qtkit_import.m +++ b/source/blender/quicktime/apple/qtkit_import.m @@ -291,7 +291,6 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position) ibuf = nsImageToiBuf(frameImage,anim->x, anim->y); [pool drain]; - ibuf->profile = IB_PROFILE_SRGB; return ibuf; } diff --git a/source/blender/quicktime/apple/quicktime_import.c b/source/blender/quicktime/apple/quicktime_import.c index 5b13d77a030..e44eba2bfe0 100644 --- a/source/blender/quicktime/apple/quicktime_import.c +++ b/source/blender/quicktime/apple/quicktime_import.c @@ -392,8 +392,6 @@ ImBuf *qtime_fetchibuf(struct anim *anim, int position) } #endif - ibuf->profile = IB_PROFILE_SRGB; - IMB_flipy(ibuf); return ibuf; } diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 1510d9adb10..395fbf8f01c 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -226,7 +226,7 @@ void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene int RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode); int RE_WriteRenderResult(struct ReportList *reports, RenderResult *rr, const char *filename, int compress); -struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty); +struct RenderResult *RE_MultilayerConvert(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty); extern const float default_envmap_layout[]; int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]); diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h index c07ed42332f..2a9a1becc42 100644 --- a/source/blender/render/extern/include/RE_render_ext.h +++ b/source/blender/render/extern/include/RE_render_ext.h @@ -39,10 +39,11 @@ /* called by meshtools */ struct View3D; struct Scene; +struct LinkNode; -void RE_make_sticky(struct Scene *scene, struct View3D *v3d); - -/* for radiosity module */ +void RE_make_sticky(struct Scene *scene, struct Object *camera, struct LinkNode *objects); + +/* for radiosity module */ struct RadView; struct RNode; struct Render; diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 26a1b9908b3..57fb80f11c0 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -134,7 +134,7 @@ typedef struct ShadeInput { int har; /* hardness */ /* texture coordinates */ - float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4]; + float lo[3], gl[3], ref[3], orn[3], winco[3], vcol[4]; float refcol[4], displace[3]; float strandco, tang[3], nmapnorm[3], nmaptang[4], stress, winspeed[4]; float duplilo[3], dupliuv[3]; @@ -150,7 +150,6 @@ typedef struct ShadeInput { float dxno[3], dyno[3], dxview, dyview; float dxlv[3], dylv[3]; float dxwin[3], dywin[3]; - float dxsticky[3], dysticky[3]; float dxrefract[3], dyrefract[3]; float dxstrand, dystrand; diff --git a/source/blender/render/intern/include/render_result.h b/source/blender/render/intern/include/render_result.h index 303d4094f8e..5d61417cbaf 100644 --- a/source/blender/render/intern/include/render_result.h +++ b/source/blender/render/intern/include/render_result.h @@ -47,6 +47,8 @@ struct RenderLayer; struct RenderResult; struct Scene; struct rcti; +struct ColorManagedDisplaySettings; +struct ColorManagedViewSettings; /* New */ @@ -55,7 +57,7 @@ struct RenderResult *render_result_new(struct Render *re, struct RenderResult *render_result_new_full_sample(struct Render *re, struct ListBase *lb, struct rcti *partrct, int crop, int savebuffers); -struct RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty); +struct RenderResult *render_result_new_from_exr(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty); /* Merge */ @@ -90,7 +92,9 @@ void render_result_rect_from_ibuf(struct RenderResult *rr, struct RenderData *rd void render_result_rect_fill_zero(struct RenderResult *rr); void render_result_rect_get_pixels(struct RenderResult *rr, struct RenderData *rd, - unsigned int *rect, int rectx, int recty); + unsigned int *rect, int rectx, int recty, + const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); #endif /* __RENDER_RESULT_H__ */ diff --git a/source/blender/render/intern/include/renderdatabase.h b/source/blender/render/intern/include/renderdatabase.h index 584e56836fa..d116dfe7b17 100644 --- a/source/blender/render/intern/include/renderdatabase.h +++ b/source/blender/render/intern/include/renderdatabase.h @@ -55,7 +55,6 @@ struct RadFace; typedef struct VertTableNode { struct VertRen *vert; float *rad; - float *sticky; float *strand; float *tangent; float *stress; @@ -110,7 +109,6 @@ struct ObjectRen *RE_addRenderObject(struct Render *re, struct Object *ob, struc struct ObjectInstanceRen *RE_addRenderInstance(struct Render *re, struct ObjectRen *obr, struct Object *ob, struct Object *par, int index, int psysindex, float mat[][4], int lay); void RE_makeRenderInstances(struct Render *re); -float *RE_vertren_get_sticky(struct ObjectRen *obr, struct VertRen *ver, int verify); float *RE_vertren_get_stress(struct ObjectRen *obr, struct VertRen *ver, int verify); float *RE_vertren_get_rad(struct ObjectRen *obr, struct VertRen *ver, int verify); float *RE_vertren_get_strand(struct ObjectRen *obr, struct VertRen *ver, int verify); diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h index e4ee19d8ed2..e873111e6bf 100644 --- a/source/blender/render/intern/include/zbuf.h +++ b/source/blender/render/intern/include/zbuf.h @@ -139,5 +139,10 @@ void zbufclipwire(struct ZSpan *zspan, int obi, int zvlnr, int ec, void zbuf_make_winmat(Render *re, float winmat[][4]); void zbuf_render_project(float winmat[][4], const float co[3], float ho[4]); +/* sould not really be exposed, bad! */ +void hoco_to_zco(ZSpan *zspan, float zco[3], const float hoco[4]); +void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, float *v3, void (*func)(void *, int, int, float, float, float) ); +void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const float ho2[4]); + #endif diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp index ddc84408e26..3926e8b8e51 100644 --- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp +++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp @@ -185,7 +185,7 @@ RTBuilder *rtbuild_get_child(RTBuilder *b, int child, RTBuilder *tmp) return tmp; } -void rtbuild_calc_bb(RTBuilder *b) +static void rtbuild_calc_bb(RTBuilder *b) { if (b->bb[0] == 1.0e30f) { for (RTBuilder::Object **index = b->sorted_begin[0]; index != b->sorted_end[0]; index++) diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp index 9e7075438cb..85c9d0d402f 100644 --- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp @@ -152,7 +152,8 @@ void bvh_hint_bb(Tree *tree, LCTSHint *hint, float *UNUSED(min), float *UNUSED(m } } -void bfree(VBVHTree *tree) +#if 0 /* UNUSED */ +static void bfree(VBVHTree *tree) { if (tot_pushup + tot_pushdown + tot_hints + tot_moves) { if (G.debug & G_DEBUG) { @@ -169,6 +170,7 @@ void bfree(VBVHTree *tree) } bvh_free(tree); } +#endif /* the cast to pointer function is needed to workarround gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11407 */ template<class Tree, int STACK_SIZE> diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index e0864533fed..9bc639515c2 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -41,6 +41,7 @@ #include "BLI_rand.h" #include "BLI_memarena.h" #include "BLI_ghash.h" +#include "BLI_linklist.h" #include "BLI_edgehash.h" #include "DNA_armature_types.h" @@ -118,6 +119,7 @@ #include "zbuf.h" #include "sunsky.h" +#include "RE_render_ext.h" /* 10 times larger than normal epsilon, test it on default nurbs sphere with ray_transp (for quad detection) */ /* or for checking vertex normal flips */ @@ -2260,14 +2262,6 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve if ((texco & TEXCO_ORCO) && (vr->orco)) { copy_v3_v3(shi->lo, vr->orco); } - if (texco & TEXCO_STICKY) { - float *sticky= RE_vertren_get_sticky(obr, vr, 0); - if (sticky) { - shi->sticky[0]= sticky[0]; - shi->sticky[1]= sticky[1]; - shi->sticky[2]= 0.0f; - } - } if (texco & TEXCO_GLOB) { copy_v3_v3(shi->gl, shi->co); mul_m4_v3(re->viewinv, shi->gl); @@ -3267,7 +3261,6 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) VlakRen *vlr; //, *vlr1; VertRen *ver; Material *ma; - MSticky *ms = NULL; DerivedMesh *dm; CustomDataMask mask; float xn, yn, zn, imat[3][3], mat[4][4]; //nor[3], @@ -3352,8 +3345,6 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) if (do_autosmooth && me->totvert==totvert && me->totface==dm->getNumTessFaces(dm)) use_original_normals= TRUE; - ms = (totvert==me->totvert)?me->msticky:NULL; - ma= give_render_material(re, ob, 1); @@ -3372,16 +3363,11 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) normalize_v3(ver->n); negate_v3(ver->n); } - + if (orco) { ver->orco= orco; orco+=3; } - if (ms) { - float *sticky= RE_vertren_get_sticky(obr, ver, 1); - copy_v2_v2(sticky, ms->co); - ms++; - } } if (!timeoffset) { @@ -5301,11 +5287,11 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con /* size of 1 pixel mapped to viewplane coords */ float psize; - psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx; + psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx; /* x angle of a pixel */ pixelphix = atan(psize / re->clipsta); - psize = BLI_RCT_SIZE_Y(&re->viewplane) / (float)re->winy; + psize = BLI_rctf_size_y(&re->viewplane) / (float)re->winy; /* y angle of a pixel */ pixelphiy = atan(psize / re->clipsta); } @@ -5873,76 +5859,3 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, if (re->r.mode & R_SHADOW) make_occ_tree(re); } - -/* ------------------------------------------------------------------------- */ -/* Sticky texture coords */ -/* ------------------------------------------------------------------------- */ - -void RE_make_sticky(Scene *scene, View3D *v3d) -{ - Object *ob; - Base *base; - MVert *mvert; - Mesh *me; - MSticky *ms; - Render *re; - float ho[4], mat[4][4]; - int a; - Object *camera= NULL; - - if (v3d==NULL) { - printf("Need a 3d view to make sticky\n"); - return; - } - - if (v3d) camera= V3D_CAMERA_LOCAL(v3d); - if (camera == NULL) camera= scene->camera; - - if (camera==NULL) { - printf("Need camera to make sticky\n"); - return; - } - if (scene->obedit) { - printf("Unable to make sticky in Edit Mode\n"); - return; - } - - re= RE_NewRender("_make sticky_"); - RE_InitState(re, NULL, &scene->r, NULL, scene->r.xsch, scene->r.ysch, NULL); - - /* use renderdata and camera to set viewplane */ - RE_SetCamera(re, camera); - - /* and set view matrix */ - normalize_m4(camera->obmat); - invert_m4_m4(mat, camera->obmat); - RE_SetView(re, mat); - - for (base= FIRSTBASE; base; base= base->next) { - if (TESTBASELIB(v3d, base)) { - if (base->object->type==OB_MESH) { - ob= base->object; - - me= ob->data; - mvert= me->mvert; - if (me->msticky) - CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert); - me->msticky= CustomData_add_layer(&me->vdata, CD_MSTICKY, - CD_CALLOC, NULL, me->totvert); - - BKE_object_where_is_calc(scene, ob); - mult_m4_m4m4(mat, re->viewmat, ob->obmat); - - ms= me->msticky; - for (a=0; a<me->totvert; a++, ms++, mvert++) { - copy_v3_v3(ho, mvert->co); - mul_m4_v3(mat, ho); - projectverto(ho, re->winmat, ho); - ms->co[0]= ho[0]/ho[3]; - ms->co[1]= ho[1]/ho[3]; - } - } - } - } -} - diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 26bd482af69..03eb21dfa23 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -472,9 +472,6 @@ static void render_envmap(Render *re, EnvMap *env) ibuf = IMB_allocImBuf(envre->rectx, envre->recty, 24, IB_rect | IB_rectfloat); memcpy(ibuf->rect_float, rl->rectf, ibuf->channels * ibuf->x * ibuf->y * sizeof(float)); - if (re->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - /* envmap renders without alpha */ alpha = ibuf->rect_float + 3; for (y = ibuf->x * ibuf->y - 1; y >= 0; y--, alpha += 4) diff --git a/source/blender/render/intern/source/gammaCorrectionTables.c b/source/blender/render/intern/source/gammaCorrectionTables.c index 64925e16ae2..1c2613e8d18 100644 --- a/source/blender/render/intern/source/gammaCorrectionTables.c +++ b/source/blender/render/intern/source/gammaCorrectionTables.c @@ -38,7 +38,7 @@ /* result remain identical (ton) */ /* gamma is only used here for correcting adding colors or alpha */ -#define RE_DEFAULT_GAMMA 2.0 +// #define RE_DEFAULT_GAMMA 2.0 // UNUSED /* This 400 is sort of based on the number of intensity levels needed for */ /* the typical dynamic range of a medium, in this case CRTs. (Foley) */ diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 7f0484c8ee6..7a9df51e493 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -396,8 +396,8 @@ static float square_rctf(rctf *rf) { float x, y; - x = BLI_RCT_SIZE_X(rf); - y = BLI_RCT_SIZE_Y(rf); + x = BLI_rctf_size_x(rf); + y = BLI_rctf_size_y(rf); return x * y; } @@ -405,7 +405,7 @@ static float clipx_rctf(rctf *rf, float x1, float x2) { float size; - size = BLI_RCT_SIZE_X(rf); + size = BLI_rctf_size_x(rf); if (rf->xmin<x1) { rf->xmin = x1; @@ -417,8 +417,8 @@ static float clipx_rctf(rctf *rf, float x1, float x2) rf->xmin = rf->xmax; return 0.0; } - else if (size!=0.0f) { - return BLI_RCT_SIZE_X(rf) / size; + else if (size != 0.0f) { + return BLI_rctf_size_x(rf) / size; } return 1.0; } @@ -427,7 +427,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2) { float size; - size = BLI_RCT_SIZE_Y(rf); + size = BLI_rctf_size_y(rf); if (rf->ymin<y1) { rf->ymin = y1; @@ -441,7 +441,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2) return 0.0; } else if (size != 0.0f) { - return BLI_RCT_SIZE_Y(rf) / size; + return BLI_rctf_size_y(rf) / size; } return 1.0; diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 66f230a40f5..88c64b44b64 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -610,8 +610,8 @@ void initparts(Render *re, int do_crop) } else disprect.ymax = ymaxb; - rectx = BLI_RCT_SIZE_X(&disprect); - recty = BLI_RCT_SIZE_Y(&disprect); + rectx = BLI_rcti_size_x(&disprect); + recty = BLI_rcti_size_y(&disprect); /* so, now can we add this part? */ if (rectx > 0 && recty > 0) { diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 485dd005be7..c8aad21b322 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -61,7 +61,6 @@ /* ------------------------- Declarations --------------------------- */ -#define INVALID_INDEX ((int)(~0)) #define INVPI ((float)M_1_PI) #define TOTCHILD 8 #define CACHE_STEP 3 diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 720287510d0..ecd8524016d 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -68,6 +68,7 @@ #include "BLI_callbacks.h" #include "PIL_time.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -205,9 +206,9 @@ RenderLayer *RE_GetRenderLayer(RenderResult *rr, const char *name) } } -RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty) +RenderResult *RE_MultilayerConvert(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty) { - return render_result_new_from_exr(exrhandle, rectx, recty); + return render_result_new_from_exr(exrhandle, colorspace, predivide, rectx, recty); } RenderLayer *render_get_active_layer(Render *re, RenderResult *rr) @@ -336,7 +337,7 @@ void RE_ResultGet32(Render *re, unsigned int *rect) RenderResult rres; RE_AcquireResultImage(re, &rres); - render_result_rect_get_pixels(&rres, &re->r, rect, re->rectx, re->recty); + render_result_rect_get_pixels(&rres, &re->r, rect, re->rectx, re->recty, &re->scene->view_settings, &re->scene->display_settings); RE_ReleaseResultImage(re); } @@ -439,8 +440,8 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * re->winy = winy; if (disprect) { re->disprect = *disprect; - re->rectx = BLI_RCT_SIZE_X(disprect); - re->recty = BLI_RCT_SIZE_Y(disprect); + re->rectx = BLI_rcti_size_x(disprect); + re->recty = BLI_rcti_size_y(disprect); } else { re->disprect.xmin = re->disprect.ymin = 0; @@ -672,15 +673,15 @@ static void *do_part_thread(void *pa_v) float panorama_pixel_rot(Render *re) { float psize, phi, xfac; - float borderfac = (float)BLI_RCT_SIZE_X(&re->disprect) / (float)re->winx; + float borderfac = (float)BLI_rcti_size_x(&re->disprect) / (float)re->winx; /* size of 1 pixel mapped to viewplane coords */ - psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx; + psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx; /* angle of a pixel */ phi = atan(psize / re->clipsta); /* correction factor for viewplane shifting, first calculate how much the viewplane angle is */ - xfac = borderfac * BLI_RCT_SIZE_X(&re->viewplane) / (float)re->xparts; + xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)re->xparts; xfac = atan(0.5f * xfac / re->clipsta); /* and how much the same viewplane angle is wrapped */ psize = 0.5f * phi * ((float)re->partx); @@ -713,7 +714,7 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane) float phi = panorama_pixel_rot(re); R.panodxp = (re->winx - (best->disprect.xmin + best->disprect.xmax) ) / 2; - R.panodxv = (BLI_RCT_SIZE_X(viewplane) * R.panodxp) / (float)(re->winx); + R.panodxv = (BLI_rctf_size_x(viewplane) * R.panodxp) / (float)(re->winx); /* shift viewplane */ R.viewplane.xmin = viewplane->xmin + R.panodxv; @@ -740,8 +741,8 @@ static RenderPart *find_next_part(Render *re, int minx) /* find center of rendered parts, image center counts for 1 too */ for (pa = re->parts.first; pa; pa = pa->next) { if (pa->ready) { - centx += BLI_RCT_CENTER_X(&pa->disprect); - centy += BLI_RCT_CENTER_Y(&pa->disprect); + centx += BLI_rcti_cent_x(&pa->disprect); + centy += BLI_rcti_cent_y(&pa->disprect); tot++; } } @@ -751,8 +752,8 @@ static RenderPart *find_next_part(Render *re, int minx) /* closest of the non-rendering parts */ for (pa = re->parts.first; pa; pa = pa->next) { if (pa->ready == 0 && pa->nr == 0) { - long long int distx = centx - BLI_RCT_CENTER_X(&pa->disprect); - long long int disty = centy - BLI_RCT_CENTER_Y(&pa->disprect); + long long int distx = centx - BLI_rcti_cent_x(&pa->disprect); + long long int disty = centy - BLI_rcti_cent_y(&pa->disprect); distx = (long long int)sqrt(distx * distx + disty * disty); if (distx < mindist) { if (re->r.mode & R_PANORAMA) { @@ -1463,7 +1464,7 @@ static void free_all_freestyle_renders(Scene *scene) static void do_merge_fullsample(Render *re, bNodeTree *ntree) { float *rectf, filt[3][3]; - int sample; + int x, y, sample; /* interaction callbacks */ if (ntree) { @@ -1484,7 +1485,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) for (sample = 0; sample < re->r.osa; sample++) { Render *re1; RenderResult rres; - int x, y, mask; + int mask; /* enable full sample print */ R.i.curfsa = sample + 1; @@ -1513,7 +1514,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) ntreeCompositTagRender(re->scene); ntreeCompositTagAnimated(ntree); - ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0); + ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0, &re->scene->view_settings, &re->scene->display_settings); } /* ensure we get either composited result or the active layer */ @@ -1549,6 +1550,18 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) if (re->test_break(re->tbh)) break; } + + /* clamp alpha and RGB to 0..1 and 0..inf, can go outside due to filter */ + for (y = 0; y < re->recty; y++) { + float *rf = rectf + 4 * y * re->rectx; + + for (x = 0; x < re->rectx; x++, rf += 4) { + rf[0] = MAX2(rf[0], 0.0f); + rf[1] = MAX2(rf[1], 0.0f); + rf[2] = MAX2(rf[2], 0.0f); + CLAMP(rf[3], 0.0f, 1.0f); + } + } /* clear interaction callbacks */ if (ntree) { @@ -1677,7 +1690,7 @@ static void do_render_composite_fields_blur_3d(Render *re) if (re->r.scemode & R_FULL_SAMPLE) do_merge_fullsample(re, ntree); else { - ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0); + ntreeCompositExecTree(ntree, &re->r, 1, G.background == 0, &re->scene->view_settings, &re->scene->display_settings); } ntree->stats_draw = NULL; @@ -1728,7 +1741,7 @@ int RE_seq_render_active(Scene *scene, RenderData *rd) static void do_render_seq(Render *re) { static int recurs_depth = 0; - struct ImBuf *ibuf; + struct ImBuf *ibuf, *out; RenderResult *rr; /* don't assign re->result here as it might change during give_ibuf_seq */ int cfra = re->r.cfra; SeqRenderData context; @@ -1755,7 +1768,16 @@ static void do_render_seq(Render *re) 100); } - ibuf = BKE_sequencer_give_ibuf(context, cfra, 0); + out = BKE_sequencer_give_ibuf(context, cfra, 0); + + if (out) { + ibuf = IMB_dupImBuf(out); + IMB_freeImBuf(out); + BKE_sequencer_imbuf_from_sequencer_space(re->scene, ibuf); + } + else { + ibuf = NULL; + } recurs_depth--; @@ -1789,6 +1811,9 @@ static void do_render_seq(Render *re) re->progress(re->prh, (float)(cfra - re->r.sfra) / (re->r.efra - re->r.sfra)); else re->progress(re->prh, 1.0f); + + /* would mark display buffers as invalid */ + re->display_draw(re->ddh, re->result, NULL); } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -2150,6 +2175,14 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr G.is_rendering = FALSE; } +static void colormanage_image_for_write(Scene *scene, ImBuf *ibuf) +{ + IMB_display_buffer_to_imbuf_rect(ibuf, &scene->view_settings, &scene->display_settings); + + if (ibuf) + imb_freerectfloatImBuf(ibuf); +} + void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene) { re->result_ok= 0; @@ -2171,19 +2204,27 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie /* write movie or image */ if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { int do_free = FALSE; - unsigned int *rect32 = (unsigned int *)rres.rect32; + ImBuf *ibuf = render_result_rect_to_ibuf(&rres, &scene->r); + /* note; the way it gets 32 bits rects is weak... */ - if (rres.rect32 == NULL) { - rect32 = MEM_mapallocN(sizeof(int) * rres.rectx * rres.recty, "temp 32 bits rect"); - RE_ResultGet32(re, rect32); + if (ibuf->rect == NULL) { + ibuf->rect = MEM_mapallocN(sizeof(int) * rres.rectx * rres.recty, "temp 32 bits rect"); + RE_ResultGet32(re, ibuf->rect); do_free = TRUE; } - ok = mh->append_movie(&re->r, scene->r.sfra, scene->r.cfra, (int *)rect32, - rres.rectx, rres.recty, re->reports); + colormanage_image_for_write(scene, ibuf); + + ok = mh->append_movie(&re->r, scene->r.sfra, scene->r.cfra, (int *) ibuf->rect, + ibuf->x, ibuf->y, re->reports); if (do_free) { - MEM_freeN(rect32); + MEM_freeN(ibuf->rect); + ibuf->rect = NULL; } + + /* imbuf knows which rects are not part of ibuf */ + IMB_freeImBuf(ibuf); + printf("Append frame %d", scene->r.cfra); } else { @@ -2200,6 +2241,12 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie } else { ImBuf *ibuf = render_result_rect_to_ibuf(&rres, &scene->r); + int do_colormanagement; + + do_colormanagement = !BKE_imtype_supports_float(scene->r.im_format.imtype); + + if (do_colormanagement) + colormanage_image_for_write(scene, ibuf); ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format); @@ -2217,6 +2264,9 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie name[strlen(name) - 4] = 0; BKE_add_image_extension(name, R_IMF_IMTYPE_JPEG90); ibuf->planes = 24; + + colormanage_image_for_write(scene, ibuf); + BKE_imbuf_write_stamp(scene, camera, ibuf, name, &imf); printf("\nSaved: %s", name); } @@ -2471,7 +2521,8 @@ void RE_init_threadcount(Render *re) * x/y offsets are only used on a partial copy when dimensions don't match */ void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, const char *filename, int x, int y) { - ImBuf *ibuf = IMB_loadiffname(filename, IB_rect); + /* OCIO_TODO: assume layer was saved in defaule color space */ + ImBuf *ibuf = IMB_loadiffname(filename, IB_rect, NULL); if (ibuf && (ibuf->rect || ibuf->rect_float)) { if (ibuf->x == layer->rectx && ibuf->y == layer->recty) { @@ -2560,8 +2611,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, return 0; } - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_LINEAR_RGB; + IMB_display_buffer_to_imbuf_rect(ibuf, &scene->view_settings, &scene->display_settings); /* to save, we first get absolute path */ BLI_strncpy(filepath, relpath, sizeof(filepath)); diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index fb1a7885390..a226556828e 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -50,6 +50,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" #include "intern/openexr/openexr_multi.h" @@ -423,8 +424,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf SceneRenderLayer *srl; int rectx, recty, nr; - rectx = BLI_RCT_SIZE_X(partrct); - recty = BLI_RCT_SIZE_Y(partrct); + rectx = BLI_rcti_size_x(partrct); + recty = BLI_rcti_size_y(partrct); if (rectx <= 0 || recty <= 0) return NULL; @@ -571,8 +572,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf } /* border render; calculate offset for use in compositor. compo is centralized coords */ - rr->xof = re->disprect.xmin + BLI_RCT_CENTER_X(&re->disprect) - (re->winx / 2); - rr->yof = re->disprect.ymin + BLI_RCT_CENTER_Y(&re->disprect) - (re->winy / 2); + rr->xof = re->disprect.xmin + BLI_rcti_cent_x(&re->disprect) - (re->winx / 2); + rr->yof = re->disprect.ymin + BLI_rcti_cent_y(&re->disprect) - (re->winy / 2); return rr; } @@ -629,12 +630,13 @@ static void ml_addpass_cb(void *UNUSED(base), void *lay, const char *str, float } /* from imbuf, if a handle was returned we convert this to render result */ -RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty) +RenderResult *render_result_new_from_exr(void *exrhandle, const char *colorspace, int predivide, int rectx, int recty) { RenderResult *rr = MEM_callocN(sizeof(RenderResult), __func__); RenderLayer *rl; RenderPass *rpass; - + const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR); + rr->rectx = rectx; rr->recty = recty; @@ -647,6 +649,11 @@ RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty) for (rpass = rl->passes.first; rpass; rpass = rpass->next) { rpass->rectx = rectx; rpass->recty = recty; + + if (rpass->channels >= 3) { + IMB_colormanagement_transform(rpass->rect, rpass->rectx, rpass->recty, rpass->channels, + colorspace, to_colorspace, predivide); + } } } @@ -1084,16 +1091,12 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) /* float factor for random dither, imbuf takes care of it */ ibuf->dither = rd->dither_intensity; - /* prepare to gamma correct to sRGB color space */ - if (rd->color_mgt_flag & R_COLOR_MANAGEMENT) { - /* sequence editor can generate 8bpc render buffers */ - if (ibuf->rect) { - ibuf->profile = IB_PROFILE_SRGB; - if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) - IMB_float_from_rect(ibuf); - } - else { - ibuf->profile = IB_PROFILE_LINEAR_RGB; + /* prepare to gamma correct to sRGB color space + * note that sequence editor can generate 8bpc render buffers + */ + if (ibuf->rect) { + if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) { + IMB_float_from_rect(ibuf); } } @@ -1109,22 +1112,14 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) return ibuf; } -void render_result_rect_from_ibuf(RenderResult *rr, RenderData *rd, ImBuf *ibuf) +void render_result_rect_from_ibuf(RenderResult *rr, RenderData *UNUSED(rd), ImBuf *ibuf) { if (ibuf->rect_float) { - /* color management: when off ensure rectf is non-lin, since thats what the internal - * render engine delivers */ - int profile_to = (rd->color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB; - int profile_from = (ibuf->profile == IB_PROFILE_LINEAR_RGB) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB; - int predivide = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); - if (!rr->rectf) rr->rectf = MEM_mallocN(4 * sizeof(float) * rr->rectx * rr->recty, "render_seq rectf"); - IMB_buffer_float_from_float(rr->rectf, ibuf->rect_float, - 4, profile_to, profile_from, predivide, - rr->rectx, rr->recty, rr->rectx, rr->rectx); - + memcpy(rr->rectf, ibuf->rect_float, 4 * sizeof(float) * rr->rectx * rr->recty); + /* TSK! Since sequence render doesn't free the *rr render result, the old rect32 * can hang around when sequence render has rendered a 32 bits one before */ if (rr->rect32) { @@ -1156,19 +1151,17 @@ void render_result_rect_fill_zero(RenderResult *rr) rr->rect32 = MEM_callocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect"); } -void render_result_rect_get_pixels(RenderResult *rr, RenderData *rd, unsigned int *rect, int rectx, int recty) +void render_result_rect_get_pixels(RenderResult *rr, RenderData *rd, unsigned int *rect, int rectx, int recty, + const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings) { if (rr->rect32) { memcpy(rect, rr->rect32, sizeof(int) * rr->rectx * rr->recty); } else if (rr->rectf) { - int profile_from = (rd->color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB; int predivide = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); - int dither = 0; - IMB_buffer_byte_from_float((unsigned char *)rect, rr->rectf, - 4, dither, IB_PROFILE_SRGB, profile_from, predivide, - rr->rectx, rr->recty, rr->rectx, rr->rectx); + IMB_display_buffer_transform_apply((unsigned char *) rect, rr->rectf, rr->rectx, rr->recty, 4, + view_settings, display_settings, predivide); } else /* else fill with black */ diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index cbe8cc81451..982f7e7d824 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -50,6 +50,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" #include "BKE_colortools.h" #include "BKE_image.h" @@ -82,6 +83,8 @@ #include "renderdatabase.h" /* needed for UV */ +#include "RE_render_ext.h" + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ /* only to be used here in this file, it's for speed */ @@ -95,7 +98,7 @@ static void init_render_texture(Render *re, Tex *tex) { /* imap test */ if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - BKE_image_user_frame_calc(&tex->iuser, re->r.cfra, re?re->flag & R_SEC_FIELD:0); + BKE_image_user_frame_calc(&tex->iuser, re ? re->r.cfra : 0, re ? re->flag & R_SEC_FIELD:0); } else if (tex->type==TEX_ENVMAP) { @@ -1224,8 +1227,8 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, 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.r.color_mgt_flag & R_COLOR_MANAGEMENT) - srgb_to_linearrgb_v3_v3(&texres->tr, &texres->tr); + if (ibuf && !(ibuf->rect_float)) + IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace); } } else { @@ -1259,18 +1262,19 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, } /* this is called for surface shading */ -int multitex_mtex(ShadeInput *shi, MTex *mtex, float *texvec, float *dxt, float *dyt, TexResult *texres) +static int multitex_mtex(ShadeInput *shi, MTex *mtex, float *texvec, float *dxt, float *dyt, TexResult *texres) { - Tex *tex= mtex->tex; + Tex *tex = mtex->tex; if (tex->use_nodes && tex->nodetree) { /* stupid exception here .. but we have to pass shi and mtex to * textures nodes for 2d mapping and color management for images */ return ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, shi->osatex, shi->thread, - tex, mtex->which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, shi, mtex); + tex, mtex->which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, shi, mtex); } - else + else { return multitex(mtex->tex, texvec, dxt, dyt, shi->osatex, texres, shi->thread, mtex->which_output); + } } /* Warning, if the texres's values are not declared zero, check the return value to be sure @@ -2149,9 +2153,6 @@ void do_material_tex(ShadeInput *shi, Render *re) co= shi->lo; dx= shi->dxlo; dy= shi->dylo; } } - else if (mtex->texco==TEXCO_STICKY) { - co= shi->sticky; dx= shi->dxsticky; dy= shi->dysticky; - } else if (mtex->texco==TEXCO_OBJECT) { Object *ob= mtex->object; if (ob) { @@ -2376,8 +2377,8 @@ void do_material_tex(ShadeInput *shi, Render *re) ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser); /* don't linearize float buffers, assumed to be linear */ - if (ibuf && !(ibuf->rect_float) && re->r.color_mgt_flag & R_COLOR_MANAGEMENT) - srgb_to_linearrgb_v3_v3(tcol, tcol); + if (ibuf && !(ibuf->rect_float)) + IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace); } if (mtex->mapto & MAP_COL) { @@ -2756,11 +2757,9 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_ /* stencil maps on the texture control slider, not texture intensity value */ /* convert RGB to intensity if intensity info isn't provided */ - if (!(rgbnor & TEX_INT)) { - if (rgbnor & TEX_RGB) { - if (texres.talpha) texres.tin = texres.ta; - else texres.tin = rgb_to_grayscale(&texres.tr); - } + if (rgbnor & TEX_RGB) { + if (texres.talpha) texres.tin = texres.ta; + else texres.tin = rgb_to_grayscale(&texres.tr); } if ((mapto_flag & MAP_EMISSION) && (mtex->mapto & MAP_EMISSION)) { @@ -2888,8 +2887,8 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) ImBuf *ibuf = BKE_image_get_ibuf(ima, &mtex->tex->iuser); /* don't linearize float buffers, assumed to be linear */ - if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT) - srgb_to_linearrgb_v3_v3(&texres.tr, &texres.tr); + if (ibuf && !(ibuf->rect_float)) + IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace); } fact= texres.tin*mtex->colfac; @@ -3103,8 +3102,8 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser); /* don't linearize float buffers, assumed to be linear */ - if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT) - srgb_to_linearrgb_v3_v3(tcol, tcol); + if (ibuf && !(ibuf->rect_float)) + IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace); } if (mtex->mapto & WOMAP_HORIZ) { @@ -3317,8 +3316,8 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser); /* don't linearize float buffers, assumed to be linear */ - if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT) - srgb_to_linearrgb_v3_v3(&texres.tr, &texres.tr); + if (ibuf && !(ibuf->rect_float)) + IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace); } /* lamp colors were premultiplied with this */ diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index c009c7b7394..0d894073cee 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -62,6 +62,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" /* local include */ #include "rayintersection.h" @@ -108,10 +109,10 @@ void calc_view_vector(float *view, float x, float y) /* move x and y to real viewplane coords */ x = (x / (float)R.winx); - view[0] = R.viewplane.xmin + x * BLI_RCT_SIZE_X(&R.viewplane); + view[0] = R.viewplane.xmin + x * BLI_rctf_size_x(&R.viewplane); y = (y / (float)R.winy); - view[1] = R.viewplane.ymin + y * BLI_RCT_SIZE_Y(&R.viewplane); + view[1] = R.viewplane.ymin + y * BLI_rctf_size_y(&R.viewplane); // if (R.flag & R_SEC_FIELD) { // if (R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor; @@ -989,6 +990,30 @@ static void convert_to_key_alpha(RenderPart *pa, RenderLayer *rl) } } +/* clamp alpha and RGB to 0..1 and 0..inf, can go outside due to filter */ +static void clamp_alpha_rgb_range(RenderPart *pa, RenderLayer *rl) +{ + RenderLayer *rlpp[RE_MAX_OSA]; + int y, sample, totsample; + + totsample= get_sample_layers(pa, rl, rlpp); + + /* not for full sample, there we clamp after compositing */ + if (totsample > 1) + return; + + for (sample= 0; sample<totsample; sample++) { + float *rectf= rlpp[sample]->rectf; + + for (y= pa->rectx*pa->recty; y>0; y--, rectf+=4) { + rectf[0] = MAX2(rectf[0], 0.0f); + rectf[1] = MAX2(rectf[1], 0.0f); + rectf[2] = MAX2(rectf[2], 0.0f); + CLAMP(rectf[3], 0.0f, 1.0f); + } + } +} + /* adds only alpha values */ static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz) { @@ -1269,6 +1294,9 @@ void zbufshadeDA_tile(RenderPart *pa) if (rl->passflag & SCE_PASS_VECTOR) reset_sky_speed(pa, rl); + + /* clamp alpha to 0..1 range, can go outside due to filter */ + clamp_alpha_rgb_range(pa, rl); /* de-premul alpha */ if (R.r.alphamode & R_ALPHAKEY) @@ -1993,6 +2021,8 @@ typedef struct BakeShade { float dxco[3], dyco[3]; short *do_update; + + struct ColorSpace *rect_colorspace; } BakeShade; static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInput *shi, int quad, int UNUSED(isect), int x, int y, float u, float v) @@ -2168,8 +2198,12 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua else { unsigned char *col= (unsigned char *)(bs->rect + bs->rectx*y + x); - if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE) && (R.r.color_mgt_flag & R_COLOR_MANAGEMENT)) { - linearrgb_to_srgb_uchar3(col, shr.combined); + if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE)) { + float rgb[3]; + + copy_v3_v3(rgb, shr.combined); + IMB_colormanagement_scene_linear_to_colorspace_v3(rgb, bs->rect_colorspace); + rgb_float_to_uchar(col, rgb); } else { rgb_float_to_uchar(col, shr.combined); @@ -2503,6 +2537,7 @@ static void shade_tface(BakeShade *bs) bs->rectx= bs->ibuf->x; bs->recty= bs->ibuf->y; bs->rect= bs->ibuf->rect; + bs->rect_colorspace= bs->ibuf->rect_colorspace; bs->rect_float= bs->ibuf->rect_float; bs->quad= 0; @@ -2613,8 +2648,6 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up ima->flag&= ~IMA_USED_FOR_RENDER; if (ibuf) { ibuf->userdata = NULL; /* use for masking if needed */ - if (ibuf->rect_float) - ibuf->profile = IB_PROFILE_LINEAR_RGB; } } diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index db045284d5b..6395a04b534 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -97,13 +97,10 @@ * the index */ /* NOTE! the hardcoded table size 256 is used still in code for going quickly over vertices/faces */ - -#define RE_STICKY_ELEMS 2 #define RE_STRESS_ELEMS 1 #define RE_RAD_ELEMS 4 #define RE_STRAND_ELEMS 1 #define RE_TANGENT_ELEMS 3 -#define RE_STRESS_ELEMS 1 #define RE_WINSPEED_ELEMS 4 #define RE_MTFACE_ELEMS 1 #define RE_MCOL_ELEMS 4 @@ -114,21 +111,6 @@ #define RE_FACE_ELEMS 1 #define RE_NMAP_TANGENT_ELEMS 16 -float *RE_vertren_get_sticky(ObjectRen *obr, VertRen *ver, int verify) -{ - float *sticky; - int nr= ver->index>>8; - - sticky= obr->vertnodes[nr].sticky; - if (sticky==NULL) { - if (verify) - sticky= obr->vertnodes[nr].sticky= MEM_mallocN(256*RE_STICKY_ELEMS*sizeof(float), "sticky table"); - else - return NULL; - } - return sticky + (ver->index & 255)*RE_STICKY_ELEMS; -} - float *RE_vertren_get_stress(ObjectRen *obr, VertRen *ver, int verify) { float *stress; @@ -218,12 +200,7 @@ VertRen *RE_vertren_copy(ObjectRen *obr, VertRen *ver) *v1= *ver; v1->index= index; - - fp1= RE_vertren_get_sticky(obr, ver, 0); - if (fp1) { - fp2= RE_vertren_get_sticky(obr, v1, 1); - memcpy(fp2, fp1, RE_STICKY_ELEMS*sizeof(float)); - } + fp1= RE_vertren_get_stress(obr, ver, 0); if (fp1) { fp2= RE_vertren_get_stress(obr, v1, 1); @@ -740,8 +717,6 @@ void free_renderdata_vertnodes(VertTableNode *vertnodes) if (vertnodes[a].rad) MEM_freeN(vertnodes[a].rad); - if (vertnodes[a].sticky) - MEM_freeN(vertnodes[a].sticky); if (vertnodes[a].strand) MEM_freeN(vertnodes[a].strand); if (vertnodes[a].tangent) diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 2d7a64bad04..bed3fb5f754 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -72,6 +72,9 @@ # define ACOMP 3 #endif +#define RCT_SIZE_X(rct) ((rct)->xmax - (rct)->xmin) +#define RCT_SIZE_Y(rct) ((rct)->ymax - (rct)->ymin) + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ /* only to be used here in this file, it's for speed */ @@ -1506,7 +1509,7 @@ static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level) root->divider[1]= 0.5f*(root->box.ymin+root->box.ymax); /* find best splitpoint */ - if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box)) + if (RCT_SIZE_X(&root->box) > RCT_SIZE_Y(&root->box)) i = root->index = 0; else i = root->index = 1; @@ -1551,7 +1554,7 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) root->divider[1]/= BSPMAX_SAMPLE; /* find best splitpoint */ - if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box)) + if (RCT_SIZE_X(&root->box) > RCT_SIZE_Y(&root->box)) i = root->index = 0; else i = root->index = 1; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index bbdcfbb5a73..35ab06cc564 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -574,10 +574,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert shi->dywin[1] = 0.0f; } } - - if (texco & TEXCO_STICKY) { - /* not supported */ - } } if (shi->do_manage) { @@ -1124,50 +1120,113 @@ void shade_input_set_shade_texco(ShadeInput *shi) for (i = 0; (tface = RE_vlakren_get_tface(obr, vlr, i, &name, 0)); i++) { ShadeInputUV *suv = &shi->uv[i]; - float *uv1, *uv2, *uv3; + const float *uv1 = tface->uv[j1]; + const float *uv2 = tface->uv[j2]; + const float *uv3 = tface->uv[j3]; shi->totuv++; suv->name = name; - - uv1 = tface->uv[j1]; - uv2 = tface->uv[j2]; - uv3 = tface->uv[j3]; - suv->uv[0] = -1.0f + 2.0f * (l * uv3[0] - u * uv1[0] - v * uv2[0]); - suv->uv[1] = -1.0f + 2.0f * (l * uv3[1] - u * uv1[1] - v * uv2[1]); - suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ + if ((shi->mat->mapflag & MA_MAPFLAG_UVPROJECT) && (shi->depth == 0)) { + float x = shi->xs; + float y = shi->ys; + + float s1[2] = {-1.0f + 2.0f * uv1[0], -1.0f + 2.0f * uv1[1]}; + float s2[2] = {-1.0f + 2.0f * uv2[0], -1.0f + 2.0f * uv2[1]}; + float s3[2] = {-1.0f + 2.0f * uv3[0], -1.0f + 2.0f * uv3[1]}; + + + float obwinmat[4][4], winmat[4][4], ho1[4], ho2[4], ho3[4]; + float Zmulx, Zmuly; + float hox, hoy, l, dl, u, v; + float s00, s01, s10, s11, detsh; + + /* old globals, localized now */ + Zmulx = ((float)R.winx) / 2.0f; + Zmuly = ((float)R.winy) / 2.0f; + + zbuf_make_winmat(&R, winmat); + if (shi->obi->flag & R_TRANSFORMED) + mult_m4_m4m4(obwinmat, winmat, obi->mat); + else + copy_m4_m4(obwinmat, winmat); + + zbuf_render_project(obwinmat, v1->co, ho1); + zbuf_render_project(obwinmat, v2->co, ho2); + zbuf_render_project(obwinmat, v3->co, ho3); + + s00 = ho3[0] / ho3[3] - ho1[0] / ho1[3]; + s01 = ho3[1] / ho3[3] - ho1[1] / ho1[3]; + s10 = ho3[0] / ho3[3] - ho2[0] / ho2[3]; + s11 = ho3[1] / ho3[3] - ho2[1] / ho2[3]; + + detsh = s00 * s11 - s10 * s01; + detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f; + s00 *= detsh; s01 *= detsh; + s10 *= detsh; s11 *= detsh; + + /* recalc u and v again */ + hox = x / Zmulx - 1.0f; + hoy = y / Zmuly - 1.0f; + u = (hox - ho3[0] / ho3[3]) * s11 - (hoy - ho3[1] / ho3[3]) * s10; + v = (hoy - ho3[1] / ho3[3]) * s00 - (hox - ho3[0] / ho3[3]) * s01; + l = 1.0f + u + v; + + suv->uv[0] = l * s3[0] - u * s1[0] - v * s2[0]; + suv->uv[1] = l * s3[1] - u * s1[1] - v * s2[1]; + suv->uv[2] = 0.0f; - if (shi->osatex) { - float duv[2]; - - dl = shi->dx_u + shi->dx_v; - duv[0] = shi->dx_u; - duv[1] = shi->dx_v; + if (shi->osatex) { + float dxuv[2], dyuv[2]; + dxuv[0] = s11 / Zmulx; + dxuv[1] = -s01 / Zmulx; + dyuv[0] = -s10 / Zmuly; + dyuv[1] = s00 / Zmuly; + + dl = dxuv[0] + dxuv[1]; + suv->dxuv[0] = dl * s3[0] - dxuv[0] * s1[0] - dxuv[1] * s2[0]; + suv->dxuv[1] = dl * s3[1] - dxuv[0] * s1[1] - dxuv[1] * s2[1]; + dl = dyuv[0] + dyuv[1]; + suv->dyuv[0] = dl * s3[0] - dyuv[0] * s1[0] - dyuv[1] * s2[0]; + suv->dyuv[1] = dl * s3[1] - dyuv[0] * s1[1] - dyuv[1] * s2[1]; + } + } + else { - suv->dxuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]); - suv->dxuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]); + suv->uv[0] = -1.0f + 2.0f * (l * uv3[0] - u * uv1[0] - v * uv2[0]); + suv->uv[1] = -1.0f + 2.0f * (l * uv3[1] - u * uv1[1] - v * uv2[1]); + suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ - dl = shi->dy_u + shi->dy_v; - duv[0] = shi->dy_u; - duv[1] = shi->dy_v; + if (shi->osatex) { + float duv[2]; - suv->dyuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]); - suv->dyuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]); - } + dl = shi->dx_u + shi->dx_v; + duv[0] = shi->dx_u; + duv[1] = shi->dx_v; - if ((mode & MA_FACETEXTURE) && i == obr->actmtface) { - if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == 0) { - shi->vcol[0] = 1.0f; - shi->vcol[1] = 1.0f; - shi->vcol[2] = 1.0f; - shi->vcol[3] = 1.0f; + suv->dxuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]); + suv->dxuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]); + + dl = shi->dy_u + shi->dy_v; + duv[0] = shi->dy_u; + duv[1] = shi->dy_v; + + suv->dyuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]); + suv->dyuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]); } - if (tface->tpage) { - render_realtime_texture(shi, tface->tpage); + + if ((mode & MA_FACETEXTURE) && i == obr->actmtface) { + if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == 0) { + shi->vcol[0] = 1.0f; + shi->vcol[1] = 1.0f; + shi->vcol[2] = 1.0f; + shi->vcol[3] = 1.0f; + } + if (tface->tpage) { + render_realtime_texture(shi, tface->tpage); + } } } - - } shi->dupliuv[0] = -1.0f + 2.0f * obi->dupliuv[0]; @@ -1236,70 +1295,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->dywin[0] = shi->dywin[2] = 0.0f; } } - - if (texco & TEXCO_STICKY) { - float *s1, *s2, *s3; - - s1 = RE_vertren_get_sticky(obr, v1, 0); - s2 = RE_vertren_get_sticky(obr, v2, 0); - s3 = RE_vertren_get_sticky(obr, v3, 0); - - if (s1 && s2 && s3) { - float obwinmat[4][4], winmat[4][4], ho1[4], ho2[4], ho3[4]; - float Zmulx, Zmuly; - float hox, hoy, l, dl, u, v; - float s00, s01, s10, s11, detsh; - - /* old globals, localized now */ - Zmulx = ((float)R.winx) / 2.0f; Zmuly = ((float)R.winy) / 2.0f; - - zbuf_make_winmat(&R, winmat); - if (shi->obi->flag & R_TRANSFORMED) - mult_m4_m4m4(obwinmat, winmat, obi->mat); - else - copy_m4_m4(obwinmat, winmat); - - zbuf_render_project(obwinmat, v1->co, ho1); - zbuf_render_project(obwinmat, v2->co, ho2); - zbuf_render_project(obwinmat, v3->co, ho3); - - s00 = ho3[0] / ho3[3] - ho1[0] / ho1[3]; - s01 = ho3[1] / ho3[3] - ho1[1] / ho1[3]; - s10 = ho3[0] / ho3[3] - ho2[0] / ho2[3]; - s11 = ho3[1] / ho3[3] - ho2[1] / ho2[3]; - - detsh = s00 * s11 - s10 * s01; - detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f; - s00 *= detsh; s01 *= detsh; - s10 *= detsh; s11 *= detsh; - - /* recalc u and v again */ - hox = x / Zmulx - 1.0f; - hoy = y / Zmuly - 1.0f; - u = (hox - ho3[0] / ho3[3]) * s11 - (hoy - ho3[1] / ho3[3]) * s10; - v = (hoy - ho3[1] / ho3[3]) * s00 - (hox - ho3[0] / ho3[3]) * s01; - l = 1.0f + u + v; - - shi->sticky[0] = l * s3[0] - u * s1[0] - v * s2[0]; - shi->sticky[1] = l * s3[1] - u * s1[1] - v * s2[1]; - shi->sticky[2] = 0.0f; - - if (shi->osatex) { - float dxuv[2], dyuv[2]; - dxuv[0] = s11 / Zmulx; - dxuv[1] = -s01 / Zmulx; - dyuv[0] = -s10 / Zmuly; - dyuv[1] = s00 / Zmuly; - - dl = dxuv[0] + dxuv[1]; - shi->dxsticky[0] = dl * s3[0] - dxuv[0] * s1[0] - dxuv[1] * s2[0]; - shi->dxsticky[1] = dl * s3[1] - dxuv[0] * s1[1] - dxuv[1] * s2[1]; - dl = dyuv[0] + dyuv[1]; - shi->dysticky[0] = dl * s3[0] - dyuv[0] * s1[0] - dyuv[1] * s2[0]; - shi->dysticky[1] = dl * s3[1] - dyuv[0] * s1[1] - dyuv[1] * s2[1]; - } - } - } } /* else { * Note! For raytracing winco is not set, @@ -1325,7 +1320,14 @@ void shade_input_initialize(ShadeInput *shi, RenderPart *pa, RenderLayer *rl, in shi->sample = sample; shi->thread = pa->thread; shi->do_preview = (R.r.scemode & R_MATNODE_PREVIEW) != 0; - shi->do_manage = (R.r.color_mgt_flag & R_COLOR_MANAGEMENT); + + /* OCIO_TODO: for now assume color management is always enabled and vertes colors are in sRGB space + * probably would be nice to have this things configurable, but for now it should work + * also probably this flag could be removed (in separated commit) before the release + * since it's not actually meaningful anymore + */ + shi->do_manage = TRUE; + shi->lay = rl->lay; shi->layflag = rl->layflag; shi->passflag = rl->passflag; diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 51be519d5b8..dc3225b7f09 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -61,11 +61,6 @@ #include "strand.h" #include "zbuf.h" -/* to be removed */ -void hoco_to_zco(ZSpan *zspan, float *zco, float *hoco); -void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, float *v3, void (*func)(void *, int, int, float, float, float) ); -void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, float *ho1, float *ho2); - /* *************** */ static float strand_eval_width(Material *ma, float strandco) diff --git a/source/blender/render/intern/source/texture_ocean.c b/source/blender/render/intern/source/texture_ocean.c index 8c9df496dd6..b2bc635cba7 100644 --- a/source/blender/render/intern/source/texture_ocean.c +++ b/source/blender/render/intern/source/texture_ocean.c @@ -42,6 +42,8 @@ #include "texture.h" +#include "texture_ocean.h" /* own include */ + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index de9572bf57b..bf6962d0087 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -3476,7 +3476,7 @@ void zbuffer_abuf_shadow(Render *re, LampRen *lar, float winmat[][4], APixstr *A /* speed pointer NULL = sky, we clear */ /* else if either alpha is full or no solid was filled in: copy speed */ /* else fill in minimum speed */ -void add_transp_speed(RenderLayer *rl, int offset, float *speed, float alpha, intptr_t *rdrect) +static void add_transp_speed(RenderLayer *rl, int offset, float speed[4], float alpha, intptr_t *rdrect) { RenderPass *rpass; @@ -3525,7 +3525,7 @@ static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob) /* ONLY OSA! merge all shaderesult samples to one */ /* target should have been cleared */ -void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) +static void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) { RenderPass *rpass; float weight= 1.0f/((float)R.osa); @@ -3627,7 +3627,7 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) } -void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alpha) +static void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alpha) { RenderPass *rpass; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index ff7c8cd2ea7..9570638fb25 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -71,8 +71,18 @@ void WM_init_state_normal_set(void); void WM_init (struct bContext *C, int argc, const char **argv); void WM_exit_ext (struct bContext *C, const short do_python); -void WM_exit (struct bContext *C); -void WM_main (struct bContext *C); + +void WM_exit (struct bContext *C) +#if defined(__GNUC__) || defined(__clang__) +__attribute__((noreturn)) +#endif +; + +void WM_main (struct bContext *C) +#if defined(__GNUC__) || defined(__clang__) +__attribute__((noreturn)) +#endif +; int WM_init_game (struct bContext *C); void WM_init_splash (struct bContext *C); @@ -104,8 +114,8 @@ void WM_cursor_set (struct wmWindow *win, int curs); void WM_cursor_modal (struct wmWindow *win, int curs); void WM_cursor_restore (struct wmWindow *win); void WM_cursor_wait (int val); -void WM_cursor_grab_enable(struct wmWindow *win, int wrap, int hide, int *bounds); -void WM_cursor_grab_disable(struct wmWindow *win); +void WM_cursor_grab_enable(struct wmWindow *win, int wrap, int hide, int bounds[4]); +void WM_cursor_grab_disable(struct wmWindow *win, int mouse_ungrab_xy[2]); void WM_cursor_time (struct wmWindow *win, int nr); void *WM_paint_cursor_activate(struct wmWindowManager *wm, @@ -361,6 +371,8 @@ void WM_progress_clear(struct wmWindow *win); /* Draw (for screenshot) */ void WM_redraw_windows(struct bContext *C); +void WM_main_playanim(int argc, const char **argv); + /* debugging only, convenience function to write on crash */ int write_crash_blend(void); diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 6fc6a57ade1..7853b40c98a 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -179,7 +179,10 @@ void WM_cursor_wait(int val) } } -void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int *bounds) +/** + * \param bounds can be NULL + */ +void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int bounds[4]) { /* Only grab cursor when not running debug. * It helps not to get a stuck WM when hitting a breakpoint @@ -193,20 +196,20 @@ void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int *bounds) const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); /* Note: There is no tabletdata on Windows if no tablet device is connected. */ if (!tabletdata) - GHOST_SetCursorGrab(win->ghostwin, mode, bounds); + GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); else if (tabletdata->Active == GHOST_kTabletModeNone) - GHOST_SetCursorGrab(win->ghostwin, mode, bounds); + GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); win->grabcursor = mode; } } } -void WM_cursor_grab_disable(wmWindow *win) +void WM_cursor_grab_disable(wmWindow *win, int mouse_ungrab_xy[2]) { if ((G.debug & G_DEBUG) == 0) { if (win && win->ghostwin) { - GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL); + GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL, mouse_ungrab_xy); win->grabcursor = GHOST_kGrabDisable; } } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 17f17baba0e..c05d9532f74 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1202,7 +1202,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) CTX_wm_region_set(C, region); } - WM_cursor_grab_disable(CTX_wm_window(C)); + WM_cursor_grab_disable(CTX_wm_window(C), NULL); WM_operator_free(handler->op); } else if (handler->ui_remove) { @@ -1432,7 +1432,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand /* remove modal handler, operator itself should have been canceled and freed */ if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { - WM_cursor_grab_disable(CTX_wm_window(C)); + WM_cursor_grab_disable(CTX_wm_window(C), NULL); BLI_remlink(handlers, handler); wm_event_free_handler(handler); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index dca28c63557..594804d10f6 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -708,11 +708,11 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, int **thumb_pt) if (scene->camera) { ibuf = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, - IB_rect, OB_SOLID, FALSE, err_out); + IB_rect, OB_SOLID, FALSE, FALSE, err_out); } else { ibuf = ED_view3d_draw_offscreen_imbuf(scene, v3d, ar, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, - IB_rect, FALSE, err_out); + IB_rect, FALSE, FALSE, err_out); } if (ibuf) { diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 2928ba024e5..b3ffb80243a 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -130,8 +130,8 @@ int wm_gesture_evaluate(wmGesture *gesture) { if (gesture->type == WM_GESTURE_TWEAK) { rcti *rect = gesture->customdata; - int dx = BLI_RCT_SIZE_X(rect); - int dy = BLI_RCT_SIZE_Y(rect); + int dx = BLI_rcti_size_x(rect); + int dy = BLI_rcti_size_y(rect); if (ABS(dx) + ABS(dy) > U.tweak_threshold) { int theta = (int)floor(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI + 0.5f); int val = EVT_GESTURE_W; diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 8c2272e4707..534bfdc369e 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -32,8 +32,8 @@ #include <stdio.h> #include <string.h> -#if WIN32 -#include <Windows.h> +#ifdef WIN32 +# include <Windows.h> #endif #include "MEM_guardedalloc.h" @@ -67,7 +67,6 @@ #include "BKE_tracking.h" /* free tracking clipboard */ #include "BLI_listbase.h" -#include "BLI_math_color.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -115,6 +114,8 @@ #include "BKE_sound.h" #include "COM_compositor.h" +#include "IMB_colormanagement.h" + static void wm_init_reports(bContext *C) { BKE_reports_init(CTX_wm_reports(C), RPT_STORE); @@ -143,15 +144,18 @@ void WM_init(bContext *C, int argc, const char **argv) ED_spacetypes_init(); /* editors/space_api/spacetype.c */ + /* initialize color management stuff + * do this before ED_file_init because that function would load images, + * so at least default byte color space should be already known + */ + IMB_colormanagement_init(); + ED_file_init(); /* for fsmenu */ ED_node_init_butfuncs(); BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */ BLF_lang_init(); - /* initialize color stuff */ - BLI_init_srgb_conversion(); - /* get the default database, plus a wm */ WM_homefile_read(C, NULL, G.factory_startup); @@ -338,9 +342,8 @@ static void free_openrecent(void) extern void free_anim_copybuf(void); extern void free_anim_drivers_copybuf(void); extern void free_fmodifiers_copybuf(void); -extern void free_posebuf(void); -#if WIN32 +#ifdef WIN32 /* Read console events until there is a key event. Also returns on any error. */ static void wait_for_console_key(void) { @@ -371,6 +374,8 @@ void WM_exit_ext(bContext *C, const short do_python) sound_exit(); + IMB_colormanagement_exit(); + /* first wrap up running stuff, we assume only the active WM is running */ /* modal handlers are on window level freed, others too? */ /* note; same code copied in wm_files.c */ @@ -421,7 +426,7 @@ void WM_exit_ext(bContext *C, const short do_python) free_anim_copybuf(); free_anim_drivers_copybuf(); free_fmodifiers_copybuf(); - free_posebuf(); + ED_clipboard_posebuf_free(); BKE_node_clipboard_clear(); BLF_exit(); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index eb6da146a73..bcddc984ed3 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -867,7 +867,6 @@ static wmKeyMapItem *wm_keymap_item_find_props( /* look into multiple handler lists to find the item */ if (win) found = wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); - if (sa && found == NULL) found = wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); @@ -901,7 +900,7 @@ static wmKeyMapItem *wm_keymap_item_find_props( found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } } - + return found; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 0259146a9d3..313fc0a819e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1296,7 +1296,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar extern int datatoc_splash_png_size; ImBuf *ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_png, - datatoc_splash_png_size, IB_rect, "<splash screen>"); + datatoc_splash_png_size, IB_rect, NULL, "<splash screen>"); #else ImBuf *ibuf = NULL; #endif @@ -1693,7 +1693,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) /* **************** link/append *************** */ -int wm_link_append_poll(bContext *C) +static int wm_link_append_poll(bContext *C) { if (WM_operator_winactive(C)) { /* linking changes active object which is pretty useful in general, diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index e3867c0a32a..35cc1545c40 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -72,6 +72,8 @@ #include "wm_event_types.h" +#include "WM_api.h" /* only for WM_main_playanim */ + typedef struct PlayState { /* playback state */ @@ -142,7 +144,7 @@ static struct WindowStateGlobal { eWS_Qual qual; } g_WS = {NULL}; -void playanim_window_get_size(int *width_r, int *height_r) +static void playanim_window_get_size(int *width_r, int *height_r) { GHOST_RectangleHandle bounds = GHOST_GetClientBounds(g_WS.ghost_window); *width_r = GHOST_GetWidthRectangle(bounds); @@ -279,7 +281,8 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid) struct anim *anim; if (IMB_isanim(first)) { - anim = IMB_open_anim(first, IB_rect, 0); + /* OCIO_TODO: support different input color space */ + anim = IMB_open_anim(first, IB_rect, 0, NULL); if (anim) { int pic; ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); @@ -378,12 +381,13 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid) pupdate_time(); if (ptottime > 1.0) { + /* OCIO_TODO: support different input color space */ if (picture->mem) { ibuf = IMB_ibImageFromMemory((unsigned char *)picture->mem, picture->size, - picture->IB_flags, picture->name); + picture->IB_flags, NULL, picture->name); } else { - ibuf = IMB_loadiffname(picture->name, picture->IB_flags); + ibuf = IMB_loadiffname(picture->name, picture->IB_flags, NULL); } if (ibuf) { playanim_toscreen(picture, ibuf, fontid); @@ -689,7 +693,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) return 1; } -void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey, int start_maximized) +static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey, int start_maximized) { GHOST_TWindowState inital_state; GHOST_TUns32 scr_w, scr_h; @@ -709,18 +713,10 @@ void playanim_window_open(const char *title, int posx, int posy, int sizex, int inital_state, GHOST_kDrawingContextTypeOpenGL, FALSE /* no stereo */, FALSE); - - //if (ghostwin) { - //if (win) { - // GHOST_SetWindowUserData(ghostwin, win); - //} else { - // GHOST_DisposeWindow(g_WS.ghost_system, ghostwin); - //} - //} } -void playanim(int argc, const char **argv) +void WM_main_playanim(int argc, const char **argv) { struct ImBuf *ibuf = NULL; char filepath[FILE_MAX]; @@ -824,7 +820,8 @@ void playanim(int argc, const char **argv) } if (IMB_isanim(filepath)) { - anim = IMB_open_anim(filepath, IB_rect, 0); + /* OCIO_TODO: support different input color spaces */ + anim = IMB_open_anim(filepath, IB_rect, 0, NULL); if (anim) { ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); IMB_close_anim(anim); @@ -836,7 +833,8 @@ void playanim(int argc, const char **argv) } if (ibuf == NULL) { - ibuf = IMB_loadiffname(filepath, IB_rect); + /* OCIO_TODO: support different input color space */ + ibuf = IMB_loadiffname(filepath, IB_rect, NULL); } if (ibuf == NULL) { @@ -948,11 +946,13 @@ void playanim(int argc, const char **argv) ibuf = IMB_anim_absolute(ps.picture->anim, ps.picture->frame, IMB_TC_NONE, IMB_PROXY_NONE); } else if (ps.picture->mem) { + /* use correct colorspace here */ ibuf = IMB_ibImageFromMemory((unsigned char *) ps.picture->mem, ps.picture->size, - ps.picture->IB_flags, ps.picture->name); + ps.picture->IB_flags, NULL, ps.picture->name); } else { - ibuf = IMB_loadiffname(ps.picture->name, ps.picture->IB_flags); + /* use correct colorspace here */ + ibuf = IMB_loadiffname(ps.picture->name, ps.picture->IB_flags, NULL); } if (ibuf) { diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index adf54af240b..4078a88b2fd 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -116,8 +116,8 @@ void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y) wmSubWindow *swin = swin_from_swinid(win, swinid); if (swin) { - *x = BLI_RCT_SIZE_X(&swin->winrct) + 1; - *y = BLI_RCT_SIZE_Y(&swin->winrct) + 1; + *x = BLI_rcti_size_x(&swin->winrct) + 1; + *y = BLI_rcti_size_y(&swin->winrct) + 1; } } @@ -256,13 +256,13 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) win->curswin = _curswin; _curwindow = win; - width = BLI_RCT_SIZE_X(&_curswin->winrct) + 1; - height = BLI_RCT_SIZE_Y(&_curswin->winrct) + 1; + width = BLI_rcti_size_x(&_curswin->winrct) + 1; + height = BLI_rcti_size_y(&_curswin->winrct) + 1; glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); if (srct) { - width = BLI_RCT_SIZE_X(srct) + 1; - height = BLI_RCT_SIZE_Y(srct) + 1; + width = BLI_rcti_size_x(srct) + 1; + height = BLI_rcti_size_y(srct) + 1; glScissor(srct->xmin, srct->ymin, width, height); } else diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 59c8235faf0..18072d805fc 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -458,8 +458,8 @@ wmWindow *WM_window_open(bContext *C, rcti *rect) win->posx = rect->xmin; win->posy = rect->ymin; - win->sizex = BLI_RCT_SIZE_X(rect); - win->sizey = BLI_RCT_SIZE_Y(rect); + win->sizex = BLI_rcti_size_x(rect); + win->sizey = BLI_rcti_size_y(rect); win->drawmethod = -1; win->drawdata = NULL; @@ -494,8 +494,8 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) win->posy = position->ymin; } - win->sizex = BLI_RCT_SIZE_X(position); - win->sizey = BLI_RCT_SIZE_Y(position); + win->sizex = BLI_rcti_size_x(position); + win->sizey = BLI_rcti_size_y(position); if (win->ghostwin) { wm_window_set_size(win, win->sizex, win->sizey); diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 44991adcc9d..04d4be05034 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -147,6 +147,7 @@ endif() bf_intern_mikktspace extern_recastnavigation bf_intern_raskter + bf_intern_opencolorio ) if(WITH_MOD_CLOTH_ELTOPO) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 9f8441f4fcf..a9522e3618d 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -431,6 +431,8 @@ void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct Poi void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) {} void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int compact) {} void uiTemplateImageSettings(struct uiLayout *layout, struct PointerRNA *imfptr) {} +void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) {} +void uiTemplateColormanagedViewSettings(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int show_global_settings) {} /* rna render */ struct RenderResult *RE_engine_begin_result(struct RenderEngine *engine, int x, int y, int w, int h) {return (struct RenderResult *) NULL;} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index b6228849ec8..5236f928581 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -302,6 +302,15 @@ if(WITH_INTERNATIONAL) ) endif() +# color management +if(WITH_OPENCOLORIO) + install( + DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/colormanagement + DESTINATION ${TARGETDIR_VER}/datafiles + PATTERN ".svn" EXCLUDE + ) +endif() + # helpful tip when using make if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*") # message after building. @@ -637,6 +646,23 @@ elseif(WIN32) endif() endif() + if(WITH_OPENCOLORIO) + set_lib_path(OCIOBIN "opencolorio/bin") + if(NOT MINGW) + install( + FILES + ${OCIOBIN}/OpenColorIO.dll + DESTINATION ${TARGETDIR} + ) + else() + install( + FILES + ${OCIOBIN}/libOpenColorIO.dll + DESTINATION ${TARGETDIR} + ) + endif() + endif() + elseif(APPLE) # handy install macro to exclude files, we use \$ escape for the "to" @@ -909,6 +935,7 @@ endif() cycles_util cycles_subd bf_intern_raskter + bf_intern_opencolorio ) if(WITH_COMPOSITOR) diff --git a/source/creator/creator.c b/source/creator/creator.c index e1dc2b5df4c..f25ff305c14 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -91,7 +91,6 @@ #include "RE_engine.h" #include "RE_pipeline.h" -//XXX #include "playanim_ext.h" #include "ED_datafiles.h" #include "WM_api.h" @@ -456,11 +455,9 @@ static int set_env(int argc, const char **argv, void *UNUSED(data)) static int playback_mode(int argc, const char **argv, void *UNUSED(data)) { - extern void playanim(int argc, const char **argv); - /* not if -b was given first */ if (G.background == 0) { - playanim(argc, argv); /* not the same argc and argv as before */ + WM_main_playanim(argc, argv); /* not the same argc and argv as before */ exit(0); /* 2.4x didn't do this */ } diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 3a06fe979e1..5cfa97e2e7e 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -125,8 +125,8 @@ static BlendFileData *load_game_data(char *filename) return bfd; } -int BL_KetsjiNextFrame(KX_KetsjiEngine *ketsjiengine, bContext *C, wmWindow *win, Scene *scene, ARegion *ar, - KX_BlenderKeyboardDevice* keyboarddevice, KX_BlenderMouseDevice* mousedevice, int draw_letterbox) +static int BL_KetsjiNextFrame(KX_KetsjiEngine *ketsjiengine, bContext *C, wmWindow *win, Scene *scene, ARegion *ar, + KX_BlenderKeyboardDevice* keyboarddevice, KX_BlenderMouseDevice* mousedevice, int draw_letterbox) { int exitrequested; @@ -143,7 +143,7 @@ int BL_KetsjiNextFrame(KX_KetsjiEngine *ketsjiengine, bContext *C, wmWindow *win // itself is unaware of the extra space, so we clear the whole region for it. glClearColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 1.0f); glViewport(ar->winrct.xmin, ar->winrct.ymin, - BLI_RCT_SIZE_X(&ar->winrct), BLI_RCT_SIZE_Y(&ar->winrct)); + BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct)); glClear(GL_COLOR_BUFFER_BIT); } @@ -198,7 +198,7 @@ struct BL_KetsjiNextFrameState { int draw_letterbox; } ketsjinextframestate; -int BL_KetsjiPyNextFrame(void *state0) +static int BL_KetsjiPyNextFrame(void *state0) { BL_KetsjiNextFrameState *state = (BL_KetsjiNextFrameState *) state0; return BL_KetsjiNextFrame( @@ -552,7 +552,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c ketsjinextframestate.draw_letterbox = draw_letterbox; pynextframestate.state = &ketsjinextframestate; - pynextframestate.func = &BL_KetsjiPyNextFrame; + pynextframestate.func = &BL_KetsjiPyNextFrame; printf("Yielding control to Python script '%s'...\n", python_main); PyRun_SimpleString(python_code); printf("Exit Python script '%s'\n", python_main); @@ -590,7 +590,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c const Py_ssize_t numitems= PyList_GET_SIZE(gameLogic_keys_new); Py_ssize_t listIndex; for (listIndex=0; listIndex < numitems; listIndex++) { - PyObject* item = PyList_GET_ITEM(gameLogic_keys_new, listIndex); + PyObject *item = PyList_GET_ITEM(gameLogic_keys_new, listIndex); if (!PySequence_Contains(gameLogic_keys, item)) { PyDict_DelItem( PyModule_GetDict(gameLogic), item); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 6236923d973..4f450bcd668 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -53,7 +53,7 @@ KX_BlenderCanvas::~KX_BlenderCanvas() void KX_BlenderCanvas::Init() { glDepthFunc(GL_LEQUAL); -} +} void KX_BlenderCanvas::SwapBuffers() @@ -143,7 +143,7 @@ KX_BlenderCanvas:: GetWindowArea( ) { return m_area_rect; -} +} void KX_BlenderCanvas:: diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 19a84acf027..7c4c759e361 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -91,7 +91,7 @@ void BL_SwapBuffers(wmWindow *win) wm_window_swap_buffers(win); } -void DisableForText() +static void DisableForText() { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */ @@ -153,7 +153,7 @@ void BL_print_game_line(int fontid, const char* text, int size, int dpi, float* } void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height) -{ +{ /* gl prepping */ DisableForText(); glDisable(GL_DEPTH_TEST); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index c4daecc9958..85b76d7c676 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -344,7 +344,7 @@ void KX_BlenderRenderTools::PopMatrix() int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) { - // taken from blender source, incompatibility between Blender Object / GameObject + // taken from blender source, incompatibility between Blender Object / GameObject KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; float glviewmat[16]; unsigned int count; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index a229c9f34e6..54ff4dde947 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -62,7 +62,7 @@ class KX_BlenderRenderTools : public RAS_IRenderTools public: KX_BlenderRenderTools(); - virtual ~KX_BlenderRenderTools(); + virtual ~KX_BlenderRenderTools(); void EndFrame(RAS_IRasterizer* rasty); void BeginFrame(RAS_IRasterizer* rasty); diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt index a205ccbdc12..aae7e93cc91 100644 --- a/source/gameengine/CMakeLists.txt +++ b/source/gameengine/CMakeLists.txt @@ -25,7 +25,7 @@ # there are too many inter-includes so best define here if(WITH_PYTHON) - blender_include_dirs("${PYTHON_INCLUDE_DIRS}") + blender_include_dirs_sys("${PYTHON_INCLUDE_DIRS}") add_definitions(-DWITH_PYTHON) endif() diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 92d04115f10..fcf09588791 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -96,7 +96,7 @@ BL_ActionActuator::BL_ActionActuator(SCA_IObject* gameobj, m_userpose(NULL), m_action(action), m_propname(propname), - m_framepropname(framepropname) + m_framepropname(framepropname) { if (!end_reset) m_flag |= ACT_FLAG_CONTINUE; @@ -299,7 +299,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) m_flag |= ACT_FLAG_ATTEMPT_PLAY; } else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent) - { + { m_flag &= ~ACT_FLAG_ATTEMPT_PLAY; m_localtime = obj->GetActionFrame(m_layer); bAction *curr_action = obj->GetCurrentAction(m_layer); @@ -347,7 +347,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) /* Python functions */ /* ------------------------------------------------------------------------- */ -PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) +PyObject *BL_ActionActuator::PyGetChannel(PyObject *value) { PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.getChannel() no longer works, please use BL_ArmatureObject.channels instead"); return NULL; @@ -555,7 +555,7 @@ PyAttributeDef BL_ActionActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); @@ -589,7 +589,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF } -PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.channelNames no longer works, please use BL_ArmatureObject.channels instead"); return NULL; @@ -620,7 +620,7 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA #endif } -PyObject* BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); return PyBool_FromLong(self->m_flag & ACT_FLAG_CONTINUE); @@ -638,7 +638,7 @@ int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUT return PY_SET_ATTR_SUCCESS; } -PyObject* BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); return PyFloat_FromDouble(((KX_GameObject*)self->m_gameobj)->GetActionFrame(self->m_layer)); diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp index 3f4a261a972..f0c4b3d32bb 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.cpp +++ b/source/gameengine/Converter/BL_ArmatureActuator.cpp @@ -146,7 +146,7 @@ void BL_ArmatureActuator::FindConstraint() bool BL_ArmatureActuator::Update(double curtime, bool frame) { // the only role of this actuator is to ensure that the armature pose will be evaluated - bool result = false; + bool result = false; bool bNegativeEvent = IsNegativeEvent(); RemoveAllEvents(); @@ -227,11 +227,11 @@ PyAttributeDef BL_ArmatureActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* BL_ArmatureActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ArmatureActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { BL_ArmatureActuator* actuator = static_cast<BL_ArmatureActuator*>(self); KX_GameObject *target = (!strcmp(attrdef->m_name, "target")) ? actuator->m_gametarget : actuator->m_gamesubtarget; - if (!target) + if (!target) Py_RETURN_NONE; else return target->GetProxy(); @@ -247,7 +247,7 @@ int BL_ArmatureActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBU return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (target != NULL) - target->UnregisterActuator(actuator); + target->UnregisterActuator(actuator); target = gameobj; @@ -257,11 +257,11 @@ int BL_ArmatureActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBU return PY_SET_ATTR_SUCCESS; } -PyObject* BL_ArmatureActuator::pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ArmatureActuator::pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { BL_ArmatureActuator* actuator = static_cast<BL_ArmatureActuator*>(self); BL_ArmatureConstraint* constraint = actuator->m_constraint; - if (!constraint) + if (!constraint) Py_RETURN_NONE; else return constraint->GetProxy(); diff --git a/source/gameengine/Converter/BL_ArmatureActuator.h b/source/gameengine/Converter/BL_ArmatureActuator.h index 638640c27ce..0c88dccb6f3 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.h +++ b/source/gameengine/Converter/BL_ArmatureActuator.h @@ -73,8 +73,8 @@ public: #ifdef WITH_PYTHON /* These are used to get and set m_target */ - static PyObject* pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif // WITH_PYTHON diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp index 7344aa9378e..e588d1d310c 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.cpp +++ b/source/gameengine/Converter/BL_ArmatureChannel.cpp @@ -62,7 +62,7 @@ PyTypeObject BL_ArmatureChannel::Type = { py_base_new }; -PyObject* BL_ArmatureChannel::py_repr(void) +PyObject *BL_ArmatureChannel::py_repr(void) { return PyUnicode_FromString(m_posechannel->name); } @@ -104,8 +104,8 @@ PyMethodDef BL_ArmatureChannel::Methods[] = { PyAttributeDef BL_ArmatureChannel::Attributes[] = { // Keep these attributes in order of BCA_ defines!!! used by py_attr_getattr and py_attr_setattr - KX_PYATTRIBUTE_RO_FUNCTION("bone",BL_ArmatureChannel,py_attr_getattr), - KX_PYATTRIBUTE_RO_FUNCTION("parent",BL_ArmatureChannel,py_attr_getattr), + KX_PYATTRIBUTE_RO_FUNCTION("bone",BL_ArmatureChannel,py_attr_getattr), + KX_PYATTRIBUTE_RO_FUNCTION("parent",BL_ArmatureChannel,py_attr_getattr), { NULL } //Sentinel }; @@ -147,7 +147,7 @@ PyAttributeDef BL_ArmatureChannel::AttributesPtr[] = { { NULL } //Sentinel }; -PyObject* BL_ArmatureChannel::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ArmatureChannel::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) { BL_ArmatureChannel* self= static_cast<BL_ArmatureChannel*>(self_v); bPoseChannel* channel = self->m_posechannel; @@ -200,7 +200,7 @@ int BL_ArmatureChannel::py_attr_setattr(void *self_v, const struct KX_PYATTRIBUT return PY_SET_ATTR_FAIL; } -PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) { bPoseChannel* pchan = static_cast<bPoseChannel*>(self_v); // decompose the pose matrix in euler rotation @@ -223,7 +223,7 @@ PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str } // remove the rest pose to get the joint movement transpose_m3(rest_mat); - mul_m3_m3m3(joint_mat, rest_mat, pose_mat); + mul_m3_m3m3(joint_mat, rest_mat, pose_mat); joints[0] = joints[1] = joints[2] = 0.f; // returns a 3 element list that gives corresponding joint int flag = 0; @@ -458,7 +458,7 @@ PyObject *BL_ArmatureBone::py_bone_get_children(void *self, const struct KX_PYAT for (child=(Bone*)bone->childbase.first; child; child=(Bone*)child->next) count++; - PyObject* childrenlist = PyList_New(count); + PyObject *childrenlist = PyList_New(count); for (count = 0, child=(Bone*)bone->childbase.first; child; child=(Bone*)child->next, ++count) PyList_SET_ITEM(childrenlist,count,NewProxyPlus_Ext(NULL,&Type,child,false)); diff --git a/source/gameengine/Converter/BL_ArmatureChannel.h b/source/gameengine/Converter/BL_ArmatureChannel.h index cd38ee2d531..b764d32e8a7 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.h +++ b/source/gameengine/Converter/BL_ArmatureChannel.h @@ -62,11 +62,11 @@ public: #ifdef WITH_PYTHON // Python access - virtual PyObject* py_repr(void); + virtual PyObject *py_repr(void); - static PyObject* py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static PyObject* py_attr_get_joint_rotation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *py_attr_get_joint_rotation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int py_attr_set_joint_rotation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif // WITH_PYTHON }; diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp index 7939d6e9235..169205d79e7 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp +++ b/source/gameengine/Converter/BL_ArmatureConstraint.cpp @@ -61,7 +61,7 @@ PyTypeObject BL_ArmatureConstraint::Type = { py_base_new }; -PyObject* BL_ArmatureConstraint::py_repr(void) +PyObject *BL_ArmatureConstraint::py_repr(void) { return PyUnicode_FromString(m_name); } @@ -267,8 +267,8 @@ PyMethodDef BL_ArmatureConstraint::Methods[] = { PyAttributeDef BL_ArmatureConstraint::Attributes[] = { // Keep these attributes in order of BCA_ defines!!! used by py_attr_getattr and py_attr_setattr - KX_PYATTRIBUTE_RO_FUNCTION("type",BL_ArmatureConstraint,py_attr_getattr), - KX_PYATTRIBUTE_RO_FUNCTION("name",BL_ArmatureConstraint,py_attr_getattr), + KX_PYATTRIBUTE_RO_FUNCTION("type",BL_ArmatureConstraint,py_attr_getattr), + KX_PYATTRIBUTE_RO_FUNCTION("name",BL_ArmatureConstraint,py_attr_getattr), KX_PYATTRIBUTE_RW_FUNCTION("enforce",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr), KX_PYATTRIBUTE_RW_FUNCTION("headtail",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr), KX_PYATTRIBUTE_RO_FUNCTION("lin_error",BL_ArmatureConstraint,py_attr_getattr), @@ -286,7 +286,7 @@ PyAttributeDef BL_ArmatureConstraint::Attributes[] = { }; -PyObject* BL_ArmatureConstraint::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ArmatureConstraint::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) { BL_ArmatureConstraint* self= static_cast<BL_ArmatureConstraint*>(self_v); bConstraint* constraint = self->m_constraint; @@ -312,12 +312,12 @@ PyObject* BL_ArmatureConstraint::py_attr_getattr(void *self_v, const struct KX_P case BCA_ROTERROR: return PyFloat_FromDouble(constraint->rot_error); case BCA_TARGET: - if (!self->m_target) + if (!self->m_target) Py_RETURN_NONE; else return self->m_target->GetProxy(); case BCA_SUBTARGET: - if (!self->m_subtarget) + if (!self->m_subtarget) Py_RETURN_NONE; else return self->m_subtarget->GetProxy(); diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.h b/source/gameengine/Converter/BL_ArmatureConstraint.h index 0d79bb1cfa7..579153a2e79 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.h +++ b/source/gameengine/Converter/BL_ArmatureConstraint.h @@ -115,9 +115,9 @@ public: #ifdef WITH_PYTHON // Python access - virtual PyObject* py_repr(void); + virtual PyObject *py_repr(void); - static PyObject* py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif // WITH_PYTHON }; diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 7174a563efa..da73d7a762a 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -430,7 +430,7 @@ void BL_ArmatureObject::ProcessReplica() m_pose = NULL; m_framePose = NULL; - game_copy_pose(&m_pose, pose, 1); + game_copy_pose(&m_pose, pose, 1); } void BL_ArmatureObject::ReParentLogic() @@ -521,7 +521,7 @@ bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, SetPose(m_framePose); if (m_activeAct && (m_activeAct!=act)) /* Reset the blend timer since this new action cancels the old one */ - m_activeAct->SetBlendTime(0.0); + m_activeAct->SetBlendTime(0.0); } m_activeAct = act; m_activePriority = priority; @@ -648,12 +648,12 @@ PyAttributeDef BL_ArmatureObject::Attributes[] = { {NULL} //Sentinel }; -PyObject* BL_ArmatureObject::pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ArmatureObject::pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return KX_PythonSeq_CreatePyObject((static_cast<BL_ArmatureObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_CONSTRAINTS); } -PyObject* BL_ArmatureObject::pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ArmatureObject::pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ArmatureObject* self = static_cast<BL_ArmatureObject*>(self_v); self->LoadChannels(); // make sure we have the channels diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 6274e770409..4e7dc3df2f3 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -116,8 +116,8 @@ public: #ifdef WITH_PYTHON // PYTHON - static PyObject* pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); KX_PYMETHOD_DOC_NOARGS(BL_ArmatureObject, update); #endif // WITH_PYTHON diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 84ad12477d0..6ffdea9f90e 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -216,7 +216,7 @@ static std::map<int, SCA_IInputDevice::KX_EnumInputs> create_translate_table() // SYSTEM -#if 0 +#if 0 /* **** XXX **** */ m[KEYBD ] = SCA_IInputDevice::KX_KEYBD; m[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD; @@ -229,7 +229,7 @@ static std::map<int, SCA_IInputDevice::KX_EnumInputs> create_translate_table() m[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT; m[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME; /* **** XXX **** */ -#endif +#endif // standard keyboard @@ -447,7 +447,7 @@ static void GetRGB(short type, else { // backup white c0 = KX_rgbaint2uint_new(color); c1 = KX_rgbaint2uint_new(color); - c2 = KX_rgbaint2uint_new(color); + c2 = KX_rgbaint2uint_new(color); if (mface->v4) c3 = KX_rgbaint2uint_new( color ); } @@ -469,7 +469,7 @@ static void GetRGB(short type, } c0 = KX_rgbaint2uint_new(color); c1 = KX_rgbaint2uint_new(color); - c2 = KX_rgbaint2uint_new(color); + c2 = KX_rgbaint2uint_new(color); if (mface->v4) c3 = KX_rgbaint2uint_new(color); } break; @@ -478,7 +478,7 @@ static void GetRGB(short type, { c0 = KX_rgbaint2uint_new(color); c1 = KX_rgbaint2uint_new(color); - c2 = KX_rgbaint2uint_new(color); + c2 = KX_rgbaint2uint_new(color); if (mface->v4) c3 = KX_rgbaint2uint_new(color); } break; @@ -491,7 +491,7 @@ typedef struct MTF_localLayer { } MTF_localLayer; // ------------------------------------ -bool ConvertMaterial( +static bool ConvertMaterial( BL_Material *material, Material *mat, MTFace* tface, @@ -1150,7 +1150,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, rgb0 = KX_rgbaint2uint_new(color); rgb1 = KX_rgbaint2uint_new(color); - rgb2 = KX_rgbaint2uint_new(color); + rgb2 = KX_rgbaint2uint_new(color); if (mface->v4) rgb3 = KX_rgbaint2uint_new(color); @@ -1535,14 +1535,14 @@ static void my_get_local_bounds(Object *ob, DerivedMesh *dm, float *center, floa ////////////////////////////////////////////////////// -void BL_CreateGraphicObjectNew(KX_GameObject* gameobj, - const MT_Point3& localAabbMin, - const MT_Point3& localAabbMax, - KX_Scene* kxscene, - bool isActive, - e_PhysicsEngine physics_engine) +static void BL_CreateGraphicObjectNew(KX_GameObject* gameobj, + const MT_Point3& localAabbMin, + const MT_Point3& localAabbMax, + KX_Scene* kxscene, + bool isActive, + e_PhysicsEngine physics_engine) { - if (gameobj->GetMeshCount() > 0) + if (gameobj->GetMeshCount() > 0) { switch (physics_engine) { @@ -1574,16 +1574,16 @@ void BL_CreateGraphicObjectNew(KX_GameObject* gameobj, } } -void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, - struct Object* blenderobject, - RAS_MeshObject* meshobj, - KX_Scene* kxscene, - int activeLayerBitInfo, - e_PhysicsEngine physics_engine, - KX_BlenderSceneConverter *converter, - bool processCompoundChildren - ) - +static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, + struct Object* blenderobject, + RAS_MeshObject* meshobj, + KX_Scene* kxscene, + int activeLayerBitInfo, + e_PhysicsEngine physics_engine, + KX_BlenderSceneConverter *converter, + bool processCompoundChildren + ) + { //SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/ //int userigidbody = SYS_GetCommandLineInt(syshandle,"norigidbody",0); @@ -1694,7 +1694,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_soft_numclusteriterations= blenderobject->bsoft->numclusteriterations; /* number of iterations to refine collision clusters*/ //objprop.m_soft_welding = blenderobject->bsoft->welding; /* welding */ /* disable welding: it doesn't bring any additional stability and it breaks the relation between soft body collision shape and graphic mesh */ - objprop.m_soft_welding = 0.f; + objprop.m_soft_welding = 0.f; objprop.m_margin = blenderobject->bsoft->margin; objprop.m_contactProcessingThreshold = 0.f; } else @@ -2086,7 +2086,7 @@ struct parentChildLink { #include "DNA_constraint_types.h" //XXX #include "BIF_editconstraint.h" -bPoseChannel *get_active_posechannel2 (Object *ob) +static bPoseChannel *get_active_posechannel2 (Object *ob) { bArmature *arm= (bArmature*)ob->data; bPoseChannel *pchan; @@ -2100,7 +2100,7 @@ bPoseChannel *get_active_posechannel2 (Object *ob) return NULL; } -ListBase *get_active_constraints2(Object *ob) +static ListBase *get_active_constraints2(Object *ob) { if (!ob) return NULL; @@ -2119,8 +2119,7 @@ ListBase *get_active_constraints2(Object *ob) return NULL; } - -void RBJconstraints(Object *ob)//not used +static void UNUSED_FUNCTION(RBJconstraints)(Object *ob)//not used { ListBase *conlist; bConstraint *curcon; @@ -2141,7 +2140,8 @@ void RBJconstraints(Object *ob)//not used #include "KX_IPhysicsController.h" #include "PHY_DynamicTypes.h" -KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc) {//not used +#if 0 /* UNUSED */ +static KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc) {//not used for (int j=0;j<sumolist->GetCount();j++) { @@ -2151,10 +2151,10 @@ KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc) {//not used } return 0; - } +#endif -KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist) +static KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist) { for (int j=0;j<sumolist->GetCount();j++) @@ -2617,7 +2617,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, KX_SlowParentRelation * slow_parent_relation = KX_SlowParentRelation::New(blenderchild->sf); pcit->m_gamechildnode->SetParentRelation(slow_parent_relation); break; - } + } case PARBONE: { // parent this to a bone @@ -2741,7 +2741,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } - } + } // create physics joints for (i=0;i<sumolist->GetCount();i++) @@ -2825,7 +2825,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); } dofbit<<=1; - } + } } else if (dat->type == PHY_LINEHINGE_CONSTRAINT) { diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index 61477fb1cac..d14160d39a3 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -89,7 +89,7 @@ public: public: -protected: +protected: RAS_Deformer *m_pDeformer; diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index c9371b9df50..b8002d05f18 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -84,7 +84,7 @@ bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*) } BL_MeshDeformer::~BL_MeshDeformer() -{ +{ if (m_transverts) delete [] m_transverts; if (m_transnors) diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index c1c94c25108..eafed8497ba 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -175,7 +175,7 @@ bool BL_ModifierDeformer::Update(void) * It may not be the case here because of replace mesh actuator */ Mesh *oldmesh = (Mesh*)blendobj->data; blendobj->data = m_bmesh; - /* execute the modifiers */ + /* execute the modifiers */ DerivedMesh *dm = mesh_create_derived_no_virtual(m_scene, blendobj, m_transverts, CD_MASK_MESH); /* restore object data */ blendobj->data = oldmesh; diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h index b4827b1bee4..5d0c3bc1317 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.h +++ b/source/gameengine/Converter/BL_ModifierDeformer.h @@ -54,7 +54,7 @@ public: Scene *scene, Object *bmeshobj, RAS_MeshObject *mesh) - : + : BL_ShapeDeformer(gameobj,bmeshobj, mesh), m_lastModifierUpdate(-1), m_scene(scene), diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index c339e10f673..8325e80db78 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -83,7 +83,7 @@ BL_ShapeActionActuator::BL_ShapeActionActuator(SCA_IObject* gameobj, m_playtype(playtype), m_priority(priority), m_action(action), - m_framepropname(framepropname), + m_framepropname(framepropname), m_propname(propname) { m_idptr = new PointerRNA(); @@ -526,7 +526,7 @@ PyAttributeDef BL_ShapeActionActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* BL_ShapeActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *BL_ShapeActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ShapeActionActuator* self= static_cast<BL_ShapeActionActuator*>(self_v); return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index b93d731c5e6..f8941e16ed2 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -173,7 +173,7 @@ bool BL_ShapeDeformer::Update(void) /* store verts locally */ VerifyStorage(); - do_rel_key(0, m_bmesh->totvert, m_bmesh->totvert, (char *)(float *)m_transverts, m_bmesh->key, NULL, 0); /* last arg is ignored */ + BKE_key_evaluate_relative(0, m_bmesh->totvert, m_bmesh->totvert, (char *)(float *)m_transverts, m_bmesh->key, NULL, 0); /* last arg is ignored */ m_bDynamic = true; } diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index efc1b546666..ecf501d9a91 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -73,7 +73,7 @@ public: }; protected: - bool m_useShapeDrivers; + bool m_useShapeDrivers; double m_lastShapeUpdate; struct Key* m_key; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 47cba81798d..c175c1e3b7b 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -67,7 +67,7 @@ extern "C"{ #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS -short get_deformflags(struct Object *bmeshobj) +static short get_deformflags(struct Object *bmeshobj) { short flags = ARM_DEF_VGROUP; @@ -85,9 +85,9 @@ short get_deformflags(struct Object *bmeshobj) } BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj, - struct Object *bmeshobj, - class RAS_MeshObject *mesh, - BL_ArmatureObject* arma) + struct Object *bmeshobj, + class RAS_MeshObject *mesh, + BL_ArmatureObject* arma) : // BL_MeshDeformer(gameobj, bmeshobj, mesh), m_armobj(arma), @@ -110,7 +110,7 @@ BL_SkinDeformer::BL_SkinDeformer( class RAS_MeshObject *mesh, bool release_object, bool recalc_normal, - BL_ArmatureObject* arma) : + BL_ArmatureObject* arma) : BL_MeshDeformer(gameobj, bmeshobj_old, mesh), m_armobj(arma), m_lastArmaUpdate(-1), @@ -327,7 +327,7 @@ void BL_SkinDeformer::BGEDeformVerts() bool BL_SkinDeformer::UpdateInternal(bool shape_applied) { /* See if the armature has been updated for this frame */ - if (PoseUpdated()) { + if (PoseUpdated()) { if (!shape_applied) { /* store verts locally */ diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index fc3b75c49ad..25da8155867 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -199,7 +199,7 @@ void BlenderWorldInfo::setBackColor(float r, float g, float b) m_backgroundcolor[2] = b; } - void + void BlenderWorldInfo::setMistStart( float d ) { @@ -215,7 +215,7 @@ BlenderWorldInfo::setMistDistance( } - void + void BlenderWorldInfo::setMistColorRed( float d ) { @@ -231,7 +231,7 @@ BlenderWorldInfo::setMistColorGreen( } - void + void BlenderWorldInfo::setMistColorBlue( float d ) { diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index e00eb99e73f..2cf706a3089 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -73,27 +73,27 @@ public: float g, float b ); - void + void setMistStart( float d ); - void + void setMistDistance( float d ); - void + void setMistColorRed( float d ); - void + void setMistColorGreen( float d ); - void + void setMistColorBlue( float d ); diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp index f020aab4d50..72212581d4b 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp @@ -78,5 +78,5 @@ KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *r return *i; } return NULL; -} +} diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h index bc5a6eeef85..980aeef7e60 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h @@ -65,7 +65,7 @@ public: BL_InterpolatorList(struct bAction *action); ~BL_InterpolatorList(); - KX_IScalarInterpolator *GetScalarInterpolator(const char *rna_path, int array_index); + KX_IScalarInterpolator *GetScalarInterpolator(const char *rna_path, int array_index); #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 1c3352454a2..9020720eaeb 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -160,7 +160,7 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() while (itmat != m_materials.end()) { delete (*itmat).second; itmat++; - } + } vector<pair<KX_Scene*,RAS_MeshObject*> >::iterator itm = m_meshobjects.begin(); @@ -201,7 +201,7 @@ bool KX_BlenderSceneConverter::TryAndLoadNewFile() // if not, clear the newfilename else { - m_newfilename = ""; + m_newfilename = ""; } */ return result; @@ -335,7 +335,7 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, ccdPhysEnv->setDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints); //todo: get a button in blender ? - //disable / enable debug drawing (contact points, aabb's etc) + //disable / enable debug drawing (contact points, aabb's etc) //ccdPhysEnv->setDebugMode(1); destinationscene->SetPhysicsEnvironment(ccdPhysEnv); break; @@ -689,7 +689,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo) void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo() { - if (addInitFromFrame) { + if (addInitFromFrame) { KX_SceneList* scenes = m_ketsjiEngine->CurrentScenes(); int numScenes = scenes->size(); if (numScenes>=0) { @@ -704,7 +704,7 @@ void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo() if (blenderobject->type==OB_ARMATURE) continue; float eu[3]; - mat4_to_eul(eu,blenderobject->obmat); + mat4_to_eul(eu,blenderobject->obmat); MT_Point3 pos = MT_Point3( blenderobject->obmat[3][0], blenderobject->obmat[3][1], @@ -779,8 +779,8 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) //const MT_Vector3& scale = gameObj->NodeGetWorldScaling(); const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation(); - float eulerAngles[3]; - float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f}; + float eulerAngles[3]; + float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f}; float tmat[3][3]; // XXX animato @@ -984,7 +984,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha } main_newlib= (Main *)MEM_callocN( sizeof(Main), "BgeMain"); - BKE_reports_init(&reports, RPT_STORE); + BKE_reports_init(&reports, RPT_STORE); load_datablocks(main_newlib, bpy_openlib, path, idcode); @@ -1000,11 +1000,11 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha BLO_blendhandle_close(bpy_openlib); BKE_reports_clear(&reports); - /* done linking */ + /* done linking */ /* needed for lookups*/ GetMainDynamic().push_back(main_newlib); - strncpy(main_newlib->name, path, sizeof(main_newlib->name)); + strncpy(main_newlib->name, path, sizeof(main_newlib->name)); if (idcode==ID_ME) { @@ -1028,7 +1028,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha scene_merge->GetLogicManager()->RegisterActionName(action->name+2, action); } } - else if (idcode==ID_SCE) { + else if (idcode==ID_SCE) { /* Merge all new linked in scene into the existing one */ ID *scene; for (scene= (ID *)main_newlib->scene.first; scene; scene= (ID *)scene->next ) { @@ -1117,7 +1117,7 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) { RAS_MeshObject *meshobj= (RAS_MeshObject *) *mapStringToMeshes.at(i); if (meshobj && IS_TAGGED(meshobj->GetMesh())) - { + { STR_HashedString mn = meshobj->GetName(); mapStringToMeshes.remove(mn); m_map_mesh_to_gamemesh.remove(CHashedPtr(meshobj->GetMesh())); @@ -1255,7 +1255,7 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) RAS_IPolyMaterial *mat= (*polymit).second; Material *bmat= NULL; - /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject*)? - Campbell */ + /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject *)? - Campbell */ if (mat->GetFlag() & RAS_BLENDERMAT) { KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat); bmat= bl_mat->GetBlenderMaterial(); @@ -1280,7 +1280,7 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) RAS_IPolyMaterial *mat= (*polymit).second; Material *bmat= NULL; - /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject*)? - Campbell */ + /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject *)? - Campbell */ if (mat->GetFlag() & RAS_BLENDERMAT) { KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat); bmat= bl_mat->GetBlenderMaterial(); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 9caa6bbf579..287be3b8359 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -903,7 +903,7 @@ void BL_ConvertActuators(const char* maggiename, modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL; break; default: - ; /* error */ + ; /* error */ } tmprandomact = new SCA_RandomActuator(gameobj, seedArg, diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 81778928c2e..3a6aa228957 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -69,7 +69,7 @@ static void LinkControllerToActuators( SCA_IController *game_controller, - bController* bcontr, + bController* bcontr, SCA_LogicManager* logicmgr, KX_BlenderSceneConverter* converter ) { diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index faa7780bac0..a63f4c38fb6 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -67,7 +67,7 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan { bProperty* prop = (bProperty*)object->prop.first; - CValue* propval; + CValue* propval; bool show_debug_info; while(prop) { @@ -177,7 +177,7 @@ void BL_ConvertTextProperty(Object* object, KX_FontObject* fontobj,SCA_TimeEvent { CValue* tprop = fontobj->GetProperty("Text"); if (!tprop) return; - bProperty* prop = get_ob_property(object, "Text"); + bProperty* prop = BKE_bproperty_object_get(object, "Text"); if (!prop) return; Curve *curve = static_cast<Curve *>(object->data); diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 9f155a6ebc3..3d4f3ae08f2 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -183,7 +183,7 @@ void BL_ConvertSensors(struct Object* blenderobject, if (gameobj->GetPhysicsController()) - { + { gamesensor = new KX_TouchSensor(eventmgr, gameobj, bFindMaterial, @@ -209,7 +209,7 @@ void BL_ConvertSensors(struct Object* blenderobject, } bool bFindMaterial = true; if (gameobj->GetPhysicsController()) - { + { gamesensor = new KX_TouchSensor(eventmgr, gameobj, bFindMaterial, @@ -224,7 +224,7 @@ void BL_ConvertSensors(struct Object* blenderobject, KX_NetworkEventManager* eventmgr = (KX_NetworkEventManager*) logicmgr->FindEventManager(SCA_EventManager::NETWORK_EVENTMGR); if (eventmgr) { - bMessageSensor* msgSens = (bMessageSensor*) sens->data; + bMessageSensor* msgSens = (bMessageSensor*) sens->data; /* Get our NetworkScene */ NG_NetworkScene *NetworkScene = kxscene->GetNetworkScene(); @@ -247,7 +247,7 @@ void BL_ConvertSensors(struct Object* blenderobject, SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR); if (eventmgr) { - STR_String nearpropertyname; + STR_String nearpropertyname; bNearSensor* blendernearsensor = (bNearSensor*)sens->data; if (blendernearsensor->name) { @@ -311,7 +311,7 @@ void BL_ConvertSensors(struct Object* blenderobject, } case SENS_MOUSE: { - int keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_NODEF; + int keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_NODEF; int trackfocus = 0; bMouseSensor *bmouse = (bMouseSensor *)sens->data; @@ -639,7 +639,7 @@ void BL_ConvertSensors(struct Object* blenderobject, gamesensor->SetInvert(invert); gamesensor->SetLevel(level); gamesensor->SetTap(tap); - gamesensor->SetName(sens->name); + gamesensor->SetName(sens->name); gameobj->AddSensor(gamesensor); diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 309959b4324..12f88251805 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -76,12 +76,12 @@ static BL_InterpolatorList *GetAdtList(struct bAction *for_act, KX_BlenderSceneC { BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_act); - if (!adtList) { + if (!adtList) { adtList = new BL_InterpolatorList(for_act); converter->RegisterInterpolatorList(adtList, for_act); } - return adtList; + return adtList; } SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_BlenderSceneConverter *converter) @@ -441,7 +441,7 @@ static void ConvertMaterialIpos( } interpolator= new KX_ScalarInterpolator(&ipocontr->m_ref, sinterp); ipocontr->AddInterpolator(interpolator); - } + } if ((sinterp = adtList->GetScalarInterpolator("emit", 0))) { if (!ipocontr) { @@ -452,7 +452,7 @@ static void ConvertMaterialIpos( interpolator= new KX_ScalarInterpolator(&ipocontr->m_emit, sinterp); ipocontr->AddInterpolator(interpolator); } - } + } } void BL_ConvertMaterialIpos( diff --git a/source/gameengine/Expressions/BoolValue.cpp b/source/gameengine/Expressions/BoolValue.cpp index 40997a25be1..e640923129a 100644 --- a/source/gameengine/Expressions/BoolValue.cpp +++ b/source/gameengine/Expressions/BoolValue.cpp @@ -205,7 +205,7 @@ CValue* CBoolValue::GetReplica() } #ifdef WITH_PYTHON -PyObject* CBoolValue::ConvertValueToPython() +PyObject *CBoolValue::ConvertValueToPython() { return PyBool_FromLong(m_bool != 0); } diff --git a/source/gameengine/Expressions/BoolValue.h b/source/gameengine/Expressions/BoolValue.h index 09e931ea661..64ac0266baf 100644 --- a/source/gameengine/Expressions/BoolValue.h +++ b/source/gameengine/Expressions/BoolValue.h @@ -29,7 +29,7 @@ class CBoolValue : public CPropValue { - //PLUGIN_DECLARE_SERIAL(CBoolValue,CValue) + //PLUGIN_DECLARE_SERIAL(CBoolValue,CValue) public: static const STR_String sTrueString; diff --git a/source/gameengine/Expressions/EXP_C-Api.cpp b/source/gameengine/Expressions/EXP_C-Api.cpp index 763d115a840..2822fd8f6de 100644 --- a/source/gameengine/Expressions/EXP_C-Api.cpp +++ b/source/gameengine/Expressions/EXP_C-Api.cpp @@ -102,8 +102,8 @@ int EXP_IsValid(EXP_ValueHandle inval) /* assign property 'propval' to 'destinationval' */ void EXP_SetProperty(EXP_ValueHandle destinationval, - const char* propname, - EXP_ValueHandle propval) + const char *propname, + EXP_ValueHandle propval) { ((CValue*) destinationval)->SetProperty(propname,(CValue*)propval); } diff --git a/source/gameengine/Expressions/EXP_C-Api.h b/source/gameengine/Expressions/EXP_C-Api.h index 6be1e57481c..4d43695f9b9 100644 --- a/source/gameengine/Expressions/EXP_C-Api.h +++ b/source/gameengine/Expressions/EXP_C-Api.h @@ -53,7 +53,7 @@ extern void EXP_ReleaseValue(EXP_ValueHandle); extern int EXP_IsValid(EXP_ValueHandle); /* assign property 'propval' to 'destinationval' */ -extern void EXP_SetProperty(EXP_ValueHandle propval,EXP_ValueHandle destinationval); +extern void EXP_SetProperty(EXP_ValueHandle destinationval, const char *propname, EXP_ValueHandle propval); /* returns NULL if property doesn't exist */ extern EXP_ValueHandle EXP_GetProperty(EXP_ValueHandle inval,const char* propname); diff --git a/source/gameengine/Expressions/FloatValue.cpp b/source/gameengine/Expressions/FloatValue.cpp index 403338573e2..c9b59e52ee8 100644 --- a/source/gameengine/Expressions/FloatValue.cpp +++ b/source/gameengine/Expressions/FloatValue.cpp @@ -314,7 +314,7 @@ CValue* CFloatValue::GetReplica() #ifdef WITH_PYTHON -PyObject* CFloatValue::ConvertValueToPython() +PyObject *CFloatValue::ConvertValueToPython() { return PyFloat_FromDouble(m_float); } diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp index 58837235d30..bdf4ee4605b 100644 --- a/source/gameengine/Expressions/InputParser.cpp +++ b/source/gameengine/Expressions/InputParser.cpp @@ -543,7 +543,7 @@ CExpression *CParser::Ex(int i) } e1 = Error(errtext); - break; + break; } default: NextSym(); @@ -573,7 +573,7 @@ CExpression* CParser::ProcessText text = intext; - chcount = 0; + chcount = 0; if (text.Length() == 0) { return NULL; } diff --git a/source/gameengine/Expressions/IntValue.cpp b/source/gameengine/Expressions/IntValue.cpp index 2d427440620..12d6e258ddf 100644 --- a/source/gameengine/Expressions/IntValue.cpp +++ b/source/gameengine/Expressions/IntValue.cpp @@ -326,7 +326,7 @@ void CIntValue::SetValue(CValue* newval) #ifdef WITH_PYTHON -PyObject* CIntValue::ConvertValueToPython() +PyObject *CIntValue::ConvertValueToPython() { if ((m_int > INT_MIN) && (m_int < INT_MAX)) return PyLong_FromSsize_t(m_int); diff --git a/source/gameengine/Expressions/KX_HashedPtr.h b/source/gameengine/Expressions/KX_HashedPtr.h index ffc6ff647d5..866689ed203 100644 --- a/source/gameengine/Expressions/KX_HashedPtr.h +++ b/source/gameengine/Expressions/KX_HashedPtr.h @@ -50,7 +50,7 @@ public: inline friend bool operator ==( const CHashedPtr & rhs,const CHashedPtr & lhs) { return rhs.m_valptr == lhs.m_valptr; - } + } #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index f43625a7821..88b0a986a05 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -278,7 +278,7 @@ bool CListValue::IsModified() /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ -Py_ssize_t listvalue_bufferlen(PyObject* self) +static Py_ssize_t listvalue_bufferlen(PyObject *self) { CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self)); if (list==NULL) @@ -287,7 +287,7 @@ Py_ssize_t listvalue_bufferlen(PyObject* self) return (Py_ssize_t)list->GetCount(); } -PyObject* listvalue_buffer_item(PyObject* self, Py_ssize_t index) +static PyObject *listvalue_buffer_item(PyObject *self, Py_ssize_t index) { CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self)); CValue *cval; @@ -309,14 +309,14 @@ PyObject* listvalue_buffer_item(PyObject* self, Py_ssize_t index) cval= list->GetValue(index); - PyObject* pyobj = cval->ConvertValueToPython(); + PyObject *pyobj = cval->ConvertValueToPython(); if (pyobj) return pyobj; else return cval->GetProxy(); } -PyObject* listvalue_mapping_subscript(PyObject* self, PyObject* pyindex) +static PyObject *listvalue_mapping_subscript(PyObject *self, PyObject *pyindex) { CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self)); if (list==NULL) { @@ -328,7 +328,7 @@ PyObject* listvalue_mapping_subscript(PyObject* self, PyObject* pyindex) { CValue *item = ((CListValue*) list)->FindValue(_PyUnicode_AsString(pyindex)); if (item) { - PyObject* pyobj = item->ConvertValueToPython(); + PyObject *pyobj = item->ConvertValueToPython(); if (pyobj) return pyobj; else @@ -348,7 +348,7 @@ PyObject* listvalue_mapping_subscript(PyObject* self, PyObject* pyindex) /* just slice it into a python list... */ -PyObject* listvalue_buffer_slice(PyObject* self,Py_ssize_t ilow, Py_ssize_t ihigh) +static PyObject *listvalue_buffer_slice(PyObject *self,Py_ssize_t ilow, Py_ssize_t ihigh) { CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self)); if (list==NULL) { @@ -374,17 +374,17 @@ PyObject* listvalue_buffer_slice(PyObject* self,Py_ssize_t ilow, Py_ssize_t ihig for (i = ilow, j = 0; i < ihigh; i++, j++) { - PyObject* pyobj = list->GetValue(i)->ConvertValueToPython(); + PyObject *pyobj = list->GetValue(i)->ConvertValueToPython(); if (!pyobj) pyobj = list->GetValue(i)->GetProxy(); PyList_SET_ITEM(newlist, i, pyobj); - } + } return newlist; } /* clist + list, return a list that python owns */ -static PyObject *listvalue_buffer_concat(PyObject * self, PyObject * other) +static PyObject *listvalue_buffer_concat(PyObject *self, PyObject *other) { CListValue *listval= static_cast<CListValue *>(BGE_PROXY_REF(self)); Py_ssize_t i, numitems, numitems_orig; @@ -560,7 +560,7 @@ PyAttributeDef CListValue::Attributes[] = { { NULL } //Sentinel }; -PyObject* CListValue::Pyappend(PyObject* value) +PyObject *CListValue::Pyappend(PyObject *value) { CValue* objval = ConvertPythonToValue(value, "CList.append(i): CValueList, "); @@ -577,15 +577,15 @@ PyObject* CListValue::Pyappend(PyObject* value) Py_RETURN_NONE; } -PyObject* CListValue::Pyreverse() +PyObject *CListValue::Pyreverse() { std::reverse(m_pValueArray.begin(),m_pValueArray.end()); Py_RETURN_NONE; } -PyObject* CListValue::Pyindex(PyObject *value) +PyObject *CListValue::Pyindex(PyObject *value) { - PyObject* result = NULL; + PyObject *result = NULL; CValue* checkobj = ConvertPythonToValue(value, "val = cList[i]: CValueList, "); if (checkobj==NULL) @@ -612,7 +612,7 @@ PyObject* CListValue::Pyindex(PyObject *value) -PyObject* CListValue::Pycount(PyObject* value) +PyObject *CListValue::Pycount(PyObject *value) { int numfound = 0; @@ -638,17 +638,17 @@ PyObject* CListValue::Pycount(PyObject* value) } /* Matches python dict.get(key, [default]) */ -PyObject* CListValue::Pyget(PyObject *args) +PyObject *CListValue::Pyget(PyObject *args) { char *key; - PyObject* def = Py_None; + PyObject *def = Py_None; if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) return NULL; CValue *item = FindValue((const char *)key); if (item) { - PyObject* pyobj = item->ConvertValueToPython(); + PyObject *pyobj = item->ConvertValueToPython(); if (pyobj) return pyobj; else @@ -659,7 +659,7 @@ PyObject* CListValue::Pyget(PyObject *args) } -PyObject* CListValue::Pyfrom_id(PyObject* value) +PyObject *CListValue::Pyfrom_id(PyObject *value) { uintptr_t id= (uintptr_t)PyLong_AsVoidPtr(value); diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h index 4d104a4bd3a..20005088310 100644 --- a/source/gameengine/Expressions/ListValue.h +++ b/source/gameengine/Expressions/ListValue.h @@ -64,7 +64,7 @@ public: bool CheckEqual(CValue* first,CValue* second); #ifdef WITH_PYTHON - virtual PyObject* py_repr(void) { + virtual PyObject *py_repr(void) { PyObject *py_proxy= this->GetProxy(); PyObject *py_list= PySequence_List(py_proxy); PyObject *py_string= PyObject_Repr(py_list); diff --git a/source/gameengine/Expressions/Operator2Expr.cpp b/source/gameengine/Expressions/Operator2Expr.cpp index 2224b0ff5e8..d0240b5ec75 100644 --- a/source/gameengine/Expressions/Operator2Expr.cpp +++ b/source/gameengine/Expressions/Operator2Expr.cpp @@ -102,7 +102,7 @@ and m_rhs m_cached_calculate = ffleft->Calc(m_op,ffright); - //if (m_cached_calculate) + //if (m_cached_calculate) // m_cached_calculate->Action(CValue::SETOWNEREXPR,&CVoidValue(this,false,CValue::STACKVALUE)); ffleft->Release(); @@ -163,7 +163,7 @@ bool COperator2Expr::IsInside(float x, float y, float z,bool bBorderInclude) } } - return inside; + return inside; } @@ -241,7 +241,7 @@ CExpression* COperator2Expr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlink if (m_rhs) return Release(m_rhs->AddRef()); -/ +/ */ return Release(); diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index a35cb4f9f69..6bb2f039b5c 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -145,7 +145,7 @@ PyObject *PyObjectPlus::py_base_repr(PyObject *self) // This should be the ent } -PyObject * PyObjectPlus::py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +PyObject *PyObjectPlus::py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyTypeObject *base_type; PyObjectPlus_Proxy *base = NULL; @@ -270,7 +270,7 @@ PyAttributeDef PyObjectPlus::Attributes[] = { -PyObject* PyObjectPlus::pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *PyObjectPlus::pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return PyBool_FromLong(self_v ? 0:1); } @@ -303,7 +303,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * ptr += attrdef->m_offset; if (attrdef->m_length > 1) { - PyObject* resultlist = PyList_New(attrdef->m_length); + PyObject *resultlist = PyList_New(attrdef->m_length); for (unsigned int i=0; i<attrdef->m_length; i++) { switch (attrdef->m_type) { @@ -420,7 +420,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * #ifdef USE_MATHUTILS return Vector_CreatePyObject(val, attrdef->m_imax, Py_NEW, NULL); #else - PyObject* resultlist = PyList_New(attrdef->m_imax); + PyObject *resultlist = PyList_New(attrdef->m_imax); for (unsigned int i=0; i<attrdef->m_imax; i++) { PyList_SET_ITEM(resultlist,i,PyFloat_FromDouble(val[i])); @@ -437,10 +437,10 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * #ifdef USE_MATHUTILS return Matrix_CreatePyObject(val, attrdef->m_imin, attrdef->m_imax, Py_WRAP, NULL); #else - PyObject* collist = PyList_New(attrdef->m_imin); + PyObject *collist = PyList_New(attrdef->m_imin); for (unsigned int i=0; i<attrdef->m_imin; i++) { - PyObject* col = PyList_New(attrdef->m_imax); + PyObject *col = PyList_New(attrdef->m_imax); for (unsigned int j=0; j<attrdef->m_imax; j++) { PyList_SET_ITEM(col,j,PyFloat_FromDouble(val[j])); @@ -460,7 +460,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * val->getValue(fval); return Vector_CreatePyObject(fval, 3, Py_NEW, NULL); #else - PyObject* resultlist = PyList_New(3); + PyObject *resultlist = PyList_New(3); for (unsigned int i=0; i<3; i++) { PyList_SET_ITEM(resultlist,i,PyFloat_FromDouble((*val)[i])); @@ -1100,7 +1100,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt } if (undoBuffer) free(undoBuffer); - return 0; + return 0; } @@ -1139,7 +1139,7 @@ PyObject *PyObjectPlus::NewProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, v if (!self) { // in case of proxy without reference to game object - PyObject* proxy = reinterpret_cast<PyObject *>PyObject_NEW( PyObjectPlus_Proxy, tp); + PyObject *proxy = reinterpret_cast<PyObject *>PyObject_NEW( PyObjectPlus_Proxy, tp); BGE_PROXY_PYREF(proxy) = false; BGE_PROXY_PYOWNS(proxy) = py_owns; BGE_PROXY_REF(proxy) = NULL; diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index f74ed7db8f7..005bf2f6cb2 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -190,9 +190,9 @@ public: \ * macro is one that also requires a documentation string */ #define KX_PYMETHOD(class_name, method_name) \ - PyObject* Py##method_name(PyObject* args, PyObject* kwds); \ - static PyObject* \ - sPy##method_name(PyObject* self, PyObject* args, PyObject* kwds) { \ + PyObject *Py##method_name(PyObject *args, PyObject *kwds); \ + static PyObject * \ + sPy##method_name(PyObject *self, PyObject *args, PyObject *kwds) { \ if(BGE_PROXY_REF(self)==NULL) { \ PyErr_SetString(PyExc_RuntimeError, \ #class_name "." #method_name "() - " \ @@ -203,9 +203,9 @@ public: \ } \ #define KX_PYMETHOD_VARARGS(class_name, method_name) \ - PyObject* Py##method_name(PyObject* args); \ + PyObject *Py##method_name(PyObject *args); \ static PyObject* \ - sPy##method_name(PyObject* self, PyObject* args) { \ + sPy##method_name(PyObject *self, PyObject *args) { \ if(BGE_PROXY_REF(self)==NULL) { \ PyErr_SetString(PyExc_RuntimeError, \ #class_name "." #method_name "() - " \ @@ -215,9 +215,9 @@ public: \ } \ #define KX_PYMETHOD_NOARGS(class_name, method_name) \ - PyObject* Py##method_name(); \ + PyObject *Py##method_name(); \ static PyObject* \ - sPy##method_name(PyObject* self) { \ + sPy##method_name(PyObject *self) { \ if(BGE_PROXY_REF(self)==NULL) { \ PyErr_SetString(PyExc_RuntimeError, \ #class_name "." #method_name "() - " \ @@ -227,9 +227,9 @@ public: \ } \ #define KX_PYMETHOD_O(class_name, method_name) \ - PyObject* Py##method_name(PyObject* value); \ + PyObject *Py##method_name(PyObject *value); \ static PyObject* \ - sPy##method_name(PyObject* self, PyObject* value) { \ + sPy##method_name(PyObject *self, PyObject *value) { \ if(BGE_PROXY_REF(self)==NULL) { \ PyErr_SetString(PyExc_RuntimeError, \ #class_name "." #method_name "(value) - " \ @@ -239,9 +239,9 @@ public: \ } \ #define KX_PYMETHOD_DOC(class_name, method_name) \ - PyObject* Py##method_name(PyObject* args, PyObject* kwds); \ + PyObject *Py##method_name(PyObject *args, PyObject *kwds); \ static PyObject* \ - sPy##method_name(PyObject* self, PyObject* args, PyObject* kwds) { \ + sPy##method_name(PyObject *self, PyObject *args, PyObject *kwds) { \ if(BGE_PROXY_REF(self)==NULL) { \ PyErr_SetString(PyExc_RuntimeError, \ #class_name "." #method_name "(...) - " \ @@ -252,9 +252,9 @@ public: \ static const char method_name##_doc[]; \ #define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \ - PyObject* Py##method_name(PyObject* args); \ + PyObject *Py##method_name(PyObject *args); \ static PyObject* \ - sPy##method_name(PyObject* self, PyObject* args) { \ + sPy##method_name(PyObject *self, PyObject *args) { \ if(BGE_PROXY_REF(self)==NULL) { \ PyErr_SetString(PyExc_RuntimeError, \ #class_name "." #method_name "(...) - " \ @@ -266,9 +266,9 @@ public: \ static const char method_name##_doc[]; \ #define KX_PYMETHOD_DOC_O(class_name, method_name) \ - PyObject* Py##method_name(PyObject* value); \ - static PyObject* \ - sPy##method_name(PyObject* self, PyObject* value) { \ + PyObject *Py##method_name(PyObject *value); \ + static PyObject * \ + sPy##method_name(PyObject *self, PyObject *value) { \ if(BGE_PROXY_REF(self)==NULL) { \ PyErr_SetString(PyExc_RuntimeError, \ #class_name "." #method_name "(value) - " \ @@ -280,9 +280,9 @@ public: \ static const char method_name##_doc[]; \ #define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \ - PyObject* Py##method_name(); \ - static PyObject* \ - sPy##method_name(PyObject* self) { \ + PyObject *Py##method_name(); \ + static PyObject * \ + sPy##method_name(PyObject *self) { \ if(BGE_PROXY_REF(self)==NULL) { \ PyErr_SetString(PyExc_RuntimeError, \ #class_name "." #method_name "() - " \ @@ -315,19 +315,19 @@ public: \ */ #define KX_PYMETHODDEF_DOC(class_name, method_name, doc_string) \ const char class_name::method_name##_doc[] = doc_string; \ -PyObject* class_name::Py##method_name(PyObject* args, PyObject* kwds) +PyObject *class_name::Py##method_name(PyObject *args, PyObject *kwds) #define KX_PYMETHODDEF_DOC_VARARGS(class_name, method_name, doc_string) \ const char class_name::method_name##_doc[] = doc_string; \ -PyObject* class_name::Py##method_name(PyObject* args) +PyObject *class_name::Py##method_name(PyObject *args) #define KX_PYMETHODDEF_DOC_O(class_name, method_name, doc_string) \ const char class_name::method_name##_doc[] = doc_string; \ -PyObject* class_name::Py##method_name(PyObject* value) +PyObject *class_name::Py##method_name(PyObject *value) #define KX_PYMETHODDEF_DOC_NOARGS(class_name, method_name, doc_string) \ const char class_name::method_name##_doc[] = doc_string; \ -PyObject* class_name::Py##method_name() +PyObject *class_name::Py##method_name() /** * Attribute management @@ -354,7 +354,7 @@ enum KX_PYATTRIBUTE_ACCESS { struct KX_PYATTRIBUTE_DEF; typedef int (*KX_PYATTRIBUTE_CHECK_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); typedef int (*KX_PYATTRIBUTE_SET_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); -typedef PyObject* (*KX_PYATTRIBUTE_GET_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); +typedef PyObject *(*KX_PYATTRIBUTE_GET_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); typedef struct KX_PYATTRIBUTE_DEF { const char *m_name; // name of the python attribute diff --git a/source/gameengine/Expressions/StringValue.h b/source/gameengine/Expressions/StringValue.h index e37b4638a1e..bc102c6e203 100644 --- a/source/gameengine/Expressions/StringValue.h +++ b/source/gameengine/Expressions/StringValue.h @@ -25,7 +25,7 @@ class CStringValue : public CPropValue { - //PLUGIN_DECLARE_SERIAL(CStringValue,CValue) + //PLUGIN_DECLARE_SERIAL(CStringValue,CValue) public: /// Construction / destruction CStringValue(); diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 6507cc32cf1..bcfb7e92d71 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -340,7 +340,7 @@ vector<STR_String> CValue::GetPropertyNames() // Clear all properties // void CValue::ClearProperties() -{ +{ // Check if we have any properties if (m_pNamedPropertyArray == NULL) return; @@ -530,13 +530,13 @@ PyAttributeDef CValue::Attributes[] = { { NULL } //Sentinel }; -PyObject * CValue::pyattr_get_name(void * self_v, const KX_PYATTRIBUTE_DEF * attrdef) +PyObject *CValue::pyattr_get_name(void * self_v, const KX_PYATTRIBUTE_DEF *attrdef) { CValue * self = static_cast<CValue *> (self_v); return PyUnicode_From_STR_String(self->GetName()); } -CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) +CValue* CValue::ConvertPythonToValue(PyObject *pyobj, const char *error_prefix) { CValue* vallie = NULL; @@ -551,7 +551,7 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) Py_ssize_t numitems = PyList_GET_SIZE(pyobj); for (i=0;i<numitems;i++) { - PyObject* listitem = PyList_GetItem(pyobj,i); /* borrowed ref */ + PyObject *listitem = PyList_GetItem(pyobj,i); /* borrowed ref */ CValue* listitemval = ConvertPythonToValue(listitem, error_prefix); if (listitemval) { @@ -597,7 +597,7 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) } -PyObject* CValue::ConvertKeysToPython(void) +PyObject *CValue::ConvertKeysToPython(void) { if (m_pNamedPropertyArray) { @@ -636,5 +636,5 @@ void CValue::SetColorOperator(VALUE_OPERATOR op) void CValue::SetValue(CValue* newval) { // no one should get here - assertd(newval->GetNumber() == 10121969); + assertd(newval->GetNumber() == 10121969); } diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index e3b52e80ba6..e0c4daeccd0 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -218,21 +218,21 @@ public: CValue(); #ifdef WITH_PYTHON - //static PyObject* PyMake(PyObject*,PyObject*); + //static PyObject *PyMake(PyObject *, PyObject *); virtual PyObject *py_repr(void) { return PyUnicode_From_STR_String(GetText()); } - virtual PyObject* ConvertValueToPython() { + virtual PyObject *ConvertValueToPython() { return NULL; } - virtual CValue* ConvertPythonToValue(PyObject* pyobj, const char *error_prefix); + virtual CValue *ConvertPythonToValue(PyObject *pyobj, const char *error_prefix); - static PyObject * pyattr_get_name(void * self, const KX_PYATTRIBUTE_DEF * attrdef); + static PyObject *pyattr_get_name(void * self, const KX_PYATTRIBUTE_DEF * attrdef); - virtual PyObject* ConvertKeysToPython( void ); + virtual PyObject *ConvertKeysToPython( void ); #endif // WITH_PYTHON @@ -250,13 +250,13 @@ public: }; /// Reference Counting - int GetRefCount() + int GetRefCount() { return m_refcount; } // Add a reference to this value - CValue* AddRef() + CValue *AddRef() { // Increase global reference count, used to see at the end of the program // if all CValue-derived classes have been dereferenced to 0 @@ -269,7 +269,7 @@ public: } // Release a reference to this value (when reference count reaches 0, the value is removed from the heap) - int Release() + int Release() { // Decrease global reference count, used to see at the end of the program // if all CValue-derived classes have been dereferenced to 0 @@ -354,16 +354,16 @@ public: virtual void SetCustomFlag2(bool bCustomFlag) { m_ValFlags.CustomFlag2 = bCustomFlag;} virtual bool IsCustomFlag2() { return m_ValFlags.CustomFlag2;} -protected: +protected: virtual void DisableRefCount(); // Disable reference counting for this value - //virtual void AddDataToReplica(CValue* replica); + //virtual void AddDataToReplica(CValue* replica); virtual ~CValue(); private: - // Member variables + // Member variables std::map<STR_String,CValue*>* m_pNamedPropertyArray; // Properties for user/game etc ValueFlags m_ValFlags; // Frequently used flags in a bitfield (low memoryusage) - int m_refcount; // Reference Counter - static double m_sZeroVec[3]; + int m_refcount; // Reference Counter + static double m_sZeroVec[3]; }; diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index 685cc3fcc48..912484a2fe5 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -65,7 +65,7 @@ class SCA_Joystick /** *support for JOYHAT_MAX hats (each is a direction) */ - int m_hat_array[JOYHAT_MAX]; + int m_hat_array[JOYHAT_MAX]; /** * Precision or range of the axes diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index 3fda542410a..6d76f122163 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -238,19 +238,19 @@ PyAttributeDef SCA_IController::Attributes[] = { { NULL } //Sentinel }; -PyObject* SCA_IController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_IController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_IController* self= static_cast<SCA_IController*>(self_v); return PyLong_FromSsize_t(self->m_statemask); } -PyObject* SCA_IController::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_IController::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - return KX_PythonSeq_CreatePyObject((static_cast<SCA_IController*>(self_v))->m_proxy, KX_PYGENSEQ_CONT_TYPE_SENSORS); + return KX_PythonSeq_CreatePyObject((static_cast<SCA_IController*>(self_v))->m_proxy, KX_PYGENSEQ_CONT_TYPE_SENSORS); } -PyObject* SCA_IController::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_IController::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - return KX_PythonSeq_CreatePyObject((static_cast<SCA_IController*>(self_v))->m_proxy, KX_PYGENSEQ_CONT_TYPE_ACTUATORS); + return KX_PythonSeq_CreatePyObject((static_cast<SCA_IController*>(self_v))->m_proxy, KX_PYGENSEQ_CONT_TYPE_ACTUATORS); } #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.cpp b/source/gameengine/GameLogic/SCA_IInputDevice.cpp index 16626b05526..f4fce034c87 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.cpp +++ b/source/gameengine/GameLogic/SCA_IInputDevice.cpp @@ -45,7 +45,7 @@ SCA_IInputDevice::SCA_IInputDevice() SCA_IInputDevice::~SCA_IInputDevice() { -} +} void SCA_IInputDevice::HookEscape() { @@ -134,6 +134,6 @@ void SCA_IInputDevice::NextFrame() break; default: ; /* error */ - } + } } } diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h index 0382a2efd21..66a1209751d 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.h +++ b/source/gameengine/GameLogic/SCA_IInputDevice.h @@ -69,7 +69,7 @@ class SCA_IInputDevice public: SCA_IInputDevice(); - virtual ~SCA_IInputDevice(); + virtual ~SCA_IInputDevice(); enum KX_EnumInputs { @@ -120,17 +120,17 @@ public: KX_RETKEY = 13, KX_SPACEKEY = 32, KX_PADASTERKEY = 42, - KX_COMMAKEY = 44, - KX_MINUSKEY = 45, + KX_COMMAKEY = 44, + KX_MINUSKEY = 45, KX_PERIODKEY = 46, KX_ZEROKEY = 48, KX_ONEKEY, // =49 - KX_TWOKEY, + KX_TWOKEY, KX_THREEKEY, - KX_FOURKEY, - KX_FIVEKEY, - KX_SIXKEY, + KX_FOURKEY, + KX_FIVEKEY, + KX_SIXKEY, KX_SEVENKEY, KX_EIGHTKEY, KX_NINEKEY, // = 57 @@ -170,14 +170,14 @@ public: KX_LEFTALTKEY, KX_RIGHTALTKEY, KX_RIGHTCTRLKEY, - KX_RIGHTSHIFTKEY, + KX_RIGHTSHIFTKEY, KX_LEFTSHIFTKEY,// 129 KX_ESCKEY, // 130 KX_TABKEY, //131 - KX_LINEFEEDKEY, // 132 + KX_LINEFEEDKEY, // 132 KX_BACKSPACEKEY, KX_DELKEY, KX_SEMICOLONKEY, // 135 @@ -188,13 +188,13 @@ public: KX_SLASHKEY, //138 KX_BACKSLASHKEY, - KX_EQUALKEY, - KX_LEFTBRACKETKEY, + KX_EQUALKEY, + KX_LEFTBRACKETKEY, KX_RIGHTBRACKETKEY, // 142 KX_LEFTARROWKEY, // 145 KX_DOWNARROWKEY, - KX_RIGHTARROWKEY, + KX_RIGHTARROWKEY, KX_UPARROWKEY, // 148 KX_PAD2 , diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index 018a939f68d..cfbdc1e750f 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -231,7 +231,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) +PyObject *SCA_ILogicBrick::pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_ILogicBrick* self= static_cast<SCA_ILogicBrick*>(self_v); CValue* parent = self->GetParent(); @@ -254,9 +254,9 @@ bool SCA_ILogicBrick::PyArgToBool(int boolArg) } } -PyObject* SCA_ILogicBrick::BoolToPyArg(bool boolarg) +PyObject *SCA_ILogicBrick::BoolToPyArg(bool boolarg) { - return PyLong_FromSsize_t(boolarg? KX_TRUE: KX_FALSE); + return PyLong_FromSsize_t(boolarg? KX_TRUE: KX_FALSE); } #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index b505353c7cd..c5fa9399ab7 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -157,7 +157,7 @@ protected: bool PyArgToBool(int boolArg); /** Convert a a c++ value to KX_TRUE, KX_FALSE in Python. */ - PyObject* BoolToPyArg(bool); + PyObject *BoolToPyArg(bool); #endif // WITH_PYTHON diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index b90952b2092..ab9e2781001 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -224,7 +224,7 @@ SCA_IController* SCA_IObject::FindController(const STR_String& controllername) { foundcontroller = (*itc); break; - } + } } return foundcontroller; } diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index 0e657794195..a850d23babf 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -43,7 +43,7 @@ class SCA_IController; class SCA_IActuator; #ifdef WITH_PYTHON -template<class T> T PyVecTo(PyObject*); +template<class T> T PyVecTo(PyObject *); #endif typedef std::vector<SCA_ISensor *> SCA_SensorList; @@ -213,7 +213,7 @@ public: */ unsigned int GetState(void) { return m_state; } -// const class MT_Point3& ConvertPythonPylist(PyObject* pylist); +// const class MT_Point3& ConvertPythonPylist(PyObject *pylist); virtual int GetGameObjectType() {return -1;} diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 76b9a8df00f..7cf0b18c3b5 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -248,7 +248,7 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr) if (result) { // the sensor triggered this frame if (m_state || !m_tap) { - ActivateControllers(logicmgr); + ActivateControllers(logicmgr); // reset these counters so that pulse are synchronized with transition m_pos_ticks = 0; m_neg_ticks = 0; @@ -380,7 +380,7 @@ PyAttributeDef SCA_ISensor::Attributes[] = { }; -PyObject* SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); int retval = 0; @@ -389,13 +389,13 @@ PyObject* SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_D return PyLong_FromSsize_t(retval); } -PyObject* SCA_ISensor::pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_ISensor::pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); int status = 0; @@ -417,13 +417,13 @@ PyObject* SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF return PyLong_FromSsize_t(status); } -PyObject* SCA_ISensor::pyattr_get_posTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_ISensor::pyattr_get_posTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *SCA_ISensor::pyattr_get_negTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); return PyLong_FromLong(self->GetNegTicks()); diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 2c6beb79fd3..7e9a4bc903c 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -60,7 +60,7 @@ SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr, m_joymode(joymode), m_joyindex(joyindex), m_bAllEvents(allevents) -{ +{ /* std::cout << " axis " << m_axis << std::endl; std::cout << " axis flag " << m_axisf << std::endl; @@ -308,7 +308,7 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = { const char SCA_JoystickSensor::GetButtonActiveList_doc[] = "getButtonActiveList\n" "\tReturns a list containing the indices of the button currently pressed.\n"; -PyObject* SCA_JoystickSensor::PyGetButtonActiveList( ) +PyObject *SCA_JoystickSensor::PyGetButtonActiveList( ) { SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex); PyObject *ls = PyList_New(0); @@ -331,7 +331,7 @@ PyObject* SCA_JoystickSensor::PyGetButtonActiveList( ) const char SCA_JoystickSensor::GetButtonStatus_doc[] = "getButtonStatus(buttonIndex)\n" "\tReturns a bool of the current pressed state of the specified button.\n"; -PyObject* SCA_JoystickSensor::PyGetButtonStatus( PyObject* args ) +PyObject *SCA_JoystickSensor::PyGetButtonStatus( PyObject *args ) { SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex); int index; @@ -345,7 +345,7 @@ PyObject* SCA_JoystickSensor::PyGetButtonStatus( PyObject* args ) return PyBool_FromLong(0); } -PyObject* SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); @@ -360,7 +360,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYAT return list; } -PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); @@ -373,7 +373,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT return PyLong_FromSsize_t(joy->GetAxisPosition(self->m_axis-1)); } -PyObject* SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); @@ -388,7 +388,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATT return list; } -PyObject* SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); @@ -396,28 +396,28 @@ PyObject* SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATT return PyLong_FromSsize_t(joy->GetHat(self->m_hat-1)); } -PyObject* SCA_JoystickSensor::pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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_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) +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_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) +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_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) +PyObject *SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h index 2d9ad45833f..fd3c0706fa7 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.h +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h @@ -54,7 +54,7 @@ public: bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode); - virtual void NextFrame(); + virtual void NextFrame(); SCA_IInputDevice* GetInputDevice(); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 5208252ceae..9a2dd9bdd57 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -351,12 +351,12 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex) CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); GetParent()->SetProperty(m_targetprop, newstringprop); newstringprop->Release(); - } + } } else { /* append */ char pchar = ToCharacter(keyIndex, IsShifted()); STR_String newprop = tprop->GetText() + pchar; - CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); + CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); GetParent()->SetProperty(m_targetprop, newstringprop); newstringprop->Release(); } @@ -365,7 +365,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex) /* Make a new property. Deletes can be ignored. */ char pchar = ToCharacter(keyIndex, IsShifted()); STR_String newprop = pchar; - CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); + CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); GetParent()->SetProperty(m_targetprop, newstringprop); newstringprop->Release(); } @@ -376,7 +376,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex) /** * Tests whether shift is pressed - */ + */ bool SCA_KeyboardSensor::IsShifted(void) { SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice(); @@ -391,9 +391,10 @@ bool SCA_KeyboardSensor::IsShifted(void) == SCA_InputEvent::KX_JUSTACTIVATED) ) { return true; - } else { + } + else { return false; - } + } } void SCA_KeyboardSensor::LogKeystrokes(void) @@ -494,25 +495,25 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = { }; -PyObject* SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_KeyboardSensor* self= static_cast<SCA_KeyboardSensor*>(self_v); SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)self->m_eventmgr)->GetInputDevice(); - PyObject* resultlist = PyList_New(0); + PyObject *resultlist = PyList_New(0); for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++) { const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i); if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS) { - PyObject* keypair = PyList_New(2); + PyObject *keypair = PyList_New(2); PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i)); PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status)); PyList_Append(resultlist,keypair); } - } + } return resultlist; } @@ -655,7 +656,7 @@ bool IsPrintable(int keyIndex) /** * Tests whether this is a delete key. - */ + */ bool IsDelete(int keyIndex) { if ( (keyIndex == SCA_IInputDevice::KX_DELKEY) diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index c059aba305b..caa141e48f2 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -134,7 +134,7 @@ bool IsPrintable(int keyIndex); /** * Tests whether this is a delete key. - */ + */ bool IsDelete(int keyIndex); diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h index 60edb2816cb..02c28807566 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.h +++ b/source/gameengine/GameLogic/SCA_MouseManager.h @@ -63,7 +63,7 @@ public: * mouse related events. Can also flag mouse movement. */ bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode); - virtual void NextFrame(); + virtual void NextFrame(); SCA_IInputDevice* GetInputDevice(); diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index f4ee54c56a6..51e0bc6550b 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -156,7 +156,7 @@ bool SCA_MouseSensor::Evaluate() case KX_MOUSESENSORMODE_WHEELDOWN: { const SCA_InputEvent& mevent = mousedev->GetEventValue(m_hotkey); - switch (mevent.m_status) { + switch (mevent.m_status) { case SCA_InputEvent::KX_JUSTACTIVATED: m_val = 1; result = true; @@ -189,15 +189,15 @@ bool SCA_MouseSensor::Evaluate() const SCA_InputEvent& eventY = mousedev->GetEventValue(SCA_IInputDevice::KX_MOUSEY); if (eventX.m_status == SCA_InputEvent::KX_JUSTACTIVATED || - eventY.m_status == SCA_InputEvent::KX_JUSTACTIVATED || - eventX.m_status == SCA_InputEvent::KX_ACTIVE || - eventY.m_status == SCA_InputEvent::KX_ACTIVE) + eventY.m_status == SCA_InputEvent::KX_JUSTACTIVATED || + eventX.m_status == SCA_InputEvent::KX_ACTIVE || + eventY.m_status == SCA_InputEvent::KX_ACTIVE) { m_val = 1; result = true; } else if (eventX.m_status == SCA_InputEvent::KX_JUSTRELEASED || - eventY.m_status == SCA_InputEvent::KX_JUSTRELEASED ) + eventY.m_status == SCA_InputEvent::KX_JUSTRELEASED ) { m_val = 0; result = true; diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 31f988fe4b9..0eab6187d07 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -173,7 +173,7 @@ isValid( SCA_PropertyActuator::KX_ACT_PROP_MODE mode ) { - bool res = false; + bool res = false; res = ((mode > KX_ACT_PROP_NODEF) && (mode < KX_ACT_PROP_MAX)); return res; } diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index ab7f57a5454..7dbbbb2a0d9 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -179,7 +179,7 @@ int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor) #ifdef WITH_PYTHON /* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */ -PyObject* SCA_PythonController::sPyGetCurrentController(PyObject *self) +PyObject *SCA_PythonController::sPyGetCurrentController(PyObject *self) { if (m_sCurrentController==NULL) { @@ -271,7 +271,7 @@ void SCA_PythonController::ErrorPrint(const char *error_msg) } bool SCA_PythonController::Compile() -{ +{ //printf("py script modified '%s'\n", m_scriptName.Ptr()); m_bModified= false; @@ -374,7 +374,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) m_sCurrentLogicManager = logicmgr; PyObject *excdict= NULL; - PyObject* resultobj= NULL; + PyObject *resultobj= NULL; switch(m_mode) { case SCA_PYEXEC_SCRIPT: @@ -447,13 +447,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) // This doesn't appear to be needed anymore //PyDict_Clear(excdict); Py_DECREF(excdict); - } + } m_triggeredSensors.clear(); m_sCurrentController = NULL; } -PyObject* SCA_PythonController::PyActivate(PyObject *value) +PyObject *SCA_PythonController::PyActivate(PyObject *value) { if (m_sCurrentController != this) { PyErr_SetString(PyExc_SystemError, "Cannot add an actuator from a non-active controller"); @@ -468,7 +468,7 @@ PyObject* SCA_PythonController::PyActivate(PyObject *value) Py_RETURN_NONE; } -PyObject* SCA_PythonController::PyDeActivate(PyObject *value) +PyObject *SCA_PythonController::PyDeActivate(PyObject *value) { if (m_sCurrentController != this) { PyErr_SetString(PyExc_SystemError, "Cannot add an actuator from a non-active controller"); @@ -483,7 +483,7 @@ PyObject* SCA_PythonController::PyDeActivate(PyObject *value) Py_RETURN_NONE; } -PyObject* SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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))))); // static_cast<void *>(dynamic_cast<Derived *>(obj)) - static_cast<void *>(obj) diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index ccdb82aa722..8a72ce6bad9 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -74,7 +74,7 @@ class SCA_PythonController : public SCA_IController //for debugging //virtual CValue* AddRef(); - //virtual int Release(); // Release a reference to this value (when reference count reaches 0, the value is removed from the heap) + //virtual int Release(); // Release a reference to this value (when reference count reaches 0, the value is removed from the heap) SCA_PythonController(SCA_IObject* gameobj, int mode); virtual ~SCA_PythonController(); @@ -96,11 +96,11 @@ class SCA_PythonController : public SCA_IController void ErrorPrint(const char *error_msg); #ifdef WITH_PYTHON - static const char* sPyGetCurrentController__doc__; - static PyObject* sPyGetCurrentController(PyObject* self); - static const char* sPyAddActiveActuator__doc__; - static PyObject* sPyAddActiveActuator(PyObject* self, - PyObject* args); + static const char *sPyGetCurrentController__doc__; + static PyObject *sPyGetCurrentController(PyObject *self); + static const char *sPyAddActiveActuator__doc__; + static PyObject *sPyAddActiveActuator(PyObject *self, + PyObject *args); static SCA_IActuator* LinkedActuatorFromPy(PyObject *value); diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp index f83b23f510c..42cda9433b8 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp @@ -58,13 +58,13 @@ SCA_PythonKeyboard::~SCA_PythonKeyboard() /* ------------------------------------------------------------------------- */ /* clipboard */ -static PyObject* gPyGetClipboard(PyObject* args, PyObject* kwds) +static PyObject *gPyGetClipboard(PyObject *args, PyObject *kwds) { char *buf = (char *)GHOST_getClipboard(0); return PyUnicode_FromString(buf?buf:""); } -static PyObject* gPySetClipboard(PyObject* args, PyObject* value) +static PyObject *gPySetClipboard(PyObject *args, PyObject *value) { char* buf; if (!PyArg_ParseTuple(value,"s:setClipboard",&buf)) @@ -109,7 +109,7 @@ PyAttributeDef SCA_PythonKeyboard::Attributes[] = { { NULL } //Sentinel }; -PyObject* SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonKeyboard* self = static_cast<SCA_PythonKeyboard*>(self_v); @@ -123,7 +123,7 @@ PyObject* SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBU return self->m_event_dict; } -PyObject* SCA_PythonKeyboard::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_PythonKeyboard::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonKeyboard* self = static_cast<SCA_PythonKeyboard*>(self_v); diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.h b/source/gameengine/GameLogic/SCA_PythonKeyboard.h index df5e46f8c28..aab49bcb83b 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.h +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.h @@ -35,7 +35,7 @@ class SCA_PythonKeyboard : public PyObjectPlus private: class SCA_IInputDevice *m_keyboard; #ifdef WITH_PYTHON - PyObject* m_event_dict; + PyObject *m_event_dict; #endif public: SCA_PythonKeyboard(class SCA_IInputDevice* keyboard); diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.cpp b/source/gameengine/GameLogic/SCA_PythonMouse.cpp index cdbeaba2235..0806bda072b 100644 --- a/source/gameengine/GameLogic/SCA_PythonMouse.cpp +++ b/source/gameengine/GameLogic/SCA_PythonMouse.cpp @@ -90,9 +90,9 @@ PyAttributeDef SCA_PythonMouse::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("position", SCA_PythonMouse, pyattr_get_position, pyattr_set_position), KX_PYATTRIBUTE_RW_FUNCTION("visible", SCA_PythonMouse, pyattr_get_visible, pyattr_set_visible), { NULL } //Sentinel -}; +}; -PyObject* SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v); @@ -106,7 +106,7 @@ PyObject* SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_ return self->m_event_dict; } -PyObject* SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v); @@ -123,7 +123,7 @@ PyObject* SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATT return self->m_event_dict; } -PyObject* SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v); const SCA_InputEvent & xevent = self->m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEX); @@ -134,7 +134,7 @@ PyObject* SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUT x_coord = self->m_canvas->GetMouseNormalizedX(xevent.m_eventval); y_coord = self->m_canvas->GetMouseNormalizedY(yevent.m_eventval); - PyObject* ret = PyTuple_New(2); + PyObject *ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(x_coord)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(y_coord)); @@ -158,7 +158,7 @@ int SCA_PythonMouse::pyattr_set_position(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_SUCCESS; } -PyObject* SCA_PythonMouse::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_PythonMouse::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v); diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.h b/source/gameengine/GameLogic/SCA_PythonMouse.h index 1313d55005f..f770a54d6e6 100644 --- a/source/gameengine/GameLogic/SCA_PythonMouse.h +++ b/source/gameengine/GameLogic/SCA_PythonMouse.h @@ -36,7 +36,7 @@ private: class SCA_IInputDevice *m_mouse; class RAS_ICanvas *m_canvas; #ifdef WITH_PYTHON - PyObject* m_event_dict; + PyObject *m_event_dict; #endif public: SCA_PythonMouse(class SCA_IInputDevice* mouse, class RAS_ICanvas* canvas); @@ -47,12 +47,12 @@ public: #ifdef WITH_PYTHON KX_PYMETHOD_DOC(SCA_PythonMouse, show); - static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value); - static PyObject* pyattr_get_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value); + static PyObject *pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static PyObject *pyattr_get_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif }; diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index c727eebd015..9a54c76ed4e 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -161,7 +161,7 @@ bool SCA_RandomActuator::Update() while (b >= a) { b = b * m_base->DrawFloat(); res++; - }; + }; tmpval = new CIntValue(res); } break; @@ -361,9 +361,9 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = { KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,MAX_PROP_NAME,false,SCA_RandomActuator,m_propname,CheckProperty), KX_PYATTRIBUTE_RW_FUNCTION("seed",SCA_RandomActuator,pyattr_get_seed,pyattr_set_seed), { NULL } //Sentinel -}; +}; -PyObject* SCA_RandomActuator::pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_RandomActuator::pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self); return PyLong_FromSsize_t(act->m_base->GetSeed()); @@ -420,7 +420,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setBoolBernouilli, } m_distribution = KX_RANDOMACT_BOOL_BERNOUILLI; - m_parameter1 = paraArg; + m_parameter1 = paraArg; enforceConstraints(); Py_RETURN_NONE; } @@ -473,7 +473,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setIntPoisson, } m_distribution = KX_RANDOMACT_INT_POISSON; - m_parameter1 = paraArg; + m_parameter1 = paraArg; enforceConstraints(); Py_RETURN_NONE; } @@ -489,7 +489,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatConst, } m_distribution = KX_RANDOMACT_FLOAT_CONST; - m_parameter1 = paraArg; + m_parameter1 = paraArg; enforceConstraints(); Py_RETURN_NONE; } @@ -544,7 +544,7 @@ KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential, } m_distribution = KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL; - m_parameter1 = paraArg; + m_parameter1 = paraArg; enforceConstraints(); Py_RETURN_NONE; } diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h index 522663651e0..f61de24c0cc 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.h +++ b/source/gameengine/GameLogic/SCA_RandomActuator.h @@ -67,10 +67,10 @@ class SCA_RandomActuator : public SCA_IActuator KX_RANDOMACT_NODEF, KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, - KX_RANDOMACT_BOOL_BERNOUILLI, + KX_RANDOMACT_BOOL_BERNOUILLI, KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, - KX_RANDOMACT_INT_POISSON, + KX_RANDOMACT_INT_POISSON, KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL, @@ -98,7 +98,7 @@ class SCA_RandomActuator : public SCA_IActuator /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - static PyObject* pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setBoolConst); diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 3b37507dcf3..17784755421 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -165,7 +165,7 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = { {NULL} //Sentinel }; -PyObject* SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v); return PyLong_FromSsize_t(self->m_basegenerator->GetSeed()); diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp index e28f00abba2..e8a6289a98e 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp @@ -54,7 +54,7 @@ SCA_TimeEventManager::~SCA_TimeEventManager() !(it == m_timevalues.end()); ++it) { (*it)->Release(); - } + } } diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp index f4224b9e255..7581484a41f 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp @@ -99,7 +99,7 @@ void GPC_Canvas::Resize(int width, int height) void GPC_Canvas::EndFrame() { if (m_bannersEnabled) - DrawAllBanners(); + DrawAllBanners(); } diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index 25a50fbcac3..453b9505183 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -163,7 +163,7 @@ public: void SetMouseState(RAS_MouseState mousestate) { - // not yet + // not yet } void SetMousePosition(int x, int y) @@ -250,7 +250,7 @@ protected: int oldWriteMask; }; - void + void PushRenderState( CanvasRenderState & render_state ); diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp index a38bba7788b..e38a9e3d6cb 100644 --- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp +++ b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp @@ -67,7 +67,8 @@ void GPC_MouseDevice::NextFrame() for (int mouseevent= KX_BEGINMOUSE; mouseevent< KX_ENDMOUSEBUTTONS; mouseevent++) { SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][mouseevent]; if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED || - oldevent.m_status == SCA_InputEvent::KX_ACTIVE) { + oldevent.m_status == SCA_InputEvent::KX_ACTIVE) + { m_eventStatusTables[m_currentTable][mouseevent] = oldevent; m_eventStatusTables[m_currentTable][mouseevent].m_status = SCA_InputEvent::KX_ACTIVE; } @@ -76,7 +77,8 @@ void GPC_MouseDevice::NextFrame() SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][mousemove]; m_eventStatusTables[m_currentTable][mousemove] = oldevent; if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED || - oldevent.m_status == SCA_InputEvent::KX_ACTIVE) { + oldevent.m_status == SCA_InputEvent::KX_ACTIVE) + { m_eventStatusTables[m_currentTable][mousemove].m_status = SCA_InputEvent::KX_JUSTRELEASED; } else { diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp index 9f129c1cdfb..c0d66541800 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp @@ -89,7 +89,7 @@ bool GPC_RawImage::Load( // Put original in upper left corner // Add vertical offset - dst += offsetY * dstBytesWidth; + dst += offsetY * dstBytesWidth; // Add horizontal offset dst += offsetX * 4; for (int row = 0; row < numRows; row++) diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 749e7748e19..9cd6715f3d2 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -442,7 +442,7 @@ void GPC_RenderTools::PopMatrix() int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) { - // taken from blender source, incompatibility between Blender Object / GameObject + // taken from blender source, incompatibility between Blender Object / GameObject KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; float glviewmat[16]; unsigned int count; diff --git a/source/gameengine/GamePlayer/common/bmfont.cpp b/source/gameengine/GamePlayer/common/bmfont.cpp index 4c1c6ae5604..6f40d13fe7a 100644 --- a/source/gameengine/GamePlayer/common/bmfont.cpp +++ b/source/gameengine/GamePlayer/common/bmfont.cpp @@ -110,7 +110,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) buffer = (unsigned char*)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/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 21de7011eda..40b52c3212a 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -479,7 +479,7 @@ bool GPG_Application::processEvent(GHOST_IEvent* event) // // first check if we want to exit // m_exitRequested = m_ketsjiengine->GetExitCode(); - // + // // // kick the engine // bool renderFrame = m_ketsjiengine->NextFrame(); // if (renderFrame) @@ -546,7 +546,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) return false; // SYS_WriteCommandLineInt(syshandle, "fixedtime", 0); - // SYS_WriteCommandLineInt(syshandle, "vertexarrays",1); + // SYS_WriteCommandLineInt(syshandle, "vertexarrays",1); GameData *gm= &m_startScene->gm; bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0); bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0); @@ -576,7 +576,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) m_canvas->Init(); if (gm->flag & GAME_SHOW_MOUSE) - m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); + m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); m_rendertools = new GPC_RenderTools(); if (!m_rendertools) @@ -681,7 +681,7 @@ bool GPG_Application::startEngine(void) // Temporary hack to disable banner display for NaN approved content. /* - m_canvas->SetBannerDisplayEnabled(true); + m_canvas->SetBannerDisplayEnabled(true); Camera* cam; cam = (Camera*)scene->camera->data; if (cam) { @@ -730,7 +730,7 @@ bool GPG_Application::startEngine(void) // Set the GameLogic.globalDict from marshal'd data, so we can // load new blend files and keep data in GameLogic.globalDict loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length); -#endif +#endif m_sceneconverter->ConvertScene( startscene, m_rendertools, diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index d8b07fd50d9..7500a55a059 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -57,10 +57,10 @@ extern "C" { #endif // __cplusplus #include "MEM_guardedalloc.h" -#include "BKE_blender.h" -#include "BKE_global.h" -#include "BKE_icons.h" -#include "BKE_node.h" +#include "BKE_blender.h" +#include "BKE_global.h" +#include "BKE_icons.h" +#include "BKE_node.h" #include "BKE_report.h" #include "BKE_library.h" #include "BLI_threads.h" @@ -223,7 +223,7 @@ void usage(const char* program, bool isBlenderPlayer) printf(" --Optional parameters--\n"); printf(" angle = field of view in degrees\n"); printf(" tilt = tilt angle in degrees\n"); - printf(" warpdata = a file to use for warping the image (absolute path)\n"); + printf(" warpdata = a file to use for warping the image (absolute path)\n"); printf(" mode: fisheye (Fisheye)\n"); printf(" truncatedfront (Front-Truncated)\n"); printf(" truncatedrear (Rear-Truncated)\n"); @@ -1016,12 +1016,12 @@ int main(int argc, char** argv) gpg_nextframestate.app = &app; gpg_nextframestate.gs = &gs; pynextframestate.state = &gpg_nextframestate; - pynextframestate.func = &GPG_PyNextFrame; + pynextframestate.func = &GPG_PyNextFrame; printf("Yielding control to Python script '%s'...\n", python_main); PyRun_SimpleString(python_code); printf("Exit Python script '%s'\n", python_main); -#endif // WITH_PYTHON +#endif // WITH_PYTHON MEM_freeN(python_code); } else { diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index c0fca88c426..e0ad1539b4a 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -431,7 +431,7 @@ void BL_Shader::SetProg(bool enable) glUseProgramObjectARB(mShader); } else { - glUseProgramObjectARB(0); + glUseProgramObjectARB(0); } } } @@ -613,7 +613,7 @@ void BL_Shader::SetUniform(int uniform, const MT_Tuple3& vec) GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects ) - { + { float value[3]; vec.getValue(value); glUniform3fvARB(uniform, 1, value); @@ -931,7 +931,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" ) { #ifdef SORT_UNIFORMS SetUniformfv(loc, BL_Uniform::UNI_FLOAT, &value, sizeof(float)); -#else +#else SetUniform( loc, (float)value ); #endif } @@ -1142,7 +1142,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv, "setUniformfv( float (list2 or list #ifdef SORT_UNIFORMS SetUniformfv(loc, BL_Uniform::UNI_FLOAT2, array2, sizeof(float)*2); #else - SetUniform(loc, array2, 2); + SetUniform(loc, array2, 2); #endif Py_RETURN_NONE; } break; @@ -1152,7 +1152,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv, "setUniformfv( float (list2 or list #ifdef SORT_UNIFORMS SetUniformfv(loc, BL_Uniform::UNI_FLOAT3, array3, sizeof(float)*3); #else - SetUniform(loc, array3, 3); + SetUniform(loc, array3, 3); #endif Py_RETURN_NONE; }break; @@ -1162,7 +1162,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv, "setUniformfv( float (list2 or list #ifdef SORT_UNIFORMS SetUniformfv(loc, BL_Uniform::UNI_FLOAT4, array4, sizeof(float)*4); #else - SetUniform(loc, array4, 4); + SetUniform(loc, array4, 4); #endif Py_RETURN_NONE; }break; @@ -1226,7 +1226,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2 #ifdef SORT_UNIFORMS SetUniformiv(loc, BL_Uniform::UNI_INT2, array2, sizeof(int)*2); #else - SetUniform(loc, array2, 2); + SetUniform(loc, array2, 2); #endif Py_RETURN_NONE; } break; @@ -1237,7 +1237,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2 SetUniformiv(loc, BL_Uniform::UNI_INT3, array3, sizeof(int)*3); #else - SetUniform(loc, array3, 3); + SetUniform(loc, array3, 3); #endif Py_RETURN_NONE; }break; @@ -1248,7 +1248,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2 SetUniformiv(loc, BL_Uniform::UNI_INT4, array4, sizeof(int)*4); #else - SetUniform(loc, array4, 4); + SetUniform(loc, array4, 4); #endif Py_RETURN_NONE; }break; diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index 2bb094f12ee..b577a1849a0 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -222,7 +222,7 @@ public: // Python interface #ifdef WITH_PYTHON - virtual PyObject* py_repr(void) { return PyUnicode_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", vertProg, fragProg); } + virtual PyObject *py_repr(void) { return PyUnicode_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", vertProg, fragProg); } // ----------------------------------- KX_PYMETHOD_DOC(BL_Shader, setSource); diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index b8cc4ebeff9..7196c1ec664 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -47,7 +47,7 @@ static int power_of_2_min_i(int num) { while (!is_power_of_2_i(num)) num= num&(num-1); - return num; + return num; } // Place holder for a full texture manager @@ -427,7 +427,7 @@ void BL_Texture::DisableAllTextures() glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_R); @@ -447,14 +447,14 @@ void BL_Texture::ActivateTexture() if (mType == GL_TEXTURE_CUBE_MAP_ARB && GLEW_ARB_texture_cube_map) { - glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, mTexture ); + glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, mTexture ); glEnable(GL_TEXTURE_CUBE_MAP_ARB); } else { if (GLEW_ARB_texture_cube_map ) glDisable(GL_TEXTURE_CUBE_MAP_ARB); - glBindTexture( GL_TEXTURE_2D, mTexture ); + glBindTexture( GL_TEXTURE_2D, mTexture ); glEnable(GL_TEXTURE_2D); } } @@ -659,7 +659,7 @@ void my_envmap_split_ima(EnvMap *env, ImBuf *ibuf) { int dx, part; - my_free_envmapdata(env); + my_free_envmapdata(env); dx= ibuf->y; dx/= 2; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index a69f02baa57..6260596159d 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -38,7 +38,7 @@ #include "NG_NetworkMessage.h" #include "NG_NetworkScene.h" #include "NG_NetworkObject.h" -#include "SCA_IObject.h" +#include "SCA_IObject.h" #include "InputParser.h" #include "ListValue.h" #include "StringValue.h" @@ -201,7 +201,7 @@ PyAttributeDef KX_NetworkMessageSensor::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_NetworkMessageSensor *self = static_cast<KX_NetworkMessageSensor*>(self_v); if (self->m_BodyList) { @@ -211,7 +211,7 @@ PyObject* KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYAT } } -PyObject* KX_NetworkMessageSensor::pyattr_get_subjects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_NetworkMessageSensor::pyattr_get_subjects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_NetworkMessageSensor *self = static_cast<KX_NetworkMessageSensor*>(self_v); if (self->m_SubjectList) { diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index 66f723d072c..6b9779de6e3 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -80,7 +80,7 @@ public: /* ------------------------------------------------------------- */ /* attributes */ - static PyObject* pyattr_get_bodies(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_bodies(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_subjects(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.cpp b/source/gameengine/Ketsji/KX_ArmatureSensor.cpp index f72d9c1dee6..523f3ceeaea 100644 --- a/source/gameengine/Ketsji/KX_ArmatureSensor.cpp +++ b/source/gameengine/Ketsji/KX_ArmatureSensor.cpp @@ -86,7 +86,7 @@ void KX_ArmatureSensor::FindConstraint() /* this constraint is not valid, can't use it */ break; m_constraint = pcon; - break; + break; } } break; @@ -193,13 +193,13 @@ PyAttributeDef KX_ArmatureSensor::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_ArmatureSensor::pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ArmatureSensor::pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_ArmatureSensor* sensor = static_cast<KX_ArmatureSensor*>(self); if (sensor->m_gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) { BL_ArmatureObject* armobj = (BL_ArmatureObject*)sensor->m_gameobj; BL_ArmatureConstraint* constraint = armobj->GetConstraint(sensor->m_posechannel, sensor->m_constraintname); - if (constraint) + if (constraint) return constraint->GetProxy(); } Py_RETURN_NONE; diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.h b/source/gameengine/Ketsji/KX_ArmatureSensor.h index 9c3faa355a6..74603b3ff01 100644 --- a/source/gameengine/Ketsji/KX_ArmatureSensor.h +++ b/source/gameengine/Ketsji/KX_ArmatureSensor.h @@ -72,7 +72,7 @@ public: /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - static PyObject* pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index b602ba447ad..2337e9569f3 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -412,7 +412,7 @@ KX_BlenderMaterial::ActivatShaders( if ((mMaterial->ras_mode &WIRE) || (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) - { + { if (mMaterial->ras_mode &WIRE) rasty->SetCullFace(false); rasty->SetLines(true); @@ -457,7 +457,7 @@ KX_BlenderMaterial::ActivateBlenderShaders( if ((mMaterial->ras_mode &WIRE) || (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) - { + { if (mMaterial->ras_mode &WIRE) rasty->SetCullFace(false); rasty->SetLines(true); @@ -506,7 +506,7 @@ KX_BlenderMaterial::ActivateMat( if ((mMaterial->ras_mode &WIRE) || (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) - { + { if (mMaterial->ras_mode &WIRE) rasty->SetCullFace(false); rasty->SetLines(true); @@ -614,7 +614,7 @@ void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const mMaterial->matcolor[2]*mMaterial->ref+mMaterial->emit, 1.0f); - rasty->SetEmissive( + rasty->SetEmissive( mMaterial->matcolor[0]*mMaterial->emit, mMaterial->matcolor[1]*mMaterial->emit, mMaterial->matcolor[2]*mMaterial->emit, @@ -835,19 +835,19 @@ PyTypeObject KX_BlenderMaterial::Type = { py_base_new }; -PyObject* KX_BlenderMaterial::pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_BlenderMaterial::pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_BlenderMaterial::pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_BlenderMaterial::pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v); unsigned int* bfunc = self->getBlendFunc(); @@ -857,7 +857,7 @@ PyObject* KX_BlenderMaterial::pyattr_get_blending(void *self_v, const KX_PYATTRI 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); - PyObject* obj = self->PysetBlending(value, NULL); + PyObject *obj = self->PysetBlending(value, NULL); if (obj) { Py_DECREF(obj); diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 8fc86ef9cf2..a69f5c92d19 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -106,11 +106,11 @@ public: #ifdef WITH_PYTHON // -------------------------------- - virtual PyObject* py_repr(void) { return PyUnicode_From_STR_String(mMaterial->matname); } + virtual PyObject *py_repr(void) { return PyUnicode_From_STR_String(mMaterial->matname); } - static PyObject* pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); KX_PYMETHOD_DOC(KX_BlenderMaterial, getShader); diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index b974886f60a..20c41b95dd3 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -269,7 +269,7 @@ void KX_BulletPhysicsController::AddCompoundChild(KX_IPhysicsController* chil rootScale[2] = 1.0/rootScale[2]; // relative scale = child_scale/parent_scale btVector3 relativeScale = childShape->getLocalScaling()*rootScale; - btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose(); + btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose(); // relative pos = parent_rot^-1 * ((parent_pos-child_pos)/parent_scale) btVector3 relativePos = rootRotInverse*((childTrans.getOrigin()-rootTrans.getOrigin())*rootScale); // relative rot = parent_rot^-1 * child_rot diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index ac17adaf052..c0071ab22f6 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -67,7 +67,7 @@ KX_Camera::~KX_Camera() delete m_pSGNode; m_pSGNode = NULL; } -} +} CValue* KX_Camera::GetReplica() @@ -119,7 +119,7 @@ const MT_Point3 KX_Camera::GetCameraLocation() const //MT_Transform trans; //trans.setBasis(NodeGetWorldOrientation()); - return NodeGetWorldPosition(); + return NodeGetWorldPosition(); } @@ -712,7 +712,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, setOnTop, Py_RETURN_NONE; } -PyObject* KX_Camera::pyattr_get_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Camera::pyattr_get_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Camera* self= static_cast<KX_Camera*>(self_v); return PyBool_FromLong(self->m_camdata.m_perspective); @@ -732,7 +732,7 @@ int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *at return PY_SET_ATTR_SUCCESS; } -PyObject* KX_Camera::pyattr_get_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Camera::pyattr_get_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Camera* self= static_cast<KX_Camera*>(self_v); return PyFloat_FromDouble(self->m_camdata.m_lens); @@ -752,7 +752,7 @@ int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, return PY_SET_ATTR_SUCCESS; } -PyObject* KX_Camera::pyattr_get_ortho_scale(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); return PyFloat_FromDouble(self->m_camdata.m_scale); @@ -772,7 +772,7 @@ int KX_Camera::pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *at return PY_SET_ATTR_SUCCESS; } -PyObject* KX_Camera::pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Camera::pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Camera* self= static_cast<KX_Camera*>(self_v); return PyFloat_FromDouble(self->m_camdata.m_clipstart); @@ -792,7 +792,7 @@ int KX_Camera::pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, return PY_SET_ATTR_SUCCESS; } -PyObject* KX_Camera::pyattr_get_far(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); return PyFloat_FromDouble(self->m_camdata.m_clipend); @@ -813,7 +813,7 @@ 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) +PyObject *KX_Camera::pyattr_get_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Camera* self= static_cast<KX_Camera*>(self_v); return PyBool_FromLong(self->GetViewport()); @@ -832,7 +832,7 @@ 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) +PyObject *KX_Camera::pyattr_get_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Camera* self= static_cast<KX_Camera*>(self_v); return PyObjectFrom(self->GetProjectionMatrix()); @@ -849,34 +849,34 @@ int KX_Camera::pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_D return PY_SET_ATTR_SUCCESS; } -PyObject* KX_Camera::pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Camera::pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +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); return PyObjectFrom(self->GetCameraToWorld()); } -PyObject* KX_Camera::pyattr_get_world_to_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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); return PyObjectFrom(self->GetWorldToCamera()); } -PyObject* KX_Camera::pyattr_get_INSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Camera::pyattr_get_INSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return PyLong_FromSsize_t(INSIDE); } -PyObject* KX_Camera::pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Camera::pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return PyLong_FromSsize_t(OUTSIDE); } -PyObject* KX_Camera::pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Camera::pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return PyLong_FromSsize_t(INTERSECT); } -bool ConvertPythonToCamera(PyObject * value, KX_Camera **object, bool py_none_ok, const char *error_prefix) +bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok, const char *error_prefix) { if (value==NULL) { PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix); @@ -976,7 +976,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition, vect[1] = 1.0 - vect[1]; //to follow Blender window coordinate system (Top-Down) - PyObject* ret = PyTuple_New(2); + PyObject *ret = PyTuple_New(2); if (ret) { PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(vect[0])); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(vect[1])); @@ -1040,7 +1040,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenRay, if (!PyArg_ParseTuple(args,"ddd|s:getScreenRay",&x,&y,&dist,&propName)) return NULL; - PyObject* argValue = PyTuple_New(2); + PyObject *argValue = PyTuple_New(2); PyTuple_SET_ITEM(argValue, 0, PyFloat_FromDouble(x)); PyTuple_SET_ITEM(argValue, 1, PyFloat_FromDouble(y)); @@ -1065,7 +1065,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenRay, if (propName) PyTuple_SET_ITEM(argValue, 2, PyUnicode_FromString(propName)); - PyObject* ret= this->PyrayCastTo(argValue,NULL); + PyObject *ret= this->PyrayCastTo(argValue,NULL); Py_DECREF(argValue); return ret; } diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index 7481b2eb7f0..d95d10e8384 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -45,7 +45,7 @@ #ifdef WITH_PYTHON /* utility conversion function */ -bool ConvertPythonToCamera(PyObject * value, KX_Camera **object, bool py_none_ok, const char *error_prefix); +bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok, const char *error_prefix); #endif class KX_Camera : public KX_GameObject @@ -156,7 +156,7 @@ public: * instance allocated on the heap. Ownership of the new * object belongs with the caller. */ - virtual CValue* + virtual CValue* GetReplica( ); virtual void ProcessReplica(); @@ -286,8 +286,8 @@ public: KX_PYMETHOD_DOC_NOARGS(KX_Camera, getCameraToWorld); KX_PYMETHOD_DOC_NOARGS(KX_Camera, getWorldToCamera); - KX_PYMETHOD_DOC_VARARGS(KX_Camera, setViewport); - KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop); + KX_PYMETHOD_DOC_VARARGS(KX_Camera, setViewport); + KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop); KX_PYMETHOD_DOC_O(KX_Camera, getScreenPosition); KX_PYMETHOD_DOC_VARARGS(KX_Camera, getScreenVect); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 4c63afa7f3e..9ca1ec59a0b 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -394,7 +394,7 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { {NULL} }; -PyObject* KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_CameraActuator* self= static_cast<KX_CameraActuator*>(self_v); if (self->m_ob==NULL) @@ -412,7 +412,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (self->m_ob) - self->m_ob->UnregisterActuator(self); + self->m_ob->UnregisterActuator(self); if ((self->m_ob = (SCA_IObject*)gameobj)) self->m_ob->RegisterActuator(self); diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.h b/source/gameengine/Ketsji/KX_CameraIpoSGController.h index 06058760332..9b7c1eddf00 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.h +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.h @@ -77,13 +77,13 @@ public: m_ipotime = time; m_modified = true; } - void SetModifyLens(bool modify) { + void SetModifyLens(bool modify) { m_modify_lens = modify; } - void SetModifyClipEnd(bool modify) { + void SetModifyClipEnd(bool modify) { m_modify_clipend = modify; } - void SetModifyClipStart(bool modify) { + void SetModifyClipStart(bool modify) { m_modify_clipstart = modify; } void AddInterpolator(KX_IInterpolator* interp); diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 322d6e60071..3caa4d35565 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -166,7 +166,7 @@ bool KX_ConstraintActuator::NeedRayCast(KX_ClientObjectInfo* client) bool KX_ConstraintActuator::Update(double curtime, bool frame) { - bool result = false; + bool result = false; bool bNegativeEvent = IsNegativeEvent(); RemoveAllEvents(); @@ -462,7 +462,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) // we expect a hit object if (!m_hitObject) result = false; - if (result) + if (result) { MT_Vector3 newnormal = callback.m_hitNormal; // compute new position & orientation @@ -619,7 +619,7 @@ int KX_ConstraintActuator::pyattr_check_direction(void *self, const struct KX_PY return 1; } act->m_refDirVector = dir/len; - return 0; + return 0; } #endif diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index f491aedba74..786e4ff53d2 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -43,7 +43,7 @@ class KX_GameObject; class KX_ConstraintActuator : public SCA_IActuator { Py_Header -protected: +protected: // Damp time (int), int m_posDampTime; int m_rotDampTime; diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index df6b08974dd..5727ed29e67 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -50,13 +50,13 @@ KX_ConstraintWrapper::~KX_ConstraintWrapper() #ifdef WITH_PYTHON -PyObject* KX_ConstraintWrapper::PyGetConstraintId() +PyObject *KX_ConstraintWrapper::PyGetConstraintId() { return PyLong_FromSsize_t(m_constraintId); } -PyObject* KX_ConstraintWrapper::PyGetParam(PyObject* args, PyObject* kwds) +PyObject *KX_ConstraintWrapper::PyGetParam(PyObject *args, PyObject *kwds) { int dof; float value; @@ -69,7 +69,7 @@ PyObject* KX_ConstraintWrapper::PyGetParam(PyObject* args, PyObject* kwds) } -PyObject* KX_ConstraintWrapper::PySetParam(PyObject* args, PyObject* kwds) +PyObject *KX_ConstraintWrapper::PySetParam(PyObject *args, PyObject *kwds) { int dof; float minLimit,maxLimit; @@ -117,7 +117,7 @@ PyAttributeDef KX_ConstraintWrapper::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_ConstraintWrapper::pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ConstraintWrapper::pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_ConstraintWrapper* self= static_cast<KX_ConstraintWrapper*>(self_v); return self->PyGetConstraintId(); diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h index a92ae83e7f0..dbc3571cad6 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h @@ -48,7 +48,7 @@ public: KX_PYMETHOD(KX_ConstraintWrapper,SetParam); KX_PYMETHOD(KX_ConstraintWrapper,GetParam); - static PyObject* pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); #endif private: diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index f1038c04499..776953206fe 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -282,7 +282,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, relativeRot.getValue(rot); shapeInfo->m_childTrans.getBasis().setFromOpenGLSubMatrix(rot); - parentShapeInfo->AddShape(shapeInfo); + parentShapeInfo->AddShape(shapeInfo); compoundShape->addChildShape(shapeInfo->m_childTrans,bm); //do some recalc? //recalc inertia for rigidbody @@ -439,7 +439,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, { env->addCcdPhysicsController( physicscontroller); } - physicscontroller->setNewClientInfo(gameobj->getClientInfo()); + physicscontroller->setNewClientInfo(gameobj->getClientInfo()); { btRigidBody* rbody = physicscontroller->GetRigidBody(); diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 44c9cb1dab8..fd3a18a9d2a 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -592,7 +592,7 @@ void KX_Dome::CreateMeshDome180(void) cubebottom[0].u[2] = 0.0; cubebottom[0].v[2] = 0.0; - nfacesbottom = 1; + nfacesbottom = 1; /* Left face - two triangles */ @@ -682,12 +682,12 @@ void KX_Dome::CreateMeshDome180(void) cubetop.resize(4*nfacestop); SplitFace(cubetop,&nfacestop); cubebottom.resize(4*nfacesbottom); - SplitFace(cubebottom,&nfacesbottom); + SplitFace(cubebottom,&nfacesbottom); cubeleft.resize(4*nfacesleft); SplitFace(cubeleft,&nfacesleft); cuberight.resize(4*nfacesright); SplitFace(cuberight,&nfacesright); - } + } // Turn into a hemisphere for (j=0;j<3;j++) { @@ -763,13 +763,13 @@ void KX_Dome::CreateMeshDome250(void) cubefront[0].verts[1][0] = 1.0; cubefront[0].verts[1][1] = 1.0; - cubefront[0].verts[1][2] = 1.0; + cubefront[0].verts[1][2] = 1.0; cubefront[0].u[1] = uv_ratio; cubefront[0].v[1] = uv_ratio; cubefront[0].verts[2][0] =-1.0; cubefront[0].verts[2][1] = 1.0; - cubefront[0].verts[2][2] = 1.0; + cubefront[0].verts[2][2] = 1.0; cubefront[0].u[2] = 0.0; cubefront[0].v[2] = uv_ratio; @@ -782,13 +782,13 @@ void KX_Dome::CreateMeshDome250(void) cubefront[1].verts[1][0] =-1.0; cubefront[1].verts[1][1] = 1.0; - cubefront[1].verts[1][2] =-1.0; + cubefront[1].verts[1][2] =-1.0; cubefront[1].u[1] = 0.0; cubefront[1].v[1] = 0.0; cubefront[1].verts[2][0] = 1.0; cubefront[1].verts[2][1] = 1.0; - cubefront[1].verts[2][2] =-1.0; + cubefront[1].verts[2][2] =-1.0; cubefront[1].u[2] = uv_ratio; cubefront[1].v[2] = 0.0; @@ -803,13 +803,13 @@ void KX_Dome::CreateMeshDome250(void) cubeleft[0].verts[1][0] =-1.0; cubeleft[0].verts[1][1] =-verts_height; - cubeleft[0].verts[1][2] = 1.0; + cubeleft[0].verts[1][2] = 1.0; cubeleft[0].u[1] = uv_base; cubeleft[0].v[1] = uv_ratio; cubeleft[0].verts[2][0] =-1.0; cubeleft[0].verts[2][1] =-verts_height; - cubeleft[0].verts[2][2] =-1.0; + cubeleft[0].verts[2][2] =-1.0; cubeleft[0].u[2] = uv_base; cubeleft[0].v[2] = 0.0; @@ -822,13 +822,13 @@ void KX_Dome::CreateMeshDome250(void) cubeleft[1].verts[1][0] =-1.0; cubeleft[1].verts[1][1] = 1.0; - cubeleft[1].verts[1][2] =-1.0; + cubeleft[1].verts[1][2] =-1.0; cubeleft[1].u[1] = uv_ratio; cubeleft[1].v[1] = 0.0; cubeleft[1].verts[2][0] =-1.0; cubeleft[1].verts[2][1] = 1.0; - cubeleft[1].verts[2][2] = 1.0; + cubeleft[1].verts[2][2] = 1.0; cubeleft[1].u[2] = uv_ratio; cubeleft[1].v[2] = uv_ratio; @@ -843,13 +843,13 @@ void KX_Dome::CreateMeshDome250(void) cuberight[0].verts[1][0] = 1.0; cuberight[0].verts[1][1] =-verts_height; - cuberight[0].verts[1][2] =-1.0; + cuberight[0].verts[1][2] =-1.0; cuberight[0].u[1] = uv_height; cuberight[0].v[1] = 0.0; cuberight[0].verts[2][0] = 1.0; cuberight[0].verts[2][1] =-verts_height; - cuberight[0].verts[2][2] = 1.0; + cuberight[0].verts[2][2] = 1.0; cuberight[0].u[2] = uv_height; cuberight[0].v[2] = uv_ratio; @@ -862,13 +862,13 @@ void KX_Dome::CreateMeshDome250(void) cuberight[1].verts[1][0] = 1.0; cuberight[1].verts[1][1] = 1.0; - cuberight[1].verts[1][2] = 1.0; + cuberight[1].verts[1][2] = 1.0; cuberight[1].u[1] = 0.0; cuberight[1].v[1] = uv_ratio; cuberight[1].verts[2][0] = 1.0; cuberight[1].verts[2][1] = 1.0; - cuberight[1].verts[2][2] =-1.0; + cuberight[1].verts[2][2] =-1.0; cuberight[1].u[2] = 0.0; cuberight[1].v[2] = 0.0; @@ -883,13 +883,13 @@ void KX_Dome::CreateMeshDome250(void) cubetop[0].verts[1][0] = 1.0; cubetop[0].verts[1][1] =-verts_height; - cubetop[0].verts[1][2] = 1.0; + cubetop[0].verts[1][2] = 1.0; cubetop[0].u[1] = uv_ratio; cubetop[0].v[1] = uv_height; cubetop[0].verts[2][0] =-1.0; cubetop[0].verts[2][1] =-verts_height; - cubetop[0].verts[2][2] = 1.0; + cubetop[0].verts[2][2] = 1.0; cubetop[0].u[2] = 0.0; cubetop[0].v[2] = uv_height; @@ -902,13 +902,13 @@ void KX_Dome::CreateMeshDome250(void) cubetop[1].verts[1][0] =-1.0; cubetop[1].verts[1][1] = 1.0; - cubetop[1].verts[1][2] = 1.0; + cubetop[1].verts[1][2] = 1.0; cubetop[1].u[1] = 0.0; cubetop[1].v[1] = 0.0; cubetop[1].verts[2][0] = 1.0; cubetop[1].verts[2][1] = 1.0; - cubetop[1].verts[2][2] = 1.0; + cubetop[1].verts[2][2] = 1.0; cubetop[1].u[2] = uv_ratio; cubetop[1].v[2] = 0.0; @@ -923,13 +923,13 @@ void KX_Dome::CreateMeshDome250(void) cubebottom[0].verts[1][0] = 1.0; cubebottom[0].verts[1][1] = 1.0; - cubebottom[0].verts[1][2] =-1.0; + cubebottom[0].verts[1][2] =-1.0; cubebottom[0].u[1] = uv_ratio; cubebottom[0].v[1] = uv_ratio; cubebottom[0].verts[2][0] =-1.0; cubebottom[0].verts[2][1] = 1.0; - cubebottom[0].verts[2][2] =-1.0; + cubebottom[0].verts[2][2] =-1.0; cubebottom[0].u[2] = 0.0; cubebottom[0].v[2] = uv_ratio; @@ -942,13 +942,13 @@ void KX_Dome::CreateMeshDome250(void) cubebottom[1].verts[1][0] =-1.0; cubebottom[1].verts[1][1] =-verts_height; - cubebottom[1].verts[1][2] =-1.0; + cubebottom[1].verts[1][2] =-1.0; cubebottom[1].u[1] = 0.0; cubebottom[1].v[1] = uv_base; cubebottom[1].verts[2][0] = 1.0; cubebottom[1].verts[2][1] =-verts_height; - cubebottom[1].verts[2][2] =-1.0; + cubebottom[1].verts[2][2] =-1.0; cubebottom[1].u[2] = uv_ratio; cubebottom[1].v[2] = uv_base; @@ -963,7 +963,7 @@ void KX_Dome::CreateMeshDome250(void) cubetop.resize(4*nfacestop); SplitFace(cubetop,&nfacestop); cubebottom.resize(4*nfacesbottom); - SplitFace(cubebottom,&nfacesbottom); + SplitFace(cubebottom,&nfacesbottom); cubeleft.resize(4*nfacesleft); SplitFace(cubeleft,&nfacesleft); cuberight.resize(4*nfacesright); @@ -986,13 +986,13 @@ void KX_Dome::CreateMeshDome250(void) //flatten onto xz plane for (i=0;i<nfacesfront;i++) - FlattenDome(cubefront[i].verts); + FlattenDome(cubefront[i].verts); for (i=0;i<nfacestop;i++) FlattenDome(cubetop[i].verts); for (i=0;i<nfacesbottom;i++) FlattenDome(cubebottom[i].verts); for (i=0;i<nfacesleft;i++) - FlattenDome(cubeleft[i].verts); + FlattenDome(cubeleft[i].verts); for (i=0;i<nfacesright;i++) FlattenDome(cuberight[i].verts); } @@ -1417,7 +1417,7 @@ void KX_Dome::SplitFace(vector <DomeFace>& face, int *nfaces) face[n2+2].u[2] = (face[i].u[2] + face[i].u[0]) /2; face[n2+2].v[0] = (face[i].v[0] + face[i].v[1]) /2; face[n2+2].v[1] = (face[i].v[1] + face[i].v[2]) /2; - face[n2+2].v[2] = (face[i].v[2] + face[i].v[0]) /2; + face[n2+2].v[2] = (face[i].v[2] + face[i].v[0]) /2; //face[i].verts[0] = face[i].verts[0]; face[i].verts[1] = (face[i].verts[0] + face[i].verts[1]) /2; @@ -1427,7 +1427,7 @@ void KX_Dome::SplitFace(vector <DomeFace>& face, int *nfaces) face[i].u[2] = (face[i].u[0] + face[i].u[2]) /2; //face[i].v[0] = face[i].v[0]; face[i].v[1] = (face[i].v[0] + face[i].v[1]) /2; - face[i].v[2] = (face[i].v[0] + face[i].v[2]) /2; + face[i].v[2] = (face[i].v[0] + face[i].v[2]) /2; n2 += 3; // number of faces } @@ -1858,7 +1858,7 @@ void KX_Dome::DrawDomeFisheye(void) glBindTexture(GL_TEXTURE_2D, domefacesId[0]); GLDrawTriangles(cubetop, nfacestop); - // bottom triangle + // bottom triangle glBindTexture(GL_TEXTURE_2D, domefacesId[1]); GLDrawTriangles(cubebottom, nfacesbottom); diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index 931eac7a974..9f6ef894f12 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -52,7 +52,7 @@ extern "C" { /* proptotype */ int GetFontId(VFont *font); -std::vector<STR_String> split_string(STR_String str) +static std::vector<STR_String> split_string(STR_String str) { std::vector<STR_String> text = std::vector<STR_String>(); @@ -73,10 +73,10 @@ std::vector<STR_String> split_string(STR_String str) return text; } -KX_FontObject::KX_FontObject( void* sgReplicationInfo, - SG_Callbacks callbacks, - RAS_IRenderTools* rendertools, - Object *ob): +KX_FontObject::KX_FontObject(void* sgReplicationInfo, + SG_Callbacks callbacks, + RAS_IRenderTools* rendertools, + Object *ob): KX_GameObject(sgReplicationInfo, callbacks), m_object(ob), m_dpi(72), @@ -252,7 +252,7 @@ PyAttributeDef KX_FontObject::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_FontObject::pyattr_get_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_FontObject::pyattr_get_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_FontObject* self= static_cast<KX_FontObject*>(self_v); STR_String str = STR_String(); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 3818cef7d6e..fe8419d5343 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -362,7 +362,7 @@ BL_ActionManager* KX_GameObject::GetActionManager() { // We only want to create an action manager if we need it if (!m_actionManager) - { + { KX_GetActiveScene()->AddAnimatedObject(this); m_actionManager = new BL_ActionManager(this); } @@ -690,7 +690,7 @@ void KX_GameObject::SynchronizeTransformFunc(SG_IObject* node, void* gameobj, vo void KX_GameObject::SetDebugColor(unsigned int bgra) { for (size_t i=0;i<m_meshes.size();i++) - m_meshes[i]->DebugColor(bgra); + m_meshes[i]->DebugColor(bgra); } @@ -701,8 +701,8 @@ void KX_GameObject::ResetDebugColor() } void KX_GameObject::InitIPO(bool ipo_as_force, - bool ipo_add, - bool ipo_local) + bool ipo_add, + bool ipo_local) { SGControllerList::iterator it = GetSGNode()->GetSGControllerList().begin(); @@ -939,7 +939,7 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) vect /= len; orimat = GetSGNode()->GetWorldOrientation(); switch (axis) - { + { case 0: //x axis ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector parallel to the pivot? @@ -1041,7 +1041,7 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) return locvel; } } - return velocity; + return velocity; } MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) @@ -1060,7 +1060,7 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) return locvel; } } - return velocity; + return velocity; } MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point) @@ -1668,7 +1668,7 @@ PyAttributeDef KX_GameObject::Attributes[] = { {NULL} //Sentinel }; -PyObject* KX_GameObject::PyReplaceMesh(PyObject* args) +PyObject *KX_GameObject::PyReplaceMesh(PyObject *args) { KX_Scene *scene = KX_GetActiveScene(); @@ -1686,7 +1686,7 @@ PyObject* KX_GameObject::PyReplaceMesh(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_GameObject::PyEndObject() +PyObject *KX_GameObject::PyEndObject() { SG_Node* node = this->GetSGNode(); KX_Scene* scene = static_cast<KX_Scene*>(node->GetSGClientInfo()); @@ -1697,7 +1697,7 @@ PyObject* KX_GameObject::PyEndObject() } -PyObject* KX_GameObject::PyReinstancePhysicsMesh(PyObject* args) +PyObject *KX_GameObject::PyReinstancePhysicsMesh(PyObject *args) { KX_GameObject *gameobj= NULL; RAS_MeshObject *mesh= NULL; @@ -1724,7 +1724,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); const char *attr_str= _PyUnicode_AsString(item); CValue* resultattr; - PyObject* pyconvert; + PyObject *pyconvert; if (self==NULL) { PyErr_SetString(PyExc_SystemError, "val = gameOb[key]: KX_GameObject, "BGE_PROXY_ERROR_MSG); @@ -1733,7 +1733,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) /* first see if the attributes a string and try get the cvalue attribute */ if (attr_str && (resultattr=self->GetProperty(attr_str))) { - pyconvert = resultattr->ConvertValueToPython(); + pyconvert = resultattr->ConvertValueToPython(); return pyconvert ? pyconvert:resultattr->GetProxy(); } /* no CValue attribute, try get the python only m_attr_dict attribute */ @@ -1907,13 +1907,13 @@ PyTypeObject KX_GameObject::Type = { py_base_new }; -PyObject* KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +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* parent = self->GetParent(); @@ -1924,7 +1924,7 @@ PyObject* KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DE Py_RETURN_NONE; } -PyObject* KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); @@ -1937,7 +1937,7 @@ PyObject* KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF Py_RETURN_NONE; } -PyObject* KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); KX_IPhysicsController *spc = self->GetPhysicsController(); @@ -1960,7 +1960,7 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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_IPhysicsController *spc = self->GetPhysicsController(); @@ -1983,7 +1983,7 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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_IPhysicsController *spc = self->GetPhysicsController(); @@ -2007,7 +2007,7 @@ 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) +PyObject *KX_GameObject::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyBool_FromLong(self->GetVisible()); @@ -2027,7 +2027,7 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL); @@ -2049,11 +2049,11 @@ int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_D return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { -#ifdef USE_MATHUTILS +#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 +#else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalPosition()); #endif @@ -2071,7 +2071,7 @@ int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_D return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); @@ -2083,7 +2083,7 @@ PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB #endif } -PyObject* KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #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); @@ -2108,7 +2108,7 @@ int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUT return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #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); @@ -2132,7 +2132,7 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL); @@ -2154,7 +2154,7 @@ int KX_GameObject::pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DE return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL); @@ -2176,7 +2176,7 @@ int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DE return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self = static_cast<KX_GameObject*>(self_v); @@ -2222,7 +2222,7 @@ int KX_GameObject::pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_ return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self = static_cast<KX_GameObject*>(self_v); @@ -2256,7 +2256,7 @@ int KX_GameObject::pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_ return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_GLOBAL); @@ -2278,7 +2278,7 @@ int KX_GameObject::pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRI return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_LOCAL); @@ -2300,7 +2300,7 @@ int KX_GameObject::pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRI return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_GLOBAL); @@ -2322,7 +2322,7 @@ int KX_GameObject::pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTR return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_LOCAL); @@ -2345,7 +2345,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) +PyObject *KX_GameObject::pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); SG_Node* sg_parent; @@ -2372,7 +2372,7 @@ int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); int state = 0; @@ -2400,7 +2400,7 @@ int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attr return PY_SET_ATTR_SUCCESS; } -PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); PyObject *meshes= PyList_New(self->m_meshes.size()); @@ -2415,7 +2415,7 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE return meshes; } -PyObject* KX_GameObject::pyattr_get_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 4, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR); @@ -2437,35 +2437,35 @@ int KX_GameObject::pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *at } /* These are experimental! */ -PyObject* KX_GameObject::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_SENSORS); } -PyObject* KX_GameObject::pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_CONTROLLERS); } -PyObject* KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_ACTUATORS); } /* End experimental */ -PyObject* KX_GameObject::pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_GameObject::pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_GameObject::pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); @@ -2476,10 +2476,10 @@ PyObject* KX_GameObject::pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_ return self->m_attr_dict; } -PyObject* KX_GameObject::PyApplyForce(PyObject* args) +PyObject *KX_GameObject::PyApplyForce(PyObject *args) { int local = 0; - PyObject* pyvect; + PyObject *pyvect; if (PyArg_ParseTuple(args, "O|i:applyForce", &pyvect, &local)) { MT_Vector3 force; @@ -2491,10 +2491,10 @@ PyObject* KX_GameObject::PyApplyForce(PyObject* args) return NULL; } -PyObject* KX_GameObject::PyApplyTorque(PyObject* args) +PyObject *KX_GameObject::PyApplyTorque(PyObject *args) { int local = 0; - PyObject* pyvect; + PyObject *pyvect; if (PyArg_ParseTuple(args, "O|i:applyTorque", &pyvect, &local)) { MT_Vector3 torque; @@ -2506,10 +2506,10 @@ PyObject* KX_GameObject::PyApplyTorque(PyObject* args) return NULL; } -PyObject* KX_GameObject::PyApplyRotation(PyObject* args) +PyObject *KX_GameObject::PyApplyRotation(PyObject *args) { int local = 0; - PyObject* pyvect; + PyObject *pyvect; if (PyArg_ParseTuple(args, "O|i:applyRotation", &pyvect, &local)) { MT_Vector3 rotation; @@ -2521,10 +2521,10 @@ PyObject* KX_GameObject::PyApplyRotation(PyObject* args) return NULL; } -PyObject* KX_GameObject::PyApplyMovement(PyObject* args) +PyObject *KX_GameObject::PyApplyMovement(PyObject *args) { int local = 0; - PyObject* pyvect; + PyObject *pyvect; if (PyArg_ParseTuple(args, "O|i:applyMovement", &pyvect, &local)) { MT_Vector3 movement; @@ -2536,7 +2536,7 @@ PyObject* KX_GameObject::PyApplyMovement(PyObject* args) return NULL; } -PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* args) +PyObject *KX_GameObject::PyGetLinearVelocity(PyObject *args) { // only can get the velocity if we have a physics object connected to us... int local = 0; @@ -2550,10 +2550,10 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* args) } } -PyObject* KX_GameObject::PySetLinearVelocity(PyObject* args) +PyObject *KX_GameObject::PySetLinearVelocity(PyObject *args) { int local = 0; - PyObject* pyvect; + PyObject *pyvect; if (PyArg_ParseTuple(args,"O|i:setLinearVelocity",&pyvect,&local)) { MT_Vector3 velocity; @@ -2565,7 +2565,7 @@ PyObject* KX_GameObject::PySetLinearVelocity(PyObject* args) return NULL; } -PyObject* KX_GameObject::PyGetAngularVelocity(PyObject* args) +PyObject *KX_GameObject::PyGetAngularVelocity(PyObject *args) { // only can get the velocity if we have a physics object connected to us... int local = 0; @@ -2579,10 +2579,10 @@ PyObject* KX_GameObject::PyGetAngularVelocity(PyObject* args) } } -PyObject* KX_GameObject::PySetAngularVelocity(PyObject* args) +PyObject *KX_GameObject::PySetAngularVelocity(PyObject *args) { int local = 0; - PyObject* pyvect; + PyObject *pyvect; if (PyArg_ParseTuple(args,"O|i:setAngularVelocity",&pyvect,&local)) { MT_Vector3 velocity; @@ -2594,7 +2594,7 @@ PyObject* KX_GameObject::PySetAngularVelocity(PyObject* args) return NULL; } -PyObject* KX_GameObject::PySetVisible(PyObject* args) +PyObject *KX_GameObject::PySetVisible(PyObject *args) { int visible, recursive = 0; if (!PyArg_ParseTuple(args,"i|i:setVisible",&visible, &recursive)) @@ -2606,7 +2606,7 @@ PyObject* KX_GameObject::PySetVisible(PyObject* args) } -PyObject* KX_GameObject::PySetOcclusion(PyObject* args) +PyObject *KX_GameObject::PySetOcclusion(PyObject *args) { int occlusion, recursive = 0; if (!PyArg_ParseTuple(args,"i|i:setOcclusion",&occlusion, &recursive)) @@ -2616,11 +2616,11 @@ PyObject* KX_GameObject::PySetOcclusion(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_GameObject::PyGetVelocity(PyObject* args) +PyObject *KX_GameObject::PyGetVelocity(PyObject *args) { // only can get the velocity if we have a physics object connected to us... MT_Point3 point(0.0,0.0,0.0); - PyObject* pypos = NULL; + PyObject *pypos = NULL; if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point))) return NULL; @@ -2634,7 +2634,7 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* args) } } -PyObject* KX_GameObject::PyGetReactionForce() +PyObject *KX_GameObject::PyGetReactionForce() { // only can get the velocity if we have a physics object connected to us... @@ -2651,7 +2651,7 @@ PyObject* KX_GameObject::PyGetReactionForce() -PyObject* KX_GameObject::PyEnableRigidBody() +PyObject *KX_GameObject::PyEnableRigidBody() { if (GetPhysicsController()) GetPhysicsController()->setRigidBody(true); @@ -2661,7 +2661,7 @@ PyObject* KX_GameObject::PyEnableRigidBody() -PyObject* KX_GameObject::PyDisableRigidBody() +PyObject *KX_GameObject::PyDisableRigidBody() { if (GetPhysicsController()) GetPhysicsController()->setRigidBody(false); @@ -2670,10 +2670,10 @@ PyObject* KX_GameObject::PyDisableRigidBody() } -PyObject* KX_GameObject::PySetParent(PyObject* args) +PyObject *KX_GameObject::PySetParent(PyObject *args) { KX_Scene *scene = KX_GetActiveScene(); - PyObject* pyobj; + PyObject *pyobj; KX_GameObject *obj; int addToCompound=1, ghost=1; @@ -2687,7 +2687,7 @@ PyObject* KX_GameObject::PySetParent(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_GameObject::PyRemoveParent() +PyObject *KX_GameObject::PyRemoveParent() { KX_Scene *scene = KX_GetActiveScene(); @@ -2696,7 +2696,7 @@ PyObject* KX_GameObject::PyRemoveParent() } -PyObject* KX_GameObject::PySetCollisionMargin(PyObject* value) +PyObject *KX_GameObject::PySetCollisionMargin(PyObject *value) { float collisionMargin = PyFloat_AsDouble(value); @@ -2716,10 +2716,10 @@ PyObject* KX_GameObject::PySetCollisionMargin(PyObject* value) -PyObject* KX_GameObject::PyApplyImpulse(PyObject* args) +PyObject *KX_GameObject::PyApplyImpulse(PyObject *args) { - PyObject* pyattach; - PyObject* pyimpulse; + PyObject *pyattach; + PyObject *pyimpulse; if (!m_pPhysicsController1) { PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller"); @@ -2743,7 +2743,7 @@ PyObject* KX_GameObject::PyApplyImpulse(PyObject* args) -PyObject* KX_GameObject::PySuspendDynamics() +PyObject *KX_GameObject::PySuspendDynamics() { SuspendDynamics(); Py_RETURN_NONE; @@ -2751,16 +2751,16 @@ PyObject* KX_GameObject::PySuspendDynamics() -PyObject* KX_GameObject::PyRestoreDynamics() +PyObject *KX_GameObject::PyRestoreDynamics() { RestoreDynamics(); Py_RETURN_NONE; } -PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* args) +PyObject *KX_GameObject::PyAlignAxisToVect(PyObject *args) { - PyObject* pyvect; + PyObject *pyvect; int axis = 2; //z axis is the default float fac = 1.0f; @@ -2780,7 +2780,7 @@ PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* args) return NULL; } -PyObject* KX_GameObject::PyGetAxisVect(PyObject* value) +PyObject *KX_GameObject::PyGetAxisVect(PyObject *value) { MT_Vector3 vect; if (PyVecTo(value, vect)) @@ -2791,7 +2791,7 @@ PyObject* KX_GameObject::PyGetAxisVect(PyObject* value) } -PyObject* KX_GameObject::PyGetPhysicsId() +PyObject *KX_GameObject::PyGetPhysicsId() { KX_IPhysicsController* ctrl = GetPhysicsController(); uint_ptr physid=0; @@ -2802,7 +2802,7 @@ PyObject* KX_GameObject::PyGetPhysicsId() return PyLong_FromSsize_t((long)physid); } -PyObject* KX_GameObject::PyGetPropertyNames() +PyObject *KX_GameObject::PyGetPropertyNames() { PyObject *list= ConvertKeysToPython(); @@ -2932,7 +2932,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, " other = 3-tuple or object reference") { MT_Point3 toPoint; - PyObject* pyarg; + PyObject *pyarg; float dist = 0.0f; char *propName = NULL; @@ -3050,8 +3050,8 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, { MT_Point3 toPoint; MT_Point3 fromPoint; - PyObject* pyto; - PyObject* pyfrom = NULL; + PyObject *pyto; + PyObject *pyfrom = NULL; float dist = 0.0f; char *propName = NULL; KX_GameObject *other; @@ -3125,7 +3125,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, if (m_pHitObject) { - PyObject* returnValue = (poly==2) ? PyTuple_New(5) : (poly) ? PyTuple_New(4) : PyTuple_New(3); + PyObject *returnValue = (poly == 2) ? PyTuple_New(5) : (poly) ? PyTuple_New(4) : PyTuple_New(3); if (returnValue) { // unlikely this would ever fail, if it does python sets an error PyTuple_SET_ITEM(returnValue, 0, m_pHitObject->GetProxy()); PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(callback.m_hitPoint)); @@ -3301,11 +3301,11 @@ KX_PYMETHODDEF_DOC(KX_GameObject, isPlayingAction, /* Matches python dict.get(key, [default]) */ -PyObject* KX_GameObject::Pyget(PyObject *args) +PyObject *KX_GameObject::Pyget(PyObject *args) { PyObject *key; - PyObject* def = Py_None; - PyObject* ret; + PyObject *def = Py_None; + PyObject *ret; if (!PyArg_ParseTuple(args, "O|O:get", &key, &def)) return NULL; @@ -3331,7 +3331,7 @@ PyObject* KX_GameObject::Pyget(PyObject *args) return def; } -bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok, const char *error_prefix) +bool ConvertPythonToGameObject(PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix) { if (value==NULL) { PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 2b0d13ff2f7..ea75ca4a917 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -68,7 +68,7 @@ struct bAction; #ifdef WITH_PYTHON /* utility conversion function */ -bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok, const char *error_prefix); +bool ConvertPythonToGameObject(PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix); #endif #ifdef USE_MATHUTILS @@ -159,7 +159,7 @@ public: * side effect of storing the result internally. The * memory for the matrix remains the property of this class. */ - double* + double * GetOpenGLMatrix( ); @@ -170,7 +170,7 @@ public: * memory for the returned matrix. */ - MT_CmMatrix4x4* + MT_CmMatrix4x4 * GetOpenGLMatrixPtr( ) { return &m_OpenGL_4x4Matrix; @@ -193,18 +193,18 @@ public: * object. It is the responsibility of the caller to decrement * the reference count when you have finished with it. */ - KX_GameObject* + KX_GameObject* GetParent( ); /** * Sets the parent of this object to a game object - */ + */ void SetParent(KX_Scene *scene, KX_GameObject *obj, bool addToCompound=true, bool ghost=true); /** * Removes the parent of this object to a game object - */ + */ void RemoveParent(KX_Scene *scene); /********************************* @@ -292,7 +292,7 @@ public: /** * Inherited from CValue -- does nothing! */ - CValue* + CValue* Calc( VALUE_OPERATOR op, CValue *val @@ -301,7 +301,7 @@ public: /** * Inherited from CValue -- does nothing! */ - CValue* + CValue* CalcFinal( VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, @@ -312,7 +312,7 @@ public: * Inherited from CValue -- does nothing! */ const - STR_String & + STR_String & GetText( ); @@ -331,14 +331,14 @@ public: /** * Inherited from CValue -- returns the name of this object. */ - STR_String& + STR_String& GetName( ); /** * Inherited from CValue -- set the name of this object. */ - void + void SetName( const char *name ); @@ -348,7 +348,7 @@ public: * instance allocated on the heap. Ownership of the new * object belongs with the caller. */ - virtual CValue* + virtual CValue* GetReplica( ); @@ -356,7 +356,7 @@ public: * Inherited from CValue -- Makes sure any internal * data owned by this class is deep copied. Called internally */ - virtual void + virtual void ProcessReplica(); /** @@ -379,7 +379,7 @@ public: /** * Return the mass of the object */ - MT_Scalar + MT_Scalar GetMass(); /** @@ -410,7 +410,7 @@ public: * Quick'n'dirty obcolor ipo stuff */ - void + void SetObjectColor( const MT_Vector4& rgbavec ); @@ -482,7 +482,7 @@ public: // adapt local position so that world position is set to desired position void NodeSetWorldPosition(const MT_Point3& trans); - void + void NodeUpdateGS( double time ); @@ -504,7 +504,7 @@ public: return m_pSGNode; } - const SG_Node* GetSGNode( ) const + const SG_Node* GetSGNode( ) const { return m_pSGNode; } @@ -581,48 +581,48 @@ public: * place. */ - void + void ApplyForce( const MT_Vector3& force, bool local ); - void + void ApplyTorque( const MT_Vector3& torque, bool local ); - void + void ApplyRotation( const MT_Vector3& drot, bool local ); - void + void ApplyMovement( const MT_Vector3& dloc, bool local ); - void + void addLinearVelocity( const MT_Vector3& lin_vel, bool local ); - void + void setLinearVelocity( const MT_Vector3& lin_vel, bool local ); - void + void setAngularVelocity( const MT_Vector3& ang_vel, bool local ); - /** + /** * Update the physics object transform based upon the current SG_Node * position. */ @@ -642,7 +642,7 @@ public: /** * Function to set IPO option at start of IPO */ - void + void InitIPO( bool ipo_as_force, bool ipo_add, @@ -652,7 +652,7 @@ public: /** * Odd function to update an ipo. ??? */ - void + void UpdateIPO( float curframetime, bool recurse @@ -676,20 +676,20 @@ public: * \section Mesh accessor functions. */ - /** + /** * Update buckets to indicate that there is a new * user of this object's meshes. */ - void + void AddMeshUser( ); - /** + /** * Update buckets with data about the mesh after * creating or duplicating the object, changing * visibility, object color, .. . */ - void + void UpdateBuckets( bool recursive ); @@ -699,7 +699,7 @@ public: * and remove from the bucketing system. * Don't think this actually deletes any of the meshes. */ - void + void RemoveMeshes( ); @@ -709,7 +709,7 @@ public: * Make sure you call RemoveMeshes() before deleting the * mesh though, */ - void + void AddMesh( RAS_MeshObject* mesh ) { @@ -719,7 +719,7 @@ public: /** * Pick out a mesh associated with the integer 'num'. */ - RAS_MeshObject* + RAS_MeshObject* GetMesh( int num ) const { @@ -730,17 +730,17 @@ public: * Return the number of meshes currently associated with this * game object. */ - int + int GetMeshCount( ) const { return m_meshes.size(); } - /** + /** * Set the debug color of the meshes associated with this * class. Does this still work? */ - void + void SetDebugColor( unsigned int bgra ); @@ -748,7 +748,7 @@ public: /** * Reset the debug color of meshes associated with this class. */ - void + void ResetDebugColor( ); @@ -855,7 +855,7 @@ public: m_bSuspendDynamics = true; } - void RestoreDynamics(void) { + void RestoreDynamics(void) { if (!m_bSuspendDynamics) { return; @@ -887,7 +887,7 @@ public: /** * \section Python interface functions. */ - virtual PyObject* py_repr(void) + virtual PyObject *py_repr(void) { return PyUnicode_From_STR_String(GetName()); } @@ -983,7 +983,7 @@ public: static PyObject* pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static int pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/Ketsji/KX_IInterpolator.h b/source/gameengine/Ketsji/KX_IInterpolator.h index 6ca44e1f6e5..6c0bf2d85cc 100644 --- a/source/gameengine/Ketsji/KX_IInterpolator.h +++ b/source/gameengine/Ketsji/KX_IInterpolator.h @@ -38,7 +38,7 @@ #include "MEM_guardedalloc.h" #endif -class KX_IInterpolator { +class KX_IInterpolator { public: virtual ~KX_IInterpolator() {} diff --git a/source/gameengine/Ketsji/KX_IScalarInterpolator.h b/source/gameengine/Ketsji/KX_IScalarInterpolator.h index 2b5aefccfe7..1e822c49c6d 100644 --- a/source/gameengine/Ketsji/KX_IScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_IScalarInterpolator.h @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #endif -class KX_IScalarInterpolator { +class KX_IScalarInterpolator { public: virtual ~KX_IScalarInterpolator() {} diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 5599f3e31c6..5ea7a2e7394 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -182,7 +182,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) m_bIpoPlaying = true; bIpoStart = true; } - } + } switch ((IpoActType)m_type) { @@ -254,7 +254,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) result = false; if (bIpoStart) - ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local); + ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local); ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse); break; } @@ -309,7 +309,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) bIpoStart = true; } else - { + { /* Perform clamping */ m_localtime=m_endframe; result = false; @@ -453,7 +453,7 @@ PyAttributeDef KX_IpoActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_IpoActuator::pyattr_get_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_IpoActuator::pyattr_get_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v); return PyFloat_FromDouble(self->m_startframe); @@ -474,7 +474,7 @@ int KX_IpoActuator::pyattr_set_frame_start(void *self_v, const KX_PYATTRIBUTE_DE return PY_SET_ATTR_SUCCESS; } -PyObject* KX_IpoActuator::pyattr_get_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_IpoActuator::pyattr_get_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v); return PyFloat_FromDouble(self->m_endframe); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index a560b606f5b..c2857141058 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -253,7 +253,7 @@ void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer) * At the moment the bge.logic module is imported into 'pythondictionary' after this function is called. * if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand. */ -void KX_KetsjiEngine::SetPyNamespace(PyObject* pythondictionary) +void KX_KetsjiEngine::SetPyNamespace(PyObject *pythondictionary) { MT_assert(pythondictionary); m_pythondictionary = pythondictionary; @@ -361,7 +361,7 @@ void KX_KetsjiEngine::RenderDome() // no FlushDebugLines } m_dome->BindImages(i); - } + } m_canvas->EndFrame();//XXX do we really need that? @@ -391,7 +391,7 @@ void KX_KetsjiEngine::RenderDome() // Draw Callback for the last scene #ifdef WITH_PYTHON scene->RunDrawingCallbacks(scene->GetPostDrawCB()); -#endif +#endif EndFrame(); } @@ -477,7 +477,7 @@ void KX_KetsjiEngine::ClearFrame() SetBackGround(firstscene->GetWorldInfo()); m_canvas->SetViewPort(clearvp.GetLeft(), clearvp.GetBottom(), - clearvp.GetRight(), clearvp.GetTop()); + clearvp.GetRight(), clearvp.GetTop()); m_rasterizer->ClearColorBuffer(); } } @@ -498,7 +498,7 @@ bool KX_KetsjiEngine::BeginFrame() } return false; -} +} void KX_KetsjiEngine::EndFrame() @@ -641,7 +641,7 @@ else scene->GetPhysicsEnvironment()->endFrame(); // Update scenegraph after physics step. This maps physics calculations - // into node positions. + // into node positions. //m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); //SG_SetActiveStage(SG_STAGE_PHYSICS1_UPDATE); //scene->UpdateParents(m_frameTime); @@ -692,7 +692,7 @@ else if (m_animation_record) - { + { m_sceneconverter->WritePhysicsObjectToAnimationIpo(++m_currentFrame); } @@ -725,7 +725,7 @@ else bool bUseAsyncLogicBricks= false;//true; if (bUseAsyncLogicBricks) - { + { // Logic update sub frame: this will let some logic bricks run at the // full frame rate. for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit) @@ -756,7 +756,7 @@ else m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); scene->GetPhysicsEnvironment()->proceedDeltaTime(m_clockTime,timestep,timestep); // Update scenegraph after physics step. This maps physics calculations - // into node positions. + // into node positions. m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_PHYSICS2); scene->UpdateParents(m_clockTime); @@ -938,7 +938,7 @@ void KX_KetsjiEngine::Render() //RenderFrame(scene); RenderFrame(scene, cam); - list<class KX_Camera*>* cameras = scene->GetCameras(); + list<class KX_Camera*>* cameras = scene->GetCameras(); // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); @@ -1013,7 +1013,7 @@ void KX_KetsjiEngine::SetBackGround(KX_WorldInfo* wi) if (wi->hasWorld()) { if (m_drawingmode == RAS_IRasterizer::KX_TEXTURED) - { + { m_rasterizer->SetBackColor( wi->getBackColorRed(), wi->getBackColorGreen(), @@ -1038,7 +1038,7 @@ void KX_KetsjiEngine::SetWorldSettings(KX_WorldInfo* wi) ); if (m_drawingmode >= RAS_IRasterizer::KX_SOLID) - { + { if (wi->hasMist()) { m_rasterizer->SetFog( @@ -1203,11 +1203,11 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) GetSceneViewport(scene, cam, area, viewport); // store the computed viewport in the scene - scene->SetSceneViewport(viewport); + scene->SetSceneViewport(viewport); // set the viewport for this frame and scene m_canvas->SetViewPort(viewport.GetLeft(), viewport.GetBottom(), - viewport.GetRight(), viewport.GetTop()); + viewport.GetRight(), viewport.GetTop()); // see KX_BlenderMaterial::Activate //m_rasterizer->SetAmbient(); @@ -1348,7 +1348,7 @@ void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene) m_rasterizer->FlushDebugShapes(); scene->Render2DFilters(m_canvas); #ifdef WITH_PYTHON - scene->RunDrawingCallbacks(scene->GetPostDrawCB()); + scene->RunDrawingCallbacks(scene->GetPostDrawCB()); #endif } @@ -1368,10 +1368,10 @@ void KX_KetsjiEngine::StopEngine() { KX_Scene* scene = *sceneit; m_sceneconverter->RemoveScene(scene); - } + } m_scenes.clear(); - // cleanup all the stuff + // cleanup all the stuff m_rasterizer->Exit(); } } @@ -1469,7 +1469,7 @@ void KX_KetsjiEngine::RenderDebugProperties() /* Profile and framerate display */ if (m_show_profile) - { + { for (int j = tc_first; j < tc_numCategories; j++) { debugtxt.Format(m_profileLabels[j]); @@ -1556,7 +1556,7 @@ void KX_KetsjiEngine::RenderDebugProperties() KX_SceneList* KX_KetsjiEngine::CurrentScenes() { - return &m_scenes; + return &m_scenes; } @@ -1572,7 +1572,7 @@ KX_Scene* KX_KetsjiEngine::FindScene(const STR_String& scenename) sceneit++; } - return ((sceneit == m_scenes.end()) ? NULL : *sceneit); + return ((sceneit == m_scenes.end()) ? NULL : *sceneit); } @@ -1635,7 +1635,7 @@ void KX_KetsjiEngine::RemoveScheduledScenes() m_scenes.erase(sceneit); break; } - } + } } m_removingScenes.clear(); } @@ -1737,7 +1737,7 @@ void KX_KetsjiEngine::ReplaceScheduledScenes() } } m_replace_scenes.clear(); - } + } } @@ -1910,7 +1910,7 @@ void KX_KetsjiEngine::SceneListsChanged(void) while ((sceneit != m_scenes.end()) && (!m_propertiesPresent)) { KX_Scene* scene = *sceneit; - vector<SCA_DebugProp*>& debugproplist = scene->GetDebugProperties(); + vector<SCA_DebugProp*>& debugproplist = scene->GetDebugProperties(); m_propertiesPresent = !debugproplist.empty(); sceneit++; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index b3bef016b0f..e05ba652bbe 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -98,7 +98,7 @@ private: /* The current list of scenes. */ KX_SceneList m_scenes; /* State variable recording the presence of object debug info in the current scene list. */ - bool m_propertiesPresent; + bool m_propertiesPresent; bool m_bInitialized; int m_activecam; @@ -136,7 +136,7 @@ private: int m_drawingmode; float m_cameraZoom; - bool m_overrideCam; + bool m_overrideCam; STR_String m_overrideSceneName; bool m_overrideCamUseOrtho; @@ -220,7 +220,7 @@ public: void SetRenderTools(RAS_IRenderTools* rendertools); void SetRasterizer(RAS_IRasterizer* rasterizer); #ifdef WITH_PYTHON - void SetPyNamespace(PyObject* pythondictionary); + void SetPyNamespace(PyObject *pythondictionary); PyObject* GetPyNamespace() { return m_pythondictionary; } #endif void SetSceneConverter(KX_ISceneConverter* sceneconverter); @@ -415,7 +415,7 @@ public: KX_Scene* CreateScene(const STR_String& scenename); KX_Scene* CreateScene(Scene *scene); - GlobalSettings* GetGlobalSettings(void); + GlobalSettings* GetGlobalSettings(void); void SetGlobalSettings(GlobalSettings* gs); protected: diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index f5aa1bb3c75..8b80daa75d3 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -344,7 +344,7 @@ PyAttributeDef KX_LightObject::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_LightObject::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_LightObject::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_LightObject* self = static_cast<KX_LightObject*>(self_v); return Py_BuildValue("[fff]", self->m_lightobj.m_red, self->m_lightobj.m_green, self->m_lightobj.m_blue); @@ -365,9 +365,9 @@ int KX_LightObject::pyattr_set_color(void *self_v, const KX_PYATTRIBUTE_DEF *att return PY_SET_ATTR_FAIL; } -PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - PyObject* retvalue; + PyObject *retvalue; const char* type = attrdef->m_name; @@ -387,13 +387,13 @@ PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT return retvalue; } -PyObject* KX_LightObject::pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_LightObject::pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_LightObject* self = static_cast<KX_LightObject*>(self_v); return PyLong_FromSsize_t(self->m_lightobj.m_type); } -int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value) +int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { KX_LightObject* self = static_cast<KX_LightObject*>(self_v); int val = PyLong_AsSsize_t(value); diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 9fe13f471ba..7426896a92a 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -76,10 +76,10 @@ public: #ifdef WITH_PYTHON /* attributes */ static PyObject* pyattr_get_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value); + static int pyattr_set_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_typeconst(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value); + static int pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif }; diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h index 3a3a9677b04..4a1ceba0963 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.h +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.h @@ -74,15 +74,15 @@ public: m_modified = true; } - void SetModifyEnergy(bool modify) { + void SetModifyEnergy(bool modify) { m_modify_energy = modify; } - void SetModifyColor(bool modify) { + void SetModifyColor(bool modify) { m_modify_color = modify; } - void SetModifyDist(bool modify) { + void SetModifyDist(bool modify) { m_modify_dist = modify; } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index f1a9a93c2db..8451dc3497d 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -105,7 +105,7 @@ KX_MeshProxy::~KX_MeshProxy() // stuff for cvalue related things CValue* KX_MeshProxy::Calc(VALUE_OPERATOR op, CValue *val) { return NULL;} -CValue* KX_MeshProxy::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val) { return NULL;} +CValue* KX_MeshProxy::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val) { return NULL;} const STR_String & KX_MeshProxy::GetText() {return m_meshobj->GetName();}; double KX_MeshProxy::GetNumber() { return -1;} @@ -116,7 +116,7 @@ CValue* KX_MeshProxy::GetReplica() { return NULL;} // stuff for python integration -PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds) +PyObject *KX_MeshProxy::PyGetMaterialName(PyObject *args, PyObject *kwds) { int matid= 1; STR_String matname; @@ -134,7 +134,7 @@ PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds) } -PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds) +PyObject *KX_MeshProxy::PyGetTextureName(PyObject *args, PyObject *kwds) { int matid= 1; STR_String matname; @@ -151,7 +151,7 @@ PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds) } -PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* args, PyObject* kwds) +PyObject *KX_MeshProxy::PyGetVertexArrayLength(PyObject *args, PyObject *kwds) { int matid= 0; int length = 0; @@ -174,7 +174,7 @@ PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* args, PyObject* kwds) } -PyObject* KX_MeshProxy::PyGetVertex(PyObject* args, PyObject* kwds) +PyObject *KX_MeshProxy::PyGetVertex(PyObject *args, PyObject *kwds) { int vertexindex; int matindex; @@ -192,10 +192,10 @@ PyObject* KX_MeshProxy::PyGetVertex(PyObject* args, PyObject* kwds) return (new KX_VertexProxy(this, vertex))->NewProxy(true); } -PyObject* KX_MeshProxy::PyGetPolygon(PyObject* args, PyObject* kwds) +PyObject *KX_MeshProxy::PyGetPolygon(PyObject *args, PyObject *kwds) { int polyindex= 1; - PyObject* polyob = NULL; + PyObject *polyob = NULL; if (!PyArg_ParseTuple(args,"i:getPolygon",&polyindex)) return NULL; @@ -218,7 +218,7 @@ PyObject* KX_MeshProxy::PyGetPolygon(PyObject* args, PyObject* kwds) return polyob; } -PyObject* KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MeshProxy* self= static_cast<KX_MeshProxy*>(self_v); @@ -233,7 +233,7 @@ PyObject* KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_ for (i=0; i<tot; mit++, i++) { RAS_IPolyMaterial *polymat = mit->m_bucket->GetPolyMaterial(); - /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject*)? - Campbell */ + /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject *)? - Campbell */ if (polymat->GetFlag() & RAS_BLENDERMAT) { KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial*>(polymat); @@ -243,7 +243,7 @@ PyObject* KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_ KX_PolygonMaterial *mat = static_cast<KX_PolygonMaterial*>(polymat); PyList_SET_ITEM(materials, i, mat->GetProxy()); } - } + } return materials; } @@ -260,7 +260,7 @@ PyObject * KX_MeshProxy::pyattr_get_numPolygons(void * selfv, const KX_PYATTRIBU } /* a close copy of ConvertPythonToGameObject but for meshes */ -bool ConvertPythonToMesh(PyObject * value, RAS_MeshObject **object, bool py_none_ok, const char *error_prefix) +bool ConvertPythonToMesh(PyObject *value, RAS_MeshObject **object, bool py_none_ok, const char *error_prefix) { if (value==NULL) { PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix); @@ -297,7 +297,7 @@ bool ConvertPythonToMesh(PyObject * value, RAS_MeshObject **object, bool py_none if (kx_mesh==NULL) { PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix); return false; - } + } *object = kx_mesh->GetMesh(); return true; diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index 58b5c87e494..a05ef6ab2e7 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -37,7 +37,7 @@ #include "SCA_IObject.h" /* utility conversion function */ -bool ConvertPythonToMesh(PyObject * value, class RAS_MeshObject **object, bool py_none_ok, const char *error_prefix); +bool ConvertPythonToMesh(PyObject *value, class RAS_MeshObject **object, bool py_none_ok, const char *error_prefix); class KX_MeshProxy : public CValue { @@ -73,8 +73,8 @@ public: KX_PYMETHOD(KX_MeshProxy,GetPolygon); static PyObject* pyattr_get_materials(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject * pyattr_get_numMaterials(void * self, const KX_PYATTRIBUTE_DEF * attrdef); - static PyObject * pyattr_get_numPolygons(void * self, const KX_PYATTRIBUTE_DEF * attrdef); + static PyObject *pyattr_get_numMaterials(void * self, const KX_PYATTRIBUTE_DEF * attrdef); + static PyObject *pyattr_get_numPolygons(void * self, const KX_PYATTRIBUTE_DEF * attrdef); }; #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index bfee124d443..3251cc4af46 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -239,7 +239,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) /* build the from and to point in normalized device coordinates * Normalized device coordinates are [-1,1] in x, y, z - * + * * The actual z coordinates used don't have to be exact just infront and * behind of the near and far clip planes. */ @@ -392,19 +392,19 @@ PyAttributeDef KX_MouseFocusSensor::Attributes[] = { }; /* Attributes */ -PyObject* KX_MouseFocusSensor::pyattr_get_ray_source(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_MouseFocusSensor::pyattr_get_ray_source(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_MouseFocusSensor::pyattr_get_ray_target(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_MouseFocusSensor::pyattr_get_ray_direction(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); MT_Vector3 dir = self->RayTarget() - self->RaySource(); @@ -413,7 +413,7 @@ PyObject* KX_MouseFocusSensor::pyattr_get_ray_direction(void *self_v, const KX_P return PyObjectFrom(dir); } -PyObject* KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); @@ -423,19 +423,19 @@ PyObject* KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYAT Py_RETURN_NONE; } -PyObject* KX_MouseFocusSensor::pyattr_get_hit_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_MouseFocusSensor::pyattr_get_hit_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_MouseFocusSensor::pyattr_get_hit_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_MouseFocusSensor::pyattr_get_hit_uv(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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 35058e5fe5d..a05292f268a 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -210,7 +210,7 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, { //detailed mesh vertex memcpy(dvertices+3*(newIdx-nverts), allVerts+3*vi, 3*sizeof(float)); - } + } } } @@ -245,7 +245,7 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, { memset(vert, 0, 3*sizeof(float)); //vertex isn't in any poly, set dummy zero coordinates } - vert+=3; + vert+=3; } //create tris @@ -294,7 +294,7 @@ bool KX_NavMeshObject::BuildNavMesh() float *vertices = NULL, *dvertices = NULL; unsigned short *polys = NULL, *dtris = NULL, *dmeshes = NULL; - int nverts = 0, npolys = 0, ndvertsuniq = 0, ndtris = 0; + int nverts = 0, npolys = 0, ndvertsuniq = 0, ndtris = 0; int vertsPerPoly = 0; if (!BuildVertIndArrays(vertices, nverts, polys, npolys, dmeshes, dvertices, ndvertsuniq, dtris, ndtris, vertsPerPoly ) @@ -446,11 +446,11 @@ bool KX_NavMeshObject::BuildNavMesh() dtl.nverts = dmeshes[i*4+1]; dtl.tbase = dmeshes[i*4+2]; dtl.ntris = dmeshes[i*4+3]; - } + } } m_navMesh = new dtStatNavMesh; - m_navMesh->init(data, dataSize, true); + m_navMesh->init(data, dataSize, true); delete [] vertices; @@ -487,7 +487,7 @@ void KX_NavMeshObject::DrawNavMesh(NavMeshRenderMode renderMode) const dtStatPoly* poly = m_navMesh->getPoly(pi); for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++) - { + { if (poly->n[j] && renderMode==RM_WALLS) continue; const float* vif = m_navMesh->getVertex(poly->v[i]); @@ -564,7 +564,7 @@ int KX_NavMeshObject::FindPath(const MT_Point3& from, const MT_Point3& to, float if (!m_navMesh) return 0; MT_Point3 localfrom = TransformToLocalCoords(from); - MT_Point3 localto = TransformToLocalCoords(to); + MT_Point3 localto = TransformToLocalCoords(to); float spos[3], epos[3]; localfrom.getValue(spos); flipAxes(spos); localto.getValue(epos); flipAxes(epos); @@ -598,7 +598,7 @@ float KX_NavMeshObject::Raycast(const MT_Point3& from, const MT_Point3& to) if (!m_navMesh) return 0.f; MT_Point3 localfrom = TransformToLocalCoords(from); - MT_Point3 localto = TransformToLocalCoords(to); + MT_Point3 localto = TransformToLocalCoords(to); float spos[3], epos[3]; localfrom.getValue(spos); flipAxes(spos); localto.getValue(epos); flipAxes(epos); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index a3f098c3b1f..f35090f9e9b 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -460,7 +460,7 @@ Mathutils_Callback mathutils_obactu_vector_cb = { mathutils_obactu_vector_set_index }; -PyObject* KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); } @@ -476,7 +476,7 @@ int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *a return PY_SET_ATTR_SUCCESS; } -PyObject* KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); } @@ -501,7 +501,7 @@ void KX_ObjectActuator_Mathutils_Callback_Init(void) #endif // USE_MATHUTILS -PyObject* KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); PyObject *retVal = PyList_New(3); @@ -517,7 +517,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE { KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); - PyObject* seq = PySequence_Fast(value, ""); + PyObject *seq = PySequence_Fast(value, ""); if (seq && PySequence_Fast_GET_SIZE(seq) == 3) { self->m_drot[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); @@ -537,7 +537,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE return PY_SET_ATTR_FAIL; } -PyObject* KX_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); PyObject *retVal = PyList_New(3); @@ -553,7 +553,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE { KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); - PyObject* seq = PySequence_Fast(value, ""); + PyObject *seq = PySequence_Fast(value, ""); if (seq && PySequence_Fast_GET_SIZE(seq) == 3) { self->m_drot[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); @@ -573,7 +573,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE return PY_SET_ATTR_FAIL; } -PyObject* KX_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); PyObject *retVal = PyList_New(3); @@ -589,7 +589,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE { KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); - PyObject* seq = PySequence_Fast(value, ""); + PyObject *seq = PySequence_Fast(value, ""); if (seq && PySequence_Fast_GET_SIZE(seq) == 3) { self->m_drot[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); @@ -609,7 +609,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE return PY_SET_ATTR_FAIL; } -PyObject* KX_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self); if (!actuator->m_reference) @@ -632,7 +632,7 @@ int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIB if (refOb==NULL) { actuator->m_reference= NULL; } - else { + else { actuator->m_reference = refOb; actuator->m_reference->RegisterActuator(actuator); } diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index a942f87856c..99d9fc7f9ee 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -257,7 +257,7 @@ void KX_ObstacleSimulation::AddObstacleForObj(KX_GameObject* gameobj) } void KX_ObstacleSimulation::AddObstaclesForNavMesh(KX_NavMeshObject* navmeshobj) -{ +{ dtStatNavMesh* navmesh = navmeshobj->GetNavMesh(); if (navmesh) { @@ -267,7 +267,7 @@ void KX_ObstacleSimulation::AddObstaclesForNavMesh(KX_NavMeshObject* navmeshobj) const dtStatPoly* poly = navmesh->getPoly(pi); for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++) - { + { if (poly->n[j]) continue; const float* vj = navmesh->getVertex(poly->v[j]); const float* vi = navmesh->getVertex(poly->v[i]); @@ -364,9 +364,9 @@ void KX_ObstacleSimulation::DrawObstacles() else if (m_obstacles[i]->m_shape==KX_OBSTACLE_CIRCLE) { KX_RasterizerDrawDebugCircle(m_obstacles[i]->m_pos, m_obstacles[i]->m_rad, bluecolor, - normal, SECTORS_NUM); + normal, SECTORS_NUM); } - } + } } static MT_Point3 nearestPointToObstacle(MT_Point3& pos ,KX_Obstacle* obstacle) @@ -424,7 +424,7 @@ KX_ObstacleSimulationTOI::KX_ObstacleSimulationTOI(MT_Scalar levelHeight, bool e void KX_ObstacleSimulationTOI::AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, - MT_Vector3& velocity, MT_Scalar maxDeltaSpeed, MT_Scalar maxDeltaAngle) + MT_Vector3& velocity, MT_Scalar maxDeltaSpeed, MT_Scalar maxDeltaAngle) { int nobs = m_obstacles.size(); int obstidx = std::find(m_obstacles.begin(), m_obstacles.end(), activeObst) - m_obstacles.begin(); @@ -446,7 +446,7 @@ void KX_ObstacleSimulationTOI::AdjustObstacleVelocity(KX_Obstacle* activeObst, K vadd(vel, activeObst->vel, dv); velocity.x() = vel[0]; - velocity.y() = vel[1]; + velocity.y() = vel[1]; } ///////////*********TOI_rays**********///////////////// @@ -642,7 +642,7 @@ static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM for (int n = 0; n < nspos; ++n) { float vcand[2]; - vcpy(vcand, &spos[n*2]); + vcpy(vcand, &spos[n*2]); // Find min time of impact and exit amongst all obstacles. float tmin = maxToi; diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.h b/source/gameengine/Ketsji/KX_ObstacleSimulation.h index 5b359fc031e..50589b5bc69 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.h +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.h @@ -34,13 +34,13 @@ class KX_GameObject; class KX_NavMeshObject; enum KX_OBSTACLE_TYPE -{ +{ KX_OBSTACLE_OBJ, KX_OBSTACLE_NAV_MESH, }; enum KX_OBSTACLE_SHAPE -{ +{ KX_OBSTACLE_CIRCLE, KX_OBSTACLE_SEGMENT, }; @@ -86,9 +86,9 @@ public: void DestroyObstacleForObj(KX_GameObject* gameobj); void AddObstaclesForNavMesh(KX_NavMeshObject* navmesh); KX_Obstacle* GetObstacle(KX_GameObject* gameobj); - void UpdateObstacles(); + void UpdateObstacles(); virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, - MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle); + MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle); }; class KX_ObstacleSimulationTOI: public KX_ObstacleSimulation diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 5058af18d15..6926fdb1d4c 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -172,10 +172,10 @@ PyAttributeDef KX_ParentActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_ParentActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_ParentActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_ParentActuator* actuator = static_cast<KX_ParentActuator*>(self); - if (!actuator->m_ob) + if (!actuator->m_ob) Py_RETURN_NONE; else return actuator->m_ob->GetProxy(); @@ -190,7 +190,7 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (actuator->m_ob != NULL) - actuator->m_ob->UnregisterActuator(actuator); + actuator->m_ob->UnregisterActuator(actuator); actuator->m_ob = (SCA_IObject*) gameobj; diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 6191b889da3..f2f5acd3dfb 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -81,7 +81,7 @@ public: /* --------------------------------------------------------------------- */ /* These are used to get and set m_ob */ - static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index 225a1628b3b..f18c35c0c78 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -51,7 +51,7 @@ KX_PhysicsObjectWrapper::~KX_PhysicsObjectWrapper() #ifdef WITH_PYTHON -PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* args) +PyObject *KX_PhysicsObjectWrapper::PySetPosition(PyObject *args) { float x,y,z; if (PyArg_ParseTuple(args,"fff:setPosition",&x,&y,&z)) @@ -65,7 +65,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* args) } -PyObject* KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject* args) +PyObject *KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject *args) { float x,y,z; int local; @@ -79,7 +79,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* args) +PyObject *KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject *args) { float x,y,z; int local; @@ -93,7 +93,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* args) +PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject *args) { int active; if (PyArg_ParseTuple(args,"i:setActive",&active)) diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 85c88337d60..13b6bda4ebc 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -102,7 +102,7 @@ KX_PolyProxy::~KX_PolyProxy() // stuff for cvalue related things CValue* KX_PolyProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;} -CValue* KX_PolyProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;} +CValue* KX_PolyProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;} STR_String sPolyName="polygone"; const STR_String & KX_PolyProxy::GetText() {return sPolyName;}; double KX_PolyProxy::GetNumber() { return -1;} @@ -112,52 +112,52 @@ CValue* KX_PolyProxy::GetReplica() { return NULL;} // stuff for python integration -PyObject* KX_PolyProxy::pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_PolyProxy::pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolyProxy::pyattr_get_texture_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolyProxy::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolyProxy::pyattr_get_material_id(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolyProxy::pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolyProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolyProxy::pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolyProxy::pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); @@ -168,13 +168,13 @@ PyObject* KX_PolyProxy::pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *at return PyLong_FromSsize_t(0); } -PyObject* KX_PolyProxy::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_PolyProxy::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolyProxy::pyattr_get_collide(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); return self->PyisCollider(); diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h index 83c3bff0ee2..9e3556a03f8 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.h +++ b/source/gameengine/Ketsji/KX_PolyProxy.h @@ -57,16 +57,16 @@ public: // stuff for python integration - static PyObject* pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_texture_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_material_id(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_collide(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_texture_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_material_id(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_collide(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex) KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex) diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 2e39190f4f9..3b58a8abd83 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -143,7 +143,7 @@ bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingI { PyObject *pyRasty = PyCapsule_New((void*)rasty, KX_POLYGONMATERIAL_CAPSULE_ID, NULL); /* new reference */ PyObject *pyCachingInfo = PyCapsule_New((void*) &cachingInfo, KX_POLYGONMATERIAL_CAPSULE_ID, NULL); /* new reference */ - PyObject *ret = PyObject_CallMethod(m_pymaterial, (char *)"activate", (char *)"(NNO)", pyRasty, pyCachingInfo, (PyObject*) this->m_proxy); + PyObject *ret = PyObject_CallMethod(m_pymaterial, (char *)"activate", (char *)"(NNO)", pyRasty, pyCachingInfo, (PyObject *) this->m_proxy); if (ret) { bool value = PyLong_AsSsize_t(ret); @@ -252,7 +252,7 @@ PyAttributeDef KX_PolygonMaterial::Attributes[] = { KX_PYATTRIBUTE_INT_RW("tile", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tile), KX_PYATTRIBUTE_INT_RW("tilexrep", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tilexrep), KX_PYATTRIBUTE_INT_RW("tileyrep", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tileyrep), - KX_PYATTRIBUTE_INT_RW("drawingmode", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_drawingmode), + KX_PYATTRIBUTE_INT_RW("drawingmode", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_drawingmode), //KX_PYATTRIBUTE_INT_RW("lightlayer", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_lightlayer), KX_PYATTRIBUTE_BOOL_RW("transparent", KX_PolygonMaterial, m_alpha), @@ -262,7 +262,7 @@ PyAttributeDef KX_PolygonMaterial::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("specularity", 0.0f, 1000.0f, KX_PolygonMaterial, m_specularity), KX_PYATTRIBUTE_RW_FUNCTION("diffuse", KX_PolygonMaterial, pyattr_get_diffuse, pyattr_set_diffuse), - KX_PYATTRIBUTE_RW_FUNCTION("specular",KX_PolygonMaterial, pyattr_get_specular, pyattr_set_specular), + KX_PYATTRIBUTE_RW_FUNCTION("specular",KX_PolygonMaterial, pyattr_get_specular, pyattr_set_specular), KX_PYATTRIBUTE_RO_FUNCTION("tface", KX_PolygonMaterial, pyattr_get_tface), /* How the heck is this even useful??? - Campbell */ KX_PYATTRIBUTE_RO_FUNCTION("gl_texture", KX_PolygonMaterial, pyattr_get_gl_texture), /* could be called 'bindcode' */ @@ -355,26 +355,26 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, activate, "activate(rasty, cachingInfo)") return NULL; } -PyObject* KX_PolygonMaterial::pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_PolygonMaterial::pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolygonMaterial::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolygonMaterial::pyattr_get_tface(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_PolygonMaterial::pyattr_get_gl_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); int bindcode= 0; @@ -385,7 +385,7 @@ 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) +PyObject *KX_PolygonMaterial::pyattr_get_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); return PyObjectFrom(self->m_diffuse); @@ -403,7 +403,7 @@ int KX_PolygonMaterial::pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DE return PY_SET_ATTR_SUCCESS; } -PyObject* KX_PolygonMaterial::pyattr_get_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_PolygonMaterial::pyattr_get_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); return PyObjectFrom(self->m_specular); diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index f7ad3973212..6384008fb7d 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -137,7 +137,7 @@ public: KX_PYMETHOD_DOC(KX_PolygonMaterial, setCustomMaterial); KX_PYMETHOD_DOC(KX_PolygonMaterial, loadProgram); - virtual PyObject* py_repr(void) { return PyUnicode_FromString(m_material ? ((ID *)m_material)->name+2 : ""); } + virtual PyObject *py_repr(void) { return PyUnicode_FromString(m_material ? ((ID *)m_material)->name+2 : ""); } static PyObject* pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); @@ -145,9 +145,9 @@ public: static PyObject* pyattr_get_tface(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_gl_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_diffuse(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_diffuse(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static PyObject* pyattr_get_specular(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_specular(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 556d451cf66..5f3a4879150 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -89,9 +89,9 @@ static char gPyGetAppliedImpulse__doc__[] = "getAppliedImpulse(int constraintId) -static PyObject* gPySetGravity(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetGravity(PyObject *self, + PyObject *args, + PyObject *kwds) { float x,y,z; if (PyArg_ParseTuple(args,"fff",&x,&y,&z)) @@ -106,9 +106,9 @@ static PyObject* gPySetGravity(PyObject* self, Py_RETURN_NONE; } -static PyObject* gPySetDebugMode(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetDebugMode(PyObject *self, + PyObject *args, + PyObject *kwds) { int mode; if (PyArg_ParseTuple(args,"i",&mode)) @@ -129,9 +129,9 @@ static PyObject* gPySetDebugMode(PyObject* self, -static PyObject* gPySetNumTimeSubSteps(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetNumTimeSubSteps(PyObject *self, + PyObject *args, + PyObject *kwds) { int substep; if (PyArg_ParseTuple(args,"i",&substep)) @@ -148,9 +148,9 @@ static PyObject* gPySetNumTimeSubSteps(PyObject* self, } -static PyObject* gPySetNumIterations(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetNumIterations(PyObject *self, + PyObject *args, + PyObject *kwds) { int iter; if (PyArg_ParseTuple(args,"i",&iter)) @@ -167,9 +167,9 @@ static PyObject* gPySetNumIterations(PyObject* self, } -static PyObject* gPySetDeactivationTime(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetDeactivationTime(PyObject *self, + PyObject *args, + PyObject *kwds) { float deactive_time; if (PyArg_ParseTuple(args,"f",&deactive_time)) @@ -186,9 +186,9 @@ static PyObject* gPySetDeactivationTime(PyObject* self, } -static PyObject* gPySetDeactivationLinearTreshold(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetDeactivationLinearTreshold(PyObject *self, + PyObject *args, + PyObject *kwds) { float linearDeactivationTreshold; if (PyArg_ParseTuple(args,"f",&linearDeactivationTreshold)) @@ -205,9 +205,9 @@ static PyObject* gPySetDeactivationLinearTreshold(PyObject* self, } -static PyObject* gPySetDeactivationAngularTreshold(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetDeactivationAngularTreshold(PyObject *self, + PyObject *args, + PyObject *kwds) { float angularDeactivationTreshold; if (PyArg_ParseTuple(args,"f",&angularDeactivationTreshold)) @@ -223,9 +223,9 @@ static PyObject* gPySetDeactivationAngularTreshold(PyObject* self, Py_RETURN_NONE; } -static PyObject* gPySetContactBreakingTreshold(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetContactBreakingTreshold(PyObject *self, + PyObject *args, + PyObject *kwds) { float contactBreakingTreshold; if (PyArg_ParseTuple(args,"f",&contactBreakingTreshold)) @@ -242,9 +242,9 @@ static PyObject* gPySetContactBreakingTreshold(PyObject* self, } -static PyObject* gPySetCcdMode(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetCcdMode(PyObject *self, + PyObject *args, + PyObject *kwds) { float ccdMode; if (PyArg_ParseTuple(args,"f",&ccdMode)) @@ -260,9 +260,9 @@ static PyObject* gPySetCcdMode(PyObject* self, Py_RETURN_NONE; } -static PyObject* gPySetSorConstant(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetSorConstant(PyObject *self, + PyObject *args, + PyObject *kwds) { float sor; if (PyArg_ParseTuple(args,"f",&sor)) @@ -278,9 +278,9 @@ static PyObject* gPySetSorConstant(PyObject* self, Py_RETURN_NONE; } -static PyObject* gPySetSolverTau(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetSolverTau(PyObject *self, + PyObject *args, + PyObject *kwds) { float tau; if (PyArg_ParseTuple(args,"f",&tau)) @@ -297,9 +297,9 @@ static PyObject* gPySetSolverTau(PyObject* self, } -static PyObject* gPySetSolverDamping(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetSolverDamping(PyObject *self, + PyObject *args, + PyObject *kwds) { float damping; if (PyArg_ParseTuple(args,"f",&damping)) @@ -315,9 +315,9 @@ static PyObject* gPySetSolverDamping(PyObject* self, Py_RETURN_NONE; } -static PyObject* gPySetLinearAirDamping(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetLinearAirDamping(PyObject *self, + PyObject *args, + PyObject *kwds) { float damping; if (PyArg_ParseTuple(args,"f",&damping)) @@ -334,9 +334,9 @@ static PyObject* gPySetLinearAirDamping(PyObject* self, } -static PyObject* gPySetUseEpa(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetUseEpa(PyObject *self, + PyObject *args, + PyObject *kwds) { int epa; if (PyArg_ParseTuple(args,"i",&epa)) @@ -351,9 +351,9 @@ static PyObject* gPySetUseEpa(PyObject* self, } Py_RETURN_NONE; } -static PyObject* gPySetSolverType(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPySetSolverType(PyObject *self, + PyObject *args, + PyObject *kwds) { int solverType; if (PyArg_ParseTuple(args,"i",&solverType)) @@ -371,9 +371,9 @@ static PyObject* gPySetSolverType(PyObject* self, -static PyObject* gPyGetVehicleConstraint(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPyGetVehicleConstraint(PyObject *self, + PyObject *args, + PyObject *kwds) { #if defined(_WIN64) __int64 constraintid; @@ -403,9 +403,9 @@ static PyObject* gPyGetVehicleConstraint(PyObject* self, } -static PyObject* gPyCreateConstraint(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPyCreateConstraint(PyObject *self, + PyObject *args, + PyObject *kwds) { /* FIXME - physicsid is a long being cast to a pointer, should at least use PyCapsule */ #if defined(_WIN64) @@ -435,7 +435,7 @@ static PyObject* gPyCreateConstraint(PyObject* self, #else success = PyArg_ParseTuple(args,"llifff",&physicsid,&physicsid2,&constrainttype, &pivotX,&pivotY,&pivotZ); -#endif +#endif } else if (len == 9) { @@ -521,9 +521,9 @@ static PyObject* gPyCreateConstraint(PyObject* self, -static PyObject* gPyGetAppliedImpulse(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPyGetAppliedImpulse(PyObject *self, + PyObject *args, + PyObject *kwds) { float appliedImpulse = 0.f; @@ -548,9 +548,9 @@ static PyObject* gPyGetAppliedImpulse(PyObject* self, } -static PyObject* gPyRemoveConstraint(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject *gPyRemoveConstraint(PyObject *self, + PyObject *args, + PyObject *kwds) { #if defined(_WIN64) __int64 constraintid; @@ -572,7 +572,7 @@ static PyObject* gPyRemoveConstraint(PyObject* self, Py_RETURN_NONE; } -static PyObject* gPyExportBulletFile(PyObject*, PyObject* args) +static PyObject *gPyExportBulletFile(PyObject *, PyObject *args) { char* filename; if (!PyArg_ParseTuple(args,"s:exportBulletFile",&filename)) @@ -655,13 +655,13 @@ static struct PyModuleDef PhysicsConstraints_module_def = { 0, /* m_free */ }; -PyObject* initPythonConstraintBinding() +PyObject *initPythonConstraintBinding() { - PyObject* ErrorObject; - PyObject* m; - PyObject* d; - PyObject* item; + PyObject *ErrorObject; + PyObject *m; + PyObject *d; + PyObject *item; /* Use existing module where possible * be careful not to init any runtime vars after this */ @@ -716,10 +716,11 @@ PyObject* initPythonConstraintBinding() return d; } - -void KX_RemovePythonConstraintBinding() +#if 0 +static void KX_RemovePythonConstraintBinding() { } +#endif void PHY_SetActiveEnvironment(class PHY_IPhysicsEnvironment* env) { diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index f459b806d2f..bc324c3b140 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -47,7 +47,7 @@ #include "KX_Python.h" #include "KX_PyMath.h" -bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &rot, const char *error_prefix) +bool PyOrientationTo(PyObject *pyval, MT_Matrix3x3 &rot, const char *error_prefix) { int size= PySequence_Size(pyval); @@ -80,7 +80,7 @@ bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &rot, const char *error_prefi return false; } -bool PyQuatTo(PyObject* pyval, MT_Quaternion &qrot) +bool PyQuatTo(PyObject *pyval, MT_Quaternion &qrot) { if (!PyVecTo(pyval, qrot)) return false; @@ -95,7 +95,7 @@ bool PyQuatTo(PyObject* pyval, MT_Quaternion &qrot) return true; } -PyObject* PyObjectFrom(const MT_Matrix4x4 &mat) +PyObject *PyObjectFrom(const MT_Matrix4x4 &mat) { #ifdef USE_MATHUTILS float fmat[16]; @@ -119,7 +119,7 @@ PyObject* PyObjectFrom(const MT_Matrix4x4 &mat) #endif } -PyObject* PyObjectFrom(const MT_Matrix3x3 &mat) +PyObject *PyObjectFrom(const MT_Matrix3x3 &mat) { #ifdef USE_MATHUTILS float fmat[9]; @@ -143,7 +143,7 @@ PyObject* PyObjectFrom(const MT_Matrix3x3 &mat) } #ifdef USE_MATHUTILS -PyObject* PyObjectFrom(const MT_Quaternion &qrot) +PyObject *PyObjectFrom(const MT_Quaternion &qrot) { /* NOTE, were re-ordering here for Mathutils compat */ float fvec[4]; @@ -152,7 +152,7 @@ PyObject* PyObjectFrom(const MT_Quaternion &qrot) } #endif -PyObject* PyObjectFrom(const MT_Tuple4 &vec) +PyObject *PyObjectFrom(const MT_Tuple4 &vec) { #ifdef USE_MATHUTILS float fvec[4]; @@ -168,7 +168,7 @@ PyObject* PyObjectFrom(const MT_Tuple4 &vec) #endif } -PyObject* PyObjectFrom(const MT_Tuple3 &vec) +PyObject *PyObjectFrom(const MT_Tuple3 &vec) { #ifdef USE_MATHUTILS float fvec[3]; @@ -180,10 +180,10 @@ PyObject* PyObjectFrom(const MT_Tuple3 &vec) PyList_SET_ITEM(list, 1, PyFloat_FromDouble(vec[1])); PyList_SET_ITEM(list, 2, PyFloat_FromDouble(vec[2])); return list; -#endif +#endif } -PyObject* PyObjectFrom(const MT_Tuple2 &vec) +PyObject *PyObjectFrom(const MT_Tuple2 &vec) { #ifdef USE_MATHUTILS float fvec[2]; diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index aec871d7700..d79397ed807 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -61,7 +61,7 @@ inline unsigned int Size(const MT_Tuple4&) { return 4; } * Converts the given python matrix (column-major) to an MT class (row-major). */ template<class T> -bool PyMatTo(PyObject* pymat, T& mat) +bool PyMatTo(PyObject *pymat, T& mat) { bool noerror = true; mat.setIdentity(); @@ -133,7 +133,7 @@ bool PyMatTo(PyObject* pymat, T& mat) * Converts a python sequence to a MT class. */ template<class T> -bool PyVecTo(PyObject* pyval, T& vec) +bool PyVecTo(PyObject *pyval, T& vec) { #ifdef USE_MATHUTILS /* no need for BaseMath_ReadCallback() here, reading the sequences will do this */ @@ -235,41 +235,41 @@ bool PyVecTo(PyObject* pyval, T& vec) } -bool PyQuatTo(PyObject* pyval, MT_Quaternion &qrot); +bool PyQuatTo(PyObject *pyval, MT_Quaternion &qrot); -bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &mat, const char *error_prefix); +bool PyOrientationTo(PyObject *pyval, MT_Matrix3x3 &mat, const char *error_prefix); /** * Converts an MT_Matrix4x4 to a python object. */ -PyObject* PyObjectFrom(const MT_Matrix4x4 &mat); +PyObject *PyObjectFrom(const MT_Matrix4x4 &mat); /** * Converts an MT_Matrix3x3 to a python object. */ -PyObject* PyObjectFrom(const MT_Matrix3x3 &mat); +PyObject *PyObjectFrom(const MT_Matrix3x3 &mat); /** * Converts an MT_Tuple2 to a python object. */ -PyObject* PyObjectFrom(const MT_Tuple2 &vec); +PyObject *PyObjectFrom(const MT_Tuple2 &vec); /** * Converts an MT_Tuple3 to a python object */ -PyObject* PyObjectFrom(const MT_Tuple3 &vec); +PyObject *PyObjectFrom(const MT_Tuple3 &vec); #ifdef USE_MATHUTILS /** * Converts an MT_Quaternion to a python object. */ -PyObject* PyObjectFrom(const MT_Quaternion &qrot); +PyObject *PyObjectFrom(const MT_Quaternion &qrot); #endif /** * Converts an MT_Tuple4 to a python object. */ -PyObject* PyObjectFrom(const MT_Tuple4 &pos); +PyObject *PyObjectFrom(const MT_Tuple4 &pos); #endif diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 7d29a20d1a2..43fca40f2da 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -210,15 +210,15 @@ static PyObject *gp_OrigPythonSysModules= NULL; #include "SCA_PythonController.h" // List of methods defined in the module -static PyObject* ErrorObject; +static PyObject *ErrorObject; static const char *gPyGetRandomFloat_doc="getRandomFloat returns a random floating point value in the range [0..1]"; -static PyObject* gPyGetRandomFloat(PyObject*) +static PyObject *gPyGetRandomFloat(PyObject *) { return PyFloat_FromDouble(MT_random()); } -static PyObject* gPySetGravity(PyObject*, PyObject* value) +static PyObject *gPySetGravity(PyObject *, PyObject *value) { MT_Vector3 vec; if (!PyVecTo(value, vec)) @@ -240,7 +240,7 @@ file to make a full path name (doesn't change during the game, even if you load\ other .blend).\n\ The function also converts the directory separator to the local file system format."; -static PyObject* gPyExpandPath(PyObject*, PyObject* args) +static PyObject *gPyExpandPath(PyObject *, PyObject *args) { char expanded[FILE_MAX]; char* filename; @@ -257,7 +257,7 @@ static char gPyStartGame_doc[] = "startGame(blend)\n\ Loads the blend file"; -static PyObject* gPyStartGame(PyObject*, PyObject* args) +static PyObject *gPyStartGame(PyObject *, PyObject *args) { char* blendfile; @@ -274,7 +274,7 @@ static char gPyEndGame_doc[] = "endGame()\n\ Ends the current game"; -static PyObject* gPyEndGame(PyObject*) +static PyObject *gPyEndGame(PyObject *) { gp_KetsjiEngine->RequestExit(KX_EXIT_REQUEST_QUIT_GAME); @@ -287,7 +287,7 @@ static char gPyRestartGame_doc[] = "restartGame()\n\ Restarts the current game by reloading the .blend file"; -static PyObject* gPyRestartGame(PyObject*) +static PyObject *gPyRestartGame(PyObject *) { gp_KetsjiEngine->RequestExit(KX_EXIT_REQUEST_RESTART_GAME); gp_KetsjiEngine->SetNameNextGame(gp_GamePythonPath); @@ -299,7 +299,7 @@ static char gPySaveGlobalDict_doc[] = "saveGlobalDict()\n" "Saves bge.logic.globalDict to a file"; -static PyObject* gPySaveGlobalDict(PyObject*) +static PyObject *gPySaveGlobalDict(PyObject *) { char marshal_path[512]; char *marshal_buffer = NULL; @@ -336,7 +336,7 @@ static char gPyLoadGlobalDict_doc[] = "LoadGlobalDict()\n" "Loads bge.logic.globalDict from a file"; -static PyObject* gPyLoadGlobalDict(PyObject*) +static PyObject *gPyLoadGlobalDict(PyObject *) { char marshal_path[512]; char *marshal_buffer = NULL; @@ -381,7 +381,7 @@ body = Message body\ to = Name of object to send the message to\ from = Name of object to send the string from"; -static PyObject* gPySendMessage(PyObject*, PyObject* args) +static PyObject *gPySendMessage(PyObject *, PyObject *args) { char* subject; char* body = (char *)""; @@ -397,9 +397,9 @@ static PyObject* gPySendMessage(PyObject*, PyObject* args) } // this gets a pointer to an array filled with floats -static PyObject* gPyGetSpectrum(PyObject*) +static PyObject *gPyGetSpectrum(PyObject *) { - PyObject* resultlist = PyList_New(512); + PyObject *resultlist = PyList_New(512); for (int index = 0; index < 512; index++) { @@ -409,7 +409,7 @@ static PyObject* gPyGetSpectrum(PyObject*) return resultlist; } -static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args) +static PyObject *gPySetLogicTicRate(PyObject *, PyObject *args) { float ticrate; if (!PyArg_ParseTuple(args, "f:setLogicTicRate", &ticrate)) @@ -419,12 +419,12 @@ static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyGetLogicTicRate(PyObject*) +static PyObject *gPyGetLogicTicRate(PyObject *) { return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate()); } -static PyObject* gPySetExitKey(PyObject*, PyObject* args) +static PyObject *gPySetExitKey(PyObject *, PyObject *args) { short exitkey; if (!PyArg_ParseTuple(args, "h:setExitKey", &exitkey)) @@ -433,12 +433,12 @@ static PyObject* gPySetExitKey(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyGetExitKey(PyObject*) +static PyObject *gPyGetExitKey(PyObject *) { return PyLong_FromSsize_t(KX_KetsjiEngine::GetExitKey()); } -static PyObject* gPySetMaxLogicFrame(PyObject*, PyObject* args) +static PyObject *gPySetMaxLogicFrame(PyObject *, PyObject *args) { int frame; if (!PyArg_ParseTuple(args, "i:setMaxLogicFrame", &frame)) @@ -448,12 +448,12 @@ static PyObject* gPySetMaxLogicFrame(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyGetMaxLogicFrame(PyObject*) +static PyObject *gPyGetMaxLogicFrame(PyObject *) { return PyLong_FromSsize_t(KX_KetsjiEngine::GetMaxLogicFrame()); } -static PyObject* gPySetMaxPhysicsFrame(PyObject*, PyObject* args) +static PyObject *gPySetMaxPhysicsFrame(PyObject *, PyObject *args) { int frame; if (!PyArg_ParseTuple(args, "i:setMaxPhysicsFrame", &frame)) @@ -463,12 +463,12 @@ static PyObject* gPySetMaxPhysicsFrame(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyGetMaxPhysicsFrame(PyObject*) +static PyObject *gPyGetMaxPhysicsFrame(PyObject *) { return PyLong_FromSsize_t(KX_KetsjiEngine::GetMaxPhysicsFrame()); } -static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args) +static PyObject *gPySetPhysicsTicRate(PyObject *, PyObject *args) { float ticrate; if (!PyArg_ParseTuple(args, "f:setPhysicsTicRate", &ticrate)) @@ -478,7 +478,7 @@ static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args) Py_RETURN_NONE; } #if 0 // unused -static PyObject* gPySetPhysicsDebug(PyObject*, PyObject* args) +static PyObject *gPySetPhysicsDebug(PyObject *, PyObject *args) { int debugMode; if (!PyArg_ParseTuple(args, "i:setPhysicsDebug", &debugMode)) @@ -490,21 +490,21 @@ static PyObject* gPySetPhysicsDebug(PyObject*, PyObject* args) #endif -static PyObject* gPyGetPhysicsTicRate(PyObject*) +static PyObject *gPyGetPhysicsTicRate(PyObject *) { return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep()); } -static PyObject* gPyGetAverageFrameRate(PyObject*) +static PyObject *gPyGetAverageFrameRate(PyObject *) { return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate()); } -static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) +static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args) { char cpath[sizeof(gp_GamePythonPath)]; char *searchpath = NULL; - PyObject* list, *value; + PyObject *list, *value; DIR *dp; struct dirent *dirp; @@ -545,7 +545,7 @@ static char gPyAddScene_doc[] = adds a scene to the game engine\n\ name = Name of the scene\n\ overlay = Overlay or underlay"; -static PyObject* gPyAddScene(PyObject*, PyObject* args) +static PyObject *gPyAddScene(PyObject *, PyObject *args) { char* name; int overlay = 1; @@ -561,7 +561,7 @@ static PyObject* gPyAddScene(PyObject*, PyObject* args) static const char *gPyGetCurrentScene_doc = "getCurrentScene()\n" "Gets a reference to the current scene.\n"; -static PyObject* gPyGetCurrentScene(PyObject* self) +static PyObject *gPyGetCurrentScene(PyObject *self) { return gp_KetsjiScene->GetProxy(); } @@ -569,10 +569,10 @@ static PyObject* gPyGetCurrentScene(PyObject* self) static const char *gPyGetSceneList_doc = "getSceneList()\n" "Return a list of converted scenes.\n"; -static PyObject* gPyGetSceneList(PyObject* self) +static PyObject *gPyGetSceneList(PyObject *self) { KX_KetsjiEngine* m_engine = KX_GetActiveEngine(); - PyObject* list; + PyObject *list; KX_SceneList* scenes = m_engine->CurrentScenes(); int numScenes = scenes->size(); int i; @@ -665,7 +665,7 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) Py_RETURN_NONE; } -static PyObject *gLibLoad(PyObject*, PyObject* args, PyObject* kwds) +static PyObject *gLibLoad(PyObject *, PyObject *args, PyObject *kwds) { KX_Scene *kx_scene= gp_KetsjiScene; char *path; @@ -721,7 +721,7 @@ static PyObject *gLibLoad(PyObject*, PyObject* args, PyObject* kwds) Py_RETURN_FALSE; } -static PyObject *gLibNew(PyObject*, PyObject* args) +static PyObject *gLibNew(PyObject *, PyObject *args) { KX_Scene *kx_scene= gp_KetsjiScene; char *path; @@ -779,7 +779,7 @@ static PyObject *gLibNew(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject *gLibFree(PyObject*, PyObject* args) +static PyObject *gLibFree(PyObject *, PyObject *args) { KX_Scene *kx_scene= gp_KetsjiScene; char *path; @@ -796,7 +796,7 @@ static PyObject *gLibFree(PyObject*, PyObject* args) } } -static PyObject *gLibList(PyObject*, PyObject* args) +static PyObject *gLibList(PyObject *, PyObject *args) { vector<Main*> &dynMaggie = gp_KetsjiScene->GetSceneConverter()->GetMainDynamic(); int i= 0; @@ -866,14 +866,14 @@ static struct PyMethodDef game_methods[] = { {NULL, (PyCFunction) NULL, 0, NULL } }; -static PyObject* gPyGetWindowHeight(PyObject*, PyObject* args) +static PyObject *gPyGetWindowHeight(PyObject *, PyObject *args) { return PyLong_FromSsize_t((gp_Canvas ? gp_Canvas->GetHeight() : 0)); } -static PyObject* gPyGetWindowWidth(PyObject*, PyObject* args) +static PyObject *gPyGetWindowWidth(PyObject *, PyObject *args) { return PyLong_FromSsize_t((gp_Canvas ? gp_Canvas->GetWidth() : 0)); } @@ -883,7 +883,7 @@ static PyObject* gPyGetWindowWidth(PyObject*, PyObject* args) // temporarility visibility thing, will be moved to rasterizer/renderer later bool gUseVisibilityTemp = false; -static PyObject* gPyEnableVisibility(PyObject*, PyObject* args) +static PyObject *gPyEnableVisibility(PyObject *, PyObject *args) { int visible; if (!PyArg_ParseTuple(args,"i:enableVisibility",&visible)) @@ -895,7 +895,7 @@ static PyObject* gPyEnableVisibility(PyObject*, PyObject* args) -static PyObject* gPyShowMouse(PyObject*, PyObject* args) +static PyObject *gPyShowMouse(PyObject *, PyObject *args) { int visible; if (!PyArg_ParseTuple(args,"i:showMouse",&visible)) @@ -916,7 +916,7 @@ static PyObject* gPyShowMouse(PyObject*, PyObject* args) -static PyObject* gPySetMousePosition(PyObject*, PyObject* args) +static PyObject *gPySetMousePosition(PyObject *, PyObject *args) { int x,y; if (!PyArg_ParseTuple(args,"ii:setMousePosition",&x,&y)) @@ -928,7 +928,7 @@ static PyObject* gPySetMousePosition(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args) +static PyObject *gPySetEyeSeparation(PyObject *, PyObject *args) { float sep; if (!PyArg_ParseTuple(args, "f:setEyeSeparation", &sep)) @@ -944,7 +944,7 @@ static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyGetEyeSeparation(PyObject*) +static PyObject *gPyGetEyeSeparation(PyObject *) { if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getEyeSeparation(), Rasterizer not available"); @@ -954,7 +954,7 @@ static PyObject* gPyGetEyeSeparation(PyObject*) return PyFloat_FromDouble(gp_Rasterizer->GetEyeSeparation()); } -static PyObject* gPySetFocalLength(PyObject*, PyObject* args) +static PyObject *gPySetFocalLength(PyObject *, PyObject *args) { float focus; if (!PyArg_ParseTuple(args, "f:setFocalLength", &focus)) @@ -970,7 +970,7 @@ static PyObject* gPySetFocalLength(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*) +static PyObject *gPyGetFocalLength(PyObject *, PyObject *, PyObject *) { if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getFocalLength(), Rasterizer not available"); @@ -982,7 +982,7 @@ static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*) Py_RETURN_NONE; } -static PyObject* gPySetBackgroundColor(PyObject*, PyObject* value) +static PyObject *gPySetBackgroundColor(PyObject *, PyObject *value) { MT_Vector4 vec; @@ -1003,7 +1003,7 @@ static PyObject* gPySetBackgroundColor(PyObject*, PyObject* value) -static PyObject* gPySetMistColor(PyObject*, PyObject* value) +static PyObject *gPySetMistColor(PyObject *, PyObject *value) { MT_Vector3 vec; @@ -1013,25 +1013,25 @@ static PyObject* gPySetMistColor(PyObject*, PyObject* value) if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistColor(color), Rasterizer not available"); return NULL; - } + } gp_Rasterizer->SetFogColor((float)vec[0], (float)vec[1], (float)vec[2]); Py_RETURN_NONE; } -static PyObject* gPyDisableMist(PyObject*) +static PyObject *gPyDisableMist(PyObject *) { if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistColor(color), Rasterizer not available"); return NULL; - } + } gp_Rasterizer->DisableFog(); Py_RETURN_NONE; } -static PyObject* gPySetMistStart(PyObject*, PyObject* args) +static PyObject *gPySetMistStart(PyObject *, PyObject *args) { float miststart; @@ -1050,7 +1050,7 @@ static PyObject* gPySetMistStart(PyObject*, PyObject* args) -static PyObject* gPySetMistEnd(PyObject*, PyObject* args) +static PyObject *gPySetMistEnd(PyObject *, PyObject *args) { float mistend; @@ -1068,7 +1068,7 @@ static PyObject* gPySetMistEnd(PyObject*, PyObject* args) } -static PyObject* gPySetAmbientColor(PyObject*, PyObject* value) +static PyObject *gPySetAmbientColor(PyObject *, PyObject *value) { MT_Vector3 vec; @@ -1078,7 +1078,7 @@ static PyObject* gPySetAmbientColor(PyObject*, PyObject* value) if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setAmbientColor(color), Rasterizer not available"); return NULL; - } + } gp_Rasterizer->SetAmbientColor((float)vec[0], (float)vec[1], (float)vec[2]); Py_RETURN_NONE; @@ -1087,7 +1087,7 @@ static PyObject* gPySetAmbientColor(PyObject*, PyObject* value) -static PyObject* gPyMakeScreenshot(PyObject*, PyObject* args) +static PyObject *gPyMakeScreenshot(PyObject *, PyObject *args) { char* filename; if (!PyArg_ParseTuple(args,"s:makeScreenshot",&filename)) @@ -1101,7 +1101,7 @@ static PyObject* gPyMakeScreenshot(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args) +static PyObject *gPyEnableMotionBlur(PyObject *, PyObject *args) { float motionblurvalue; if (!PyArg_ParseTuple(args,"f:enableMotionBlur",&motionblurvalue)) @@ -1117,7 +1117,7 @@ static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyDisableMotionBlur(PyObject*) +static PyObject *gPyDisableMotionBlur(PyObject *) { if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.disableMotionBlur(), Rasterizer not available"); @@ -1147,9 +1147,9 @@ static int getGLSLSettingFlag(const char *setting) return -1; } -static PyObject* gPySetGLSLMaterialSetting(PyObject*, - PyObject* args, - PyObject*) +static PyObject *gPySetGLSLMaterialSetting(PyObject *, + PyObject *args, + PyObject *) { GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings(); char *setting; @@ -1190,9 +1190,9 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, Py_RETURN_NONE; } -static PyObject* gPyGetGLSLMaterialSetting(PyObject*, - PyObject* args, - PyObject*) +static PyObject *gPyGetGLSLMaterialSetting(PyObject *, + PyObject *args, + PyObject *) { GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings(); char *setting; @@ -1216,9 +1216,9 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*, #define KX_BLENDER_MULTITEX_MATERIAL 1 #define KX_BLENDER_GLSL_MATERIAL 2 -static PyObject* gPySetMaterialType(PyObject*, - PyObject* args, - PyObject*) +static PyObject *gPySetMaterialType(PyObject *, + PyObject *args, + PyObject *) { GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings(); int type; @@ -1240,7 +1240,7 @@ static PyObject* gPySetMaterialType(PyObject*, Py_RETURN_NONE; } -static PyObject* gPyGetMaterialType(PyObject*) +static PyObject *gPyGetMaterialType(PyObject *) { GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings(); int flag; @@ -1255,7 +1255,7 @@ static PyObject* gPyGetMaterialType(PyObject*) return PyLong_FromSsize_t(flag); } -static PyObject* gPySetAnisotropicFiltering(PyObject*, PyObject* args) +static PyObject *gPySetAnisotropicFiltering(PyObject *, PyObject *args) { short level; @@ -1272,16 +1272,16 @@ static PyObject* gPySetAnisotropicFiltering(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPyGetAnisotropicFiltering(PyObject*, PyObject* args) +static PyObject *gPyGetAnisotropicFiltering(PyObject *, PyObject *args) { return PyLong_FromLong(gp_Rasterizer->GetAnisotropicFiltering()); } -static PyObject* gPyDrawLine(PyObject*, PyObject* args) +static PyObject *gPyDrawLine(PyObject *, PyObject *args) { - PyObject* ob_from; - PyObject* ob_to; - PyObject* ob_color; + PyObject *ob_from; + PyObject *ob_to; + PyObject *ob_color; if (!gp_Rasterizer) { PyErr_SetString(PyExc_RuntimeError, "Rasterizer.drawLine(obFrom, obTo, color): Rasterizer not available"); @@ -1306,7 +1306,7 @@ static PyObject* gPyDrawLine(PyObject*, PyObject* args) Py_RETURN_NONE; } -static PyObject* gPySetWindowSize(PyObject*, PyObject* args) +static PyObject *gPySetWindowSize(PyObject *, PyObject *args) { int width, height; if (!PyArg_ParseTuple(args, "ii:resize", &width, &height)) @@ -1383,11 +1383,11 @@ static struct PyModuleDef GameLogic_module_def = { 0, /* m_free */ }; -PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack to get gravity hook +PyObject *initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack to get gravity hook { - PyObject* m; - PyObject* d; - PyObject* item; /* temp PyObject* storage */ + PyObject *m; + PyObject *d; + PyObject *item; /* temp PyObject *storage */ gp_KetsjiEngine = engine; gp_KetsjiScene = scene; @@ -1405,7 +1405,7 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack } else { PyErr_Clear(); - // Create the module and add the functions + // Create the module and add the functions m = PyModule_Create(&GameLogic_module_def); PyDict_SetItemString(PySys_GetObject("modules"), GameLogic_module_def.m_name, m); } @@ -1832,7 +1832,7 @@ static void restorePySysObjects(void) PyDict_Clear(sys_mods); PyDict_Update(sys_mods, gp_OrigPythonSysModules); Py_DECREF(gp_OrigPythonSysModules); - gp_OrigPythonSysModules= NULL; + gp_OrigPythonSysModules= NULL; // fprintf(stderr, "\nRestore Path: %d ", PyList_GET_SIZE(sys_path)); @@ -1862,7 +1862,7 @@ static struct _inittab bge_internal_modules[]= { * Python is not initialized. * see bpy_interface.c's BPY_python_start() which shares the same functionality in blender. */ -PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie, int argc, char** argv) +PyObject *initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie, int argc, char** argv) { /* Yet another gotcha in the py api * Cant run PySys_SetArgv more then once because this adds the @@ -1935,7 +1935,7 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur } void exitGamePlayerPythonScripting() -{ +{ /* Clean up the Python mouse and keyboard */ delete gp_PythonKeyboard; gp_PythonKeyboard = NULL; @@ -1956,7 +1956,7 @@ void exitGamePlayerPythonScripting() /** * Python is already initialized. */ -PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie) +PyObject *initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie) { #if 0 // XXX TODO Py3 STR_String pname = progname; @@ -1998,9 +1998,10 @@ void exitGamePythonScripting() /* similar to the above functions except it sets up the namespace * and other more general things */ -void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *blenderdata, PyObject * pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv) +void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene *startscene, Main *blenderdata, + PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv) { - PyObject* dictionaryobject; + PyObject *dictionaryobject; if (argv) /* player only */ dictionaryobject= initGamePlayerPythonScripting("Ketsji", psl_Lowest, blenderdata, argc, argv); @@ -2053,15 +2054,15 @@ static struct PyModuleDef Rasterizer_module_def = { 0, /* m_free */ }; -PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) +PyObject *initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) { gp_Canvas = canvas; gp_Rasterizer = rasty; - PyObject* m; - PyObject* d; - PyObject* item; + PyObject *m; + PyObject *d; + PyObject *item; /* Use existing module where possible * be careful not to init any runtime vars after this */ @@ -2114,9 +2115,9 @@ static char gPyEventToString_doc[] = "EventToString(event) - Take a valid event from the GameKeys module or Keyboard Sensor and return a name" ; -static PyObject* gPyEventToString(PyObject*, PyObject* value) +static PyObject *gPyEventToString(PyObject *, PyObject *value) { - PyObject* mod, *dict, *key, *val, *ret = NULL; + PyObject *mod, *dict, *key, *val, *ret = NULL; Py_ssize_t pos = 0; mod = PyImport_ImportModule( "GameKeys" ); @@ -2144,7 +2145,7 @@ static char gPyEventToCharacter_doc[] = "EventToCharacter(event, is_shift) - Take a valid event from the GameKeys module or Keyboard Sensor and return a character" ; -static PyObject* gPyEventToCharacter(PyObject*, PyObject* args) +static PyObject *gPyEventToCharacter(PyObject *, PyObject *args) { int event, shift; if (!PyArg_ParseTuple(args,"ii:EventToCharacter", &event, &shift)) @@ -2179,11 +2180,11 @@ static struct PyModuleDef GameKeys_module_def = { 0, /* m_free */ }; -PyObject* initGameKeys() +PyObject *initGameKeys() { - PyObject* m; - PyObject* d; - PyObject* item; + PyObject *m; + PyObject *d; + PyObject *item; /* Use existing module where possible */ m = PyImport_ImportModule( "GameKeys" ); @@ -2231,24 +2232,24 @@ PyObject* initGameKeys() KX_MACRO_addTypesToDict(d, YKEY, SCA_IInputDevice::KX_YKEY); KX_MACRO_addTypesToDict(d, ZKEY, SCA_IInputDevice::KX_ZKEY); - KX_MACRO_addTypesToDict(d, ZEROKEY, SCA_IInputDevice::KX_ZEROKEY); - KX_MACRO_addTypesToDict(d, ONEKEY, SCA_IInputDevice::KX_ONEKEY); - KX_MACRO_addTypesToDict(d, TWOKEY, SCA_IInputDevice::KX_TWOKEY); + KX_MACRO_addTypesToDict(d, ZEROKEY, SCA_IInputDevice::KX_ZEROKEY); + KX_MACRO_addTypesToDict(d, ONEKEY, SCA_IInputDevice::KX_ONEKEY); + KX_MACRO_addTypesToDict(d, TWOKEY, SCA_IInputDevice::KX_TWOKEY); KX_MACRO_addTypesToDict(d, THREEKEY, SCA_IInputDevice::KX_THREEKEY); - KX_MACRO_addTypesToDict(d, FOURKEY, SCA_IInputDevice::KX_FOURKEY); - KX_MACRO_addTypesToDict(d, FIVEKEY, SCA_IInputDevice::KX_FIVEKEY); - KX_MACRO_addTypesToDict(d, SIXKEY, SCA_IInputDevice::KX_SIXKEY); + KX_MACRO_addTypesToDict(d, FOURKEY, SCA_IInputDevice::KX_FOURKEY); + KX_MACRO_addTypesToDict(d, FIVEKEY, SCA_IInputDevice::KX_FIVEKEY); + KX_MACRO_addTypesToDict(d, SIXKEY, SCA_IInputDevice::KX_SIXKEY); KX_MACRO_addTypesToDict(d, SEVENKEY, SCA_IInputDevice::KX_SEVENKEY); KX_MACRO_addTypesToDict(d, EIGHTKEY, SCA_IInputDevice::KX_EIGHTKEY); - KX_MACRO_addTypesToDict(d, NINEKEY, SCA_IInputDevice::KX_NINEKEY); + KX_MACRO_addTypesToDict(d, NINEKEY, SCA_IInputDevice::KX_NINEKEY); KX_MACRO_addTypesToDict(d, CAPSLOCKKEY, SCA_IInputDevice::KX_CAPSLOCKKEY); - KX_MACRO_addTypesToDict(d, LEFTCTRLKEY, SCA_IInputDevice::KX_LEFTCTRLKEY); + 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, RIGHTSHIFTKEY, SCA_IInputDevice::KX_RIGHTSHIFTKEY); + KX_MACRO_addTypesToDict(d, RIGHTSHIFTKEY, SCA_IInputDevice::KX_RIGHTSHIFTKEY); KX_MACRO_addTypesToDict(d, LEFTSHIFTKEY, SCA_IInputDevice::KX_LEFTSHIFTKEY); KX_MACRO_addTypesToDict(d, ESCKEY, SCA_IInputDevice::KX_ESCKEY); @@ -2256,25 +2257,25 @@ PyObject* initGameKeys() KX_MACRO_addTypesToDict(d, RETKEY, SCA_IInputDevice::KX_RETKEY); KX_MACRO_addTypesToDict(d, ENTERKEY, SCA_IInputDevice::KX_RETKEY); KX_MACRO_addTypesToDict(d, SPACEKEY, SCA_IInputDevice::KX_SPACEKEY); - KX_MACRO_addTypesToDict(d, LINEFEEDKEY, SCA_IInputDevice::KX_LINEFEEDKEY); + KX_MACRO_addTypesToDict(d, LINEFEEDKEY, SCA_IInputDevice::KX_LINEFEEDKEY); KX_MACRO_addTypesToDict(d, BACKSPACEKEY, SCA_IInputDevice::KX_BACKSPACEKEY); KX_MACRO_addTypesToDict(d, DELKEY, SCA_IInputDevice::KX_DELKEY); KX_MACRO_addTypesToDict(d, SEMICOLONKEY, SCA_IInputDevice::KX_SEMICOLONKEY); - KX_MACRO_addTypesToDict(d, PERIODKEY, SCA_IInputDevice::KX_PERIODKEY); - KX_MACRO_addTypesToDict(d, COMMAKEY, SCA_IInputDevice::KX_COMMAKEY); - KX_MACRO_addTypesToDict(d, QUOTEKEY, SCA_IInputDevice::KX_QUOTEKEY); - KX_MACRO_addTypesToDict(d, ACCENTGRAVEKEY, SCA_IInputDevice::KX_ACCENTGRAVEKEY); - KX_MACRO_addTypesToDict(d, MINUSKEY, SCA_IInputDevice::KX_MINUSKEY); - KX_MACRO_addTypesToDict(d, SLASHKEY, SCA_IInputDevice::KX_SLASHKEY); + KX_MACRO_addTypesToDict(d, PERIODKEY, SCA_IInputDevice::KX_PERIODKEY); + KX_MACRO_addTypesToDict(d, COMMAKEY, SCA_IInputDevice::KX_COMMAKEY); + KX_MACRO_addTypesToDict(d, QUOTEKEY, SCA_IInputDevice::KX_QUOTEKEY); + KX_MACRO_addTypesToDict(d, ACCENTGRAVEKEY, SCA_IInputDevice::KX_ACCENTGRAVEKEY); + KX_MACRO_addTypesToDict(d, MINUSKEY, SCA_IInputDevice::KX_MINUSKEY); + KX_MACRO_addTypesToDict(d, SLASHKEY, SCA_IInputDevice::KX_SLASHKEY); KX_MACRO_addTypesToDict(d, BACKSLASHKEY, SCA_IInputDevice::KX_BACKSLASHKEY); - KX_MACRO_addTypesToDict(d, EQUALKEY, SCA_IInputDevice::KX_EQUALKEY); - KX_MACRO_addTypesToDict(d, LEFTBRACKETKEY, SCA_IInputDevice::KX_LEFTBRACKETKEY); - KX_MACRO_addTypesToDict(d, RIGHTBRACKETKEY, SCA_IInputDevice::KX_RIGHTBRACKETKEY); + KX_MACRO_addTypesToDict(d, EQUALKEY, SCA_IInputDevice::KX_EQUALKEY); + KX_MACRO_addTypesToDict(d, LEFTBRACKETKEY, SCA_IInputDevice::KX_LEFTBRACKETKEY); + KX_MACRO_addTypesToDict(d, RIGHTBRACKETKEY, SCA_IInputDevice::KX_RIGHTBRACKETKEY); KX_MACRO_addTypesToDict(d, LEFTARROWKEY, SCA_IInputDevice::KX_LEFTARROWKEY); KX_MACRO_addTypesToDict(d, DOWNARROWKEY, SCA_IInputDevice::KX_DOWNARROWKEY); - KX_MACRO_addTypesToDict(d, RIGHTARROWKEY, SCA_IInputDevice::KX_RIGHTARROWKEY); - KX_MACRO_addTypesToDict(d, UPARROWKEY, SCA_IInputDevice::KX_UPARROWKEY); + KX_MACRO_addTypesToDict(d, RIGHTARROWKEY, SCA_IInputDevice::KX_RIGHTARROWKEY); + KX_MACRO_addTypesToDict(d, UPARROWKEY, SCA_IInputDevice::KX_UPARROWKEY); KX_MACRO_addTypesToDict(d, PAD2 , SCA_IInputDevice::KX_PAD2); KX_MACRO_addTypesToDict(d, PAD4 , SCA_IInputDevice::KX_PAD4); @@ -2347,14 +2348,14 @@ PyObject* initGameKeys() int saveGamePythonConfig( char **marshal_buffer) { int marshal_length = 0; - PyObject* gameLogic = PyImport_ImportModule("GameLogic"); + PyObject *gameLogic = PyImport_ImportModule("GameLogic"); if (gameLogic) { - PyObject* pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module + PyObject *pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module if (pyGlobalDict) { -#ifdef Py_MARSHAL_VERSION - PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5 +#ifdef Py_MARSHAL_VERSION + PyObject *pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5 #else - PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict ); + PyObject *pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict ); #endif if (pyGlobalDictMarshal) { // for testing only @@ -2384,12 +2385,12 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) { /* Restore the dict */ if (marshal_buffer) { - PyObject* gameLogic = PyImport_ImportModule("GameLogic"); + PyObject *gameLogic = PyImport_ImportModule("GameLogic"); if (gameLogic) { - PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length); + PyObject *pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length); if (pyGlobalDict) { - PyObject* pyGlobalDict_orig = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module. + PyObject *pyGlobalDict_orig = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module. if (pyGlobalDict_orig) { PyDict_Clear(pyGlobalDict_orig); PyDict_Update(pyGlobalDict_orig, pyGlobalDict); @@ -2405,10 +2406,11 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) PyErr_Clear(); printf("Error could not marshall string\n"); } - } else { + } + else { PyErr_Clear(); printf("Error, bge.logic failed to import bge.logic.globalDict will be lost\n"); - } + } } return 0; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 1500dd97ae1..69517b2b1e9 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -52,7 +52,8 @@ void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie); void exitGamePythonScripting(); -void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *blenderdata, PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv); +void setupGamePython(KX_KetsjiEngine *ketsjiengine, KX_Scene *startscene, Main *blenderdata, + PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv); void setGamePythonPath(const char *path); void resetGamePythonPath(); @@ -72,11 +73,12 @@ class KX_Scene* KX_GetActiveScene(); class KX_KetsjiEngine* KX_GetActiveEngine(); typedef int (*PyNextFrameFunc)(void *); + struct PyNextFrameState { - //state: can be either a GPG_NextFrameState or a BL_KetsjiNextFrameState - void *state; - //func: can be either GPG_PyNextFrame or BL_KetsjiPyNextFrame - PyNextFrameFunc func; + /** can be either a GPG_NextFrameState or a BL_KetsjiNextFrameState */ + void *state; + /** can be either GPG_PyNextFrame or BL_KetsjiPyNextFrame */ + PyNextFrameFunc func; }; extern struct PyNextFrameState pynextframestate; @@ -84,7 +86,7 @@ extern struct PyNextFrameState pynextframestate; void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color); void KX_RasterizerDrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color, - const MT_Vector3& normal, int nsector); + const MT_Vector3& normal, int nsector); #endif //__KX_PYTHONINIT_H__ diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp index 3033c534e84..d0e3d26f61b 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -29,14 +29,10 @@ * \ingroup ketsji */ - - - -#ifndef _adr_py_init_types_h_ // only process once, -#define _adr_py_init_types_h_ // even if multiply included - #ifdef WITH_PYTHON +#include "KX_PythonInitTypes.h" + /* Only for Class::Parents */ #include "BL_BlenderShader.h" #include "BL_ShapeActionActuator.h" @@ -166,7 +162,7 @@ static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *a void initPyTypes(void) { - + /* * initPyObjectPlusType(BL_ActionActuator::Parents); * ..... @@ -266,5 +262,3 @@ void initPyTypes(void) } #endif // WITH_PYTHON - -#endif diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.h b/source/gameengine/Ketsji/KX_PythonInitTypes.h index a06fe46a0ea..d8ee4f75fdd 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.h +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.h @@ -29,11 +29,11 @@ * \ingroup ketsji */ -#ifndef _adr_py_init_types_h_ // only process once, -#define _adr_py_init_types_h_ // even if multiply included +#ifndef __KX_PYTHON_INIT_TYPES__ +#define __KX_PYTHON_INIT_TYPES__ #ifdef WITH_PYTHON void initPyTypes(void); #endif -#endif +#endif /* __KX_PYTHON_INIT_TYPES__ */ diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index 6eadc0cbef3..5ab3de15fb3 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -69,7 +69,7 @@ static void KX_PythonSeq_dealloc(KX_PythonSeq * self) PyObject_GC_Del(self); } -static Py_ssize_t KX_PythonSeq_len( PyObject * self ) +static Py_ssize_t KX_PythonSeq_len( PyObject *self ) { PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); @@ -100,7 +100,7 @@ static Py_ssize_t KX_PythonSeq_len( PyObject * self ) } } -static PyObject *KX_PythonSeq_getIndex(PyObject* self, int index) +static PyObject *KX_PythonSeq_getIndex(PyObject *self, int index) { PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); @@ -264,7 +264,7 @@ static PyObjectPlus * KX_PythonSeq_subscript__internal(PyObject *self, const cha } -static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key) +static PyObject * KX_PythonSeq_subscript(PyObject *self, PyObject *key) { PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); @@ -314,10 +314,10 @@ static int KX_PythonSeq_contains(PyObject *self, PyObject *key) } /* Matches python dict.get(key, [default]) */ -PyObject* KX_PythonSeq_get(PyObject * self, PyObject *args) +static PyObject *KX_PythonSeq_get(PyObject *self, PyObject *args) { char *key; - PyObject* def = Py_None; + PyObject *def = Py_None; PyObjectPlus* ret_plus; if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) @@ -396,7 +396,7 @@ static PyObject *KX_PythonSeq_nextIter(KX_PythonSeq *self) static int KX_PythonSeq_compare( KX_PythonSeq * a, KX_PythonSeq * b ) { - return ( a->type == b->type && a->base == b->base) ? 0 : -1; + return ( a->type == b->type && a->base == b->base) ? 0 : -1; } static PyObject *KX_PythonSeq_richcmp(PyObject *a, PyObject *b, int op) diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 74009f51078..fb949fffa8a 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -217,7 +217,7 @@ PyAttributeDef KX_RadarSensor::Attributes[] = { {NULL} //Sentinel }; -PyObject* KX_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_RadarSensor* self= static_cast<KX_RadarSensor*>(self_v); diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 58ca847b617..14786e8429e 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -361,7 +361,7 @@ PyAttributeDef KX_RaySensor::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_RaySensor::pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_RaySensor::pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_RaySensor* self = static_cast<KX_RaySensor*>(self_v); if (self->m_hitObject) diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index f5d1c72d098..27aaa442dcd 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -94,7 +94,7 @@ public: #ifdef WITH_PYTHON /* Attributes */ - static PyObject* pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 841feda5237..d850168afdf 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -203,10 +203,10 @@ PyAttributeDef KX_SCA_AddObjectActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_SCA_AddObjectActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SCA_AddObjectActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self); - if (!actuator->m_OriginalObject) + if (!actuator->m_OriginalObject) Py_RETURN_NONE; else return actuator->m_OriginalObject->GetProxy(); @@ -221,7 +221,7 @@ int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYAT return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (actuator->m_OriginalObject != NULL) - actuator->m_OriginalObject->UnregisterActuator(actuator); + actuator->m_OriginalObject->UnregisterActuator(actuator); actuator->m_OriginalObject = (SCA_IObject*)gameobj; @@ -231,7 +231,7 @@ int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYAT return PY_SET_ATTR_SUCCESS; } -PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self); if (!actuator->m_lastCreatedObject) @@ -240,7 +240,7 @@ PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, con return actuator->m_lastCreatedObject->GetProxy(); } -PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject() +PyObject *KX_SCA_AddObjectActuator::PyInstantAddObject() { InstantAddObject(); @@ -253,7 +253,7 @@ void KX_SCA_AddObjectActuator::InstantAddObject() { if (m_OriginalObject) { - // Add an identical object, with properties inherited from the original object + // Add an identical object, with properties inherited from the original object // Now it needs to be added to the current scene. SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp ); KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index f49f2473036..9c8cbfa3d09 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -112,7 +112,7 @@ public: virtual bool Update(); - SCA_IObject* + SCA_IObject * GetLastCreatedObject( ) const; @@ -122,9 +122,9 @@ public: KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,InstantAddObject); - static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static PyObject* pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index f408b2cd7c9..5dc67a4cff3 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -119,14 +119,14 @@ bool KX_SCA_DynamicActuator::Update() switch (m_dyn_operation) { - case 0: - obj->RestoreDynamics(); + case 0: + obj->RestoreDynamics(); break; case 1: obj->SuspendDynamics(); break; case 2: - controller->setRigidBody(true); + controller->setRigidBody(true); break; case 3: controller->setRigidBody(false); diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index ffe5556cfe6..b105256836b 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -87,7 +87,7 @@ PyAttributeDef KX_SCA_ReplaceMeshActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_SCA_ReplaceMeshActuator::pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SCA_ReplaceMeshActuator::pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self); if (!actuator->m_mesh) diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index 6db16a0e1b6..52a20142442 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -84,7 +84,7 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator m_scene= val; }; - static PyObject* pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,instantReplaceMesh); diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp index 13200696ffb..19b9d13087d 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp @@ -51,14 +51,14 @@ KX_BoneParentRelation:: New(Bone* bone ) { return new KX_BoneParentRelation(bone); -} +} bool KX_BoneParentRelation:: UpdateChildCoordinates( SG_Spatial * child, const SG_Spatial * parent, - bool& parentUpdated + bool& parentUpdated ) { MT_assert(child != NULL); @@ -71,7 +71,7 @@ UpdateChildCoordinates( // we don't know if the armature has been updated or not, assume yes parentUpdated = true; - // the childs world locations which we will update. + // the childs world locations which we will update. MT_Vector3 child_w_scale; MT_Point3 child_w_pos; diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h index 76fefdebe08..6f4fd482198 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h @@ -57,7 +57,7 @@ public : static KX_BoneParentRelation * New(Bone* bone - ); + ); /** * Updates the childs world coordinates relative to the parent's diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp index 699b267496d..e80de76861e 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp @@ -45,14 +45,14 @@ KX_NormalParentRelation:: New( ) { return new KX_NormalParentRelation(); -} +} bool KX_NormalParentRelation:: UpdateChildCoordinates( SG_Spatial * child, const SG_Spatial * parent, - bool& parentUpdated + bool& parentUpdated ) { MT_assert(child != NULL); @@ -67,7 +67,7 @@ UpdateChildCoordinates( return true; //false; } else { - // the childs world locations which we will update. + // the childs world locations which we will update. const MT_Vector3 & p_world_scale = parent->GetWorldScaling(); const MT_Point3 & p_world_pos = parent->GetWorldPosition(); const MT_Matrix3x3 & p_world_rotation = parent->GetWorldOrientation(); @@ -121,7 +121,7 @@ KX_VertexParentRelation:: UpdateChildCoordinates( SG_Spatial * child, const SG_Spatial * parent, - bool& parentUpdated + bool& parentUpdated ) { MT_assert(child != NULL); @@ -176,7 +176,7 @@ New( MT_Scalar relaxation ) { return new KX_SlowParentRelation(relaxation); -} +} /** * Method inherited from KX_ParentRelation @@ -187,7 +187,7 @@ KX_SlowParentRelation:: UpdateChildCoordinates( SG_Spatial * child, const SG_Spatial * parent, - bool& parentUpdated + bool& parentUpdated ) { MT_assert(child != NULL); @@ -198,7 +198,7 @@ UpdateChildCoordinates( const MT_Point3 & child_pos = child->GetLocalPosition(); const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation(); - // the childs world locations which we will update. + // the childs world locations which we will update. MT_Vector3 child_w_scale; MT_Point3 child_w_pos; @@ -230,7 +230,7 @@ UpdateChildCoordinates( child_w_scale = child->GetWorldScaling(); child_w_pos = child->GetWorldPosition(); - child_w_rotation = child->GetWorldOrientation(); + child_w_rotation = child->GetWorldOrientation(); // now 'interpolate' the normal coordinates with the last // world coordinates to get the new world coordinates. diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h index b5ab5302910..5d777f5028f 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h @@ -57,7 +57,7 @@ public : static KX_NormalParentRelation * New( - ); + ); /** * Method inherited from KX_ParentRelation @@ -67,7 +67,7 @@ public : UpdateChildCoordinates( SG_Spatial * child, const SG_Spatial * parent, - bool& parentUpdated + bool& parentUpdated ); /** @@ -106,7 +106,7 @@ public : static KX_VertexParentRelation * New( - ); + ); /** * Method inherited from KX_ParentRelation @@ -116,7 +116,7 @@ public : UpdateChildCoordinates( SG_Spatial * child, const SG_Spatial * parent, - bool& parentUpdated + bool& parentUpdated ); /** @@ -162,7 +162,7 @@ public : KX_SlowParentRelation * New( MT_Scalar relaxation - ); + ); /** * Method inherited from KX_ParentRelation @@ -172,7 +172,7 @@ public : UpdateChildCoordinates( SG_Spatial * child, const SG_Spatial * parent, - bool& parentUpdated + bool& parentUpdated ); /** diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index c1afed82b02..652ed2ab2dd 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -98,7 +98,7 @@ #include <stdio.h> -void* KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene) +static void *KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene) { KX_GameObject* replica = ((KX_Scene*)scene)->AddNodeReplicaObject(node,(KX_GameObject*)gameobj); @@ -108,7 +108,7 @@ void* KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene) return (void*)replica; } -void* KX_SceneDestructionFunc(SG_IObject* node,void* gameobj,void* scene) +static void *KX_SceneDestructionFunc(SG_IObject* node,void* gameobj,void* scene) { ((KX_Scene*)scene)->RemoveNodeDestructObject(node,(KX_GameObject*)gameobj); @@ -368,7 +368,7 @@ void KX_Scene::SetFramingType(RAS_FrameSettings & frame_settings) const RAS_FrameSettings& KX_Scene::GetFramingType() const { return m_frame_settings; -}; +}; @@ -441,7 +441,7 @@ void KX_Scene::EnableZBufferClearing(bool isclearingZbuffer) void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gameobj) { - KX_GameObject* orgobj = (KX_GameObject*)gameobj; + KX_GameObject* orgobj = (KX_GameObject*)gameobj; if (NewRemoveObject(orgobj) != 0) { // object is not yet deleted because a reference is hanging somewhere. @@ -1072,7 +1072,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u } if (use_gfx && mesh != NULL) - { + { gameobj->RemoveMeshes(); gameobj->AddMesh(mesh); @@ -1278,7 +1278,7 @@ void KX_Scene::AddCamera(KX_Camera* cam) KX_Camera* KX_Scene::GetActiveCamera() -{ +{ // NULL if not defined return m_active_camera; } @@ -1634,16 +1634,17 @@ void KX_Scene::UpdateObjectActivity(void) * Manhattan distance. */ MT_Point3 obpos = ob->NodeGetWorldPosition(); - if ( (fabs(camloc[0] - obpos[0]) > m_activity_box_radius) - || (fabs(camloc[1] - obpos[1]) > m_activity_box_radius) - || (fabs(camloc[2] - obpos[2]) > m_activity_box_radius) ) - { + if ((fabs(camloc[0] - obpos[0]) > m_activity_box_radius) || + (fabs(camloc[1] - obpos[1]) > m_activity_box_radius) || + (fabs(camloc[2] - obpos[2]) > m_activity_box_radius) ) + { ob->Suspend(); - } else { + } + else { ob->Resume(); } } - } + } } } @@ -1944,15 +1945,15 @@ void KX_Scene::Render2DFilters(RAS_ICanvas* canvas) #ifdef WITH_PYTHON -void KX_Scene::RunDrawingCallbacks(PyObject* cb_list) +void KX_Scene::RunDrawingCallbacks(PyObject *cb_list) { Py_ssize_t len; if (cb_list && (len=PyList_GET_SIZE(cb_list))) { - PyObject* args= PyTuple_New(0); // save python creating each call - PyObject* func; - PyObject* ret; + PyObject *args = PyTuple_New(0); // save python creating each call + PyObject *func; + PyObject *ret; // Iterate the list and run the callbacks for (Py_ssize_t pos=0; pos < len; pos++) @@ -2019,7 +2020,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) { KX_Scene* self= static_cast<KX_Scene*>BGE_PROXY_REF(self_v); const char *attr_str= _PyUnicode_AsString(item); - PyObject* pyconvert; + PyObject *pyconvert; if (self==NULL) { PyErr_SetString(PyExc_SystemError, "val = scene[key]: KX_Scene, "BGE_PROXY_ERROR_MSG); @@ -2122,31 +2123,31 @@ PySequenceMethods KX_Scene::Sequence = { (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; -PyObject* KX_Scene::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Scene::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_Scene::pyattr_get_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_Scene::pyattr_get_objects_inactive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_Scene::pyattr_get_lights(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Scene* self= static_cast<KX_Scene*>(self_v); return self->GetLightList()->GetProxy(); } -PyObject* KX_Scene::pyattr_get_cameras(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Scene::pyattr_get_cameras(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { /* With refcounts in this case... * the new CListValue is owned by python, so its possible python holds onto it longer then the BGE @@ -2167,7 +2168,7 @@ PyObject* KX_Scene::pyattr_get_cameras(void *self_v, const KX_PYATTRIBUTE_DEF *a return clist->NewProxy(true); } -PyObject* KX_Scene::pyattr_get_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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_Camera* cam= self->GetActiveCamera(); @@ -2190,7 +2191,7 @@ int KX_Scene::pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *a return PY_SET_ATTR_SUCCESS; } -PyObject* KX_Scene::pyattr_get_drawing_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Scene::pyattr_get_drawing_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Scene* self = static_cast<KX_Scene*>(self_v); @@ -2200,7 +2201,7 @@ PyObject* KX_Scene::pyattr_get_drawing_callback_pre(void *self_v, const KX_PYATT return self->m_draw_call_pre; } -PyObject* KX_Scene::pyattr_get_drawing_callback_post(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_Scene::pyattr_get_drawing_callback_post(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Scene* self = static_cast<KX_Scene*>(self_v); @@ -2354,8 +2355,8 @@ KX_PYMETHODDEF_DOC(KX_Scene, drawObstacleSimulation, KX_PYMETHODDEF_DOC(KX_Scene, get, "") { PyObject *key; - PyObject* def = Py_None; - PyObject* ret; + PyObject *def = Py_None; + PyObject *ret; if (!PyArg_ParseTuple(args, "O|O:get", &key, &def)) return NULL; diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index f8480753395..bb329da99de 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -237,7 +237,7 @@ protected: /** * The execution priority of replicated object actuators? - */ + */ int m_ueberExecutionPriority; /** @@ -295,7 +295,7 @@ protected: KX_ObstacleSimulation* m_obstacleSimulation; -public: +public: KX_Scene(class SCA_IInputDevice* keyboarddevice, class SCA_IInputDevice* mousedevice, class NG_NetworkDeviceInterface* ndi, @@ -303,7 +303,7 @@ public: struct Scene* scene, class RAS_ICanvas* canvas); - virtual + virtual ~KX_Scene(); RAS_BucketManager* GetBucketManager(); @@ -349,11 +349,11 @@ public: void LogicUpdateFrame(double curtime, bool frame); void UpdateAnimations(double curtime); - void + void LogicEndFrame( ); - CListValue* + CListValue* GetTempObjectList( ); @@ -361,23 +361,23 @@ public: GetObjectList( ); - CListValue* + CListValue* GetInactiveList( ); - CListValue* + CListValue* GetRootParentList( ); - CListValue* + CListValue* GetLightList( ); - SCA_LogicManager* + SCA_LogicManager * GetLogicManager( ); - SCA_TimeEventManager* + SCA_TimeEventManager * GetTimeEventManager( ); @@ -426,7 +426,7 @@ public: ); /** Find the currently active camera. */ - KX_Camera* + KX_Camera* GetActiveCamera( ); @@ -435,7 +435,7 @@ public: * camera is not present in the camera list, it will be added */ - void + void SetActiveCamera( class KX_Camera* ); @@ -453,7 +453,7 @@ public: * Activates new desired canvas width set at design time. * \param width The new desired width. */ - void + void SetCanvasDesignWidth( unsigned int width ); @@ -461,7 +461,7 @@ public: * Activates new desired canvas height set at design time. * \param width The new desired height. */ - void + void SetCanvasDesignHeight( unsigned int height ); @@ -469,7 +469,7 @@ public: * Returns the current desired canvas width set at design time. * \return The desired width. */ - unsigned int + unsigned int GetCanvasDesignWidth( void ) const; @@ -478,7 +478,7 @@ public: * Returns the current desired canvas height set at design time. * \return The desired height. */ - unsigned int + unsigned int GetCanvasDesignHeight( void ) const; @@ -617,7 +617,7 @@ public: static PyObject* pyattr_get_drawing_callback_post(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_drawing_callback_post(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - virtual PyObject* py_repr(void) { return PyUnicode_From_STR_String(GetName()); } + virtual PyObject *py_repr(void) { return PyUnicode_From_STR_String(GetName()); } /* getitem/setitem */ static PyMappingMethods Mapping; @@ -626,10 +626,10 @@ public: /** * Run the registered python drawing functions. */ - void RunDrawingCallbacks(PyObject* cb_list); + void RunDrawingCallbacks(PyObject *cb_list); - PyObject* GetPreDrawCB() { return m_draw_call_pre; } - PyObject* GetPostDrawCB() { return m_draw_call_post; } + PyObject *GetPreDrawCB() { return m_draw_call_pre; } + PyObject *GetPostDrawCB() { return m_draw_call_post; } #endif /** diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 781c1fdab87..83b57dee7c1 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -256,7 +256,7 @@ PyAttributeDef KX_SceneActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_SceneActuator::pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SceneActuator::pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self); if (!actuator->m_camera) @@ -279,7 +279,7 @@ int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_ if (camOb==NULL) { actuator->m_camera= NULL; } - else { + else { actuator->m_camera = camOb; actuator->m_camera->RegisterActuator(actuator); } diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index 8e157544e2e..0b633334cce 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -99,7 +99,7 @@ class KX_SceneActuator : public SCA_IActuator /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - static PyObject* pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index db91cea9074..c0191db640a 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -358,7 +358,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound, } /* Atribute setting and getting -------------------------------------------- */ -PyObject* KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); const char* prop = attrdef->m_name; @@ -392,11 +392,11 @@ PyObject* KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_P Py_RETURN_NONE; } - PyObject* result = PyFloat_FromDouble(result_value); + PyObject *result = PyFloat_FromDouble(result_value); return result; } -PyObject* KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); float position = 0.0; @@ -404,32 +404,32 @@ PyObject* KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_P if (!actuator->m_handle.isNull()) position = actuator->m_handle->getPosition(); - PyObject* result = PyFloat_FromDouble(position); + PyObject *result = PyFloat_FromDouble(position); return result; } -PyObject* KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); float gain = actuator->m_volume; - PyObject* result = PyFloat_FromDouble(gain); + PyObject *result = PyFloat_FromDouble(gain); return result; } -PyObject* KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); float pitch = actuator->m_pitch; - PyObject* result = PyFloat_FromDouble(pitch); + PyObject *result = PyFloat_FromDouble(pitch); return result; } -PyObject* KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); if (!actuator->m_sound.isNull()) @@ -542,7 +542,7 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D int KX_SoundActuator::pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - PyObject* sound = NULL; + PyObject *sound = NULL; KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); if (!PyArg_Parse(value, "O", &sound)) return PY_SET_ATTR_FAIL; diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index dbdb17d0da5..fcaf214dd90 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -115,12 +115,12 @@ public: static int pyattr_set_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static int pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static PyObject* pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.cpp b/source/gameengine/Ketsji/KX_SteeringActuator.cpp index 16b9285386a..2fa72c04a20 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.cpp +++ b/source/gameengine/Ketsji/KX_SteeringActuator.cpp @@ -253,7 +253,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) static const MT_Vector3 PATH_COLOR(1,0,0); m_navmesh->DrawPath(m_path, m_pathLen, PATH_COLOR); } - } + } } break; @@ -285,7 +285,7 @@ bool KX_SteeringActuator::Update(double curtime, bool frame) //temporary solution: set 2D steering velocity directly to obj //correct way is to apply physical force MT_Vector3 curvel = obj->GetLinearVelocity(); - newvel.z() = curvel.z(); + newvel.z() = curvel.z(); obj->setLinearVelocity(newvel, false); } else @@ -356,8 +356,8 @@ static bool getNavmeshNormal(dtStatNavMesh* navmesh, const MT_Vector3& pos, MT_V { static const float polyPickExt[3] = {2, 4, 2}; float spos[3]; - pos.getValue(spos); - flipAxes(spos); + pos.getValue(spos); + flipAxes(spos); dtStatPolyRef sPolyRef = navmesh->findNearestPoly(spos, polyPickExt); if (sPolyRef == 0) return false; @@ -382,7 +382,7 @@ static bool getNavmeshNormal(dtStatNavMesh* navmesh, const MT_Vector3& pos, MT_V { distMin = dist; idxMin = i; - } + } } if (idxMin>=0) @@ -416,7 +416,7 @@ void KX_SteeringActuator::HandleActorFace(MT_Vector3& velocity) KX_GameObject* curobj = (KX_GameObject*) GetParent(); MT_Vector3 dir = m_facingMode==0 ? curobj->NodeGetLocalOrientation().getColumn(1) : velocity; if (dir.fuzzyZero()) - return; + return; dir.normalize(); MT_Vector3 up(0,0,1); MT_Vector3 left; @@ -431,7 +431,7 @@ void KX_SteeringActuator::HandleActorFace(MT_Vector3& velocity) { left = (dir.cross(up)).safe_normalized(); - dir = (-left.cross(normal)).safe_normalized(); + dir = (-left.cross(normal)).safe_normalized(); up = normal; } } @@ -495,7 +495,7 @@ void KX_SteeringActuator::HandleActorFace(MT_Vector3& velocity) MT_Point3 localpos; localpos = curobj->GetSGNode()->GetLocalPosition(); MT_Matrix3x3 parentmatinv; - parentmatinv = parentObject->NodeGetWorldOrientation ().inverse (); + parentmatinv = parentObject->NodeGetWorldOrientation ().inverse (); mat = parentmatinv * mat; mat = m_parentlocalmat * mat; curobj->NodeSetLocalOrientation(mat); @@ -551,16 +551,16 @@ PyAttributeDef KX_SteeringActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("turnspeed", 0.0f, 720.0f, KX_SteeringActuator, m_turnspeed), KX_PYATTRIBUTE_BOOL_RW("selfterminated", KX_SteeringActuator, m_isSelfTerminated), KX_PYATTRIBUTE_BOOL_RW("enableVisualization", KX_SteeringActuator, m_enableVisualization), - KX_PYATTRIBUTE_RO_FUNCTION("steeringVec", KX_SteeringActuator, pyattr_get_steeringVec), + KX_PYATTRIBUTE_RO_FUNCTION("steeringVec", KX_SteeringActuator, pyattr_get_steeringVec), KX_PYATTRIBUTE_SHORT_RW("facingMode", 0, 6, true, KX_SteeringActuator, m_facingMode), KX_PYATTRIBUTE_INT_RW("pathUpdatePeriod", -1, 100000, true, KX_SteeringActuator, m_pathUpdatePeriod), { NULL } //Sentinel }; -PyObject* KX_SteeringActuator::pyattr_get_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SteeringActuator::pyattr_get_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self); - if (!actuator->m_target) + if (!actuator->m_target) Py_RETURN_NONE; else return actuator->m_target->GetProxy(); @@ -575,7 +575,7 @@ int KX_SteeringActuator::pyattr_set_target(void *self, const struct KX_PYATTRIBU return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (actuator->m_target != NULL) - actuator->m_target->UnregisterActuator(actuator); + actuator->m_target->UnregisterActuator(actuator); actuator->m_target = (KX_GameObject*) gameobj; @@ -585,10 +585,10 @@ int KX_SteeringActuator::pyattr_set_target(void *self, const struct KX_PYATTRIBU return PY_SET_ATTR_SUCCESS; } -PyObject* KX_SteeringActuator::pyattr_get_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SteeringActuator::pyattr_get_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self); - if (!actuator->m_navmesh) + if (!actuator->m_navmesh) Py_RETURN_NONE; else return actuator->m_navmesh->GetProxy(); @@ -609,7 +609,7 @@ int KX_SteeringActuator::pyattr_set_navmesh(void *self, const struct KX_PYATTRIB } if (actuator->m_navmesh != NULL) - actuator->m_navmesh->UnregisterActuator(actuator); + actuator->m_navmesh->UnregisterActuator(actuator); actuator->m_navmesh = static_cast<KX_NavMeshObject*>(gameobj); @@ -619,7 +619,7 @@ int KX_SteeringActuator::pyattr_set_navmesh(void *self, const struct KX_PYATTRIB return PY_SET_ATTR_SUCCESS; } -PyObject* KX_SteeringActuator::pyattr_get_steeringVec(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_SteeringActuator::pyattr_get_steeringVec(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self); const MT_Vector3& steeringVec = actuator->GetSteeringVec(); diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.h b/source/gameengine/Ketsji/KX_SteeringActuator.h index c22a636cd95..341421d8948 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.h +++ b/source/gameengine/Ketsji/KX_SteeringActuator.h @@ -82,7 +82,7 @@ public: KX_GameObject *navmesh, float distance, float velocity, - float acceleration, + float acceleration, float turnspeed, bool isSelfTerminated, int pathUpdatePeriod, @@ -107,11 +107,11 @@ public: /* --------------------------------------------------------------------- */ /* These are used to get and set m_target */ - static PyObject* pyattr_get_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static PyObject* pyattr_get_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static PyObject* pyattr_get_steeringVec(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static PyObject *pyattr_get_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static PyObject *pyattr_get_steeringVec(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index d7bcf1306a1..885ac70061e 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -331,7 +331,7 @@ PyAttributeDef KX_TouchSensor::Attributes[] = { /* Python API */ -PyObject* KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_TouchSensor* self= static_cast<KX_TouchSensor*>(self_v); @@ -341,7 +341,7 @@ PyObject* KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBU Py_RETURN_NONE; } -PyObject* KX_TouchSensor::pyattr_get_object_hit_list(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +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); return self->m_colliders->GetProxy(); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index d739144d70d..c80b8598e43 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -56,7 +56,7 @@ protected: /** * The sensor should only look for objects with this property. */ - STR_String m_touchedpropname; + STR_String m_touchedpropname; bool m_bFindMaterial; bool m_bTouchPulse; /* changes in the colliding objects trigger pulses */ diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 99732130f83..1597948bafe 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -90,7 +90,7 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj, /* old function from Blender */ -MT_Matrix3x3 EulToMat3(float *eul) +static MT_Matrix3x3 EulToMat3(float eul[3]) { MT_Matrix3x3 mat; float ci, cj, ch, si, sj, sh, cc, cs, sc, ss; @@ -122,7 +122,7 @@ MT_Matrix3x3 EulToMat3(float *eul) /* old function from Blender */ -void Mat3ToEulOld(MT_Matrix3x3 mat, float eul[3]) +static void Mat3ToEulOld(MT_Matrix3x3 mat, float eul[3]) { const float cy = sqrtf(mat[0][0] * mat[0][0] + mat[0][1] * mat[0][1]); @@ -141,7 +141,7 @@ void Mat3ToEulOld(MT_Matrix3x3 mat, float eul[3]) /* old function from Blender */ -void compatible_eulFast(float *eul, float *oldrot) +static void compatible_eulFast(float *eul, float *oldrot) { float dx, dy, dz; @@ -164,9 +164,9 @@ void compatible_eulFast(float *eul, float *oldrot) -MT_Matrix3x3 matrix3x3_interpol(MT_Matrix3x3 oldmat, MT_Matrix3x3 mat, int m_time) +static MT_Matrix3x3 matrix3x3_interpol(MT_Matrix3x3 oldmat, MT_Matrix3x3 mat, int m_time) { - float eul[3], oldeul[3]; + float eul[3], oldeul[3]; Mat3ToEulOld(oldmat, oldeul); Mat3ToEulOld(mat, eul); @@ -238,7 +238,7 @@ void KX_TrackToActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map) bool KX_TrackToActuator::Update(double curtime, bool frame) { - bool result = false; + bool result = false; bool bNegativeEvent = IsNegativeEvent(); RemoveAllEvents(); @@ -395,7 +395,7 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) localpos = curobj->GetSGNode()->GetLocalPosition(); // Get the inverse of the parent matrix MT_Matrix3x3 parentmatinv; - parentmatinv = m_parentobj->NodeGetWorldOrientation ().inverse (); + parentmatinv = m_parentobj->NodeGetWorldOrientation ().inverse (); // transform the local coordinate system into the parents system mat = parentmatinv * mat; // append the initial parent local rotation matrix @@ -458,10 +458,10 @@ PyAttributeDef KX_TrackToActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_TrackToActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_TrackToActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_TrackToActuator* actuator = static_cast<KX_TrackToActuator*>(self); - if (!actuator->m_object) + if (!actuator->m_object) Py_RETURN_NONE; else return actuator->m_object->GetProxy(); @@ -476,7 +476,7 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (actuator->m_object != NULL) - actuator->m_object->UnregisterActuator(actuator); + actuator->m_object->UnregisterActuator(actuator); actuator->m_object = (SCA_IObject*) gameobj; diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index fb2ced2a415..6329c7b34d9 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -74,8 +74,8 @@ class KX_TrackToActuator : public SCA_IActuator /* Python part */ /* These are used to get and set m_ob */ - static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index 1c03df80dc1..b5d6f11a2d5 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -34,11 +34,11 @@ KX_VehicleWrapper::~KX_VehicleWrapper() #ifdef WITH_PYTHON -PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* args) +PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args) { - PyObject* pylistPos,*pylistDir,*pylistAxleDir; - PyObject* wheelGameObject; + PyObject *pylistPos,*pylistDir,*pylistAxleDir; + PyObject *wheelGameObject; float suspensionRestLength,wheelRadius; int hasSteering; @@ -83,7 +83,7 @@ PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* args) -PyObject* KX_VehicleWrapper::PyGetWheelPosition(PyObject* args) +PyObject *KX_VehicleWrapper::PyGetWheelPosition(PyObject *args) { int wheelIndex; @@ -98,7 +98,7 @@ PyObject* KX_VehicleWrapper::PyGetWheelPosition(PyObject* args) return NULL; } -PyObject* KX_VehicleWrapper::PyGetWheelRotation(PyObject* args) +PyObject *KX_VehicleWrapper::PyGetWheelRotation(PyObject *args) { int wheelIndex; if (PyArg_ParseTuple(args,"i:getWheelRotation",&wheelIndex)) @@ -108,7 +108,7 @@ PyObject* KX_VehicleWrapper::PyGetWheelRotation(PyObject* args) return NULL; } -PyObject* KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject* args) +PyObject *KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject *args) { int wheelIndex; if (PyArg_ParseTuple(args,"i:getWheelOrientationQuaternion",&wheelIndex)) @@ -124,20 +124,20 @@ PyObject* KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject* args) } -PyObject* KX_VehicleWrapper::PyGetNumWheels(PyObject* args) +PyObject *KX_VehicleWrapper::PyGetNumWheels(PyObject *args) { return PyLong_FromSsize_t(m_vehicle->GetNumWheels()); } -PyObject* KX_VehicleWrapper::PyGetConstraintId(PyObject* args) +PyObject *KX_VehicleWrapper::PyGetConstraintId(PyObject *args) { return PyLong_FromSsize_t(m_vehicle->GetUserConstraintId()); } -PyObject* KX_VehicleWrapper::PyApplyEngineForce(PyObject* args) +PyObject *KX_VehicleWrapper::PyApplyEngineForce(PyObject *args) { float force; int wheelIndex; @@ -153,7 +153,7 @@ PyObject* KX_VehicleWrapper::PyApplyEngineForce(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* args) +PyObject *KX_VehicleWrapper::PySetTyreFriction(PyObject *args) { float wheelFriction; int wheelIndex; @@ -168,7 +168,7 @@ PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* args) +PyObject *KX_VehicleWrapper::PySetSuspensionStiffness(PyObject *args) { float suspensionStiffness; int wheelIndex; @@ -183,7 +183,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* args) +PyObject *KX_VehicleWrapper::PySetSuspensionDamping(PyObject *args) { float suspensionDamping; int wheelIndex; @@ -197,7 +197,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* args) +PyObject *KX_VehicleWrapper::PySetSuspensionCompression(PyObject *args) { float suspensionCompression; int wheelIndex; @@ -211,7 +211,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* args) Py_RETURN_NONE; } -PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* args) +PyObject *KX_VehicleWrapper::PySetRollInfluence(PyObject *args) { float rollInfluence; int wheelIndex; @@ -227,7 +227,7 @@ PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* args) } -PyObject* KX_VehicleWrapper::PyApplyBraking(PyObject* args) +PyObject *KX_VehicleWrapper::PyApplyBraking(PyObject *args) { float braking; int wheelIndex; @@ -245,7 +245,7 @@ PyObject* KX_VehicleWrapper::PyApplyBraking(PyObject* args) -PyObject* KX_VehicleWrapper::PySetSteeringValue(PyObject* args) +PyObject *KX_VehicleWrapper::PySetSteeringValue(PyObject *args) { float steeringValue; int wheelIndex; @@ -261,7 +261,7 @@ PyObject* KX_VehicleWrapper::PySetSteeringValue(PyObject* args) } -PyObject* KX_VehicleWrapper::PyGetConstraintType(PyObject* args) +PyObject *KX_VehicleWrapper::PyGetConstraintType(PyObject *args) { return PyLong_FromSsize_t(m_vehicle->GetUserConstraintType()); } diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index d489c015273..461563d4512 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -101,85 +101,85 @@ PyAttributeDef KX_VertexProxy::Attributes[] = { { NULL } //Sentinel }; -PyObject* KX_VertexProxy::pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_VertexProxy::pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { 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) +PyObject *KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); const unsigned char *colp = self->m_vertex->getRGBA(); @@ -188,7 +188,7 @@ PyObject* KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DE return PyObjectFrom(color); } -PyObject* KX_VertexProxy::pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_VertexProxy::pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); return PyObjectFrom(MT_Vector3(self->m_vertex->getNormal())); @@ -459,12 +459,12 @@ CValue* KX_VertexProxy::GetReplica() { return NULL;} // stuff for python integration -PyObject* KX_VertexProxy::PyGetXYZ() +PyObject *KX_VertexProxy::PyGetXYZ() { return PyObjectFrom(MT_Point3(m_vertex->getXYZ())); } -PyObject* KX_VertexProxy::PySetXYZ(PyObject* value) +PyObject *KX_VertexProxy::PySetXYZ(PyObject *value) { MT_Point3 vec; if (!PyVecTo(value, vec)) @@ -475,12 +475,12 @@ PyObject* KX_VertexProxy::PySetXYZ(PyObject* value) Py_RETURN_NONE; } -PyObject* KX_VertexProxy::PyGetNormal() +PyObject *KX_VertexProxy::PyGetNormal() { return PyObjectFrom(MT_Vector3(m_vertex->getNormal())); } -PyObject* KX_VertexProxy::PySetNormal(PyObject* value) +PyObject *KX_VertexProxy::PySetNormal(PyObject *value) { MT_Vector3 vec; if (!PyVecTo(value, vec)) @@ -492,13 +492,13 @@ PyObject* KX_VertexProxy::PySetNormal(PyObject* value) } -PyObject* KX_VertexProxy::PyGetRGBA() +PyObject *KX_VertexProxy::PyGetRGBA() { int *rgba = (int *) m_vertex->getRGBA(); return PyLong_FromSsize_t(*rgba); } -PyObject* KX_VertexProxy::PySetRGBA(PyObject* value) +PyObject *KX_VertexProxy::PySetRGBA(PyObject *value) { if (PyLong_Check(value)) { int rgba = PyLong_AsSsize_t(value); @@ -521,12 +521,12 @@ PyObject* KX_VertexProxy::PySetRGBA(PyObject* value) } -PyObject* KX_VertexProxy::PyGetUV() +PyObject *KX_VertexProxy::PyGetUV() { return PyObjectFrom(MT_Vector2(m_vertex->getUV1())); } -PyObject* KX_VertexProxy::PySetUV(PyObject* value) +PyObject *KX_VertexProxy::PySetUV(PyObject *value) { MT_Point2 vec; if (!PyVecTo(value, vec)) @@ -537,17 +537,17 @@ PyObject* KX_VertexProxy::PySetUV(PyObject* value) Py_RETURN_NONE; } -PyObject* KX_VertexProxy::PyGetUV2() +PyObject *KX_VertexProxy::PyGetUV2() { return PyObjectFrom(MT_Vector2(m_vertex->getUV2())); } -PyObject* KX_VertexProxy::PySetUV2(PyObject* args) +PyObject *KX_VertexProxy::PySetUV2(PyObject *args) { MT_Point2 vec; unsigned int unit= RAS_TexVert::SECOND_UV; - PyObject* list= NULL; + PyObject *list = NULL; if (!PyArg_ParseTuple(args, "O|i:setUV2", &list, &unit)) return NULL; diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h index 3084e5fac93..f56e2be26a3 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.h +++ b/source/gameengine/Ketsji/KX_VertexProxy.h @@ -59,21 +59,21 @@ public: // stuff for python integration - static PyObject* pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject *pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_x(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static int pyattr_set_y(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static int pyattr_set_z(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.h b/source/gameengine/Ketsji/KX_WorldIpoController.h index 409b1fec321..575d4e72f14 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.h +++ b/source/gameengine/Ketsji/KX_WorldIpoController.h @@ -72,15 +72,15 @@ public: m_modified = true; } - void SetModifyMistStart(bool modify) { + void SetModifyMistStart(bool modify) { m_modify_mist_start = modify; } - void SetModifyMistColor(bool modify) { + void SetModifyMistColor(bool modify) { m_modify_mist_color = modify; } - void SetModifyMistDist(bool modify) { + void SetModifyMistDist(bool modify) { m_modify_mist_dist = modify; } diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h index 92ba6100359..f9d2146a766 100644 --- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h +++ b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h @@ -36,7 +36,7 @@ #include "NG_NetworkDeviceInterface.h" class NG_LoopBackNetworkDeviceInterface : public NG_NetworkDeviceInterface -{ +{ std::deque<NG_NetworkMessage*> m_messages[2]; int m_currentQueue; diff --git a/source/gameengine/Network/NG_NetworkScene.h b/source/gameengine/Network/NG_NetworkScene.h index 41ac8ead5e4..381b71da0d7 100644 --- a/source/gameengine/Network/NG_NetworkScene.h +++ b/source/gameengine/Network/NG_NetworkScene.h @@ -51,7 +51,7 @@ class NG_NetworkDeviceInterface; class NG_NetworkScene { - class NG_NetworkDeviceInterface *m_networkdevice; + class NG_NetworkDeviceInterface *m_networkdevice; CTR_Map<STR_HashedString, class NG_NetworkObject *> m_networkObjects; // CTR_Maps used as a 'Bloom' filter @@ -107,7 +107,7 @@ protected: * Releases messages for the given message map. * \param map Message map with messages. */ - void ClearMessageMap(TMessageMap& map); + void ClearMessageMap(TMessageMap& map); #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h index 60ff475832b..15edfeb5759 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.h +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h @@ -33,7 +33,7 @@ class CcdPhysicsEnvironment; class btCollisionObject; ///CcdGraphicController is a graphic object that supports view frustrum culling and occlusion -class CcdGraphicController : public PHY_IGraphicController +class CcdGraphicController : public PHY_IGraphicController { public: CcdGraphicController(CcdPhysicsEnvironment* phyEnv, PHY_IMotionState* motionState); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index ed2b9cfcb0b..81bf66d9536 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -787,7 +787,7 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta if (oldbody->getActivationState() == DISABLE_DEACTIVATION) body->setActivationState(DISABLE_DEACTIVATION); } - } + } // sensor object are added when needed if (!m_cci.m_bSensor) m_cci.m_physicsEnv->addCcdPhysicsController(this); @@ -806,7 +806,7 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta m_sumoObj = new SM_Object( orgsumoobject->getShapeHandle(), - orgsumoobject->getMaterialProps(), + orgsumoobject->getMaterialProps(), orgsumoobject->getShapeProps(), dynaparent); @@ -1142,7 +1142,7 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo btTransform xform = m_object->getWorldTransform(); if (local) - { + { force = xform.getBasis()*force; } btRigidBody* body = GetRigidBody(); @@ -1661,7 +1661,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, } if (vert_tag_array[mf->v3]==true) { /* *** v3 *** */ vert_tag_array[mf->v3]= false; - *bt++ = v3->co[0]; + *bt++ = v3->co[0]; *bt++ = v3->co[1]; *bt++ = v3->co[2]; } @@ -1693,7 +1693,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, 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[1]; *bt++ = v4->co[2]; } } @@ -2089,7 +2089,7 @@ bool CcdShapeConstructionInfo::SetProxy(CcdShapeConstructionInfo* shapeInfo) btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, bool useGimpact, bool useBvh) { btCollisionShape* collisionShape = 0; - btCompoundShape* compoundShape = 0; + btCompoundShape* compoundShape = 0; if (m_shapeType == PHY_SHAPE_PROXY && m_shapeProxy != NULL) return m_shapeProxy->CreateBulletShape(margin, useGimpact, useBvh); @@ -2138,7 +2138,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, b // One possible optimization is to use directly the btBvhTriangleMeshShape when the scale is 1,1,1 // and btScaledBvhTriangleMeshShape otherwise. if (useGimpact) - { + { btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray( m_polygonIndexArray.size(), &m_triFaceArray[0], diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 94dc796df23..2204f224e7d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -171,7 +171,7 @@ public: btVector3 m_halfExtend; btTransform m_childTrans; btVector3 m_childScale; - void* m_userData; + void* m_userData; btAlignedObjectArray<btScalar> m_vertexArray; // Contains both vertex array for polytope shape and // triangle array for concave mesh shape. Each vertex is 3 consecutive values // In this case a triangle is made of 3 consecutive points @@ -397,7 +397,7 @@ class btCollisionObject; class btSoftBody; ///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution. -class CcdPhysicsController : public PHY_IPhysicsController +class CcdPhysicsController : public PHY_IPhysicsController { protected: btCollisionObject* m_object; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 5d28bf47401..55bbc0d33b9 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -303,13 +303,13 @@ static void DrawAabb(btIDebugDraw* debugDrawer,const btVector3& from,const btVec { for (j=0;j<3;j++) { - pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], + pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], edgecoord[2]*halfExtents[2]); pa+=center; int othercoord = j%3; edgecoord[othercoord]*=-1.f; - pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], + pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], edgecoord[2]*halfExtents[2]); pb+=center; @@ -484,9 +484,8 @@ void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctr body->getCollisionShape()->calculateLocalInertia(newMass, inertia); body->setMassProps(newMass, inertia); m_dynamicsWorld->addRigidBody(body, newCollisionGroup, newCollisionMask); - } - else - { + } + else { m_dynamicsWorld->addCollisionObject(obj, newCollisionGroup, newCollisionMask); } } @@ -605,7 +604,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float float subStep = timeStep / float(m_numTimeSubSteps); i = m_dynamicsWorld->stepSimulation(interval,25,subStep);//perform always a full simulation step -//uncomment next line to see where Bullet spend its time (printf in console) +//uncomment next line to see where Bullet spend its time (printf in console) //CProfileManager::dumpAll(); processFhSprings(curTime,i*subStep); @@ -1084,7 +1083,7 @@ static bool GetHitTriangle(btCollisionShape* shape, CcdShapeConstructionInfo* sh btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride); - triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); + triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); } meshInterface->unLockReadOnlyVertexBase(0); return true; @@ -1248,7 +1247,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac result.m_hitNormal[1] = rayCallback.m_hitNormalWorld.getY(); result.m_hitNormal[2] = rayCallback.m_hitNormalWorld.getZ(); filterCallback.reportHit(&result); - } + } return result.m_controller; @@ -1391,7 +1390,7 @@ struct OcclusionBuffer static bool project(btVector4* p,int n) { for (int i=0;i<n;++i) - { + { p[i][2]=1/p[i][3]; p[i][0]*=p[i][2]; p[i][1]*=p[i][2]; @@ -1611,7 +1610,7 @@ struct OcclusionBuffer 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); + 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]}; @@ -1674,7 +1673,7 @@ struct OcclusionBuffer const float* c, const float* d, const float face) - { + { btVector4 p[4]; transformM(a,p[0]); transformM(b,p[1]); @@ -1744,7 +1743,7 @@ struct DbvtCullingCallback : btDbvt::ICollide Process(node); } void Process(const btDbvtNode* leaf) - { + { btBroadphaseProxy* proxy=(btBroadphaseProxy*)leaf->data; // the client object is a graphic controller CcdGraphicController* ctrl = static_cast<CcdGraphicController*>(proxy->m_clientObject); @@ -1817,11 +1816,11 @@ bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* user dispatcher.m_ocb = &gOcb; // occlusion culling, the direction of the view is taken from the first plan which MUST be the near plane btDbvt::collideOCL(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); - btDbvt::collideOCL(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); + btDbvt::collideOCL(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); } else { btDbvt::collideKDOP(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,nplanes,dispatcher); - btDbvt::collideKDOP(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,nplanes,dispatcher); + btDbvt::collideKDOP(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,nplanes,dispatcher); } return true; } diff --git a/source/gameengine/Physics/common/PHY_DynamicTypes.h b/source/gameengine/Physics/common/PHY_DynamicTypes.h index 69bbc7745e0..6994706ce2d 100644 --- a/source/gameengine/Physics/common/PHY_DynamicTypes.h +++ b/source/gameengine/Physics/common/PHY_DynamicTypes.h @@ -32,11 +32,11 @@ struct PHY__Vector2 operator const float* () const { return &m_vec[0]; - } + } operator float* () { return &m_vec[0]; - } + } }; struct PHY__Vector3 @@ -46,11 +46,11 @@ struct PHY__Vector3 operator const float* () const { return &m_vec[0]; - } + } operator float* () { return &m_vec[0]; - } + } }; struct PHY__Vector4 @@ -75,11 +75,11 @@ struct PHY__Vector4 operator const float* () const { return &m_vec[0]; - } + } operator float* () { return &m_vec[0]; - } + } }; //typedef float PHY__Vector3[4]; diff --git a/source/gameengine/Physics/common/PHY_IController.h b/source/gameengine/Physics/common/PHY_IController.h index 239ac3366e1..729abd8ec04 100644 --- a/source/gameengine/Physics/common/PHY_IController.h +++ b/source/gameengine/Physics/common/PHY_IController.h @@ -45,7 +45,7 @@ class PHY_IPhysicsEnvironment; controlled by the physics engine. This includes the physics objects and the graphics object for view frustrum and occlusion culling. */ -class PHY_IController +class PHY_IController { public: virtual ~PHY_IController(); diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h index 2eb2a9f39cf..72ff37468ee 100644 --- a/source/gameengine/Physics/common/PHY_IMotionState.h +++ b/source/gameengine/Physics/common/PHY_IMotionState.h @@ -43,7 +43,7 @@ class PHY_IMotionState { - public: + public: virtual ~PHY_IMotionState(); virtual void getWorldPosition(float& posX,float& posY,float& posZ)=0; diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index 30d63e6695d..3f8699d25d2 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -48,7 +48,7 @@ class PHY_IPhysicsController; */ struct PHY_RayCastResult { - PHY_IPhysicsController* m_controller; + PHY_IPhysicsController* m_controller; PHY__Vector3 m_hitPoint; PHY__Vector3 m_hitNormal; const RAS_MeshObject* m_meshObject; // !=NULL for mesh object (only for Bullet controllers) diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 06251cd2282..7312b521788 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -110,7 +110,7 @@ void RAS_2DFilterManager::PrintShaderErrors(unsigned int shader, const char *tas unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource) { - GLuint program = 0; + GLuint program = 0; GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); GLint success; @@ -469,7 +469,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glEnable(GL_DEPTH_TEST); glViewport(viewport[0],viewport[1],viewport[2],viewport[3]); - EndShaderProgram(); + EndShaderProgram(); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 90587bb9739..457fd0ad90c 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -232,8 +232,8 @@ void RAS_BucketManager::Renderbuckets( /* beginning each frame, clear (texture/material) caching information */ rasty->ClearCachingInfo(); - RenderSolidBuckets(cameratrans, rasty, rendertools); - RenderAlphaBuckets(cameratrans, rasty, rendertools); + RenderSolidBuckets(cameratrans, rasty, rendertools); + RenderAlphaBuckets(cameratrans, rasty, rendertools); rendertools->SetClientObject(rasty, NULL); } diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 51c4da3c49d..d70e56dc285 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -91,7 +91,7 @@ public: protected: class RAS_MeshObject *m_pMesh; - bool m_bDynamic; + bool m_bDynamic; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp index 1cd110f8cc6..53d9b64ab0e 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp +++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp @@ -43,7 +43,7 @@ ComputeDefaultFrustum( const short sensor_fit, const float design_aspect_ratio, RAS_FrameFrustum & frustum -) { +) { float halfSize; float sizeX; float sizeY; @@ -202,7 +202,7 @@ ComputeViewport( { ComputeBestFitViewRect( availableViewport, - design_aspect_ratio, + design_aspect_ratio, viewport ); @@ -260,7 +260,7 @@ ComputeFrustum( RAS_Rect vt; ComputeBestFitViewRect( availableViewport, - design_aspect_ratio, + design_aspect_ratio, vt ); @@ -277,13 +277,13 @@ ComputeFrustum( frustum.y2 *= y_scale; break; - } + } case RAS_FrameSettings::e_frame_scale : case RAS_FrameSettings::e_frame_bars: default : break; } -} +} void RAS_FramingManager:: @@ -330,7 +330,7 @@ RAS_FramingManager:: RAS_Rect vt; ComputeBestFitViewRect( availableViewport, - design_aspect_ratio, + design_aspect_ratio, vt ); @@ -347,7 +347,7 @@ RAS_FramingManager:: frustum.y2 *= y_scale; break; - } + } case RAS_FrameSettings::e_frame_scale : case RAS_FrameSettings::e_frame_bars: default : diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h index dd640bc6839..122f0ca46ec 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.h +++ b/source/gameengine/Rasterizer/RAS_FramingManager.h @@ -109,7 +109,7 @@ public : */ const - RAS_FrameType & + RAS_FrameType & FrameType( ) const { return m_frame_type; @@ -143,13 +143,13 @@ public : unsigned int DesignAspectWidth( ) const { - return m_design_aspect_width; + return m_design_aspect_width; }; unsigned int DesignAspectHeight( ) const { - return m_design_aspect_height; + return m_design_aspect_height; }; private : @@ -262,7 +262,7 @@ public : const short sensor_fit, const float design_aspect_ratio, RAS_FrameFrustum & frustum - ); + ); static void diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 7749c4af9d6..8efc10f2118 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -301,7 +301,7 @@ public: virtual int GetDrawingMode()=0; /** * Sets face culling - */ + */ virtual void SetCullFace(bool enable)=0; /** * Sets wireframe mode. diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index c02bc5e7a44..ca6f20b71ad 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -72,18 +72,18 @@ public: { }; - virtual + virtual ~RAS_IRenderTools( ) {}; virtual - void + void BeginFrame( RAS_IRasterizer* rasty )=0; virtual - void + void EndFrame( RAS_IRasterizer* rasty )=0; @@ -94,7 +94,7 @@ public: // so must be renamed to 'applyTransform' or something virtual - void + void applyTransform( class RAS_IRasterizer* rasty, double* oglmatrix, @@ -112,7 +112,7 @@ public: * \param aspect A scaling factor to compensate for the size. */ virtual - void + void RenderText3D(int fontid, const char* text, int size, @@ -133,7 +133,7 @@ public: * \param height Height of the canvas to draw to. */ virtual - void + void RenderText2D( RAS_TEXT_RENDER_MODE mode, const char* text, @@ -145,7 +145,7 @@ public: // 3d text, mapped on polygon virtual - void + void RenderText( int mode, RAS_IPolyMaterial* polymat, @@ -156,8 +156,8 @@ public: int glattrib )=0; - virtual - void + virtual + void ProcessLighting( RAS_IRasterizer *rasty, bool uselights, @@ -165,35 +165,35 @@ public: )=0; virtual - void + void SetClientObject( RAS_IRasterizer* rasty, void* obj ); - void + void SetAuxilaryClientInfo( void* inf ); virtual - void + void PushMatrix( )=0; virtual - void + void PopMatrix( )=0; virtual - void + void AddLight( struct RAS_LightObject* lightobject ); virtual - void + void RemoveLight( struct RAS_LightObject* lightobject ); diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index a18adfd8986..183da9d252e 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -489,7 +489,7 @@ bool RAS_MeshSlot::Split(bool force) } -#ifdef USE_SPLIT +#ifdef USE_SPLIT bool RAS_MeshSlot::IsCulled() { if (m_joinSlot) @@ -502,7 +502,7 @@ bool RAS_MeshSlot::IsCulled() return false; return true; } -#endif +#endif /* material bucket sorting */ @@ -531,12 +531,12 @@ RAS_IPolyMaterial* RAS_MaterialBucket::GetPolyMaterial() const } bool RAS_MaterialBucket::IsAlpha() const -{ +{ return (m_material->IsAlpha()); } bool RAS_MaterialBucket::IsZSort() const -{ +{ return (m_material->IsZSort()); } diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 25afefbcc5a..c50aa28e9fc 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -173,7 +173,7 @@ const STR_String& RAS_MeshObject::GetMaterialName(unsigned int matid) RAS_MeshMaterial* RAS_MeshObject::GetMeshMaterial(unsigned int matid) { - if (m_materials.size() > 0 && (matid < m_materials.size())) + if ((m_materials.empty() == false) && (matid < m_materials.size())) { list<RAS_MeshMaterial>::iterator it = m_materials.begin(); while (matid--) ++it; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index b769fc4b703..67423123a7a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -438,7 +438,7 @@ void RAS_OpenGLRasterizer::EndFrame() glDisable(GL_MULTISAMPLE_ARB); m_2DCanvas->EndFrame(); -} +} void RAS_OpenGLRasterizer::SetRenderArea() { @@ -975,7 +975,7 @@ void RAS_OpenGLRasterizer::SetProjectionMatrix(const MT_Matrix4x4 & mat) /* Get into argument. Looks a bit dodgy, but it's ok. */ mat.getValue(matrix); /* Internally, MT_Matrix4x4 uses doubles (MT_Scalar). */ - glLoadMatrixd(matrix); + glLoadMatrixd(matrix); m_camortho= (mat[3][3] != 0.0); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index e5eba249175..8b54f507ee0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -278,7 +278,7 @@ public: line.m_type = OglDebugShape::CIRCLE; line.m_pos= center; line.m_param = normal; - line.m_color = color; + line.m_color = color; line.m_param2.x() = radius; line.m_param2.y() = (float) nsector; m_debugShapes.push_back(line); diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h index d82738dbb86..455aaf90d6d 100644 --- a/source/gameengine/SceneGraph/SG_Controller.h +++ b/source/gameengine/SceneGraph/SG_Controller.h @@ -53,7 +53,7 @@ public: ) {}; virtual - bool + bool Update( double time )=0; @@ -69,13 +69,13 @@ public: ); virtual - void + void SetSimulatedTime( double time )=0; - virtual - SG_Controller* + virtual + SG_Controller* GetReplica( class SG_Node* destnode )=0; diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp index afd647c2a2a..9ae32a89ff8 100644 --- a/source/gameengine/SceneGraph/SG_IObject.cpp +++ b/source/gameengine/SceneGraph/SG_IObject.cpp @@ -70,7 +70,7 @@ AddSGController( m_SGcontrollers.push_back(cont); } - void + void SG_IObject:: RemoveSGController( SG_Controller* cont diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index c36c984f3d3..53b51507e97 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -174,7 +174,7 @@ public: * this object is deleted. */ - void + void AddSGController( SG_Controller* cont ); @@ -196,7 +196,7 @@ public: * leaks. */ - void + void RemoveAllControllers( ); @@ -233,7 +233,7 @@ public: * This may be NULL. */ - inline const void* GetSGClientObject() const + inline const void* GetSGClientObject() const { return m_SGclientObject; } @@ -280,7 +280,7 @@ public: void SetControllerTime(double time); virtual - void + void Destruct( ) = 0; diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index 33af9f16d7c..04d9a306fc4 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -143,7 +143,7 @@ Destruct() } const - SG_Node* + SG_Node * SG_Node:: GetRootSGParent( ) const { diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 1d0c0e592e6..063eeaab01d 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -63,7 +63,7 @@ public: * make a deep copy. */ - void + void AddChild( SG_Node* child ); @@ -75,7 +75,7 @@ public: * If the node was not a child of this object no action is performed. */ - void + void RemoveChild( SG_Node* child ); @@ -149,7 +149,7 @@ public: * Disconnect this node from it's parent */ - void + void DisconnectFromParent( ); @@ -182,12 +182,12 @@ public: - /** + /** * Update the spatial data of this node. Iterate through * the children of this node and update their world data. */ - void + void UpdateWorldData( double time, bool parentUpdated=false @@ -198,7 +198,7 @@ public: * the children nodes and update their simulated time. */ - void + void SetSimulatedTime( double time, bool recurse @@ -244,17 +244,17 @@ public: * Node replication functions. */ - SG_Node* + SG_Node* GetSGReplica( ); - void + void Destruct( ); private: - void + void ProcessSGReplica( SG_Node** replica ); diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 4478ed11bc1..6e314996456 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -118,7 +118,7 @@ protected : */ SG_ParentRelation( - ) { + ) { }; /** diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index f8c4b5165ee..8c0d2b88c63 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -161,8 +161,8 @@ RelativeTranslate( } } SetModified(); -} - +} + /** * Scaling methods. diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h index e456851d183..7630af51781 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.h +++ b/source/gameengine/SceneGraph/SG_Spatial.h @@ -137,7 +137,7 @@ public: } - void + void RelativeRotate( const MT_Matrix3x3& rot, bool local @@ -178,12 +178,12 @@ public: m_worldScaling = scale; } - const MT_Point3& GetLocalPosition() const + const MT_Point3& GetLocalPosition() const { return m_localPosition; } - const MT_Matrix3x3& GetLocalOrientation() const + const MT_Matrix3x3& GetLocalOrientation() const { return m_localRotation; } @@ -193,17 +193,17 @@ public: return m_localScaling; } - const MT_Point3& GetWorldPosition() const + const MT_Point3& GetWorldPosition() const { return m_worldPosition; } - const MT_Matrix3x3& GetWorldOrientation() const + const MT_Matrix3x3& GetWorldOrientation() const { return m_worldRotation; } - const MT_Vector3& GetWorldScaling() const + const MT_Vector3& GetWorldScaling() const { return m_worldScaling; } diff --git a/source/gameengine/SceneGraph/SG_Tree.cpp b/source/gameengine/SceneGraph/SG_Tree.cpp index 0f8264985de..99f68ef625a 100644 --- a/source/gameengine/SceneGraph/SG_Tree.cpp +++ b/source/gameengine/SceneGraph/SG_Tree.cpp @@ -236,7 +236,7 @@ void SG_TreeFactory::Add(SG_Tree* tree) SG_Tree* SG_TreeFactory::MakeTreeDown(SG_BBox &bbox) { - if (m_objects.size() == 0) + if (m_objects.empty()) return NULL; if (m_objects.size() == 1) return *m_objects.begin(); diff --git a/source/gameengine/VideoTexture/BlendType.h b/source/gameengine/VideoTexture/BlendType.h index 0131cc61c44..e19aadc49d2 100644 --- a/source/gameengine/VideoTexture/BlendType.h +++ b/source/gameengine/VideoTexture/BlendType.h @@ -37,7 +37,7 @@ public: BlendType (const char * name) : m_name(name) {} /// check blender type and return pointer to contained object or NULL (if type is not valid) - PyObj * checkType (PyObject * obj) + PyObj *checkType(PyObject *obj) { // if pointer to type isn't set if (m_objType == NULL) @@ -55,17 +55,18 @@ public: return NULL; // return pointer to object, this class can only be used for KX object => // the Py object is actually a proxy - return (PyObj*)BGE_PROXY_REF(obj); + return (PyObj *)BGE_PROXY_REF(obj); } /// parse arguments to get object - PyObj * parseArg (PyObject * args) + PyObj *parseArg(PyObject *args) { // parse arguments - PyObject * obj; - if (PyArg_ParseTuple(args, "O", &obj)) + PyObject *obj; + if (PyArg_ParseTuple(args, "O", &obj)) { // if successfully parsed, return pointer to object return checkType(obj); + } // otherwise return NULL return NULL; } @@ -74,7 +75,7 @@ protected: /// name of Python type const char * m_name; /// pointer to Python type - PyTypeObject * m_objType; + PyTypeObject *m_objType; }; diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp index 90ea8436ffe..6ec5e237ac2 100644 --- a/source/gameengine/VideoTexture/FilterBase.cpp +++ b/source/gameengine/VideoTexture/FilterBase.cpp @@ -90,10 +90,10 @@ PyTypeList pyFilterTypes; // object allocation -PyObject * Filter_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds) +PyObject *Filter_allocNew (PyTypeObject *type, PyObject *args, PyObject *kwds) { // allocate object - PyFilter * self = reinterpret_cast<PyFilter*>(type->tp_alloc(type, 0)); + PyFilter *self = reinterpret_cast<PyFilter*>(type->tp_alloc(type, 0)); // initialize object structure self->m_filter = NULL; // return allocated object @@ -101,7 +101,7 @@ PyObject * Filter_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwd } // object deallocation -void Filter_dealloc (PyFilter * self) +void Filter_dealloc (PyFilter *self) { // release object attributes if (self->m_filter != NULL) @@ -114,7 +114,7 @@ void Filter_dealloc (PyFilter * self) // get previous pixel filter object -PyObject * Filter_getPrevious (PyFilter * self, void * closure) +PyObject *Filter_getPrevious (PyFilter *self, void *closure) { // if filter object is available if (self->m_filter != NULL) @@ -135,7 +135,7 @@ PyObject * Filter_getPrevious (PyFilter * self, void * closure) // set previous pixel filter object -int Filter_setPrevious (PyFilter * self, PyObject * value, void * closure) +int Filter_setPrevious (PyFilter *self, PyObject *value, void *closure) { // if filter object is available if (self->m_filter != NULL) diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h index 63561c25ffa..422cf86f23e 100644 --- a/source/gameengine/VideoTexture/FilterBase.h +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -118,9 +118,9 @@ extern PyTypeList pyFilterTypes; // functions for python interface // object initialization -template <class T> static int Filter_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +template <class T> static int Filter_init (PyObject *pySelf, PyObject *args, PyObject *kwds) { - PyFilter * self = reinterpret_cast<PyFilter*>(pySelf); + PyFilter *self = reinterpret_cast<PyFilter*>(pySelf); // create filter object if (self->m_filter != NULL) delete self->m_filter; self->m_filter = new T(); @@ -129,14 +129,14 @@ template <class T> static int Filter_init (PyObject * pySelf, PyObject * args, P } // object allocation -PyObject * Filter_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds); +PyObject *Filter_allocNew(PyTypeObject *type, PyObject *args, PyObject *kwds); // object deallocation -void Filter_dealloc (PyFilter * self); +void Filter_dealloc(PyFilter *self); // get previous pixel filter object -PyObject * Filter_getPrevious (PyFilter * self, void * closure); +PyObject *Filter_getPrevious(PyFilter *self, void *closure); // set previous pixel filter object -int Filter_setPrevious (PyFilter * self, PyObject * value, void * closure); +int Filter_setPrevious(PyFilter *self, PyObject *value, void *closure); #endif diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp index 02a6a8f0344..8559e8f87f4 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp +++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp @@ -66,21 +66,21 @@ void FilterBlueScreen::setLimits (unsigned short minLimit, unsigned short maxLim // cast Filter pointer to FilterBlueScreen -inline FilterBlueScreen * getFilter (PyFilter * self) +inline FilterBlueScreen * getFilter (PyFilter *self) { return static_cast<FilterBlueScreen*>(self->m_filter); } // python methods and get/sets // get color -static PyObject * getColor (PyFilter * self, void * closure) +static PyObject *getColor (PyFilter *self, void *closure) { return Py_BuildValue("[BBB]", getFilter(self)->getColor()[0], getFilter(self)->getColor()[1], getFilter(self)->getColor()[2]); } // set color -static int setColor (PyFilter * self, PyObject * value, void * closure) +static int setColor (PyFilter *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 3 @@ -100,14 +100,14 @@ static int setColor (PyFilter * self, PyObject * value, void * closure) } // get limits -static PyObject * getLimits (PyFilter * self, void * closure) +static PyObject *getLimits (PyFilter *self, void *closure) { return Py_BuildValue("[II]", getFilter(self)->getLimits()[0], getFilter(self)->getLimits()[1]); } // set limit -static int setLimits (PyFilter * self, PyObject * value, void * closure) +static int setLimits (PyFilter *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2 diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp index ed75b4f8da8..35a6414f383 100644 --- a/source/gameengine/VideoTexture/FilterColor.cpp +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -108,14 +108,14 @@ void FilterColor::setMatrix (ColorMatrix & mat) // cast Filter pointer to FilterColor -inline FilterColor * getFilterColor (PyFilter * self) +inline FilterColor * getFilterColor (PyFilter *self) { return static_cast<FilterColor*>(self->m_filter); } // python methods and get/sets // get color matrix -static PyObject * getMatrix (PyFilter * self, void * closure) +static PyObject *getMatrix (PyFilter *self, void *closure) { ColorMatrix & mat = getFilterColor(self)->getMatrix(); return Py_BuildValue("((hhhhh)(hhhhh)(hhhhh)(hhhhh))", @@ -126,7 +126,7 @@ static PyObject * getMatrix (PyFilter * self, void * closure) } // set color matrix -static int setMatrix (PyFilter * self, PyObject * value, void * closure) +static int setMatrix (PyFilter *self, PyObject *value, void *closure) { // matrix to store items ColorMatrix mat; @@ -243,14 +243,14 @@ void FilterLevel::setLevels (ColorLevel & lev) // cast Filter pointer to FilterLevel -inline FilterLevel * getFilterLevel (PyFilter * self) +inline FilterLevel * getFilterLevel (PyFilter *self) { return static_cast<FilterLevel*>(self->m_filter); } // python methods and get/sets // get color levels -static PyObject * getLevels (PyFilter * self, void * closure) +static PyObject *getLevels (PyFilter *self, void *closure) { ColorLevel & lev = getFilterLevel(self)->getLevels(); return Py_BuildValue("((HH)(HH)(HH)(HH))", @@ -259,7 +259,7 @@ static PyObject * getLevels (PyFilter * self, void * closure) } // set color levels -static int setLevels (PyFilter * self, PyObject * value, void * closure) +static int setLevels (PyFilter *self, PyObject *value, void *closure) { // matrix to store items ColorLevel lev; diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index dda1a493291..03c500a7e14 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -59,20 +59,20 @@ void FilterNormal::setDepth (float depth) // cast Filter pointer to FilterNormal -inline FilterNormal * getFilter (PyFilter * self) +inline FilterNormal * getFilter (PyFilter *self) { return static_cast<FilterNormal*>(self->m_filter); } // python methods and get/sets // get index of color used to calculate normal -static PyObject * getColor (PyFilter * self, void * closure) +static PyObject *getColor (PyFilter *self, void *closure) { return Py_BuildValue("H", getFilter(self)->getColor()); } // set index of color used to calculate normal -static int setColor (PyFilter * self, PyObject * value, void * closure) +static int setColor (PyFilter *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PyLong_Check(value)) @@ -88,13 +88,13 @@ static int setColor (PyFilter * self, PyObject * value, void * closure) // get depth -static PyObject * getDepth (PyFilter * self, void * closure) +static PyObject *getDepth (PyFilter *self, void *closure) { return Py_BuildValue("f", getFilter(self)->getDepth()); } // set depth -static int setDepth (PyFilter * self, PyObject * value, void * closure) +static int setDepth (PyFilter *self, PyObject *value, void *closure) { // check validity of parameter if (value) diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index 54c1939ce6b..2de49795681 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -128,7 +128,7 @@ PyImage * ImageBase::getSource (const char * id) // set source object -bool ImageBase::setSource (const char * id, PyImage * source) +bool ImageBase::setSource (const char * id, PyImage *source) { // find source ImageSourceList::iterator src = findSource(id); @@ -315,7 +315,7 @@ bool ImageSource::is (const char * id) // set source object -void ImageSource::setSource (PyImage * source) +void ImageSource::setSource (PyImage *source) { // reference new source if (source != NULL) Py_INCREF(source); @@ -358,10 +358,10 @@ PyTypeList pyImageTypes; // functions for python interface // object allocation -PyObject * Image_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds) +PyObject *Image_allocNew (PyTypeObject *type, PyObject *args, PyObject *kwds) { // allocate object - PyImage * self = reinterpret_cast<PyImage*>(type->tp_alloc(type, 0)); + PyImage *self = reinterpret_cast<PyImage*>(type->tp_alloc(type, 0)); // initialize object structure self->m_image = NULL; // return allocated object @@ -369,7 +369,7 @@ PyObject * Image_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds } // object deallocation -void Image_dealloc (PyImage * self) +void Image_dealloc (PyImage *self) { // release object attributes if (self->m_image != NULL) @@ -388,7 +388,7 @@ void Image_dealloc (PyImage * self) } // get image data -PyObject * Image_getImage (PyImage * self, char * mode) +PyObject *Image_getImage (PyImage *self, char * mode) { try { @@ -463,7 +463,7 @@ PyObject * Image_getImage (PyImage * self, char * mode) } } } - return (PyObject*)buffer; + return (PyObject *)buffer; } } catch (Exception & exp) @@ -475,28 +475,28 @@ PyObject * Image_getImage (PyImage * self, char * mode) } // get image size -PyObject * Image_getSize (PyImage * self, void * closure) +PyObject *Image_getSize (PyImage *self, void *closure) { return Py_BuildValue("(hh)", self->m_image->getSize()[0], self->m_image->getSize()[1]); } // refresh image -PyObject * Image_refresh (PyImage * self) +PyObject *Image_refresh (PyImage *self) { self->m_image->refresh(); Py_RETURN_NONE; } // get scale -PyObject * Image_getScale (PyImage * self, void * closure) +PyObject *Image_getScale (PyImage *self, void *closure) { if (self->m_image != NULL && self->m_image->getScale()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } // set scale -int Image_setScale (PyImage * self, PyObject * value, void * closure) +int Image_setScale (PyImage *self, PyObject *value, void *closure) { // check parameter, report failure if (value == NULL || !PyBool_Check(value)) @@ -511,14 +511,14 @@ int Image_setScale (PyImage * self, PyObject * value, void * closure) } // get flip -PyObject * Image_getFlip (PyImage * self, void * closure) +PyObject *Image_getFlip (PyImage *self, void *closure) { if (self->m_image != NULL && self->m_image->getFlip()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } // set flip -int Image_setFlip (PyImage * self, PyObject * value, void * closure) +int Image_setFlip (PyImage *self, PyObject *value, void *closure) { // check parameter, report failure if (value == NULL || !PyBool_Check(value)) @@ -534,7 +534,7 @@ int Image_setFlip (PyImage * self, PyObject * value, void * closure) // get filter source object -PyObject * Image_getSource (PyImage * self, PyObject * args) +PyObject *Image_getSource (PyImage *self, PyObject *args) { // get arguments char * id; @@ -543,7 +543,7 @@ PyObject * Image_getSource (PyImage * self, PyObject * args) if (self->m_image != NULL) { // get source object - PyObject * src = reinterpret_cast<PyObject*>(self->m_image->getSource(id)); + PyObject *src = reinterpret_cast<PyObject*>(self->m_image->getSource(id)); // if source is available if (src != NULL) { @@ -558,11 +558,11 @@ PyObject * Image_getSource (PyImage * self, PyObject * args) // set filter source object -PyObject * Image_setSource (PyImage * self, PyObject * args) +PyObject *Image_setSource (PyImage *self, PyObject *args) { // get arguments char * id; - PyObject * obj; + PyObject *obj; if (!PyArg_ParseTuple(args, "sO:setSource", &id, &obj)) return NULL; if (self->m_image != NULL) @@ -593,7 +593,7 @@ PyObject * Image_setSource (PyImage * self, PyObject * args) // get pixel filter object -PyObject * Image_getFilter (PyImage * self, void * closure) +PyObject *Image_getFilter (PyImage *self, void *closure) { // if image object is available if (self->m_image != NULL) @@ -614,7 +614,7 @@ PyObject * Image_getFilter (PyImage * self, void * closure) // set pixel filter object -int Image_setFilter (PyImage * self, PyObject * value, void * closure) +int Image_setFilter (PyImage *self, PyObject *value, void *closure) { // if image object is available if (self->m_image != NULL) @@ -632,7 +632,7 @@ int Image_setFilter (PyImage * self, PyObject * value, void * closure) // return success return 0; } -PyObject * Image_valid(PyImage * self, void * closure) +PyObject *Image_valid(PyImage *self, void *closure) { if (self->m_image->isImageAvailable()) { @@ -644,7 +644,7 @@ PyObject * Image_valid(PyImage * self, void * closure) } } -int Image_getbuffer(PyImage *self, Py_buffer *view, int flags) +static int Image_getbuffer(PyImage *self, Py_buffer *view, int flags) { unsigned int * image; int ret; @@ -674,7 +674,7 @@ int Image_getbuffer(PyImage *self, Py_buffer *view, int flags) self->m_image->m_exports++; return 0; } - ret = PyBuffer_FillInfo(view, (PyObject*)self, image, self->m_image->getBuffSize(), 0, flags); + ret = PyBuffer_FillInfo(view, (PyObject *)self, image, self->m_image->getBuffSize(), 0, flags); if (ret >= 0) self->m_image->m_exports++; return ret; @@ -684,14 +684,14 @@ error: // The bug is fixed in Python SVN 77916, as soon as the python revision used by Blender is // updated, you can simply return -1 and set the error static char* buf = (char *)""; - ret = PyBuffer_FillInfo(view, (PyObject*)self, buf, 0, 0, flags); + ret = PyBuffer_FillInfo(view, (PyObject *)self, buf, 0, 0, flags); if (ret >= 0) self->m_image->m_exports++; return ret; } -void Image_releaseBuffer(PyImage *self, Py_buffer *buffer) +static void Image_releaseBuffer(PyImage *self, Py_buffer *buffer) { self->m_image->m_exports--; } diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h index 6c38b107a4d..bb3f0c19e4b 100644 --- a/source/gameengine/VideoTexture/ImageBase.h +++ b/source/gameengine/VideoTexture/ImageBase.h @@ -82,7 +82,7 @@ public: /// get source object PyImage * getSource (const char * id); /// set source object, return true, if source was set - bool setSource (const char * id, PyImage * source); + bool setSource (const char * id, PyImage *source); /// get pixel filter PyFilter * getFilter (void) { return m_pyfilter; } @@ -276,7 +276,7 @@ public: /// get source object PyImage * getSource (void) { return m_source; } /// set source object - void setSource (PyImage * source); + void setSource (PyImage *source); /// get image from source unsigned int * getImage (double ts=-1.0); @@ -312,9 +312,9 @@ extern PyTypeList pyImageTypes; // functions for python interface // object initialization -template <class T> static int Image_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +template <class T> static int Image_init (PyObject *pySelf, PyObject *args, PyObject *kwds) { - PyImage * self = reinterpret_cast<PyImage*>(pySelf); + PyImage *self = reinterpret_cast<PyImage*>(pySelf); // create source object if (self->m_image != NULL) delete self->m_image; self->m_image = new T(); @@ -323,37 +323,37 @@ template <class T> static int Image_init (PyObject * pySelf, PyObject * args, Py } // object allocation -PyObject * Image_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds); +PyObject *Image_allocNew (PyTypeObject *type, PyObject *args, PyObject *kwds); // object deallocation -void Image_dealloc (PyImage * self); +void Image_dealloc (PyImage *self); // get image data -PyObject * Image_getImage (PyImage * self, char * mode); +PyObject *Image_getImage (PyImage *self, char * mode); // get image size -PyObject * Image_getSize (PyImage * self, void * closure); +PyObject *Image_getSize (PyImage *self, void *closure); // refresh image - invalidate current content -PyObject * Image_refresh (PyImage * self); +PyObject *Image_refresh (PyImage *self); // get scale -PyObject * Image_getScale (PyImage * self, void * closure); +PyObject *Image_getScale (PyImage *self, void *closure); // set scale -int Image_setScale (PyImage * self, PyObject * value, void * closure); +int Image_setScale (PyImage *self, PyObject *value, void *closure); // get flip -PyObject * Image_getFlip (PyImage * self, void * closure); +PyObject *Image_getFlip (PyImage *self, void *closure); // set flip -int Image_setFlip (PyImage * self, PyObject * value, void * closure); +int Image_setFlip (PyImage *self, PyObject *value, void *closure); // get filter source object -PyObject * Image_getSource (PyImage * self, PyObject * args); +PyObject *Image_getSource (PyImage *self, PyObject *args); // set filter source object -PyObject * Image_setSource (PyImage * self, PyObject * args); +PyObject *Image_setSource (PyImage *self, PyObject *args); // get pixel filter object -PyObject * Image_getFilter (PyImage * self, void * closure); +PyObject *Image_getFilter (PyImage *self, void *closure); // set pixel filter object -int Image_setFilter (PyImage * self, PyObject * value, void * closure); +int Image_setFilter (PyImage *self, PyObject *value, void *closure); // check if a buffer can be extracted -PyObject * Image_valid(PyImage * self, void * closure); +PyObject *Image_valid(PyImage *self, void *closure); // for buffer access to PyImage objects extern PyBufferProcs imageBufferProcs; diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index 17513d20a39..eec0bccbe56 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -47,7 +47,7 @@ FilterRGB24 defFilter; // forward declaration; extern PyTypeObject ImageBuffType; -static int ImageBuff_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +static int ImageBuff_init (PyObject *pySelf, PyObject *args, PyObject *kwds) { short width = -1; short height = -1; @@ -55,7 +55,7 @@ static int ImageBuff_init (PyObject * pySelf, PyObject * args, PyObject * kwds) PyObject *py_scale = Py_False; ImageBuff *image; - PyImage * self = reinterpret_cast<PyImage*>(pySelf); + PyImage *self = reinterpret_cast<PyImage*>(pySelf); // create source object if (self->m_image != NULL) delete self->m_image; @@ -190,7 +190,7 @@ void ImageBuff::plot (ImageBuff* img, short x, short y, short mode) // cast Image pointer to ImageBuff -inline ImageBuff * getImageBuff (PyImage * self) +inline ImageBuff * getImageBuff (PyImage *self) { return static_cast<ImageBuff*>(self->m_image); } @@ -245,7 +245,7 @@ static bool testBGLBuffer(Buffer* buffer, int width, int height, unsigned int pi // load image -static PyObject * load (PyImage * self, PyObject * args) +static PyObject *load(PyImage *self, PyObject *args) { // parameters: string image buffer, its size, width, height Py_buffer buffer; @@ -306,10 +306,10 @@ static PyObject * load (PyImage * self, PyObject * args) } if (PyErr_Occurred()) return NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } -static PyObject * plot (PyImage * self, PyObject * args) +static PyObject *plot (PyImage *self, PyObject *args) { PyImage * other; Buffer* bglBuffer; @@ -332,7 +332,7 @@ static PyObject * plot (PyImage * self, PyObject * args) PyBuffer_Release(&buffer); if (PyErr_Occurred()) return NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } PyErr_Clear(); // try the other format @@ -354,7 +354,7 @@ static PyObject * plot (PyImage * self, PyObject * args) } if (PyErr_Occurred()) return NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } // methods structure diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index cd8c6683a7f..f09454a517b 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -101,14 +101,14 @@ void ImageMix::calcImage (unsigned int texId, double ts) // cast Image pointer to ImageMix -inline ImageMix * getImageMix (PyImage * self) +inline ImageMix * getImageMix (PyImage *self) { return static_cast<ImageMix*>(self->m_image); } // python methods // get source weight -PyObject * getWeight (PyImage * self, PyObject * args) +static PyObject *getWeight (PyImage *self, PyObject *args) { // weight short weight = 0; @@ -125,7 +125,7 @@ PyObject * getWeight (PyImage * self, PyObject * args) // set source weight -PyObject * setWeight (PyImage * self, PyObject * args) +static PyObject *setWeight (PyImage *self, PyObject *args) { // get arguments char * id; diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index c8763671dd1..2135d0a07eb 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -277,7 +277,7 @@ void ImageRender::Render() // cast Image pointer to ImageRender -inline ImageRender * getImageRender (PyImage * self) +inline ImageRender * getImageRender (PyImage *self) { return static_cast<ImageRender*>(self->m_image); } @@ -290,10 +290,10 @@ BlendType<KX_Camera> cameraType ("KX_Camera"); // object initialization -static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +static int ImageRender_init (PyObject *pySelf, PyObject *args, PyObject *kwds) { // parameters - scene object - PyObject * scene; + PyObject *scene; // camera object PyObject * camera; // parameter keywords @@ -317,7 +317,7 @@ static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds if (cameraPtr == NULL) THRWEXCP(CameraInvalid, S_OK); // get pointer to image structure - PyImage * self = reinterpret_cast<PyImage*>(pySelf); + PyImage *self = reinterpret_cast<PyImage*>(pySelf); // create source object if (self->m_image != NULL) delete self->m_image; self->m_image = new ImageRender(scenePtr, cameraPtr); @@ -333,7 +333,7 @@ static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds // get background color -PyObject * getBackground (PyImage * self, void * closure) +static PyObject *getBackground (PyImage *self, void *closure) { return Py_BuildValue("[BBBB]", getImageRender(self)->getBackground(0), @@ -343,7 +343,7 @@ PyObject * getBackground (PyImage * self, void * closure) } // set color -static int setBackground (PyImage * self, PyObject * value, void * closure) +static int setBackground (PyImage *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 4 @@ -434,14 +434,14 @@ PyTypeObject ImageRenderType = }; // object initialization -static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +static int ImageMirror_init (PyObject *pySelf, PyObject *args, PyObject *kwds) { // parameters - scene object - PyObject * scene; + PyObject *scene; // reference object for mirror - PyObject * observer; + PyObject *observer; // object holding the mirror - PyObject * mirror; + PyObject *mirror; // material of the mirror short materialID = 0; // parameter keywords @@ -490,7 +490,7 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds THRWEXCP(MaterialNotAvail, S_OK); // get pointer to image structure - PyImage * self = reinterpret_cast<PyImage*>(pySelf); + PyImage *self = reinterpret_cast<PyImage*>(pySelf); // create source object if (self->m_image != NULL) @@ -510,13 +510,13 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds } // get background color -PyObject * getClip (PyImage * self, void * closure) +static PyObject *getClip (PyImage *self, void *closure) { return PyFloat_FromDouble(getImageRender(self)->getClip()); } // set clip -static int setClip (PyImage * self, PyObject * value, void * closure) +static int setClip (PyImage *self, PyObject *value, void *closure) { // check validity of parameter double clip; diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index a780fdcc38c..9b503efcf39 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -165,7 +165,7 @@ void ImageViewport::calcImage (unsigned int texId, double ts) // cast Image pointer to ImageViewport -inline ImageViewport * getImageViewport (PyImage * self) +inline ImageViewport * getImageViewport (PyImage *self) { return static_cast<ImageViewport*>(self->m_image); } @@ -173,14 +173,14 @@ inline ImageViewport * getImageViewport (PyImage * self) // get whole -PyObject * ImageViewport_getWhole (PyImage * self, void * closure) +PyObject *ImageViewport_getWhole (PyImage *self, void *closure) { if (self->m_image != NULL && getImageViewport(self)->getWhole()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } // set whole -int ImageViewport_setWhole (PyImage * self, PyObject * value, void * closure) +int ImageViewport_setWhole (PyImage *self, PyObject *value, void *closure) { // check parameter, report failure if (value == NULL || !PyBool_Check(value)) @@ -203,14 +203,14 @@ int ImageViewport_setWhole (PyImage * self, PyObject * value, void * closure) } // get alpha -PyObject * ImageViewport_getAlpha (PyImage * self, void * closure) +PyObject *ImageViewport_getAlpha (PyImage *self, void *closure) { if (self->m_image != NULL && getImageViewport(self)->getAlpha()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } // set whole -int ImageViewport_setAlpha (PyImage * self, PyObject * value, void * closure) +int ImageViewport_setAlpha (PyImage *self, PyObject *value, void *closure) { // check parameter, report failure if (value == NULL || !PyBool_Check(value)) @@ -226,14 +226,14 @@ int ImageViewport_setAlpha (PyImage * self, PyObject * value, void * closure) // get position -static PyObject * ImageViewport_getPosition (PyImage * self, void * closure) +static PyObject *ImageViewport_getPosition (PyImage *self, void *closure) { return Py_BuildValue("(ii)", getImageViewport(self)->getPosition()[0], getImageViewport(self)->getPosition()[1]); } // set position -static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * closure) +static int ImageViewport_setPosition (PyImage *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2 @@ -254,14 +254,14 @@ static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * c } // get capture size -PyObject * ImageViewport_getCaptureSize (PyImage * self, void * closure) +PyObject *ImageViewport_getCaptureSize (PyImage *self, void *closure) { return Py_BuildValue("(ii)", getImageViewport(self)->getCaptureSize()[0], getImageViewport(self)->getCaptureSize()[1]); } // set capture size -int ImageViewport_setCaptureSize (PyImage * self, PyObject * value, void * closure) +int ImageViewport_setCaptureSize (PyImage *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2 diff --git a/source/gameengine/VideoTexture/ImageViewport.h b/source/gameengine/VideoTexture/ImageViewport.h index ccc58a41605..198655c6ebf 100644 --- a/source/gameengine/VideoTexture/ImageViewport.h +++ b/source/gameengine/VideoTexture/ImageViewport.h @@ -91,12 +91,12 @@ protected: GLint * getViewportSize (void) { return m_viewport + 2; } }; -PyObject * ImageViewport_getCaptureSize (PyImage * self, void * closure); -int ImageViewport_setCaptureSize (PyImage * self, PyObject * value, void * closure); -PyObject * ImageViewport_getWhole (PyImage * self, void * closure); -int ImageViewport_setWhole (PyImage * self, PyObject * value, void * closure); -PyObject * ImageViewport_getAlpha (PyImage * self, void * closure); -int ImageViewport_setAlpha (PyImage * self, PyObject * value, void * closure); +PyObject *ImageViewport_getCaptureSize (PyImage *self, void *closure); +int ImageViewport_setCaptureSize (PyImage *self, PyObject *value, void *closure); +PyObject *ImageViewport_getWhole (PyImage *self, void *closure); +int ImageViewport_setWhole (PyImage *self, PyObject *value, void *closure); +PyObject *ImageViewport_getAlpha (PyImage *self, void *closure); +int ImageViewport_setAlpha (PyImage *self, PyObject *value, void *closure); #endif diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp index ed53e8bd1f1..9fe98544961 100644 --- a/source/gameengine/VideoTexture/PyTypeList.cpp +++ b/source/gameengine/VideoTexture/PyTypeList.cpp @@ -41,7 +41,7 @@ PyTypeList::~PyTypeList() } /// check, if type is in list -bool PyTypeList::in (PyTypeObject * type) +bool PyTypeList::in (PyTypeObject *type) { // if list exists if (m_list.get() != NULL) @@ -54,7 +54,7 @@ bool PyTypeList::in (PyTypeObject * type) } /// add type to list -void PyTypeList::add (PyTypeObject * type, const char * name) +void PyTypeList::add (PyTypeObject *type, const char * name) { // if list doesn't exist, create it if (m_list.get() == NULL) @@ -78,7 +78,7 @@ bool PyTypeList::ready (void) } /// register types to module -void PyTypeList::reg (PyObject * module) +void PyTypeList::reg(PyObject *module) { // if list exists if (m_list.get() != NULL) @@ -88,6 +88,6 @@ void PyTypeList::reg (PyObject * module) // increase ref count Py_INCREF((*it)->getType()); // add type to module - PyModule_AddObject(module, (char*)(*it)->getName(), (PyObject*)(*it)->getType()); + PyModule_AddObject(module, (char*)(*it)->getName(), (PyObject *)(*it)->getType()); } } diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h index aa1df0ce54b..4872b3c3d5c 100644 --- a/source/gameengine/VideoTexture/PyTypeList.h +++ b/source/gameengine/VideoTexture/PyTypeList.h @@ -49,16 +49,16 @@ public: ~PyTypeList(); /// check, if type is in list - bool in (PyTypeObject * type); + bool in (PyTypeObject *type); /// add type to list - void add (PyTypeObject * type, const char * name); + void add (PyTypeObject *type, const char * name); /// prepare types bool ready (void); /// register types to module - void reg (PyObject * module); + void reg(PyObject *module); protected: /// pointer to list of types @@ -71,21 +71,21 @@ class PyTypeListItem { public: /// constructor adds type into list - PyTypeListItem (PyTypeObject * type, const char * name) + PyTypeListItem (PyTypeObject *type, const char * name) : m_type(type), m_name(name) { } /// does type match - PyTypeObject * getType (void) { return m_type; } + PyTypeObject *getType (void) { return m_type; } /// get name of type const char * getName (void) { return m_name; } protected: /// pointer to type object - PyTypeObject * m_type; + PyTypeObject *m_type; /// name of type - const char * m_name; + const char *m_name; }; diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index a21300018eb..f58d17f949c 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -108,7 +108,7 @@ RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID) } // get pointer to a lamp -KX_LightObject * getLamp(PyObject *obj) +static KX_LightObject *getLamp(PyObject *obj) { // if object is available if (obj == NULL) return NULL; @@ -119,7 +119,7 @@ KX_LightObject * getLamp(PyObject *obj) // get material ID -short getMaterialID(PyObject * obj, const char *name) +short getMaterialID(PyObject *obj, const char *name) { // search for material for (short matID = 0;; ++matID) @@ -147,7 +147,7 @@ short getMaterialID(PyObject * obj, const char *name) // Texture object allocation -PyObject * Texture_new (PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *Texture_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { // allocate object Texture * self = reinterpret_cast<Texture*>(type->tp_alloc(type, 0)); @@ -167,22 +167,22 @@ PyObject * Texture_new (PyTypeObject *type, PyObject *args, PyObject *kwds) // forward declaration -PyObject * Texture_close(Texture * self); -int Texture_setSource (Texture * self, PyObject * value, void * closure); +PyObject *Texture_close(Texture * self); +int Texture_setSource (Texture * self, PyObject *value, void *closure); // Texture object deallocation -void Texture_dealloc (Texture * self) +static void Texture_dealloc(Texture *self) { // release renderer Py_XDECREF(self->m_source); // close texture - PyObject* ret = Texture_close(self); + PyObject *ret = Texture_close(self); Py_DECREF(ret); // release scaled image buffer delete [] self->m_scaledImg; // release object - Py_TYPE((PyObject *)self)->tp_free((PyObject*)self); + Py_TYPE((PyObject *)self)->tp_free((PyObject *)self); } @@ -190,10 +190,10 @@ ExceptionID MaterialNotAvail; ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is not available"); // Texture object initialization -int Texture_init (Texture *self, PyObject *args, PyObject *kwds) +static int Texture_init(Texture *self, PyObject *args, PyObject *kwds) { // parameters - game object with video texture - PyObject * obj = NULL; + PyObject *obj = NULL; // material ID short matID = 0; // texture ID @@ -275,7 +275,7 @@ int Texture_init (Texture *self, PyObject *args, PyObject *kwds) // close added texture -PyObject * Texture_close(Texture * self) +PyObject *Texture_close(Texture * self) { // restore texture if (self->m_orgSaved) @@ -298,10 +298,10 @@ PyObject * Texture_close(Texture * self) // refresh texture -PyObject * Texture_refresh (Texture * self, PyObject * args) +static PyObject *Texture_refresh(Texture *self, PyObject *args) { // get parameter - refresh source - PyObject * param; + PyObject *param; double ts = -1.0; if (!PyArg_ParseTuple(args, "O|d:refresh", ¶m, &ts) || !PyBool_Check(param)) @@ -390,14 +390,14 @@ PyObject * Texture_refresh (Texture * self, PyObject * args) } // get OpenGL Bind Id -PyObject * Texture_getBindId (Texture * self, void * closure) +static PyObject *Texture_getBindId(Texture *self, void *closure) { unsigned int id = self->m_actTex; return Py_BuildValue("h", id); } // get mipmap value -PyObject * Texture_getMipmap (Texture * self, void * closure) +static PyObject *Texture_getMipmap(Texture *self, void *closure) { // return true if flag is set, otherwise false if (self->m_mipmap) Py_RETURN_TRUE; @@ -405,7 +405,7 @@ PyObject * Texture_getMipmap (Texture * self, void * closure) } // set mipmap value -int Texture_setMipmap (Texture * self, PyObject * value, void * closure) +static int Texture_setMipmap(Texture *self, PyObject *value, void *closure) { // check parameter, report failure if (value == NULL || !PyBool_Check(value)) @@ -421,7 +421,7 @@ int Texture_setMipmap (Texture * self, PyObject * value, void * closure) // get source object -PyObject * Texture_getSource (Texture * self, PyObject * value, void * closure) +static PyObject *Texture_getSource(Texture *self, PyObject *value, void *closure) { // if source exists if (self->m_source != NULL) @@ -435,7 +435,7 @@ PyObject * Texture_getSource (Texture * self, PyObject * value, void * closure) // set source object -int Texture_setSource (Texture * self, PyObject * value, void * closure) +int Texture_setSource (Texture * self, PyObject *value, void *closure) { // check new value if (value == NULL || !pyImageTypes.in(Py_TYPE(value))) diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index ad5b7b9fb44..cc265725b29 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -78,14 +78,14 @@ struct Texture extern PyTypeObject TextureType; // load texture -void loadTexture (unsigned int texId, unsigned int * texture, short * size, - bool mipmap = false); +void loadTexture(unsigned int texId, unsigned int *texture, short *size, + bool mipmap = false); // get material -RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID); +RAS_IPolyMaterial *getMaterial(PyObject *obj, short matID); // get material ID -short getMaterialID (PyObject * obj, const char *name); +short getMaterialID(PyObject *obj, const char *name); // Exceptions extern ExceptionID MaterialNotAvail; diff --git a/source/gameengine/VideoTexture/VideoBase.cpp b/source/gameengine/VideoTexture/VideoBase.cpp index 6662df8d7d1..1eb2e830d37 100644 --- a/source/gameengine/VideoTexture/VideoBase.cpp +++ b/source/gameengine/VideoTexture/VideoBase.cpp @@ -116,24 +116,24 @@ void Video_open (VideoBase * self, char * file, short captureID) // play video -PyObject * Video_play (PyImage * self) +PyObject *Video_play(PyImage *self) { if (getVideo(self)->play()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } // pause video -PyObject * Video_pause (PyImage * self) +PyObject *Video_pause(PyImage *self) { if (getVideo(self)->pause()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } -PyObject * Video_stop (PyImage * self) +PyObject *Video_stop(PyImage *self) { if (getVideo(self)->stop()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } // get status -PyObject * Video_getStatus (PyImage * self, void * closure) +PyObject *Video_getStatus(PyImage *self, void *closure) { return Py_BuildValue("h", getVideo(self)->getStatus()); } // refresh video -PyObject * Video_refresh (PyImage * self) +PyObject *Video_refresh(PyImage *self) { getVideo(self)->refresh(); return Video_getStatus(self, NULL); @@ -141,19 +141,20 @@ PyObject * Video_refresh (PyImage * self) // get range -PyObject * Video_getRange (PyImage * self, void * closure) +PyObject *Video_getRange(PyImage *self, void *closure) { return Py_BuildValue("[ff]", getVideo(self)->getRange()[0], getVideo(self)->getRange()[1]); } // set range -int Video_setRange (PyImage * self, PyObject * value, void * closure) +int Video_setRange(PyImage *self, PyObject *value, void *closure) { // check validity of parameter - if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2 - || !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0)) - || !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1))) + if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2 || + /* XXX - this is incorrect if the sequence is not a list/tuple! */ + !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0)) || + !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1))) { PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 float"); return -1; @@ -166,11 +167,11 @@ int Video_setRange (PyImage * self, PyObject * value, void * closure) } // get repeat -PyObject * Video_getRepeat (PyImage * self, void * closure) +PyObject *Video_getRepeat (PyImage *self, void *closure) { return Py_BuildValue("h", getVideo(self)->getRepeat()); } // set repeat -int Video_setRepeat (PyImage * self, PyObject * value, void * closure) +int Video_setRepeat(PyImage *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PyLong_Check(value)) @@ -185,11 +186,11 @@ int Video_setRepeat (PyImage * self, PyObject * value, void * closure) } // get frame rate -PyObject * Video_getFrameRate (PyImage * self, void * closure) +PyObject *Video_getFrameRate (PyImage *self, void *closure) { return Py_BuildValue("f", double(getVideo(self)->getFrameRate())); } // set frame rate -int Video_setFrameRate (PyImage * self, PyObject * value, void * closure) +int Video_setFrameRate(PyImage *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PyFloat_Check(value)) diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h index e221d876358..4cf913d755d 100644 --- a/source/gameengine/VideoTexture/VideoBase.h +++ b/source/gameengine/VideoTexture/VideoBase.h @@ -164,14 +164,14 @@ protected: // cast Image pointer to Video -inline VideoBase * getVideo (PyImage * self) +inline VideoBase *getVideo(PyImage *self) { return static_cast<VideoBase*>(self->m_image); } extern ExceptionID SourceVideoCreation; // object initialization -template <class T> void Video_init (PyImage * self) +template <class T> void Video_init(PyImage *self) { // create source video object if (self->m_image != NULL) delete self->m_image; @@ -182,18 +182,18 @@ template <class T> void Video_init (PyImage * self) // video functions -void Video_open (VideoBase * self, char * file, short captureID); -PyObject * Video_play (PyImage * self); -PyObject * Video_pause (PyImage * self); -PyObject * Video_stop (PyImage * self); -PyObject * Video_refresh (PyImage * self); -PyObject * Video_getStatus (PyImage * self, void * closure); -PyObject * Video_getRange (PyImage * self, void * closure); -int Video_setRange (PyImage * self, PyObject * value, void * closure); -PyObject * Video_getRepeat (PyImage * self, void * closure); -int Video_setRepeat (PyImage * self, PyObject * value, void * closure); -PyObject * Video_getFrameRate (PyImage * self, void * closure); -int Video_setFrameRate (PyImage * self, PyObject * value, void * closure); +void Video_open(VideoBase * self, char * file, short captureID); +PyObject *Video_play(PyImage *self); +PyObject *Video_pause(PyImage *self); +PyObject *Video_stop(PyImage *self); +PyObject *Video_refresh(PyImage *self); +PyObject *Video_getStatus(PyImage *self, void *closure); +PyObject *Video_getRange(PyImage *self, void *closure); +int Video_setRange(PyImage *self, PyObject *value, void *closure); +PyObject *Video_getRepeat(PyImage *self, void *closure); +int Video_setRepeat(PyImage *self, PyObject *value, void *closure); +PyObject *Video_getFrameRate(PyImage *self, void *closure); +int Video_setFrameRate(PyImage *self, PyObject *value, void *closure); #endif diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 1ba944aa955..cf65362c31d 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -524,7 +524,7 @@ void VideoFFmpeg::openFile (char * filename) if (m_codecCtx->gop_size) m_preseek = (m_codecCtx->gop_size < 25) ? m_codecCtx->gop_size+1 : 25; - else if (m_codecCtx->has_b_frames) + else if (m_codecCtx->has_b_frames) m_preseek = 25; // should determine gopsize else m_preseek = 0; @@ -1076,14 +1076,14 @@ AVFrame *VideoFFmpeg::grabFrame(long position) // cast Image pointer to VideoFFmpeg -inline VideoFFmpeg * getVideoFFmpeg (PyImage * self) +inline VideoFFmpeg * getVideoFFmpeg (PyImage *self) { return static_cast<VideoFFmpeg*>(self->m_image); } // object initialization -static int VideoFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +static int VideoFFmpeg_init (PyObject *pySelf, PyObject *args, PyObject *kwds) { - PyImage * self = reinterpret_cast<PyImage*>(pySelf); + PyImage *self = reinterpret_cast<PyImage*>(pySelf); // parameters - video source // file name or format type for capture (only for Linux: video4linux or dv1394) char * file = NULL; @@ -1123,13 +1123,13 @@ static int VideoFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds return 0; } -PyObject * VideoFFmpeg_getPreseek (PyImage *self, void * closure) +static PyObject *VideoFFmpeg_getPreseek(PyImage *self, void *closure) { return Py_BuildValue("h", getFFmpeg(self)->getPreseek()); } // set range -int VideoFFmpeg_setPreseek (PyImage * self, PyObject * value, void * closure) +static int VideoFFmpeg_setPreseek(PyImage *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !PyLong_Check(value)) @@ -1144,7 +1144,7 @@ int VideoFFmpeg_setPreseek (PyImage * self, PyObject * value, void * closure) } // get deinterlace -PyObject * VideoFFmpeg_getDeinterlace (PyImage * self, void * closure) +static PyObject *VideoFFmpeg_getDeinterlace(PyImage *self, void *closure) { if (getFFmpeg(self)->getDeinterlace()) Py_RETURN_TRUE; @@ -1153,7 +1153,7 @@ PyObject * VideoFFmpeg_getDeinterlace (PyImage * self, void * closure) } // set flip -int VideoFFmpeg_setDeinterlace (PyImage * self, PyObject * value, void * closure) +static int VideoFFmpeg_setDeinterlace(PyImage *self, PyObject *value, void *closure) { // check parameter, report failure if (value == NULL || !PyBool_Check(value)) @@ -1239,9 +1239,9 @@ PyTypeObject VideoFFmpegType = }; // object initialization -static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +static int ImageFFmpeg_init (PyObject *pySelf, PyObject *args, PyObject *kwds) { - PyImage * self = reinterpret_cast<PyImage*>(pySelf); + PyImage *self = reinterpret_cast<PyImage*>(pySelf); // parameters - video source // file name or format type for capture (only for Linux: video4linux or dv1394) char * file = NULL; @@ -1269,7 +1269,7 @@ static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds return 0; } -PyObject * Image_reload (PyImage * self, PyObject *args) +static PyObject *Image_reload(PyImage *self, PyObject *args) { char * newname = NULL; if (!PyArg_ParseTuple(args, "|s:reload", &newname)) diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index e63032e0c66..cd0edfc09ef 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -204,7 +204,7 @@ private: static void *cacheThread(void *); }; -inline VideoFFmpeg * getFFmpeg (PyImage * self) +inline VideoFFmpeg *getFFmpeg(PyImage *self) { return static_cast<VideoFFmpeg*>(self->m_image); } diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 627da57baac..dd9d83c043f 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -26,6 +26,8 @@ http://www.gnu.org/copyleft/lesser.txt. #include "PyObjectPlus.h" +#include "KX_PythonInit.h" + #include <RAS_GLExtensionManager.h> #include <RAS_IPolygonMaterial.h> @@ -46,10 +48,10 @@ http://www.gnu.org/copyleft/lesser.txt. // get material id -static PyObject * getMaterialID (PyObject *self, PyObject *args) +static PyObject *getMaterialID (PyObject *self, PyObject *args) { // parameters - game object with video texture - PyObject * obj = NULL; + PyObject *obj = NULL; // material name char * matName; @@ -70,13 +72,13 @@ static PyObject * getMaterialID (PyObject *self, PyObject *args) // get last error description -static PyObject * getLastError (PyObject *self, PyObject *args) +static PyObject *getLastError (PyObject *self, PyObject *args) { return PyUnicode_FromString(Exception::m_lastError.c_str()); } // set log file -static PyObject * setLogFile (PyObject *self, PyObject *args) +static PyObject *setLogFile (PyObject *self, PyObject *args) { // get parameters if (!PyArg_ParseTuple(args, "s:setLogFile", &Exception::m_logFile)) @@ -87,10 +89,10 @@ static PyObject * setLogFile (PyObject *self, PyObject *args) // image to numpy array -static PyObject * imageToArray (PyObject * self, PyObject *args) +static PyObject *imageToArray(PyObject *self, PyObject *args) { // parameter is Image object - PyObject * pyImg; + PyObject *pyImg; char *mode = NULL; if (!PyArg_ParseTuple(args, "O|s:imageToArray", &pyImg, &mode) || !pyImageTypes.in(Py_TYPE(pyImg))) { @@ -168,9 +170,9 @@ static struct PyModuleDef VideoTexture_module_def = { 0, /* m_free */ }; -PyObject* initVideoTexture(void) +PyObject *initVideoTexture(void) { - PyObject * m; + PyObject *m; // initialize GL extensions //bgl::InitExtensions(0); @@ -208,7 +210,7 @@ PyObject* initVideoTexture(void) pyFilterTypes.reg(m); Py_INCREF(&TextureType); - PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType); + PyModule_AddObject(m, (char*)"Texture", (PyObject *)&TextureType); PyModule_AddIntConstant(m, (char*)"SOURCE_ERROR", SourceError); PyModule_AddIntConstant(m, (char*)"SOURCE_EMPTY", SourceEmpty); PyModule_AddIntConstant(m, (char*)"SOURCE_READY", SourceReady); diff --git a/source/tests/bl_rna_wiki_reference.py b/source/tests/bl_rna_wiki_reference.py index 2018c4327a3..a4019214138 100644 --- a/source/tests/bl_rna_wiki_reference.py +++ b/source/tests/bl_rna_wiki_reference.py @@ -21,15 +21,30 @@ # Use for validating our wiki interlinking. # ./blender.bin --background -noaudio --python source/tests/bl_rna_wiki_reference.py # -# 1) test_lookup_coverage() -- ensure that we have lookups for _every_ RNA path -# 2) test_urls() -- ensure all the URL's are correct -# 3) test_language_coverage() -- ensure language lookup table is complete +# 1) test_data() -- ensure the data we have is correct format +# 2) test_lookup_coverage() -- ensure that we have lookups for _every_ RNA path +# 3) test_urls() -- ensure all the URL's are correct +# 4) test_language_coverage() -- ensure language lookup table is complete # import bpy -# a stripped down version of api_dump() in rna_info_dump.py +def test_data(): + import rna_wiki_reference + + assert(isinstance(rna_wiki_reference.url_manual_mapping, tuple)) + for i, value in enumerate(rna_wiki_reference.url_manual_mapping): + try: + assert(len(value) == 2) + assert(isinstance(value[0], str)) + assert(isinstance(value[1], str)) + except: + print("Expected a tuple of 2 strings, instead item %d is a %s: %r" % (i, type(value), value)) + import traceback + traceback.print_exc() + raise +# a stripped down version of api_dump() in rna_info_dump.py def test_lookup_coverage(): @@ -39,20 +54,37 @@ def test_lookup_coverage(): struct = rna_info.BuildRNAInfo()[0] for struct_id, v in sorted(struct.items()): props = [(prop.identifier, prop) for prop in v.properties] + struct_path = "bpy.types.%s" % struct_id[1] for prop_id, prop in props: - yield "bpy.types.%s.%s" % (struct_id[1], prop_id) + yield (struct_path, "%s.%s" % (struct_path, prop_id)) for submod_id in dir(bpy.ops): + op_path = "bpy.ops.%s" % submod_id for op_id in dir(getattr(bpy.ops, submod_id)): - yield "bpy.ops.%s.%s" % (submod_id, op_id) + yield (op_path, "%s.%s" % (op_path, op_id)) # check coverage from bl_operators import wm - for rna_id in rna_ids(): + set_group_all = set() + set_group_doc = set() + + for rna_group, rna_id in rna_ids(): url = wm.WM_OT_doc_view_manual._lookup_rna_url(rna_id, verbose=False) print(rna_id, "->", url) + set_group_all.add(rna_group) + if url is not None: + set_group_doc.add(rna_group) + + # finally report undocumented groups + print("") + print("---------------------") + print("Undocumented Sections") + + for rna_group in sorted(set_group_all): + if rna_group not in set_group_doc: + print("%s.*" % rna_group) def test_urls(): pass # TODO @@ -63,6 +95,7 @@ def test_language_coverage(): def main(): + test_data() test_lookup_coverage() test_language_coverage() diff --git a/source/tests/bl_run_operators.py b/source/tests/bl_run_operators.py index 53cc37bc02b..146b60b8f28 100644 --- a/source/tests/bl_run_operators.py +++ b/source/tests/bl_run_operators.py @@ -44,7 +44,7 @@ op_blacklist = ( "help.operator_cheat_sheet", "wm.keyconfig_test", # just annoying - but harmless "wm.memory_statistics", # another annoying one - # "mesh.vertex_color_remove", #crashes! fixme + "console.*", # just annoying - but harmless ) @@ -61,7 +61,7 @@ def filter_op_list(operators): operators[:] = [op for op in operators if is_op_ok(op[0])] -def run_ops(operators, setup_func=None): +def run_ops(operators, setup_func=None, reset=True): print("\ncontext:", setup_func.__name__) # first invoke for op_id, op in operators: @@ -70,7 +70,8 @@ def run_ops(operators, setup_func=None): sys.stdout.flush() # in case of crash # disable will get blender in a bad state and crash easy! - bpy.ops.wm.read_factory_settings() + if reset: + bpy.ops.wm.read_factory_settings() setup_func() @@ -82,6 +83,11 @@ def run_ops(operators, setup_func=None): #traceback.print_exc() pass + if not operators: + # run test + if reset: + bpy.ops.wm.read_factory_settings() + setup_func() # contexts def ctx_clear_scene(): # copied from batch_import.py @@ -99,7 +105,23 @@ def ctx_clear_scene(): # copied from batch_import.py def ctx_editmode_mesh(): bpy.ops.object.mode_set(mode='EDIT') + + +def ctx_editmode_mesh_extra(): bpy.ops.object.vertex_group_add() + bpy.ops.object.shape_key_add(from_mix=False) + bpy.ops.object.shape_key_add(from_mix=True) + bpy.ops.mesh.uv_texture_add() + bpy.ops.mesh.vertex_color_add() + bpy.ops.object.material_slot_add() + # editmode last! + bpy.ops.object.mode_set(mode='EDIT') + + +def ctx_editmode_mesh_empty(): + bpy.ops.object.mode_set(mode='EDIT') + bpy.ops.mesh.select_all(action='SELECT') + bpy.ops.mesh.delete() def ctx_editmode_curves(): @@ -107,6 +129,12 @@ def ctx_editmode_curves(): bpy.ops.object.mode_set(mode='EDIT') +def ctx_editmode_curves_empty(): + bpy.ops.curve.primitive_nurbs_circle_add() + bpy.ops.object.mode_set(mode='EDIT') + bpy.ops.curve.delete(type='ALL') + + def ctx_editmode_surface(): bpy.ops.surface.primitive_nurbs_surface_torus_add() bpy.ops.object.mode_set(mode='EDIT') @@ -127,6 +155,13 @@ def ctx_editmode_armature(): bpy.ops.object.mode_set(mode='EDIT') +def ctx_editmode_armature_empty(): + bpy.ops.object.armature_add() + bpy.ops.object.mode_set(mode='EDIT') + bpy.ops.armature.select_all(action='SELECT') + bpy.ops.armature.delete() + + def ctx_editmode_lattice(): bpy.ops.object.add(type='LATTICE') bpy.ops.object.mode_set(mode='EDIT') @@ -137,10 +172,28 @@ def ctx_object_empty(): bpy.ops.object.add(type='EMPTY') -def ctx_weightpaint(): +def ctx_object_pose(): + bpy.ops.object.armature_add() + bpy.ops.object.mode_set(mode='POSE') + bpy.ops.pose.select_all(action='SELECT') + + +def ctx_object_paint_weight(): bpy.ops.object.mode_set(mode='WEIGHT_PAINT') +def ctx_object_paint_vertex(): + bpy.ops.object.mode_set(mode='VERTEX_PAINT') + + +def ctx_object_paint_sculpt(): + bpy.ops.object.mode_set(mode='SCULPT') + + +def ctx_object_paint_texture(): + bpy.ops.object.mode_set(mode='TEXTURE_PAINT') + + def bpy_check_type_duplicates(): # non essential sanity check bl_types = dir(bpy.types) @@ -178,21 +231,39 @@ def main(): #import random #random.shuffle(operators) - - # Run the operator tests in different contexts - run_ops(operators, setup_func=lambda: None) - run_ops(operators, setup_func=ctx_editmode_surface) - run_ops(operators, setup_func=ctx_object_empty) - run_ops(operators, setup_func=ctx_editmode_armature) - run_ops(operators, setup_func=ctx_editmode_mesh) - run_ops(operators, setup_func=ctx_clear_scene) - run_ops(operators, setup_func=ctx_editmode_curves) - run_ops(operators, setup_func=ctx_editmode_mball) - run_ops(operators, setup_func=ctx_editmode_text) - run_ops(operators, setup_func=ctx_weightpaint) - run_ops(operators, setup_func=ctx_editmode_lattice) - - print("finished") + + # 2 passes, first just run setup_func to make sure they are ok + for operators_test in ((), operators): + # Run the operator tests in different contexts + run_ops(operators_test, setup_func=lambda: None) + run_ops(operators_test, setup_func=ctx_clear_scene) + # object modes + run_ops(operators_test, setup_func=ctx_object_empty) + run_ops(operators_test, setup_func=ctx_object_pose) + run_ops(operators_test, setup_func=ctx_object_paint_weight) + run_ops(operators_test, setup_func=ctx_object_paint_vertex) + run_ops(operators_test, setup_func=ctx_object_paint_sculpt) + run_ops(operators_test, setup_func=ctx_object_paint_texture) + # mesh + run_ops(operators_test, setup_func=ctx_editmode_mesh) + run_ops(operators_test, setup_func=ctx_editmode_mesh_extra) + run_ops(operators_test, setup_func=ctx_editmode_mesh_empty) + # armature + run_ops(operators_test, setup_func=ctx_editmode_armature) + run_ops(operators_test, setup_func=ctx_editmode_armature_empty) + # curves + run_ops(operators_test, setup_func=ctx_editmode_curves) + run_ops(operators_test, setup_func=ctx_editmode_curves_empty) + run_ops(operators_test, setup_func=ctx_editmode_surface) + # other + run_ops(operators_test, setup_func=ctx_editmode_mball) + run_ops(operators_test, setup_func=ctx_editmode_text) + run_ops(operators_test, setup_func=ctx_editmode_lattice) + + if not operators_test: + print("All setup functions run fine!") + + print("Finished %r" % __file__) if __name__ == "__main__": main() |