diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-07-14 03:23:06 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-07-14 03:23:06 +0400 |
commit | 065605e0da8ecd7add39f159db624ae9063ec476 (patch) | |
tree | 46cb2051e28dcef4a04a998e2d9ef82a7b36ecfa /source/blender | |
parent | b7b50298148ef502d14143b0a5fa01dfac2ecce4 (diff) | |
parent | 807ad1f0e0de49711d58ade2b660e74ec5452b2b (diff) |
Merged changes in the trunk up to revision 48893.
Conflicts resolved:
source/blender/blenkernel/CMakeLists.txt
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_filter.c
source/blender/makesrna/RNA_enum_types.h
Diffstat (limited to 'source/blender')
570 files changed, 8181 insertions, 4949 deletions
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index 3d04db56d43..cceba82aca7 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -870,7 +870,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) } } else if (movie->streams[i].sh.Type == FCC("auds")) { - // pass + /* pass */ } #endif } diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 18932ffdac8..364d5f90af3 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -40,10 +40,10 @@ void BLF_exit(void); void BLF_cache_clear(void); int BLF_load(const char *name); -int BLF_load_mem(const char *name, unsigned char *mem, int mem_size); +int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size); int BLF_load_unique(const char *name); -int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size); +int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size); void BLF_unload(const char *name); diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index 2c786f87521..56eabf4bb43 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -54,6 +54,8 @@ void BLF_lang_init(void); /* Set the current locale. */ void BLF_lang_set(const char *); +/* Get the current locale (short code, e.g. es_ES). */ +const char *BLF_lang_get(void); /* Set the current encoding name. */ void BLF_lang_encoding(const char *str); diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 70794a11ff2..683ef3f821c 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -227,7 +227,7 @@ void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size) } } -int BLF_load_mem(const char *name, unsigned char *mem, int mem_size) +int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) { FontBLF *font; int i; @@ -262,7 +262,7 @@ int BLF_load_mem(const char *name, unsigned char *mem, int mem_size) return i; } -int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size) +int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) { FontBLF *font; int i; diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 6ab942f4e4d..945565e22a9 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -560,12 +560,12 @@ void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_s FT_Open_Args open; open.flags = FT_OPEN_MEMORY; - open.memory_base = (FT_Byte *)mem; + open.memory_base = (const FT_Byte *)mem; open.memory_size = mem_size; FT_Attach_Stream(font->face, &open); } -FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_size) +FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size) { FontBLF *font; FT_Error err; diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index f43fa8a7458..ba66fce8374 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -47,7 +47,7 @@ int blf_font_init(void); void blf_font_exit(void); struct FontBLF *blf_font_new(const char *name, const char *filename); -struct FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_size); +struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size); 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); diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 88d34b5e36f..9e8884ad94d 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -112,7 +112,8 @@ static const char *locales[] = { void BLF_lang_init(void) { char *messagepath = BLI_get_folder(BLENDER_DATAFILES, "locale"); - +/* printf("%s\n", messagepath);*/ + BLI_strncpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT, sizeof(global_encoding_name)); if (messagepath) { @@ -276,6 +277,11 @@ void BLF_lang_set(const char *str) bind_textdomain_codeset(TEXT_DOMAIN_NAME, global_encoding_name); } +const char *BLF_lang_get(void) +{ + return locales[2 * U.language + 1]; +} + void BLF_lang_encoding(const char *str) { BLI_strncpy(global_encoding_name, str, sizeof(global_encoding_name)); @@ -301,4 +307,9 @@ void BLF_lang_set(const char *str) return; } +const char *BLF_lang_get(void) +{ + return ""; +} + #endif /* WITH_INTERNATIONAL */ diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 171b62461a0..48c7103d8fd 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 13 +#define BLENDER_SUBVERSION 14 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 2436ada9eaf..3cf4a2c5cdc 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -60,15 +60,33 @@ typedef union IDPropertyTemplate { /* note: as a start to move away from the stupid IDP_New function, this type * has it's own allocation function.*/ -IDProperty *IDP_NewIDPArray(const char *name); -IDProperty *IDP_CopyIDPArray(IDProperty *array); +IDProperty *IDP_NewIDPArray(const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +IDProperty *IDP_CopyIDPArray(IDProperty *array) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; void IDP_FreeIDPArray(IDProperty *prop); /* shallow copies item */ void IDP_SetIndexArray(struct IDProperty *prop, int index, struct IDProperty *item); -struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index); -struct IDProperty *IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item); +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +void IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item); void IDP_ResizeIDPArray(struct IDProperty *prop, int len); /* ----------- Numeric Array Type ----------- */ @@ -77,11 +95,33 @@ void IDP_ResizeArray(struct IDProperty *prop, int newlen); void IDP_FreeArray(struct IDProperty *prop); /* ---------- String Type ------------ */ -IDProperty *IDP_NewString(const char *st, const char *name, int maxlen); /* maxlen excludes '\0' */ -void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen); /* maxlen excludes '\0' */ -void IDP_ConcatStringC(struct IDProperty *prop, const char *st); -void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append); -void IDP_FreeString(struct IDProperty *prop); +IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) /* maxlen excludes '\0' */ +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull (2))) /* 'name' arg */ +#endif +; + +void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen) /* maxlen excludes '\0' */ +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; +void IDP_ConcatStringC(struct IDProperty *prop, const char *st) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; +void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; +void IDP_FreeString(struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /*-------- ID Type -------*/ void IDP_LinkID(struct IDProperty *prop, ID *id); @@ -90,17 +130,29 @@ void IDP_UnlinkID(struct IDProperty *prop); /*-------- Group Functions -------*/ /** Sync values from one group to another, only where they match */ -void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src); +void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** * replaces all properties with the same name in a destination group from a source group. */ -void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src); +void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** * Checks if a property with the same name as prop exists, and if so replaces it. * Use this to preserve order!*/ -void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop); +void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** * This function has a sanity check to make sure ID properties with the same name don't @@ -117,12 +169,20 @@ void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop); * struct. In the future this will just be IDP_FreeProperty and the code will * be reorganized to work properly. */ -int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop); +int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** this is the same as IDP_AddToGroup, only you pass an item * in the group list to be inserted after. */ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, - struct IDProperty *pnew); + struct IDProperty *pnew) +#ifdef __GNUC__ +__attribute__((nonnull (1, 3))) /* 'group', 'pnew' */ +#endif +; /** \note this does not free the property!! * @@ -130,18 +190,36 @@ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, * IDP_FreeProperty(prop); //free all subdata * MEM_freeN(prop); //free property struct itself */ -void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop); +void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; -IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name); +IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** same as above but ensure type match */ -IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type); +IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Get an iterator to iterate over the members of an id property group. * Note that this will automatically free the iterator once iteration is complete; * if you stop the iteration before hitting the end, make sure to call * IDP_FreeIterBeforeEnd(). */ -void *IDP_GetGroupIterator(struct IDProperty *prop); +void *IDP_GetGroupIterator(struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +#endif +; /** * Returns the next item in the iteration. To use, simple for a loop like the following: @@ -149,21 +227,44 @@ void *IDP_GetGroupIterator(struct IDProperty *prop); * ... * } */ -IDProperty *IDP_GroupIterNext(void *vself); +IDProperty *IDP_GroupIterNext(void *vself) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Frees the iterator pointed to at vself, only use this if iteration is stopped early; * when the iterator hits the end of the list it'll automatically free itself.*/ -void IDP_FreeIterBeforeEnd(void *vself); +void IDP_FreeIterBeforeEnd(void *vself) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /*-------- Main Functions --------*/ /** Get the Group property that contains the id properties for ID id. Set create_if_needed * to create the Group property and attach it to id if it doesn't exist; otherwise * the function will return NULL if there's no Group property attached to the ID.*/ -struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed); -struct IDProperty *IDP_CopyProperty(struct IDProperty *prop); +struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +struct IDProperty *IDP_CopyProperty(struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; -int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2); +int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +#endif +; /** * Allocate a new ID. @@ -190,7 +291,12 @@ int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2); * IDP_AddToGroup or MEM_freeN the property, doing anything else might result in * a memory leak. */ -struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name); +struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** \note this will free all child properties of list arrays and groups! * Also, note that this does NOT unlink anything! Plus it doesn't free diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h index f9137e50d74..3acd4d1986e 100644 --- a/source/blender/blenkernel/BKE_lamp.h +++ b/source/blender/blenkernel/BKE_lamp.h @@ -38,9 +38,9 @@ extern "C" { struct Lamp; -void *BKE_lamp_add(const char *name); -struct Lamp *BKE_lamp_copy(struct Lamp *la); -struct Lamp *localize_lamp(struct Lamp *la); +struct Lamp *BKE_lamp_add(const char *name) WARN_UNUSED; +struct Lamp *BKE_lamp_copy(struct Lamp *la) WARN_UNUSED; +struct Lamp *localize_lamp(struct Lamp *la) WARN_UNUSED; void BKE_lamp_make_local(struct Lamp *la); void BKE_lamp_free(struct Lamp *la); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 3248944dae8..91756448297 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -45,8 +45,18 @@ struct bContext; struct PointerRNA; struct PropertyRNA; -void *BKE_libblock_alloc(struct ListBase *lb, short type, const char *name); -void *BKE_libblock_copy(struct ID *id); +void *BKE_libblock_alloc(struct ListBase *lb, short type, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +void *BKE_libblock_copy(struct ID *id) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const short do_action); void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id); @@ -82,7 +92,12 @@ void name_uiprefix_id(char *name, struct ID *id); void test_idbutton(char *name); void text_idbutton(struct ID *id, char *text); void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only); -struct ID *BKE_libblock_find_name(const short type, const char *name); +struct ID *BKE_libblock_find_name(const short type, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; void clear_id_newpoins(void); void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index ee7c13ba7cb..50d8576dd91 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -64,12 +64,15 @@ void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, struct ListBase * /* splines */ struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay); +int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, const int resol); + float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2]; float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2]; +float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, const int resol, int *tot_diff_point))[2]; float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2]; -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, - int width, int height, int *tot_feather_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, const int resol, int *tot_feather_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_feather_point))[2]; float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]; @@ -184,6 +187,12 @@ void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer, const short do_aspect_correct, const short do_mask_aa, const short do_feather); +/* initialization for tiling */ +#ifdef __PLX_RASKTER_MT__ +void BKE_mask_init_layers(Mask *mask, struct layer_init_data *mlayer_data, int width, int height, + const short do_aspect_correct); +#endif + #define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & 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) ) @@ -196,4 +205,21 @@ void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer, #define MASKPOINT_SEL_HANDLE(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0 #define MASKPOINT_DESEL_HANDLE(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0 -#endif +/* disable to test alternate rasterizer */ +#define USE_RASKTER + +/* mask_rasterize.c */ +#ifndef USE_RASKTER +struct MaskRasterHandle; +typedef struct MaskRasterHandle MaskRasterHandle; + +MaskRasterHandle *BLI_maskrasterize_handle_new(void); +void BLI_maskrasterize_handle_free(MaskRasterHandle *mr_handle); +void BLI_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mask, + const int width, const int height, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather); +float BLI_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2]); +#endif /* USE_RASKTER */ + +#endif /* __BKE_MASK_H__ */ diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index b3f17c06d5c..7bd9f75b2dd 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -660,6 +660,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat); #define CMP_NODE_MASK 268 #define CMP_NODE_KEYINGSCREEN 269 #define CMP_NODE_KEYING 270 +#define CMP_NODE_TRACKPOS 271 #define CMP_NODE_GLARE 301 #define CMP_NODE_TONEMAP 302 diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 723a0e32605..1bafc023740 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -103,6 +103,7 @@ set(SRC intern/lattice.c intern/library.c intern/linestyle.c + intern/mask_rasterize.c intern/mask.c intern/material.c intern/mball.c diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 35bf4c0961f..c456840637a 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -2210,7 +2210,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataAdd(co, r, ss); } - // edge flags cleared later + /* edge flags cleared later */ } for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { CCGVert *v = effectedV[ptrIdx]; @@ -2337,7 +2337,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataAdd(nCo, r, ss); } - // vert flags cleared later + /* vert flags cleared later */ } if (ss->useAgeCounts) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3f28a4afe8d..120a0b2ba27 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -74,7 +74,7 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm); #endif -#include "BLO_sys_types.h" // for intptr_t support +#include "BLO_sys_types.h" /* for intptr_t support */ #include "GL/glew.h" @@ -956,22 +956,22 @@ void weight_to_rgb(float r_rgb[3], const float weight) { const float blend = ((weight / 2.0f) + 0.5f); - if (weight <= 0.25f) { // blue->cyan + if (weight <= 0.25f) { /* blue->cyan */ r_rgb[0] = 0.0f; r_rgb[1] = blend * weight * 4.0f; r_rgb[2] = blend; } - else if (weight <= 0.50f) { // cyan->green + else if (weight <= 0.50f) { /* cyan->green */ r_rgb[0] = 0.0f; r_rgb[1] = blend; r_rgb[2] = blend * (1.0f - ((weight - 0.25f) * 4.0f)); } - else if (weight <= 0.75f) { // green->yellow + else if (weight <= 0.75f) { /* green->yellow */ r_rgb[0] = blend * ((weight - 0.50f) * 4.0f); r_rgb[1] = blend; r_rgb[2] = 0.0f; } - else if (weight <= 1.0f) { // yellow->red + else if (weight <= 1.0f) { /* yellow->red */ r_rgb[0] = blend; r_rgb[1] = blend * (1.0f - ((weight - 0.75f) * 4.0f)); r_rgb[2] = 0.0f; @@ -2379,16 +2379,16 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob) typedef struct { float *precomputedFaceNormals; - MTFace *mtface; // texture coordinates - MFace *mface; // indices - MVert *mvert; // vertices & normals + MTFace *mtface; /* texture coordinates */ + MFace *mface; /* indices */ + MVert *mvert; /* vertices & normals */ float (*orco)[3]; - float (*tangent)[4]; // destination + float (*tangent)[4]; /* destination */ int numTessFaces; } SGLSLMeshToTangent; -// interface +/* interface */ #include "mikktspace.h" static int GetNumFaces(const SMikkTSpaceContext *pContext) @@ -2508,7 +2508,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) BLI_memarena_use_calloc(arena); vtangents = MEM_callocN(sizeof(VertexTangent *) * totvert, "VertexTangent"); - // new computation method + /* new computation method */ iCalcNewMethod = 1; if (iCalcNewMethod != 0) { SGLSLMeshToTangent mesh2tangent = {0}; @@ -2532,7 +2532,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) sInterface.m_getNormal = GetNormal; sInterface.m_setTSpaceBasic = SetTSpace; - // 0 if failed + /* 0 if failed */ iCalcNewMethod = genTangSpaceDefault(&sContext); } @@ -2638,7 +2638,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) tex_coords[3] = mtface[f].uv[3]; } - // discard degenerate faces + /* discard degenerate faces */ is_degenerate = 0; if (equals_v3v3(verts[0], verts[1]) || equals_v3v3(verts[0], verts[2]) || equals_v3v3(verts[1], verts[2]) || equals_v2v2(tex_coords[0], tex_coords[1]) || equals_v2v2(tex_coords[0], tex_coords[2]) || equals_v2v2(tex_coords[1], tex_coords[2])) @@ -2646,7 +2646,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) is_degenerate = 1; } - // verify last vertex as well if this is a quad + /* verify last vertex as well if this is a quad */ if (is_degenerate == 0 && nr_verts == 4) { if (equals_v3v3(verts[3], verts[0]) || equals_v3v3(verts[3], verts[1]) || equals_v3v3(verts[3], verts[2]) || equals_v2v2(tex_coords[3], tex_coords[0]) || equals_v2v2(tex_coords[3], tex_coords[1]) || equals_v2v2(tex_coords[3], tex_coords[2])) @@ -2654,7 +2654,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) is_degenerate = 1; } - // verify the winding is consistent + /* verify the winding is consistent */ if (is_degenerate == 0) { float prev_edge[2]; int is_signed = 0; @@ -2681,11 +2681,11 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) } } - // proceed if not a degenerate face + /* proceed if not a degenerate face */ if (is_degenerate == 0) { int nr_tris_to_pile = 0; - // quads split at shortest diagonal - int offs = 0; // initial triangulation is 0,1,2 and 0, 2, 3 + /* quads split at shortest diagonal */ + int offs = 0; /* initial triangulation is 0,1,2 and 0, 2, 3 */ if (nr_verts == 4) { float pos_len_diag0, pos_len_diag1; float vtmp[3]; @@ -2743,7 +2743,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) } } - // finalize + /* finalize */ { const float avg_area_ratio = (nr_accumulated > 0) ? ((float)(dsum / nr_accumulated)) : 1.0f; const float use_as_render_bump_scale = sqrtf(avg_area_ratio); // use width of average surface ratio as your bump scale diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 8d1707725b5..af6583fd726 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -134,7 +134,7 @@ void BKE_action_make_local(bAction *act) if (act->id.lib == NULL) return; - // XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default + /* XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default */ if ((act->id.flag & LIB_FAKEUSER) && (act->id.us <= 1)) { id_clear_lib_data(bmain, &act->id); return; @@ -547,7 +547,7 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) outPose->ikparam = MEM_dupallocN(src->ikparam); for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) { - // TODO: rename this argument... + /* TODO: rename this argument... */ if (copycon) { copy_constraints(&listb, &pchan->constraints, TRUE); // copy_constraints NULLs listb pchan->constraints = listb; @@ -807,7 +807,7 @@ void framechange_poses_clear_unkeyed(void) bPoseChannel *pchan; /* This needs to be done for each object that has a pose */ - // TODO: proxies may/may not be correctly handled here... (this needs checking) + /* TODO: proxies may/may not be correctly handled here... (this needs checking) */ for (ob = G.main->object.first; ob; ob = ob->id.next) { /* we only need to do this on objects with a pose */ if ( (pose = ob->pose) ) { @@ -907,7 +907,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ float nmin, nmax; /* get extents for this curve */ - // TODO: allow enabling/disabling this? + /* TODO: allow enabling/disabling this? */ calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE); /* compare to the running tally */ @@ -949,7 +949,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ } break; - // TODO: function modifier may need some special limits + /* TODO: function modifier may need some special limits */ default: /* all other standard modifiers are on the infinite range... */ min = MINAFRAMEF; @@ -1129,7 +1129,7 @@ void BKE_pose_copy_result(bPose *to, bPose *from) bPoseChannel *pchanto, *pchanfrom; if (to == NULL || from == NULL) { - printf("pose result copy error to:%p from:%p\n", (void *)to, (void *)from); // debug temp + printf("pose result copy error to:%p from:%p\n", (void *)to, (void *)from); /* debug temp */ return; } @@ -1378,12 +1378,12 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip /* 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 + /* 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 + /* 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); } diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 52399801691..16ff1646f43 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -86,24 +86,24 @@ void animviz_settings_init(bAnimVizSettings *avs) /* sanity check */ if (avs == NULL) return; - + /* ghosting settings */ avs->ghost_bc = avs->ghost_ac = 10; - - avs->ghost_sf = 1; // xxx - take from scene instead? - avs->ghost_ef = 250; // xxx - take from scene instead? - + + avs->ghost_sf = 1; /* xxx - take from scene instead? */ + avs->ghost_ef = 250; /* xxx - take from scene instead? */ + avs->ghost_step = 1; - - + + /* path settings */ avs->path_bc = avs->path_ac = 10; - - avs->path_sf = 1; // xxx - take from scene instead? - avs->path_ef = 250; // xxx - take from scene instead? - + + avs->path_sf = 1; /* xxx - take from scene instead? */ + avs->path_ef = 250; /* xxx - take from scene instead? */ + avs->path_viewflag = (MOTIONPATH_VIEW_KFRAS | MOTIONPATH_VIEW_KFNOS); - + avs->path_step = 1; } @@ -246,7 +246,7 @@ typedef struct MPathTarget { /* get list of motion paths to be baked for the given object * - assumes the given list is ready to be used */ -// TODO: it would be nice in future to be able to update objects dependent on these bones too? +/* TODO: it would be nice in future to be able to update objects dependent on these bones too? */ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) { MPathTarget *mpt; @@ -309,7 +309,9 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) BLI_addhead(&scene->base, base); mpt->ob->flag |= BA_TEMP_TAG; - break; // we really don't need to continue anymore once this happens, but this line might really 'break' + + /* we really don't need to continue anymore once this happens, but this line might really 'break' */ + break; } } } @@ -328,17 +330,17 @@ static void motionpaths_calc_update_scene(Scene *scene) DAG_scene_update_flags(G.main, scene, scene->lay, TRUE); /* find the last object with the tag - * - all those afterwards are assumed to not be relevant for our calculations + * - all those afterwards are assumed to not be relevant for our calculations */ - // optimize further by moving out... + /* optimize further by moving out... */ for (base = scene->base.first; base; base = base->next) { if (base->object->flag & BA_TEMP_TAG) last = base; } /* perform updates for tagged objects */ - // XXX: this will break if rigs depend on scene or other data that - // is animated but not attached to/updatable from objects + /* XXX: this will break if rigs depend on scene or other data that + * is animated but not attached to/updatable from objects */ for (base = scene->base.first; base; base = base->next) { /* update this object */ BKE_object_handle_update(scene, base->object); @@ -353,7 +355,7 @@ static void motionpaths_calc_update_scene(Scene *scene) * that doesn't force complete update, but for now, this is the * most accurate way! */ - BKE_scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving + BKE_scene_update_for_newframe(G.main, scene, scene->lay); /* XXX this is the best way we can get anything moving */ #endif } @@ -401,9 +403,9 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) /* Perform baking of the given object's and/or its bones' transforms to motion paths * - scene: current scene * - ob: object whose flagged motionpaths should get calculated - * - recalc: whether we need to + * - recalc: whether we need to */ -// TODO: include reports pointer? +/* TODO: include reports pointer? */ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) { MPathTarget *mpt; @@ -418,9 +420,9 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) cfra = CFRA; sfra = efra = cfra; - // TODO: this method could be improved... - // 1) max range for standard baking - // 2) minimum range for recalc baking (i.e. between keyframes, but how?) + /* TODO: this method could be improved... + * 1) max range for standard baking + * 2) minimum range for recalc baking (i.e. between keyframes, but how?) */ for (mpt = targets->first; mpt; mpt = mpt->next) { /* try to increase area to do (only as much as needed) */ sfra = MIN2(sfra, mpt->mpath->start_frame); @@ -429,7 +431,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) if (efra <= sfra) return; /* optimize the depsgraph for faster updates */ - // TODO: whether this is used should depend on some setting for the level of optimisations used + /* TODO: whether this is used should depend on some setting for the level of optimisations used */ motionpaths_calc_optimise_depsgraph(scene, targets); /* calculate path over requested range */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e4ecdf245d1..ea625ec7699 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -76,9 +76,9 @@ short id_type_can_have_animdata(ID *id) /* sanity check */ if (id == NULL) return 0; - + /* Only some ID-blocks have this info for now */ - // TODO: finish adding this for the other blocktypes + /* TODO: finish adding this for the other blocktypes */ switch (GS(id->name)) { /* has AnimData */ case ID_OB: @@ -232,7 +232,7 @@ void BKE_free_animdata(ID *id) free_fcurves(&adt->drivers); /* free overrides */ - // TODO... + /* TODO... */ /* free animdata now */ MEM_freeN(adt); @@ -335,7 +335,7 @@ void BKE_animdata_make_local(AnimData *adt) if (adt->remap && adt->remap->target) BKE_action_make_local(adt->remap->target); /* Drivers */ - // TODO: need to remap the ID-targets too? + /* TODO: need to remap the ID-targets too? */ /* NLA Data */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) @@ -506,8 +506,8 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths else if (dstAdt->action == srcAdt->action) { printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n", srcID->name, dstID->name, srcAdt->action->id.name); - - // TODO: review this... + + /* TODO: review this... */ id_us_min(&dstAdt->action->id); dstAdt->action = add_empty_action(dstAdt->action->id.name + 2); } @@ -535,9 +535,9 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths /* just need to change lists */ BLI_remlink(&srcAdt->drivers, fcu); BLI_addtail(&dstAdt->drivers, fcu); - - // TODO: add depsgraph flushing calls? - + + /* TODO: add depsgraph flushing calls? */ + /* can stop now, as moved already */ break; } @@ -604,7 +604,7 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o BLI_dynstr_free(ds); /* check if the new path will solve our problems */ - // TODO: will need to check whether this step really helps in practice + /* TODO: will need to check whether this step really helps in practice */ if (!verify_paths || check_rna_path_is_valid(owner_id, newPath)) { /* free the old path, and return the new one, since we've solved the issues */ MEM_freeN(oldpath); @@ -914,7 +914,7 @@ void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const cha /* Finding Tools --------------------------- */ /* Find the first path that matches the given criteria */ -// TODO: do we want some method to perform partial matches too? +/* TODO: do we want some method to perform partial matches too? */ KS_Path *BKE_keyingset_find_path(KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int UNUSED(group_mode)) { KS_Path *ksp; @@ -943,7 +943,7 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks, ID *id, const char group_name[], /* group */ if (group_name) { - // FIXME: these checks need to be coded... for now, it's not too important though + /* FIXME: these checks need to be coded... for now, it's not too important though */ } /* if all aspects are ok, return */ @@ -1026,7 +1026,7 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks, ID *id, const char group_name[], ksp->idtype = GS(id->name); /* just copy path info */ - // TODO: should array index be checked too? + /* TODO: should array index be checked too? */ ksp->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); ksp->array_index = array_index; @@ -1123,11 +1123,13 @@ void BKE_keyingsets_free(ListBase *list) static short animsys_remap_path(AnimMapper *UNUSED(remap), char *path, char **dst) { /* is there a valid remapping table to use? */ - //if (remap) { - /* find a matching entry... to use to remap */ - // ...TODO... - //} - +#if 0 + if (remap) { + /* find a matching entry... to use to remap */ + /* ...TODO... */ + } +#endif + /* nothing suitable found, so just set dst to look at path (i.e. no alloc/free needed) */ *dst = path; return 0; @@ -1223,8 +1225,8 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in } else { /* failed to get path */ - // XXX don't tag as failed yet though, as there are some legit situations (Action Constraint) - // where some channels will not exist, but shouldn't lock up Action + /* XXX don't tag as failed yet though, as there are some legit situations (Action Constraint) + * where some channels will not exist, but shouldn't lock up Action */ if (G.debug & G_DEBUG) { printf("Animato: Invalid path. ID = '%s', '%s[%d]'\n", (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>", @@ -1432,11 +1434,11 @@ static void nlastrip_evaluate_controls(NlaStrip *strip, float ctime) animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, NULL, ctime); } - /* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped + /* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped * to lie within extents of the action-clip, so that a steady changing rate of progress through several cycles of the clip * can be achieved easily */ - // NOTE: if we add any more of these special cases, we better group them up nicely... + /* NOTE: if we add any more of these special cases, we better group them up nicely... */ if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC)) strip->strip_time = fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart); } @@ -1518,7 +1520,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short * - skip if no influence (i.e. same effect as muting the strip) * - negative influence is not supported yet... how would that be defined? */ - // TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on... + /* TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on... */ nlastrip_evaluate_controls(estrip, ctime); if (estrip->influence <= 0.0f) return NULL; @@ -1675,7 +1677,7 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, short break; case NLASTRIP_MODE_REPLACE: - default: // TODO: do we really want to blend by default? it seems more uses might prefer add... + default: /* TODO: do we really want to blend by default? it seems more uses might prefer add... */ /* do linear interpolation * - the influence of the accumulated data (elsewhere, that is called dstweight) * is 1 - influence, since the strip's influence is srcweight @@ -1871,7 +1873,7 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li tmp_nes = *nes; /* evaluate these strips into a temp-buffer (tmp_channels) */ - // FIXME: modifier evalation here needs some work... + /* FIXME: modifier evalation here needs some work... */ /* first strip */ tmp_nes.strip_mode = NES_TIME_TRANSITION_START; tmp_nes.strip = s1; @@ -1935,11 +1937,11 @@ static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes) { NlaStrip *strip = nes->strip; - + /* to prevent potential infinite recursion problems (i.e. transition strip, beside meta strip containing a transition * several levels deep inside it), we tag the current strip as being evaluated, and clear this when we leave */ - // TODO: be careful with this flag, since some edit tools may be running and have set this while animplayback was running + /* TODO: be careful with this flag, since some edit tools may be running and have set this while animplayback was running */ if (strip->flag & NLASTRIP_FLAG_EDIT_TOUCHED) return; strip->flag |= NLASTRIP_FLAG_EDIT_TOUCHED; @@ -2004,7 +2006,7 @@ void nladata_flush_channels(ListBase *channels) RNA_property_enum_set(ptr, prop, (int)value); break; default: - // can't do anything with other types of property.... + /* can't do anything with other types of property.... */ break; } } @@ -2088,7 +2090,7 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData } else { /* special case - evaluate as if there isn't any NLA data */ - // TODO: this is really just a stop-gap measure... + /* TODO: this is really just a stop-gap measure... */ animsys_evaluate_action(ptr, adt->action, adt->remap, ctime); return; } @@ -2114,10 +2116,10 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime) { ListBase echannels = {NULL, NULL}; - - // TODO: need to zero out all channels used, otherwise we have problems with threadsafety - // and also when the user jumps between different times instead of moving sequentially... - + + /* TODO: need to zero out all channels used, otherwise we have problems with threadsafety + * and also when the user jumps between different times instead of moving sequentially... */ + /* evaluate the NLA stack, obtaining a set of values to flush */ animsys_evaluate_nla(&echannels, ptr, adt, ctime); @@ -2137,9 +2139,9 @@ static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime) #if 0 AnimOverride *BKE_animsys_validate_override(PointerRNA *UNUSED(ptr), char *UNUSED(path), int UNUSED(array_index)) { - // FIXME: need to define how to get overrides + /* FIXME: need to define how to get overrides */ return NULL; -} +} #endif /* -------------------- */ @@ -2209,7 +2211,7 @@ void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ct * - NLA before Active Action, as Active Action behaves as 'tweaking track' * that overrides 'rough' work in NLA */ - // TODO: need to double check that this all works correctly + /* TODO: need to double check that this all works correctly */ if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM)) { /* evaluate NLA data */ if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF)) { diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 0def299c24a..9e222307aa9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -301,8 +301,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath //setscreen(G.curscreen); } - // FIXME: this version patching should really be part of the file-reading code, - // but we still get too many unrelated data-corruption crashes otherwise... + /* FIXME: this version patching should really be part of the file-reading code, + * but we still get too many unrelated data-corruption crashes otherwise... */ if (G.main->versionfile < 250) do_versions_ipos_to_animato(G.main); diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index e1f4e45e9c3..722dc1834dd 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -96,9 +96,9 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) ysize = (bytes + (ibuf->x - 1)) / ibuf->x; if (ysize < ibuf->y) { - // we're first going to copy all data into a liniar buffer. - // step can be 4 or 1 bytes, and the data is not sequential because - // the bitmap was flipped vertically. + /* we're first going to copy all data into a liniar buffer. + * step can be 4 or 1 bytes, and the data is not sequential because + * the bitmap was flipped vertically. */ buffer = MEM_mallocN(bytes, "readBitmapFontVersion0:buffer"); @@ -107,18 +107,18 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) buffer[i] = rect[index]; index += step; if (index >= linelength) { - // we've read one line, no skip to the line *before* that + /* we've read one line, no skip to the line *before* that */ rect -= linelength; index -= linelength; } } - // we're now going to endian convert the data + /* we're now going to endian convert the data */ bmfont = MEM_mallocN(bytes, "readBitmapFontVersion0:bmfont"); index = 0; - // first read the header + /* first read the header */ bmfont->magic[0] = buffer[index++]; bmfont->magic[1] = buffer[index++]; bmfont->magic[2] = buffer[index++]; @@ -151,16 +151,16 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) printf("bytes = %d\n", bytes); } - // we've read the data from the image. Now we're going - // to crop the image vertically so only the bitmap data - // remains visible - + /* we've read the data from the image. Now we're going + * to crop the image vertically so only the bitmap data + * remains visible */ + ibuf->y -= ysize; ibuf->userdata = bmfont; ibuf->userflags |= IB_BITMAPFONT; if (ibuf->planes < 32) { - // we're going to fake alpha here: + /* we're going to fake alpha here: */ calcAlpha(ibuf); } } @@ -176,32 +176,32 @@ void detectBitmapFont(ImBuf *ibuf) int i; if (ibuf != NULL && ibuf->rect != NULL) { - // bitmap must have an x size that is a power of two + /* bitmap must have an x size that is a power of two */ if (is_power_of_two(ibuf->x)) { rect = (unsigned char *) (ibuf->rect + (ibuf->x * (ibuf->y - 1))); - // printf ("starts with: %s %c %c %c %c\n", rect, rect[0], rect[1], rect[2], rect[3]); + /* printf ("starts with: %s %c %c %c %c\n", rect, rect[0], rect[1], rect[2], rect[3]); */ if (rect[0] == 'B' && rect[1] == 'F' && rect[2] == 'N' && rect[3] == 'T') { - // printf("found 8bit font !\n"); - // round y size down - // do the 8 bit font stuff. (not yet) + /* printf("found 8bit font !\n"); + * round y size down + * do the 8 bit font stuff. (not yet) */ } else { - // we try all 4 possible combinations + /* we try all 4 possible combinations */ for (i = 0; i < 4; i++) { if (rect[0] == 'B' && rect[4] == 'F' && rect[8] == 'N' && rect[12] == 'T') { - // printf("found 24bit font !\n"); - // We're going to parse the file: - + /* printf("found 24bit font !\n"); + * We're going to parse the file: */ + version = (rect[16] << 8) | rect[20]; - + if (version == 0) { readBitmapFontVersion0(ibuf, rect, 4); } else { printf("detectBitmapFont :Unsupported version %d\n", version); } - - // on succes ibuf->userdata points to the bitmapfont + + /* on succes ibuf->userdata points to the bitmapfont */ if (ibuf->userdata) { break; } @@ -221,23 +221,23 @@ int locateGlyph(bmFont *bmfont, unsigned short unicode) min = 0; max = bmfont->glyphcount; while (1) { - // look halfway for glyph + /* look halfway for glyph */ current = (min + max) >> 1; if (bmfont->glyphs[current].unicode == unicode) { break; } else if (bmfont->glyphs[current].unicode < unicode) { - // have to move up + /* have to move up */ min = current; } else { - // have to move down + /* have to move down */ max = current; } - + if (max - min <= 1) { - // unable to locate glyph + /* unable to locate glyph */ current = 0; break; } @@ -278,7 +278,7 @@ void matrixGlyph(ImBuf * ibuf, unsigned short unicode, *centerx = bmfont->glyphs[0].locx / (float) ibuf->x; *centery = (ibuf->y - bmfont->glyphs[0].locy) / (float) ibuf->y; - // 2.0 units is the default size of an object + /* 2.0 units is the default size of an object */ *movey = 1.0f - *sizey + 2.0f * (bmfont->glyphs[index].ofsy - bmfont->glyphs[0].ofsy) / (float) bmfont->glyphs[0].sizey; *movex = *sizex - 1.0f + 2.0f * (bmfont->glyphs[index].ofsx - bmfont->glyphs[0].ofsx) / (float) bmfont->glyphs[0].sizex; diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 972793227a8..be79077bb58 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -44,19 +44,19 @@ CSG_DestroyMeshDescriptor( CSG_MeshDescriptor *mesh ) { - // Call mesh descriptors destroy function.... + /* Call mesh descriptors destroy function.... */ mesh->m_destroy_func(mesh); } - -// Destroy function for blender mesh internals. + +/* Destroy function for blender mesh internals. */ static void CSG_DestroyBlenderMeshInternals( CSG_MeshDescriptor *mesh ) { - // Free face and vertex iterators. - FreeMeshDescriptors(&(mesh->m_face_iterator),&(mesh->m_vertex_iterator)); + /* Free face and vertex iterators. */ + FreeMeshDescriptors(&(mesh->m_face_iterator),&(mesh->m_vertex_iterator)); } @@ -140,18 +140,18 @@ CSG_AddMeshToBlender( invert_m4_m4(inv_mat,mesh->base->object->obmat); - // Create a new blender mesh object - using 'base' as - // a template for the new object. + /* Create a new blender mesh object - using 'base' as + * a template for the new object. */ ob_new= AddNewBlenderMesh(mesh->base); me_new = ob_new->data; - // make sure the iterators are reset. + /* make sure the iterators are reset. */ mesh->m_face_iterator.Reset(mesh->m_face_iterator.it); mesh->m_vertex_iterator.Reset(mesh->m_vertex_iterator.it); - // iterate through results of operation and insert into new object - // see subsurf.c + /* iterate through results of operation and insert into new object + * see subsurf.c */ ConvertCSGDescriptorsToMeshObject( ob_new, @@ -195,8 +195,8 @@ CSG_PerformOp( output->base = mesh1->base; if (output->m_descriptor.user_face_vertex_data_size) { - // Then use the only interp function supported - success = + /* Then use the only interp function supported */ + success = CSG_PerformBooleanOperation( bool_op, op_type, @@ -225,8 +225,8 @@ CSG_PerformOp( bool_op = NULL; return 0; } - - // get the ouput mesh descriptors. + + /* get the ouput mesh descriptors. */ CSG_OutputFaceDescriptor(bool_op,&(output->m_face_iterator)); CSG_OutputVertexDescriptor(bool_op,&(output->m_vertex_iterator)); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 741d4b729ae..53a9057116c 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1074,7 +1074,7 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], const int radius = BKE_brush_size_get(scene, brush); const int diameter = 2 * radius; - // find random position within a circle of diameter 1 + /* find random position within a circle of diameter 1 */ do { rand_pos[0] = BLI_frand() - 0.5f; rand_pos[1] = BLI_frand() - 0.5f; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 752bdab2c00..32ae6d04934 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -330,7 +330,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } } - // Account for numerical round-off error + /* Account for numerical round-off error */ if (sqrDist < FLT_EPSILON) sqrDist = 0.0f; @@ -345,7 +345,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f add_v3_v3v3(z, z, y); //sub_v3_v3v3(d, p, z); copy_v3_v3(nearest, z); - // d = p - ( v0 + S * e0 + T * e1 ); + //d = p - ( v0 + S * e0 + T * e1 ); } *v = lv; *e = le; diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index f9e72be4fc1..74bfa0d60fc 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -224,26 +224,26 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon verts = cloth->verts; mfaces = cloth->mfaces; - // in the moment, return zero if no faces there + /* in the moment, return zero if no faces there */ if (!cloth->numfaces) return NULL; - - // create quadtree with k=26 + + /* create quadtree with k=26 */ bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 4, 26); - - // fill tree + + /* fill tree */ for (i = 0; i < cloth->numfaces; i++, mfaces++) { copy_v3_v3(&co[0*3], verts[mfaces->v1].xold); copy_v3_v3(&co[1*3], verts[mfaces->v2].xold); copy_v3_v3(&co[2*3], verts[mfaces->v3].xold); - + if (mfaces->v4) copy_v3_v3(&co[3*3], verts[mfaces->v4].xold); - + BLI_bvhtree_insert(bvhtree, i, co, (mfaces->v4 ? 4 : 3)); } - - // balance tree + + /* balance tree */ BLI_bvhtree_balance(bvhtree); return bvhtree; @@ -313,23 +313,23 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving) return; mfaces = cloth->mfaces; - + // update vertex position in bvh tree if (verts && mfaces) { for (i = 0; i < cloth->numverts; i++, verts++) { copy_v3_v3(&co[0*3], verts->txold); - + // copy new locations into array if (moving) { // update moving positions copy_v3_v3(&co_moving[0*3], verts->tx); - + ret = BLI_bvhtree_update_node(bvhtree, i, co, co_moving, 1); } else { ret = BLI_bvhtree_update_node(bvhtree, i, co, NULL, 1); } - + // check if tree is already full if (!ret) break; @@ -673,7 +673,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd ) if ( cloth ) { if (G.rt > 0) printf("cloth_free_modifier_extern in\n"); - + // If our solver provides a free function, call it if ( solvers [clmd->sim_parms->solver_type].free ) { solvers [clmd->sim_parms->solver_type].free ( clmd ); @@ -691,12 +691,12 @@ void cloth_free_modifier_extern(ClothModifierData *clmd ) LinkNode *search = cloth->springs; while (search) { ClothSpring *spring = search->link; - + MEM_freeN ( spring ); search = search->next; } BLI_linklist_free(cloth->springs, NULL); - + cloth->springs = NULL; } @@ -713,11 +713,11 @@ void cloth_free_modifier_extern(ClothModifierData *clmd ) // we save our faces for collision objects if ( cloth->mfaces ) MEM_freeN ( cloth->mfaces ); - + if (cloth->edgehash) BLI_edgehash_free ( cloth->edgehash, NULL ); - - + + /* if (clmd->clothObject->facemarks) MEM_freeN(clmd->clothObject->facemarks); @@ -875,10 +875,10 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d cloth_from_mesh ( clmd, dm ); - // create springs + // create springs clmd->clothObject->springs = NULL; clmd->clothObject->numsprings = -1; - + if ( clmd->sim_parms->shapekey_rest ) shapekey_rest = dm->getVertDataArray ( dm, CD_CLOTH_ORCO ); @@ -1127,13 +1127,13 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) for (i = 0; i < numverts; i++) { cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f / ((float)cloth->verts[i].spring_count); } - + // shear springs for ( i = 0; i < numfaces; i++ ) { // triangle faces already have shear springs due to structural geometry if ( !mface[i].v4 ) - continue; - + continue; + spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) { @@ -1174,7 +1174,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) BLI_linklist_prepend ( &cloth->springs, spring ); } - + if (numfaces) { // bending springs search2 = cloth->springs; @@ -1187,14 +1187,14 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) while ( search ) { tspring = search->link; index2 = ( ( tspring->ij==tspring2->kl ) ? ( tspring->kl ) : ( tspring->ij ) ); - + // check for existing spring // check also if startpoint is equal to endpoint if (!BLI_edgehash_haskey(edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2)) && (index2 != tspring2->ij)) { spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - + if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); return 0; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 7acbcbf6c93..516de35fab3 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -226,69 +226,69 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM zero_v3(i2); zero_v3(i3); - // only handle static collisions here + /* only handle static collisions here */ if ( collpair->flag & COLLISION_IN_FUTURE ) continue; - // compute barycentric coordinates for both collision points + /* compute barycentric coordinates for both collision points */ collision_compute_barycentric ( collpair->pa, cloth1->verts[collpair->ap1].txold, cloth1->verts[collpair->ap2].txold, cloth1->verts[collpair->ap3].txold, &w1, &w2, &w3 ); - // was: txold + /* was: txold */ collision_compute_barycentric ( collpair->pb, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, &u1, &u2, &u3 ); - // Calculate relative "velocity". + /* Calculate relative "velocity". */ collision_interpolateOnTriangle ( v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3 ); collision_interpolateOnTriangle ( v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3 ); sub_v3_v3v3(relativeVelocity, v2, v1); - // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). + /* Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). */ magrelVel = dot_v3v3(relativeVelocity, collpair->normal); - // printf("magrelVel: %f\n", magrelVel); + /* printf("magrelVel: %f\n", magrelVel); */ - // Calculate masses of points. - // TODO + /* Calculate masses of points. + * TODO */ - // If v_n_mag < 0 the edges are approaching each other. + /* If v_n_mag < 0 the edges are approaching each other. */ if ( magrelVel > ALMOST_ZERO ) { - // Calculate Impulse magnitude to stop all motion in normal direction. + /* Calculate Impulse magnitude to stop all motion in normal direction. */ float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; float vrel_t_pre[3]; float temp[3], spf; - // calculate tangential velocity + /* calculate tangential velocity */ copy_v3_v3 ( temp, collpair->normal ); mul_v3_fl(temp, magrelVel); sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); - // Decrease in magnitude of relative tangential velocity due to coulomb friction - // in original formula "magrelVel" should be the "change of relative velocity in normal direction" + /* Decrease in magnitude of relative tangential velocity due to coulomb friction + * in original formula "magrelVel" should be the "change of relative velocity in normal direction" */ magtangent = minf(clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre))); - // Apply friction impulse. + /* Apply friction impulse. */ if ( magtangent > ALMOST_ZERO ) { normalize_v3(vrel_t_pre); - impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * + impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); /* 2.0 * */ VECADDMUL ( i1, vrel_t_pre, w1 * impulse ); VECADDMUL ( i2, vrel_t_pre, w2 * impulse ); VECADDMUL ( i3, vrel_t_pre, w3 * impulse ); } - // Apply velocity stopping impulse - // I_c = m * v_N / 2.0 - // no 2.0 * magrelVel normally, but looks nicer DG + /* Apply velocity stopping impulse + * I_c = m * v_N / 2.0 + * no 2.0 * magrelVel normally, but looks nicer DG */ impulse = magrelVel / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); VECADDMUL ( i1, collpair->normal, w1 * impulse ); @@ -300,24 +300,24 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM VECADDMUL ( i3, collpair->normal, w3 * impulse ); cloth1->verts[collpair->ap3].impulse_count++; - // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) - // DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: - // v += impulse; x_new = x + v; - // We don't use dt!! - // DG TODO: Fix usage of dt here! + /* Apply repulse impulse if distance too short + * I_r = -min(dt*kd, m(0, 1d/dt - v_n)) + * DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: + * v += impulse; x_new = x + v; + * We don't use dt!! + * DG TODO: Fix usage of dt here! */ spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance; if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) { repulse = MIN2 ( d*1.0f/spf, 0.1f*d*spf - magrelVel ); - // stay on the safe side and clamp repulse + /* stay on the safe side and clamp repulse */ if ( impulse > ALMOST_ZERO ) repulse = MIN2 ( repulse, 5.0*impulse ); repulse = MAX2 ( impulse, repulse ); - impulse = repulse / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // original 2.0 / 0.25 + impulse = repulse / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); /* original 2.0 / 0.25 */ VECADDMUL ( i1, collpair->normal, impulse ); VECADDMUL ( i2, collpair->normal, impulse ); VECADDMUL ( i3, collpair->normal, impulse ); @@ -326,19 +326,19 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM result = 1; } else { - // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, max(0, 1d/dt - v_n)) - // DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: - // v += impulse; x_new = x + v; - // We don't use dt!! + /* Apply repulse impulse if distance too short + * I_r = -min(dt*kd, max(0, 1d/dt - v_n)) + * DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: + * v += impulse; x_new = x + v; + * We don't use dt!! */ float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; float d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance; if ( d > ALMOST_ZERO) { - // stay on the safe side and clamp repulse + /* stay on the safe side and clamp repulse */ float repulse = d*1.0f/spf; - float impulse = repulse / ( 3.0 * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); // original 2.0 / 0.25 + float impulse = repulse / ( 3.0 * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); /* original 2.0 / 0.25 */ VECADDMUL ( i1, collpair->normal, impulse ); VECADDMUL ( i2, collpair->normal, impulse ); @@ -805,7 +805,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo //////////////////////////////////////////////////////////// if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) { - // TODO: add coll quality rounds again + /* TODO: add coll quality rounds again */ BVHTreeOverlap *overlap = NULL; unsigned int result = 0; diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 6879ec506f0..31ad4d0380a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -71,7 +71,7 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa clipmaxx = MAX2(minx, maxx); clipmaxy = MAX2(miny, maxy); - BLI_init_rctf(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); + BLI_rctf_init(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); cumap->clipr = cumap->curr; cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c12e740958c..c2b38442a6b 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1316,7 +1316,7 @@ static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase * bFollowPathConstraint *data = con->data; /* get Object transform (loc/rot/size) to determine transformation from path */ - // TODO: this used to be local at one point, but is probably more useful as-is + /* TODO: this used to be local at one point, but is probably more useful as-is */ copy_m4_m4(obmat, cob->matrix); /* get scaling of object before applying constraint */ @@ -2163,7 +2163,7 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT Object workob; /* evaluate using workob */ - // FIXME: we don't have any consistent standards on limiting effects on object... + /* FIXME: we don't have any consistent standards on limiting effects on object... */ what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); BKE_object_to_mat4(&workob, ct->matrix); } @@ -2623,7 +2623,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t } /* if soft-distance is enabled, start fading once owner is dist-soft from the target */ else if (data->flag & LIMITDIST_USESOFT) { - // FIXME: there's a problem with "jumping" when this kicks in + /* FIXME: there's a problem with "jumping" when this kicks in */ if (dist >= (data->dist - data->soft)) { sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) + data->dist); if (dist != 0.0f) sfac /= dist; @@ -2989,7 +2989,7 @@ static void rbj_new_data(void *cdata) { bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)cdata; - // removed code which set target of this constraint + /* removed code which set target of this constraint */ data->type = 1; } @@ -3608,7 +3608,7 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t if (normalize_v3(tarvec) == 0.0f) { /* the target is sitting on the owner, so just make them use the same direction vectors */ - // FIXME: or would it be better to use the pure direction vector? + /* FIXME: or would it be better to use the pure direction vector? */ copy_v3_v3(tarvec, obvec); //copy_v3_v3(tarvec, track_dir_vecs[data->trackflag]); } @@ -3839,7 +3839,7 @@ static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta } /* get rotation matrix representing the rotation of the owner */ - // TODO: perhaps we might want to include scaling based on the pivot too? + /* TODO: perhaps we might want to include scaling based on the pivot too? */ copy_m3_m4(rotMat, cob->matrix); normalize_m3(rotMat); @@ -4395,7 +4395,7 @@ static bConstraint *add_new_constraint_internal(const char *name, short type) } else { /* if no name is provided, use the generic "Const" name */ - // NOTE: any constraint type that gets here really shouldn't get added... + /* NOTE: any constraint type that gets here really shouldn't get added... */ newName = (name && name[0]) ? name : "Const"; } @@ -4435,9 +4435,9 @@ static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const ch /* make this constraint the active one */ constraints_set_active(list, con); } - + /* set type+owner specific immutable settings */ - // TODO: does action constraint need anything here - i.e. spaceonce? + /* TODO: does action constraint need anything here - i.e. spaceonce? */ switch (type) { case CONSTRAINT_TYPE_CHILDOF: { diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index f551b2d18a4..8dd3b3da705 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -337,12 +337,12 @@ static void layerSwap_tface(void *data, const int *corner_indices) copy_v2_v2(uv[j], tf->uv[source_index]); - // swap pinning flags around + /* swap pinning flags around */ if (tf->unwrap & pin_flags[source_index]) { unwrap |= pin_flags[j]; } - // swap selection flags around + /* swap selection flags around */ if (tf->flag & sel_flags[source_index]) { flag |= sel_flags[j]; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 05a2cfee8e6..4026d3f06d3 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -320,7 +320,7 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node DRIVER_TARGETS_USED_LOOPER(dvar) { if (dtar->id) { - // FIXME: other data types need to be added here so that they can work! + /* FIXME: other data types need to be added here so that they can work! */ if (GS(dtar->id->name) == ID_OB) { Object *ob = (Object *)dtar->id; @@ -365,10 +365,10 @@ static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode * /* nodetree's nodes... */ for (n = ntree->nodes.first; n; n = n->next) { if (n->id && GS(n->id->name) == ID_MA) { - ma = (Material *)n->id; - if (ma != rootma) { - dag_add_material_driver_relations(dag, node, ma); - } + ma = (Material *)n->id; + if (ma != rootma) { + dag_add_material_driver_relations(dag, node, ma); + } } else if (n->type == NODE_GROUP && n->id) { dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id, rootma); @@ -383,11 +383,11 @@ static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Mat if (ma->adt) { dag_add_driver_relation(ma->adt, dag, node, 1); } - + /* textures */ // TODO... //dag_add_texture_driver_relations(DagForest *dag, DagNode *node, ID *id); - + /* material's nodetree */ if (ma->nodetree) { dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree, ma); @@ -399,8 +399,8 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec Base *base; DagNode *node2; - // would be nice to have a list of colliders here - // so for now walk all objects in scene check 'same layer rule' + /* would be nice to have a list of colliders here + * so for now walk all objects in scene check 'same layer rule' */ for (base = scene->base.first; base; base = base->next) { if ((base->lay & ob->lay) && base->object->pd) { Object *ob1 = base->object; @@ -672,7 +672,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O * engine instancing assumes particular ordering of objects in list */ dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualization"); if (part->dup_ob->type == OB_MBALL) - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualization"); + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA, "Particle Object Visualization"); } if (part->ren_as == PART_DRAW_GR && part->dup_group) { @@ -858,7 +858,7 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask) } } - // cycle detection and solving + /* cycle detection and solving */ // solve_cycles(dag); return dag; @@ -1567,7 +1567,7 @@ DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) node = dag_find_node(dag, ob); - // need to go over the whole dag for adj list + /* need to go over the whole dag for adj list */ nqueue = queue_create(node->ancestor_count); node1 = dag->DagNode.first; @@ -2205,8 +2205,8 @@ static int object_modifiers_use_time(Object *ob) return 1; } - // XXX: also, should check NLA strips, though for now assume that nobody uses - // that and we can omit that for performance reasons... + /* XXX: also, should check NLA strips, though for now assume that nobody uses + * that and we can omit that for performance reasons... */ } return 0; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 6e5d6ffb0e9..9b349598db1 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -499,16 +499,14 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, int flipnormal) /* vert data */ f1 = dlnew->verts; totvert = 0; - sf_vert = sf_ctx.fillvertbase.first; - while (sf_vert) { + + for (sf_vert = sf_ctx.fillvertbase.first; sf_vert; sf_vert = sf_vert->next) { copy_v3_v3(f1, sf_vert->co); f1 += 3; /* index number */ sf_vert->tmp.l = totvert; totvert++; - - sf_vert = sf_vert->next; } /* index data */ diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index dd5751c5d1f..8122f9bf617 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3417,7 +3417,9 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, sampleStrength *= sample_factor; } - else continue; + else { + continue; + } /* velocity brush, only do on main sample */ if (brush->flags & MOD_DPAINT_USES_VELOCITY && ss == 0 && brushVelocity) { diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index b32ac24084f..a4e7676c602 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -393,7 +393,7 @@ void pd_point_from_soft(Scene *scene, float *loc, float *vel, int index, Effecte // triangle - ray callback function static void eff_tri_ray_hit(void *UNUSED(userData), int UNUSED(index), const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit) { - // whenever we hit a bounding box, we don't check further + /* whenever we hit a bounding box, we don't check further */ hit->dist = -1; hit->index = 1; } @@ -418,24 +418,24 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect negate_v3_v3(norm, efd->vec_to_point); len = normalize_v3(norm); - // check all collision objects + /* check all collision objects */ for (col = colls->first; col; col = col->next) { CollisionModifierData *collmd = col->collmd; if (col->ob == eff->ob) continue; - + if (collmd->bvhtree) { BVHTreeRayHit hit; - + hit.index = -1; hit.dist = len + FLT_EPSILON; - - // check if the way is blocked + + /* check if the way is blocked */ if (BLI_bvhtree_ray_cast(collmd->bvhtree, point->loc, norm, 0.0f, &hit, eff_tri_ray_hit, NULL)>=0) { absorption= col->ob->pd->absorption; - // visibility is only between 0 and 1, calculated from 1-absorption + /* visibility is only between 0 and 1, calculated from 1-absorption */ visibility *= CLAMPIS(1.0f-absorption, 0.0f, 1.0f); if (visibility <= 0.0f) @@ -1006,7 +1006,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we do_physical_effector(eff, &efd, point, force); - // for softbody backward compatibility + /* for softbody backward compatibility */ if (point->flag & PE_WIND_AS_SPEED && impulse) { sub_v3_v3v3(temp2, force, temp1); sub_v3_v3v3(impulse, impulse, temp2); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index d072ffb72ec..97b245bd067 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -285,12 +285,12 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, for (fcu = src->first; fcu; fcu = fcu->next) { /* check if quoted string matches the path */ if ((fcu->rna_path) && strstr(fcu->rna_path, dataPrefix)) { - char *quotedName = BLI_getQuotedStr(fcu->rna_path, dataPrefix); + char *quotedName = BLI_str_quoted_substrN(fcu->rna_path, dataPrefix); if (quotedName) { /* check if the quoted name matches the required name */ if (strcmp(quotedName, dataName) == 0) { - LinkData *ld = MEM_callocN(sizeof(LinkData), "list_find_data_fcurves"); + LinkData *ld = MEM_callocN(sizeof(LinkData), __func__); ld->data = fcu; BLI_addtail(dst, ld); @@ -422,7 +422,7 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short if (loopbreaker == (maxloop - 1)) { printf("Error: binarysearch_bezt_index() was taking too long\n"); - // include debug info + /* include debug info */ printf("\tround = %d: start = %d, end = %d, arraylen = %d\n", loopbreaker, start, end, arraylen); } @@ -634,9 +634,9 @@ short fcurve_are_keyframes_usable(FCurve *fcu) /* if it has modifiers, none of these should "drastically" alter the curve */ if (fcu->modifiers.first) { FModifier *fcm; - + /* check modifiers from last to first, as last will be more influential */ - // TODO: optionally, only check modifier if it is the active one... + /* TODO: optionally, only check modifier if it is the active one... */ for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) { /* ignore if muted/disabled */ if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) @@ -748,7 +748,7 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample int cfra; /* sanity checks */ - // TODO: make these tests report errors using reports not printf's + /* TODO: make these tests report errors using reports not printf's */ if (ELEM(NULL, fcu, sample_cb)) { printf("Error: No F-Curve with F-Curve Modifiers to Bake\n"); return; @@ -1018,7 +1018,7 @@ static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar) id = dtar_id_ensure_proxy_from(dtar->id); /* error check for missing pointer... */ - // TODO: tag the specific target too as having issues + /* TODO: tag the specific target too as having issues */ if (id == NULL) { printf("Error: driver has an invalid target to use\n"); if (G.debug & G_DEBUG) printf("\tpath = %s\n", dtar->rna_path); @@ -1152,14 +1152,14 @@ static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar) } /* evaluate 'location difference' driver variable */ -// TODO: this needs to take into account space conversions... +/* TODO: this needs to take into account space conversions... */ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) { float loc1[3] = {0.0f, 0.0f, 0.0f}; float loc2[3] = {0.0f, 0.0f, 0.0f}; /* get two location values */ - // NOTE: for now, these are all just worldspace + /* NOTE: for now, these are all just worldspace */ DRIVER_TARGETS_USED_LOOPER(dvar) { /* get pointer to loc values to store in */ @@ -1206,7 +1206,7 @@ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) /* object */ if (dtar->flag & DTAR_FLAG_LOCALSPACE) { if (dtar->flag & DTAR_FLAG_LOCAL_CONSTS) { - // XXX: this should practically be the same as transform space... + /* XXX: this should practically be the same as transform space... */ float mat[4][4]; /* extract transform just like how the constraints do it! */ @@ -1796,7 +1796,7 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o) c = c0; if (a != 0.0) { - // discriminant + /* discriminant */ p = b * b - 4 * a * c; if (p > 0) { diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index f981ecaf810..cefcbdd2762 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -433,7 +433,7 @@ static void fcm_envelope_verify(FModifier *fcm) /* if the are points, perform bubble-sort on them, as user may have changed the order */ if (env->data) { - // XXX todo... + /* XXX todo... */ } } @@ -463,7 +463,7 @@ static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cv } else { /* evaltime occurs somewhere between segments */ - // TODO: implement binary search for this to make it faster? + /* TODO: implement binary search for this to make it faster? */ for (a = 0; prevfed && fed && (a < env->totvert - 1); a++, prevfed = fed, fed++) { /* evaltime occurs within the interval defined by these two envelope points */ if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) { @@ -539,7 +539,7 @@ static float fcm_cycles_time(FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), int cycles = 0, ofs = 0; /* check if modifier is first in stack, otherwise disable ourself... */ - // FIXME... + /* FIXME... */ if (fcm->prev) { fcm->flag |= FMODIFIER_FLAG_DISABLED; return evaltime; @@ -883,7 +883,7 @@ static void fcm_stepped_new_data(void *mdata) FMod_Stepped *data = (FMod_Stepped *)mdata; /* just need to set the step-size to 2-frames by default */ - // XXX: or would 5 be more normal? + /* XXX: or would 5 be more normal? */ data->step_size = 2.0f; } @@ -1005,7 +1005,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type) /* special checks for whether modifier can be added */ if ((modifiers->first) && (type == FMODIFIER_TYPE_CYCLES)) { /* cycles modifier must be first in stack, so for now, don't add if it can't be */ - // TODO: perhaps there is some better way, but for now, + /* TODO: perhaps there is some better way, but for now, */ printf("Error: Cannot add 'Cycles' modifier to F-Curve, as 'Cycles' modifier can only be first in stack.\n"); return NULL; } @@ -1104,7 +1104,7 @@ int remove_fmodifier(ListBase *modifiers, FModifier *fcm) return 1; } else { - // XXX this case can probably be removed some day, as it shouldn't happen... + /* XXX this case can probably be removed some day, as it shouldn't happen... */ printf("remove_fmodifier() - no modifier stack given\n"); MEM_freeN(fcm); return 0; @@ -1343,7 +1343,7 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end) ChannelDriver *driver; /* sanity checks */ - // TODO: make these tests report errors using reports not printf's + /* TODO: make these tests report errors using reports not printf's */ if (ELEM(NULL, fcu, fcu->modifiers.first)) { printf("Error: No F-Curve with F-Curve Modifiers to Bake\n"); return; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 5d33c8fbcbf..050f921998d 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -133,7 +133,7 @@ struct TmpFont *BKE_vfont_find_tmpfont(VFont *vfont) if (vfont == NULL) return NULL; - // Try finding the font from font list + /* Try finding the font from font list */ tmpfnt = ttfdata.first; while (tmpfnt) { if (tmpfnt->vfont == vfont) @@ -150,28 +150,28 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (vfont == NULL) return NULL; - // Try finding the font from font list + /* Try finding the font from font list */ tmpfnt = BKE_vfont_find_tmpfont(vfont); - - // And then set the data + + /* And then set the data */ if (!vfont->data) { PackedFile *pf; - + if (strcmp(vfont->name, FO_BUILTIN_NAME) == 0) { pf = get_builtin_packedfile(); } else { if (vfont->packedfile) { pf = vfont->packedfile; - - // We need to copy a tmp font to memory unless it is already there + + /* We need to copy a tmp font to memory unless it is already there */ if (!tmpfnt) { tpf = MEM_callocN(sizeof(*tpf), "PackedFile"); tpf->data = MEM_mallocN(pf->size, "packFile"); tpf->size = pf->size; memcpy(tpf->data, pf->data, pf->size); - - // Add temporary packed file to globals + + /* Add temporary packed file to globals */ tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; @@ -183,8 +183,8 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (!tmpfnt) { tpf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); - - // Add temporary packed file to globals + + /* Add temporary packed file to globals */ tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; @@ -251,21 +251,21 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) } BLI_strncpy(vfont->name, name, sizeof(vfont->name)); - // if autopack is on store the packedfile in de font structure + /* if autopack is on store the packedfile in de font structure */ if (!is_builtin && (G.fileflags & G_AUTOPACK)) { vfont->packedfile = pf; } - - // Do not add FO_BUILTIN_NAME to temporary listbase + + /* Do not add FO_BUILTIN_NAME to temporary listbase */ if (strcmp(filename, FO_BUILTIN_NAME)) { tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); - } + } } - - // Free the packed file + + /* Free the packed file */ if (!vfont || vfont->packedfile != pf) { freePackedFile(pf); } @@ -390,11 +390,11 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo che = find_vfont_char(vfd, character); - // Select the glyph data + /* Select the glyph data */ if (che) nu1 = che->nurbsbase.first; - // Create the character + /* Create the character */ while (nu1) { bezt1 = nu1->bezt; if (bezt1) { @@ -508,7 +508,7 @@ int BKE_vfont_select_get(Object *ob, int *start, int *end) static float char_width(Curve *cu, VChar *che, CharInfo *info) { - // The character wasn't found, propably ascii = 0, then the width shall be 0 as well + /* The character wasn't found, propably ascii = 0, then the width shall be 0 as well */ if (che == NULL) { return 0.0f; } @@ -543,20 +543,20 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int if (ob->type != OB_FONT) return NULL; - // Set font data + /* Set font data */ cu = (Curve *) ob->data; vfont = cu->vfont; - + if (cu->str == NULL) return NULL; if (vfont == NULL) return NULL; - // Create unicode string + /* Create unicode string */ utf8len = BLI_strlen_utf8(cu->str); mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem"); - + BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1); - // Count the wchar_t string length + /* Count the wchar_t string length */ slen = wcslen(mem); if (cu->ulheight == 0.0f) @@ -612,7 +612,7 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int curbox = 0; for (i = 0; i <= slen; i++) { makebreak: - // Characters in the list + /* Characters in the list */ info = &(custrinfo[i]); ascii = mem[i]; if (info->flag & CU_CHINFO_SMALLCAPS) { @@ -664,7 +664,7 @@ makebreak: twidth = char_width(cu, che, info); - // Calculate positions + /* Calculate positions */ if ((tb->w != 0.0f) && (ct->dobreak == 0) && ((xof - (tb->x / cu->fsize) + twidth) * cu->fsize) > tb->w + cu->xof * cu->fsize) { // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); for (j = i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak == 0); j--) { @@ -762,7 +762,7 @@ makebreak: } else wsfac = 1.0f; - // Set the width of the character + /* Set the width of the character */ twidth = char_width(cu, che, info); xof += (twidth * wsfac * (1.0f + (info->kern / 40.0f)) ) + xtrax; @@ -781,10 +781,10 @@ makebreak: if (ascii == '\n' || ascii == '\r' || ct->dobreak) cu->lines++; } - // linedata is now: width of line - // linedata2 is now: number of characters - // linedata3 is now: maxlen of that line - // linedata4 is now: number of whitespaces of line + /* linedata is now: width of line + * linedata2 is now: number of characters + * linedata3 is now: maxlen of that line + * linedata4 is now: number of whitespaces of line */ if (cu->spacemode != CU_LEFT) { ct = chartransdata; @@ -1023,7 +1023,7 @@ makebreak: /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */ info->mat_nr = 0; } - // We do not want to see any character for \n or \r + /* We do not want to see any character for \n or \r */ if (cha != '\n' && cha != '\r') buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i); @@ -1035,8 +1035,8 @@ makebreak: { uloverlap = xtrax + 0.1f; } - // Find the character, the characters has to be in the memory already - // since character checking has been done earlier already. + /* Find the character, the characters has to be in the memory already + * since character checking has been done earlier already. */ che = find_vfont_char(vfd, cha); twidth = char_width(cu, che, info); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 42c7869a365..a65d03e64cf 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -33,11 +33,13 @@ #include <stddef.h> #include <string.h> +#include "BLI_utildefines.h" +#include "BLI_string.h" +#include "BLI_listbase.h" + #include "BKE_idprop.h" #include "BKE_library.h" -#include "BLI_blenlib.h" - #include "MEM_guardedalloc.h" /* IDPropertyTemplate is a union in DNA_ID.h */ @@ -122,11 +124,10 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index) return GETPROP(prop, index); } -IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item) +void IDP_AppendArray(IDProperty *prop, IDProperty *item) { IDP_ResizeIDPArray(prop, prop->len + 1); IDP_SetIndexArray(prop, prop->len - 1, item); - return item; } void IDP_ResizeIDPArray(IDProperty *prop, int newlen) @@ -603,7 +604,9 @@ IDProperty *IDP_CopyProperty(IDProperty *prop) IDProperty *IDP_GetProperties(ID *id, int create_if_needed) { - if (id->properties) return id->properties; + if (id->properties) { + return id->properties; + } else { if (create_if_needed) { id->properties = MEM_callocN(sizeof(IDProperty), "IDProperty"); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d2a2412843a..658be1fb494 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1216,7 +1216,7 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i { BKE_imformat_defaults(im_format); - // file type + /* file type */ if (imbuf->ftype == IMAGIC) im_format->imtype = R_IMF_IMTYPE_IRIS; @@ -1297,7 +1297,7 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i im_format->quality = imbuf->ftype & ~JPG_MSK; } - // planes + /* planes */ switch (imbuf->channels) { case 0: case 4: im_format->planes = R_IMF_PLANES_RGBA; @@ -1312,6 +1312,31 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i } +static void timecode_simple_string(char *text, size_t text_size, const int cfra, int const frs_sec) +{ + int f = (int)(cfra % frs_sec); + int s = (int)(cfra / frs_sec); + int h = 0; + int m = 0; + + if (s) { + m = (int)(s / 60); + s %= 60; + + if (m) { + h = (int)(m / 60); + m %= 60; + } + } + + if (frs_sec < 100) { + BLI_snprintf(text, text_size, "%02d:%02d:%02d.%02d", h, m, s, f); + } + else { + BLI_snprintf(text, text_size, "%02d:%02d:%02d.%03d", h, m, s, f); + } +} + /* could allow access externally - 512 is for long names, 64 is for id names */ typedef struct StampData { char file[512]; @@ -1371,26 +1396,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d } if (scene->r.stamp & R_STAMP_TIME) { - int f = (int)(scene->r.cfra % scene->r.frs_sec); - int s = (int)(scene->r.cfra / scene->r.frs_sec); - int h = 0; - int m = 0; - - if (s) { - m = (int)(s / 60); - s %= 60; - - if (m) { - h = (int)(m / 60); - m %= 60; - } - } - - if (scene->r.frs_sec < 100) - BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%02d", h, m, s, f); - else - BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f); - + timecode_simple_string(text, sizeof(text), scene->r.cfra, scene->r.frs_sec); BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s" : "%s", text); } else { diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 4755fccff99..5b3e823f050 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -185,7 +185,7 @@ DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts) /* create long vector */ DO_INLINE lfVector *create_lfvector(unsigned int verts) { - // TODO: check if memory allocation was successfull */ + /* TODO: check if memory allocation was successfull */ return (lfVector *)MEM_callocN(verts * sizeof(lfVector), "cloth_implicit_alloc_vector"); // return (lfVector *)cloth_aligned_malloc(&MEMORY_BASE, verts * sizeof(lfVector)); } @@ -529,8 +529,8 @@ DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix) /* copy big matrix */ DO_INLINE void cp_bfmatrix(fmatrix3x3 *to, fmatrix3x3 *from) -{ - // TODO bounds checking +{ + // TODO bounds checking memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount+from[0].scount)); } @@ -1239,13 +1239,13 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, s->flags |= CLOTH_SPRING_FLAG_NEEDED; k = clmd->sim_parms->structural; - + scaling = k + s->stiffness * ABS(clmd->sim_parms->max_struct-k); - + k = scaling / (clmd->sim_parms->avg_spring_len + FLT_EPSILON); - + // TODO: verify, half verified (couldn't see error) - mul_fvector_S(stretch_force, dir, k*(length-L)); + mul_fvector_S(stretch_force, dir, k*(length-L)); VECADD(s->f, s->f, stretch_force); @@ -1833,11 +1833,11 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase * for (i=0, cv=cloth->verts; i<cloth->numverts; i++, cv++) { copy_v3_v3(initial_cos[i], cv->tx); } - + // call collision function // TODO: check if "step" or "step+dt" is correct - dg do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale); - + // copy corrected positions back to simulation for (i = 0; i < numverts; i++) { // correct velocity again, just to be sure we had to change it due to adaptive collisions diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index f51fee674cf..2fe567cc9bf 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -895,7 +895,7 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con /* special case for rotdiff drivers... we don't need a property for this... */ break; - // TODO... add other blocktypes... + /* TODO... add other blocktypes... */ default: printf("IPO2ANIMATO WARNING: No path for blocktype %d, adrcode %d yet\n", blocktype, adrcode); break; @@ -1588,9 +1588,9 @@ static void action_to_animdata(ID *id, bAction *act) /* ------------------------- */ -// TODO: -// - NLA group duplicators info -// - NLA curve/stride modifiers... +/* TODO: + * - NLA group duplicators info + * - NLA curve/stride modifiers... */ /* Convert NLA-Strip to new system */ static void nlastrips_to_animdata(ID *id, ListBase *strips) diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 20e3edc7044..4782d09a7c8 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -51,7 +51,7 @@ #include "BKE_main.h" #include "BKE_node.h" -void *BKE_lamp_add(const char *name) +Lamp *BKE_lamp_add(const char *name) { Lamp *la; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 1cd2d159431..d3ca785caaf 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1357,7 +1357,7 @@ static void lib_indirect_test_id(ID *id, Library *lib) int a; #if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ - // XXX old animation system! -------------------------------------- + /* XXX old animation system! -------------------------------------- */ { bActionStrip *strip; for (strip = ob->nlastrips.first; strip; strip = strip->next) { @@ -1366,7 +1366,7 @@ static void lib_indirect_test_id(ID *id, Library *lib) LIBTAG(strip->ipo); } } - // XXX: new animation system needs something like this? + /* XXX: new animation system needs something like this? */ #endif for (a = 0; a < ob->totcol; a++) { diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index b400332db81..4e683d1618f 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -314,14 +314,32 @@ static int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int return resol; } -float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height, - int *tot_diff_point))[2] +int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const int resol) +{ + int len; + + /* count */ + len = (spline->tot_point - 1) * resol; + + if (spline->flag & MASK_SPLINE_CYCLIC) { + len += resol; + } + else { + len++; + } + + return len; +} + +float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, const int resol, + int *tot_diff_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); MaskSplinePoint *point, *prev; float (*diff_points)[2], (*fp)[2]; - int a, len, resol = BKE_mask_spline_resolution(spline, width, height); + const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); + int a; if (spline->tot_point <= 1) { /* nothing to differentiate */ @@ -329,17 +347,9 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int wi return NULL; } - /* count */ - len = (spline->tot_point - 1) * resol; - - if (spline->flag & MASK_SPLINE_CYCLIC) - len += resol; - else - len++; - /* len+1 because of 'forward_diff_bezier' function */ - *tot_diff_point = len; - diff_points = fp = MEM_mallocN((len + 1) * sizeof(*diff_points), "mask spline vets"); + *tot_diff_point = tot; + diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets"); a = spline->tot_point - 1; if (spline->flag & MASK_SPLINE_CYCLIC) @@ -378,24 +388,54 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int wi return diff_points; } +float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height, + int *tot_diff_point))[2] +{ + int resol = BKE_mask_spline_resolution(spline, width, height); + + return BKE_mask_spline_differentiate_with_resolution_ex(spline, resol, tot_diff_point); +} + float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2] { return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point); } -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, - int *tot_feather_point))[2] +/** + * values align with #BKE_mask_spline_differentiate_with_resolution_ex + * when \a resol arguments match. + */ +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, const int resol, + int *tot_feather_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - + MaskSplinePoint *point, *prev; float (*feather)[2], (*fp)[2]; - int i, j, tot, resol = BKE_mask_spline_feather_resolution(spline, width, height); - tot = resol * spline->tot_point; - feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather diff points"); + const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); + int a; - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *point = &points_array[i]; + /* tot+1 because of 'forward_diff_bezier' function */ + feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points"); + + a = spline->tot_point - 1; + if (spline->flag & MASK_SPLINE_CYCLIC) + a++; + + prev = points_array; + point = prev + 1; + + while (a--) { + /* BezTriple *prevbezt; */ /* UNUSED */ + /* BezTriple *bezt; */ /* UNUSED */ + int j; + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) + point = points_array; + + + /* prevbezt = &prev->bezt; */ + /* bezt = &point->bezt; */ for (j = 0; j < resol; j++, fp++) { float u = (float) j / resol, weight; @@ -403,12 +443,26 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline /* TODO - these calls all calculate similar things * could be unified for some speed */ - BKE_mask_point_segment_co(spline, point, u, co); - BKE_mask_point_normal(spline, point, u, n); - weight = BKE_mask_point_weight(spline, point, u); + BKE_mask_point_segment_co(spline, prev, u, co); + BKE_mask_point_normal(spline, prev, u, n); + weight = BKE_mask_point_weight(spline, prev, u); + + madd_v2_v2v2fl(*fp, co, n, weight); + } + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { + float u = 1.0f, weight; + float co[2], n[2]; + + BKE_mask_point_segment_co(spline, prev, u, co); + BKE_mask_point_normal(spline, prev, u, n); + weight = BKE_mask_point_weight(spline, prev, u); madd_v2_v2v2fl(*fp, co, n, weight); } + + prev = point; + point++; } *tot_feather_point = tot; @@ -416,6 +470,14 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline return feather; } +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, + int *tot_feather_point))[2] +{ + int resol = BKE_mask_spline_feather_resolution(spline, width, height); + + return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, resol, tot_feather_point); +} + float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2] { return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point); @@ -2219,7 +2281,7 @@ void BKE_mask_rasterize_layers(ListBase *masklayers, int width, int height, floa if (tot_diff_point) { PLX_raskterize(diff_points, tot_diff_point, - buffer_tmp, width, height, do_mask_aa); + buffer_tmp, width, height,do_mask_aa); if (tot_diff_feather_points) { PLX_raskterize_feather(diff_points, tot_diff_point, @@ -2273,13 +2335,86 @@ void BKE_mask_rasterize_layers(ListBase *masklayers, int width, int height, floa } } + if(do_mask_aa){ + //PLX_antialias_buffer(buffer,width,height); + } /* clamp at the end */ clamp_vn_vn(buffer, buffer_size); } - MEM_freeN(buffer_tmp); } +#ifdef __PLX_RASKTER_MT__ +void BKE_mask_init_layers(Mask *mask, struct layer_init_data *mlayer_data, int width, int height, const short do_aspect_correct){ + MaskLayer *masklay; + int numLayers=0; + int currLayer=0; + for (masklay = mask->masklayers->first; masklay; masklay = masklay->next) { + numLayers++; + } + mlayer_data = MEM_mallocN(sizeof(struct layer_init_data) * numLayers, __func__); //size correct? + + + for (masklay = mask->masklayers->first; masklay; masklay = masklay->next) { + MaskSpline *spline; + for (spline = masklay->splines.first; spline; spline = spline->next) { + float (*diff_points)[2]; + int tot_diff_point; + + float (*diff_feather_points)[2]; + int tot_diff_feather_points; + + diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, + &tot_diff_point); + + if (tot_diff_point) { + if (do_feather) { + diff_feather_points = + BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, + &tot_diff_feather_points); + } + else { + tot_diff_feather_points = 0; + diff_feather_points = NULL; + } + + if (do_aspect_correct) { + if (width != height) { + float *fp; + float *ffp; + int i; + float asp; + + if (width < height) { + fp = &diff_points[0][0]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; + asp = (float)width / (float)height; + } + else { + fp = &diff_points[0][1]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; + asp = (float)height / (float)width; + } + + for (i = 0; i < tot_diff_point; i++, fp += 2) { + (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; + } + + if (tot_diff_feather_points) { + for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { + (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; + } + } + } + } + PLX_init_base_data(mlayer_data[currLayer], diff_points, tot_diff_points, width, height); + currLayer++; + } + } + } +} +#endif + void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, const short do_aspect_correct, const short do_mask_aa, const short do_feather) diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c new file mode 100644 index 00000000000..bb18166ba6d --- /dev/null +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -0,0 +1,638 @@ +/* + * ***** 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 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/mask_rasterize.c + * \ingroup bke + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_vec_types.h" +#include "DNA_mask_types.h" + +#include "BLI_utildefines.h" +#include "BLI_kdopbvh.h" +#include "BLI_scanfill.h" + +#include "BLI_math.h" +#include "BLI_rect.h" +#include "BLI_listbase.h" +#include "BLI_mempool.h" + +#include "BKE_mask.h" + +#ifndef USE_RASKTER + +#define RESOL 32 + +/** + * A single #MaskRasterHandle contains multile #MaskRasterLayer's, + * each #MaskRasterLayer does its own lookup which contributes to + * the final pixel with its own blending mode and the final pixel is blended between these. + */ + +/* internal use only */ +typedef struct MaskRasterLayer { + /* xy raytree */ + BVHTree *bvhtree; + + /* 2d bounds (to quickly skip raytree lookup) */ + rctf bounds; + + /* geometry */ + unsigned int (*tri_array)[4]; /* access coords tri/quad */ + float (*tri_coords)[3]; /* xy, z 0-1 (1.0 == filled) */ + + + /* copied direct from #MaskLayer.--- */ + /* blending options */ + float alpha; + char blend; + char blend_flag; + +} MaskRasterLayer; + + +/** + * opaque local struct for mask pixel lookup, each MaskLayer needs one of these + */ +struct MaskRasterHandle { + MaskRasterLayer *layers; + unsigned int layers_tot; + + /* 2d bounds (to quickly skip raytree lookup) */ + rctf bounds; +}; + +MaskRasterHandle *BLI_maskrasterize_handle_new(void) +{ + MaskRasterHandle *mr_handle; + + mr_handle = MEM_callocN(sizeof(MaskRasterHandle), STRINGIFY(MaskRasterHandle)); + + return mr_handle; +} + +void BLI_maskrasterize_handle_free(MaskRasterHandle *mr_handle) +{ + const unsigned int layers_tot = mr_handle->layers_tot; + unsigned int i; + MaskRasterLayer *raslayers = mr_handle->layers; + + /* raycast vars */ + for (i = 0; i < layers_tot; i++, raslayers++) { + BLI_bvhtree_free(raslayers->bvhtree); + + if (raslayers->tri_array) { + MEM_freeN(raslayers->tri_array); + } + + if (raslayers->tri_coords) { + MEM_freeN(raslayers->tri_coords); + } + } + + MEM_freeN(mr_handle->layers); + MEM_freeN(mr_handle); +} + +#define PRINT_MASK_DEBUG printf + +#define SF_EDGE_IS_BOUNDARY 0xff + +#define SF_KEYINDEX_TEMP_ID ((unsigned int) -1) + + +void maskrasterize_spline_differentiate_point_inset(float (*diff_feather_points)[2], float (*diff_points)[2], + const int tot_diff_point, const float ofs, const int do_test) +{ + int k_prev = tot_diff_point - 2; + int k_curr = tot_diff_point - 1; + int k_next = 0; + + int k; + + float d_prev[2]; + float d_next[2]; + float d[2]; + + const float *co_prev; + const float *co_curr; + const float *co_next; + + const float ofs_squared = ofs * ofs; + + co_prev = diff_points[k_prev]; + co_curr = diff_points[k_curr]; + co_next = diff_points[k_next]; + + /* precalc */ + sub_v2_v2v2(d_prev, co_prev, co_curr); + normalize_v2(d_prev); + + /* TODO, speedup by only doing one normalize per iter */ + + + for (k = 0; k < tot_diff_point; k++) { + + co_prev = diff_points[k_prev]; + co_curr = diff_points[k_curr]; + co_next = diff_points[k_next]; + + /* sub_v2_v2v2(d_prev, co_prev, co_curr); */ /* precalc */ + sub_v2_v2v2(d_next, co_curr, co_next); + + /* normalize_v2(d_prev); */ /* precalc */ + normalize_v2(d_next); + + if ((do_test == FALSE) || + (len_squared_v2v2(diff_feather_points[k], diff_points[k]) < ofs_squared)) + { + + add_v2_v2v2(d, d_prev, d_next); + + normalize_v2(d); + + diff_feather_points[k][0] = diff_points[k][0] + ( d[1] * ofs); + diff_feather_points[k][1] = diff_points[k][1] + (-d[0] * ofs); + } + + /* use next iter */ + copy_v2_v2(d_prev, d_next); + + k_prev = k_curr; + k_curr = k_next; + k_next++; + } +} + +#define TRI_VERT ((unsigned int) -1) + +void BLI_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mask, + const int width, const int height, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather) +{ + /* TODO: real size */ + const int resol = RESOL; + const float aa_filter_size = 1.0f / MIN2(width, height); + + const float zvec[3] = {0.0f, 0.0f, 1.0f}; + MaskLayer *masklay; + int masklay_index; + + mr_handle->layers_tot = BLI_countlist(&mask->masklayers); + mr_handle->layers = MEM_mallocN(sizeof(MaskRasterLayer) * mr_handle->layers_tot, STRINGIFY(MaskRasterLayer)); + BLI_rctf_init_minmax(&mr_handle->bounds); + + for (masklay = mask->masklayers.first, masklay_index = 0; masklay; masklay = masklay->next, masklay_index++) { + + MaskSpline *spline; + + /* scanfill */ + ScanFillContext sf_ctx; + ScanFillVert *sf_vert = NULL; + ScanFillVert *sf_vert_next = NULL; + ScanFillFace *sf_tri; + + unsigned int sf_vert_tot = 0; + unsigned int tot_feather_quads = 0; + + if (masklay->restrictflag & MASK_RESTRICT_RENDER) { + continue; + } + + BLI_scanfill_begin(&sf_ctx); + + for (spline = masklay->splines.first; spline; spline = spline->next) { + + float (*diff_points)[2]; + int tot_diff_point; + + float (*diff_feather_points)[2]; + int tot_diff_feather_points; + + diff_points = BKE_mask_spline_differentiate_with_resolution_ex(spline, resol, &tot_diff_point); + + /* dont ch*/ + if (do_feather) { + diff_feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, resol, &tot_diff_feather_points); + } + else { + tot_diff_feather_points = 0; + diff_feather_points = NULL; + } + + if (tot_diff_point > 3) { + ScanFillVert *sf_vert_prev; + int j; + + float co[3]; + co[2] = 0.0f; + + if (do_aspect_correct) { + if (width != height) { + float *fp; + float *ffp; + int i; + float asp; + + if (width < height) { + fp = &diff_points[0][0]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; + asp = (float)width / (float)height; + } + else { + fp = &diff_points[0][1]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; + asp = (float)height / (float)width; + } + + for (i = 0; i < tot_diff_point; i++, fp += 2) { + (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; + } + + if (tot_diff_feather_points) { + for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { + (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; + } + } + } + } + + /* fake aa, using small feather */ + if (do_mask_aa == TRUE) { + if (do_feather == FALSE) { + tot_diff_feather_points = tot_diff_point; + diff_feather_points = MEM_mallocN(sizeof(*diff_feather_points) * tot_diff_feather_points, __func__); + /* add single pixel feather */ + maskrasterize_spline_differentiate_point_inset(diff_feather_points, diff_points, + tot_diff_point, aa_filter_size, FALSE); + } + else { + /* ensure single pixel feather, on any zero feather areas */ + maskrasterize_spline_differentiate_point_inset(diff_feather_points, diff_points, + tot_diff_point, aa_filter_size, TRUE); + } + } + + copy_v2_v2(co, diff_points[0]); + sf_vert_prev = BLI_scanfill_vert_add(&sf_ctx, co); + sf_vert_prev->tmp.u = sf_vert_tot; + sf_vert_prev->keyindex = sf_vert_tot + tot_diff_point; /* absolute index of feather vert */ + sf_vert_tot++; + + /* TODO, an alternate functions so we can avoid double vector copy! */ + for (j = 1; j < tot_diff_point; j++) { + copy_v2_v2(co, diff_points[j]); + sf_vert = BLI_scanfill_vert_add(&sf_ctx, co); + sf_vert->tmp.u = sf_vert_tot; + sf_vert->keyindex = sf_vert_tot + tot_diff_point; /* absolute index of feather vert */ + sf_vert_tot++; + } + + sf_vert = sf_vert_prev; + sf_vert_prev = sf_ctx.fillvertbase.last; + + for (j = 0; j < tot_diff_point; j++) { + ScanFillEdge *sf_edge = BLI_scanfill_edge_add(&sf_ctx, sf_vert_prev, sf_vert); + sf_edge->tmp.c = SF_EDGE_IS_BOUNDARY; + + sf_vert_prev = sf_vert; + sf_vert = sf_vert->next; + } + + if (diff_feather_points) { + float co_feather[3]; + co_feather[2] = 1.0f; + + BLI_assert(tot_diff_feather_points == tot_diff_point); + + /* note: only added for convenience, we dont infact use these to scanfill, + * only to create feather faces after scanfill */ + for (j = 0; j < tot_diff_feather_points; j++) { + copy_v2_v2(co_feather, diff_feather_points[j]); + sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather); + + /* no need for these attrs */ +#if 0 + sf_vert->tmp.u = sf_vert_tot; + sf_vert->keyindex = sf_vert_tot + tot_diff_point; /* absolute index of feather vert */ +#endif + sf_vert->keyindex = SF_KEYINDEX_TEMP_ID; + sf_vert_tot++; + } + + if (diff_feather_points) { + MEM_freeN(diff_feather_points); + } + + tot_feather_quads += tot_diff_point; + } + } + + if (diff_points) { + MEM_freeN(diff_points); + } + } + + if (sf_ctx.fillvertbase.first) { + unsigned int (*tri_array)[4], *tri; /* access coords */ + float (*tri_coords)[3], *cos; /* xy, z 0-1 (1.0 == filled) */ + int sf_tri_tot; + rctf bounds; + int tri_index; + + BVHTree *bvhtree; + float bvhcos[4][3]; + + /* now we have all the splines */ + tri_coords = MEM_mallocN((sizeof(float) * 3) * sf_vert_tot, "maskrast_tri_coords"); + + /* init bounds */ + BLI_rctf_init_minmax(&bounds); + + /* coords */ + cos = (float *)tri_coords; + for (sf_vert = sf_ctx.fillvertbase.first; sf_vert; sf_vert = sf_vert_next) { + sf_vert_next = sf_vert->next; + copy_v3_v3(cos, sf_vert->co); + + /* remove so as not to interfear with fill (called after) */ + if (sf_vert->keyindex == SF_KEYINDEX_TEMP_ID) { + BLI_remlink(&sf_ctx.fillvertbase, sf_vert); + } + + /* bounds */ + BLI_rctf_do_minmax_v(&bounds, cos); + + cos += 3; + } + + /* main scanfill */ + sf_tri_tot = BLI_scanfill_calc_ex(&sf_ctx, FALSE, zvec); + + tri_array = MEM_mallocN(sizeof(*tri_array) * (sf_tri_tot + tot_feather_quads), "maskrast_tri_index"); + + /* */ + bvhtree = BLI_bvhtree_new(sf_tri_tot + tot_feather_quads, 0.000001f, 8, 6); + + /* tri's */ + tri = (unsigned int *)tri_array; + for (sf_tri = sf_ctx.fillfacebase.first, tri_index = 0; sf_tri; sf_tri = sf_tri->next, tri_index++) { + *(tri++) = sf_tri->v1->tmp.u; + *(tri++) = sf_tri->v2->tmp.u; + *(tri++) = sf_tri->v3->tmp.u; + *(tri++) = TRI_VERT; + + copy_v3_v3(bvhcos[0], tri_coords[*(tri - 4)]); + copy_v3_v3(bvhcos[1], tri_coords[*(tri - 3)]); + copy_v3_v3(bvhcos[2], tri_coords[*(tri - 2)]); + + BLI_bvhtree_insert(bvhtree, tri_index, (float *)bvhcos, 3); + } + + /* start of feather faces... if we have this set, + * 'tri_index' is kept from loop above */ + + BLI_assert(tri_index == sf_tri_tot); + + if (tot_feather_quads) { + ScanFillEdge *sf_edge; + + for (sf_edge = sf_ctx.filledgebase.first; sf_edge; sf_edge = sf_edge->next) { + if (sf_edge->tmp.c == SF_EDGE_IS_BOUNDARY) { + *(tri++) = sf_edge->v1->tmp.u; + *(tri++) = sf_edge->v2->tmp.u; + *(tri++) = sf_edge->v2->keyindex; + *(tri++) = sf_edge->v1->keyindex; + + copy_v3_v3(bvhcos[0], tri_coords[*(tri - 4)]); + copy_v3_v3(bvhcos[1], tri_coords[*(tri - 3)]); + copy_v3_v3(bvhcos[2], tri_coords[*(tri - 2)]); + copy_v3_v3(bvhcos[3], tri_coords[*(tri - 1)]); + + BLI_bvhtree_insert(bvhtree, tri_index++, (const float *)bvhcos, 4); + } + } + } + + fprintf(stderr, "%d %d\n", tri_index, sf_tri_tot + tot_feather_quads); + + BLI_assert(tri_index == sf_tri_tot + tot_feather_quads); + + BLI_bvhtree_balance(bvhtree); + + { + MaskRasterLayer *raslayer = &mr_handle->layers[masklay_index]; + + raslayer->tri_coords = tri_coords; + raslayer->tri_array = tri_array; + raslayer->bounds = bounds; + raslayer->bvhtree = bvhtree; + + /* copy as-is */ + raslayer->alpha = masklay->alpha; + raslayer->blend = masklay->blend; + raslayer->blend_flag = masklay->blend_flag; + + + BLI_union_rctf(&mr_handle->bounds, &bounds); + } + + PRINT_MASK_DEBUG("tris %d, feather tris %d\n", sf_tri_tot, tot_feather_quads); + } + + /* add trianges */ + BLI_scanfill_end(&sf_ctx); + } +} + +//static void tri_flip_tri(unsigned int tri[3]) +//{ + +//} + +/* 2D ray test */ +static float maskrasterize_layer_z_depth_tri(const float pt[2], + const float v1[3], const float v2[3], const float v3[3]) +{ + float w[3]; + barycentric_weights_v2(v1, v2, v3, pt, w); + return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]); +} + +#if 0 +static float maskrasterize_layer_z_depth_quad(const float pt[2], + const float v1[3], const float v2[3], const float v3[3], const float v4[3]) +{ + float w[4]; + barycentric_weights_v2_quad(v1, v2, v3, v4, pt, w); + return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]) + (v4[2] * w[3]); +} +#endif + +static void maskrasterize_layer_bvh_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) +{ + MaskRasterLayer *layer = (struct MaskRasterLayer *)userdata; + unsigned int *tri = layer->tri_array[index]; + float (*cos)[3] = layer->tri_coords; + const float dist_orig = hit->dist; + + /* we always cast from same place only need xy */ + if (tri[3] == TRI_VERT) { + /* --- tri --- */ + + /* not essential but avoids unneeded extra lookups */ + if ((cos[0][2] < dist_orig) || + (cos[1][2] < dist_orig) || + (cos[2][2] < dist_orig)) + { + if (isect_point_tri_v2(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]])) { + /* we know all tris are close for now */ +#if 0 + const float dist = maskrasterize_layer_z_depth_tri(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]]); + if (dist < dist_orig) { + hit->index = index; + hit->dist = dist; + } +#else + hit->index = index; + hit->dist = 0.0f; +#endif + } + } + } + else { + /* --- quad --- */ + + /* not essential but avoids unneeded extra lookups */ + if ((cos[0][2] < dist_orig) || + (cos[1][2] < dist_orig) || + (cos[2][2] < dist_orig) || + (cos[3][2] < dist_orig)) + { + + /* needs work */ +#if 0 + if (isect_point_quad_v2(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]], cos[tri[3]])) { + const float dist = maskrasterize_layer_z_depth_quad(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]], cos[tri[3]]); + if (dist < dist_orig) { + hit->index = index; + hit->dist = dist; + } + } +#elif 1 + if (isect_point_tri_v2(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]])) { + const float dist = maskrasterize_layer_z_depth_tri(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]]); + if (dist < dist_orig) { + hit->index = index; + hit->dist = dist; + } + } + else if (isect_point_tri_v2(ray->origin, cos[tri[0]], cos[tri[2]], cos[tri[3]])) { + const float dist = maskrasterize_layer_z_depth_tri(ray->origin, cos[tri[0]], cos[tri[2]], cos[tri[3]]); + if (dist < dist_orig) { + hit->index = index; + hit->dist = dist; + } + } +#else + /* cheat - we know first 2 verts are z0.0f and second 2 are z 1.0f */ + /* ... worth looking into */ +#endif + } + } +} + +float BLI_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2]) +{ + /* TODO - AA jitter */ + + if (BLI_in_rctf_v(&mr_handle->bounds, xy)) { + const unsigned int layers_tot = mr_handle->layers_tot; + unsigned int i; + MaskRasterLayer *layer = mr_handle->layers; + + /* raycast vars*/ + const float co[3] = {xy[0], xy[1], 0.0f}; + const float dir[3] = {0.0f, 0.0f, 1.0f}; + const float radius = 1.0f; + BVHTreeRayHit hit = {0}; + + /* return */ + float value = 0.0f; + + for (i = 0; i < layers_tot; i++, layer++) { + + if (BLI_in_rctf_v(&layer->bounds, xy)) { + + hit.dist = FLT_MAX; + hit.index = -1; + + /* TODO, and axis aligned version of this function, avoids 2 casts */ + BLI_bvhtree_ray_cast(layer->bvhtree, co, dir, radius, &hit, maskrasterize_layer_bvh_cb, layer); + + /* --- hit (start) --- */ + if (hit.index != -1) { + const float dist = 1.0f - hit.dist; + const float dist_ease = (3.0f * dist * dist - 2.0f * dist * dist * dist); + + float v; + /* apply alpha */ + v = dist_ease * layer->alpha; + + if (layer->blend_flag & MASK_BLENDFLAG_INVERT) { + v = 1.0f - v; + } + + switch (layer->blend) { + case MASK_BLEND_SUBTRACT: + { + value -= v; + break; + } + case MASK_BLEND_ADD: + default: + { + value += v; + break; + } + } + } + /* --- hit (end) --- */ + + } + } + + return CLAMPIS(value, 0.0f, 1.0f); + } + else { + return 0.0f; + } +} + +#endif /* USE_RASKTER */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e0761311c98..6167379309c 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1619,13 +1619,13 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall) /* boolean check to see if the mesh needs a material */ static int check_tfaceneedmaterial(int flag) { - // check if the flags we have are not deprecated != than default material options - // also if only flags are visible and collision see if all objects using this mesh have this option in physics + /* check if the flags we have are not deprecated != than default material options + * also if only flags are visible and collision see if all objects using this mesh have this option in physics */ /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */ flag -= 1; - // deprecated flags + /* deprecated flags */ flag &= ~TF_OBCOL; flag &= ~TF_SHAREDVERT; flag &= ~TF_SHAREDCOL; @@ -1633,12 +1633,12 @@ static int check_tfaceneedmaterial(int flag) /* light tface flag is ignored in GLSL mode */ flag &= ~TF_LIGHT; - // automatic detected if tex image has alpha + /* automatic detected if tex image has alpha */ flag &= ~(TF_ALPHA << 15); - // automatic detected if using texture + /* automatic detected if using texture */ flag &= ~TF_TEX; - // settings for the default NoMaterial + /* settings for the default NoMaterial */ if (flag == TF_DYNAMIC) return 0; @@ -1647,7 +1647,7 @@ static int check_tfaceneedmaterial(int flag) } /* return number of digits of an integer */ -// XXX to be optmized or replaced by an equivalent blender internal function +/* XXX to be optmized or replaced by an equivalent blender internal function */ static int integer_getdigits(int number) { int i = 0; @@ -1662,9 +1662,9 @@ static int integer_getdigits(int number) static void calculate_tface_materialname(char *matname, char *newname, int flag) { - // if flag has only light and collision and material matches those values - // you can do strcpy(name, mat_name); - // otherwise do: + /* if flag has only light and collision and material matches those values + * you can do strcpy(name, mat_name); + * otherwise do: */ int digits = integer_getdigits(flag); /* clamp the old name, remove the MA prefix and add the .TF.flag suffix * e.g. matname = "MALoooooooooooooongName"; newname = "Loooooooooooooon.TF.2" */ @@ -1737,9 +1737,9 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) set_facetexture_flags(ma, tf->tpage); decode_tfaceflag(ma, flag, 1); - // the final decoding will happen after, outside the main loop - // for now store the flag into the material and change light/tex/collision - // store the flag as a negative number + /* the final decoding will happen after, outside the main loop + * for now store the flag into the material and change light/tex/collision + * store the flag as a negative number */ ma->game.flag = -flag; id_us_min((ID *)ma); } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 54e93f58307..de367b6b4d0 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -322,6 +322,8 @@ typedef struct MovieClipCache { /* cache for stable shot */ struct { + ImBuf *reference_ibuf; + ImBuf *ibuf; int framenr; int postprocess_flag; @@ -338,6 +340,10 @@ typedef struct MovieClipImBufCacheKey { short render_flag; } MovieClipImBufCacheKey; +typedef struct MovieClipCachePriorityData { + int framenr; +} MovieClipCachePriorityData; + static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags) { MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)userkey; @@ -378,6 +384,32 @@ static int moviecache_hashcmp(const void *av, const void *bv) return 0; } +void *moviecache_getprioritydata(void *key_v) +{ + MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *) key_v; + MovieClipCachePriorityData *priority_data; + + priority_data = MEM_callocN(sizeof(priority_data), "movie cache clip priority data"); + priority_data->framenr = key->framenr; + + return priority_data; +} + +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; + + return -abs(last_userkey->framenr - priority_data->framenr); +} + +void moviecache_prioritydeleter(void *priority_data_v) +{ + MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *) priority_data_v; + + MEM_freeN(priority_data); +} + static ImBuf *get_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag) { if (clip->cache) { @@ -405,10 +437,20 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i MovieClipImBufCacheKey key; if (!clip->cache) { + struct MovieCache *moviecache; + + // char cache_name[64]; + // BLI_snprintf(cache_name, sizeof(cache_name), "movie %s", clip->id.name); + clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache"); - clip->cache->moviecache = IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash, - moviecache_hashcmp, moviecache_keydata); + moviecache = IMB_moviecache_create("movieclip", sizeof(MovieClipImBufCacheKey), moviecache_hashhash, moviecache_hashcmp); + + IMB_moviecache_set_getdata_callback(moviecache, moviecache_keydata); + IMB_moviecache_set_priority_callback(moviecache, moviecache_getprioritydata, moviecache_getitempriority, + moviecache_prioritydeleter); + + clip->cache->moviecache = moviecache; } key.framenr = user->framenr; @@ -655,9 +697,6 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u MovieTrackingCamera *camera = &clip->tracking.camera; ImBuf *postproc_ibuf = NULL; - if (cache->postprocessed.ibuf) - IMB_freeImBuf(cache->postprocessed.ibuf); - cache->postprocessed.framenr = user->framenr; cache->postprocessed.flag = postprocess_flag; @@ -695,13 +734,10 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u IMB_refImBuf(postproc_ibuf); - cache->postprocessed.ibuf = postproc_ibuf; + if (cache->postprocessed.ibuf) + IMB_freeImBuf(cache->postprocessed.ibuf); - if (cache->stabilized.ibuf) { - /* force stable buffer be re-calculated */ - IMB_freeImBuf(cache->stabilized.ibuf); - cache->stabilized.ibuf = NULL; - } + cache->postprocessed.ibuf = postproc_ibuf; return postproc_ibuf; } @@ -777,7 +813,8 @@ ImBuf *BKE_movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user return movieclip_get_postprocessed_ibuf(clip, user, clip->flag, postprocess_flag, 0); } -static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int framenr, int postprocess_flag) +static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, ImBuf *reference_ibuf, + int framenr, int postprocess_flag) { MovieClipCache *cache = clip->cache; MovieTracking *tracking = &clip->tracking; @@ -796,6 +833,9 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr) return NULL; + if (cache->stabilized.reference_ibuf != reference_ibuf) + return NULL; + /* cached ibuf used different proxy settings */ if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy) return NULL; @@ -836,13 +876,8 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user float tloc[2], tscale, tangle; int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr); - if (cache->stabilized.ibuf) - IMB_freeImBuf(cache->stabilized.ibuf); - stableibuf = BKE_tracking_stabilize_frame(&clip->tracking, clip_framenr, ibuf, tloc, &tscale, &tangle); - cache->stabilized.ibuf = stableibuf; - copy_v2_v2(cache->stabilized.loc, tloc); cache->stabilized.scale = tscale; @@ -862,6 +897,11 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user cache->stabilized.postprocess_flag = postprocess_flag; + if (cache->stabilized.ibuf) + IMB_freeImBuf(cache->stabilized.ibuf); + + cache->stabilized.ibuf = stableibuf; + IMB_refImBuf(stableibuf); return stableibuf; @@ -881,7 +921,7 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { MovieClipCache *cache = clip->cache; - stableibuf = get_stable_cached_frame(clip, user, framenr, postprocess_flag); + stableibuf = get_stable_cached_frame(clip, user, ibuf, framenr, postprocess_flag); if (!stableibuf) stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index fb15aa82fa2..d62b03b5060 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -407,7 +407,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short /* reversed = play strip backwards */ if (strip->flag & NLASTRIP_FLAG_REVERSE) { - // FIXME: this won't work right with Graph Editor? + /* FIXME: this won't work right with Graph Editor? */ if (mode == NLATIME_CONVERT_MAP) { return strip->end - scale * (cframe - strip->actstart); } @@ -1154,7 +1154,7 @@ static short nlastrip_is_first(AnimData *adt, NlaStrip *strip) return 0; /* check other tracks to see if they have a strip that's earlier */ - // TODO: or should we check that the strip's track is also the first? + /* TODO: or should we check that the strip's track is also the first? */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { /* only check the first strip, assuming that they're all in order */ ns = nlt->strips.first; @@ -1234,7 +1234,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) /* store path - make copy, and store that */ fcu->rna_path = BLI_strdupn("influence", 9); - // TODO: insert a few keyframes to ensure default behavior? + /* TODO: insert a few keyframes to ensure default behavior? */ } } @@ -1255,7 +1255,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) /* store path - make copy, and store that */ fcu->rna_path = BLI_strdupn("strip_time", 10); - // TODO: insert a few keyframes to ensure default behavior? + /* TODO: insert a few keyframes to ensure default behavior? */ } } } @@ -1340,7 +1340,7 @@ static void nlastrip_get_endpoint_overlaps(NlaStrip *strip, NlaTrack *track, flo /* find strips that overlap over the start/end of the given strip, * but which don't cover the entire length */ - // TODO: this scheme could get quite slow for doing this on many strips... + /* TODO: this scheme could get quite slow for doing this on many strips... */ for (nls = track->strips.first; nls; nls = nls->next) { /* check if strip overlaps (extends over or exactly on) the entire range of the strip we're validating */ if ((nls->start <= strip->start) && (nls->end >= strip->end)) { @@ -1443,7 +1443,7 @@ void BKE_nla_validate_state(AnimData *adt) /* apart from 'nothing' option which user has to explicitly choose, we don't really know if * we should be overwriting the extend setting (but assume that's what the user wanted) */ - // TODO: 1 solution is to tie this in with auto-blending... + /* TODO: 1 solution is to tie this in with auto-blending... */ if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) { /* 1) First strip must be set to extend hold, otherwise, stuff before acts dodgy * 2) Only overwrite extend mode if *not* changing it will most probably result in @@ -1469,20 +1469,20 @@ void BKE_nla_validate_state(AnimData *adt) * for normal editing only (i.e. not in editmode for some strip's action), * so no checks for this are performed. */ -// TODO: maybe we should have checks for this too... +/* TODO: maybe we should have checks for this too... */ void BKE_nla_action_pushdown(AnimData *adt) { NlaStrip *strip; - + /* sanity checks */ - // TODO: need to report the error for this + /* TODO: need to report the error for this */ if (ELEM(NULL, adt, adt->action)) return; - - /* if the action is empty, we also shouldn't try to add to stack, + + /* if the action is empty, we also shouldn't try to add to stack, * as that will cause us grief down the track */ - // TODO: what about modifiers? + /* TODO: what about modifiers? */ if (action_has_motion(adt->action) == 0) { printf("BKE_nla_action_pushdown(): action has no data\n"); return; @@ -1505,7 +1505,7 @@ void BKE_nla_action_pushdown(AnimData *adt) /* not first, so extend mode can only be NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD, * so that it doesn't override strips in previous tracks */ - // FIXME: this needs to be more automated, since user can rearrange strips + /* FIXME: this needs to be more automated, since user can rearrange strips */ strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; } @@ -1632,8 +1632,8 @@ void BKE_nla_tweakmode_exit(AnimData *adt) if ((adt->flag & ADT_NLA_EDIT_ON) == 0) return; - // TODO: need to sync the user-strip with the new state of the action! - + /* TODO: need to sync the user-strip with the new state of the action! */ + /* for all Tracks, clear the 'disabled' flag * for all Strips, clear the 'tweak-user' flag */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 33df8e4b503..56b1c0a17e8 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -321,15 +321,18 @@ bNode *nodeAddNode(bNodeTree *ntree, struct bNodeTemplate *ntemp) node->color[0] = node->color[1] = node->color[2] = 0.608; /* default theme color */ node_add_sockets_from_type(ntree, node, ntype); - - /* initialize the node name with the node label */ - BLI_strncpy(node->name, nodeLabel(node), NODE_MAXSTR); - nodeUniqueName(ntree, node); - + BLI_addtail(&ntree->nodes, node); if (ntype->initfunc!=NULL) ntype->initfunc(ntree, node, ntemp); + + /* initialize the node name with the node label. + * note: do this after the initfunc so nodes get + * their data set which may be used in naming + * (node groups for example) */ + BLI_strncpy(node->name, nodeLabel(node), NODE_MAXSTR); + nodeUniqueName(ntree, node); ntree->update |= NTREE_UPDATE_NODES; @@ -1939,6 +1942,7 @@ static void registerCompositNodes(bNodeTreeType *ttype) register_node_type_cmp_switch(ttype); register_node_type_cmp_mask(ttype); + register_node_type_cmp_trackpos(ttype); } static void registerShaderNodes(bNodeTreeType *ttype) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index cd53bf01a67..f471ffef0f6 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -225,7 +225,7 @@ void BKE_object_link_modifiers(struct Object *ob, struct Object *from) BKE_object_copy_particlesystems(ob, from); BKE_object_copy_softbody(ob, from); - // TODO: smoke?, cloth? + /* TODO: smoke?, cloth? */ } /* here we will collect all local displist stuff */ @@ -378,7 +378,7 @@ void BKE_object_unlink(Object *ob) unlink_actuators(&ob->actuators); /* check all objects: parents en bevels and fields, also from libraries */ - // FIXME: need to check all animation blocks (drivers) + /* FIXME: need to check all animation blocks (drivers) */ obt = bmain->object.first; while (obt) { if (obt->proxy == ob) @@ -1386,7 +1386,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) BKE_object_copy_proxy_drivers(ob, target); /* skip constraints? */ - // FIXME: this is considered by many as a bug + /* FIXME: this is considered by many as a bug */ /* set object type and link to data */ ob->type = target->type; @@ -1968,8 +1968,8 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] break; } - // total - mul_serie_m4(tmat, totmat, ob->parentinv, + /* total */ + mul_serie_m4(tmat, totmat, ob->parentinv, NULL, NULL, NULL, NULL, NULL, NULL); mul_serie_m4(obmat, tmat, locmat, NULL, NULL, NULL, NULL, NULL, NULL); @@ -1978,10 +1978,10 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] } else { - // external usable originmat + /* external usable originmat */ copy_m3_m4(originmat, tmat); - // origin, voor help line + /* origin, for help line */ if ((ob->partype & PARTYPE) == PARSKEL) { copy_v3_v3(ob->orig, par->obmat[3]); } @@ -1997,7 +1997,7 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ float fac1, fac2; int a; - // include framerate + /* include framerate */ fac1 = (1.0f / (1.0f + fabsf(ob->sf)) ); if (fac1 >= 1.0f) return 0; fac2 = 1.0f - fac1; @@ -2310,14 +2310,21 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) } if (change == FALSE) { + float size[3]; + + copy_v3_v3(size, ob->size); + if (ob->type == OB_EMPTY) { + mul_v3_fl(size, ob->empty_drawsize); + } + minmax_v3v3_v3(min_r, max_r, ob->obmat[3]); copy_v3_v3(vec, ob->obmat[3]); - add_v3_v3(vec, ob->size); + add_v3_v3(vec, size); minmax_v3v3_v3(min_r, max_r, vec); copy_v3_v3(vec, ob->obmat[3]); - sub_v3_v3(vec, ob->size); + sub_v3_v3(vec, size); minmax_v3v3_v3(min_r, max_r, vec); } } @@ -2513,7 +2520,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, * which is only in BKE_object_where_is_calc now */ - // XXX: should this case be OB_RECALC_OB instead? + /* XXX: should this case be OB_RECALC_OB instead? */ if (ob->recalc & OB_RECALC_ALL) { if (G.debug & G_DEBUG) @@ -2549,7 +2556,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) if (adt) { /* evaluate drivers - datalevel */ - // XXX: for mesh types, should we push this to derivedmesh instead? + /* XXX: for mesh types, should we push this to derivedmesh instead? */ BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS); } @@ -3173,7 +3180,7 @@ struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet /* iterate over all selected and visible objects */ for (base = scene->base.first; base; base = base->next) { if (objectSet == OB_SET_ALL) { - // as we get all anyways just add it + /* as we get all anyways just add it */ Object *ob = base->object; obrel_list_add(&links, ob); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index a2c89967f44..52acbeb94e5 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -132,7 +132,7 @@ int countPackedFiles(Main *bmain) bSound *sound; int count = 0; - // let's check if there are packed files... + /* let's check if there are packed files... */ for (ima = bmain->image.first; ima; ima = ima->id.next) if (ima->packedfile) count++; @@ -181,13 +181,13 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char //XXX waitcursor(1); - // convert relative filenames to absolute filenames - + /* convert relative filenames to absolute filenames */ + BLI_strncpy(name, filename, sizeof(name)); BLI_path_abs(name, basepath); - - // open the file - // and create a PackedFile structure + + /* open the file + * and create a PackedFile structure */ file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file <= 0) { @@ -197,8 +197,8 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char filelen = BLI_file_descriptor_size(file); if (filelen == 0) { - // MEM_mallocN complains about MEM_mallocN(0, "bla"); - // we don't care.... + /* MEM_mallocN complains about MEM_mallocN(0, "bla"); + * we don't care.... */ data = MEM_mallocN(1, "packFile"); } else { @@ -294,7 +294,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i } } - // make sure the path to the file exists... + /* make sure the path to the file exists... */ BLI_make_existing_file(name); file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); @@ -354,23 +354,23 @@ int checkPackedFile(const char *filename, PackedFile *pf) ret_val = PF_DIFFERS; } else { - // we'll have to compare the two... - + /* we'll have to compare the two... */ + file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file < 0) { ret_val = PF_NOFILE; } else { ret_val = PF_EQUAL; - + for (i = 0; i < pf->size; i += sizeof(buf)) { len = pf->size - i; if (len > sizeof(buf)) { len = sizeof(buf); } - + if (read(file, buf, len) != len) { - // read error ... + /* read error ... */ ret_val = PF_DIFFERS; break; } @@ -412,24 +412,24 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na temp = abs_name; break; case PF_USE_LOCAL: - // if file exists use it + /* if file exists use it */ if (BLI_exists(local_name)) { temp = local_name; break; } - // else fall through and create it + /* else fall through and create it */ case PF_WRITE_LOCAL: if (writePackedFile(reports, local_name, pf, 1) == RET_OK) { temp = local_name; } break; case PF_USE_ORIGINAL: - // if file exists use it + /* if file exists use it */ if (BLI_exists(abs_name)) { temp = abs_name; break; } - // else fall through and create it + /* else fall through and create it */ case PF_WRITE_ORIGINAL: if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) { temp = abs_name; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a1fe1f7b8a9..c8b07e2ec11 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -546,7 +546,7 @@ void psys_free(Object *ob, ParticleSystem *psys) psys->totchild = 0; } - // check if we are last non-visible particle system + /* check if we are last non-visible particle system */ for (tpsys = ob->particlesystem.first; tpsys; tpsys = tpsys->next) { if (tpsys->part) { if (ELEM(tpsys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { @@ -555,7 +555,7 @@ void psys_free(Object *ob, ParticleSystem *psys) } } } - // clear do-not-draw-flag + /* clear do-not-draw-flag */ if (!nr) ob->transflag &= ~OB_DUPLIPARTS; @@ -3400,6 +3400,12 @@ void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, Pa { float vec[3]; + /* can happen when called from a different object's modifier */ + if (!dm) { + unit_m4(hairmat); + return; + } + psys_face_mat(0, dm, pa, hairmat, 0); psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, 0, 0); copy_v3_v3(hairmat[3], vec); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 65f22ebc88f..aa798f59482 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1576,7 +1576,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) } } -static void get_angular_velocity_vector(short avemode, ParticleKey *state, float *vec) +static void get_angular_velocity_vector(short avemode, ParticleKey *state, float vec[3]) { switch (avemode) { case PART_AVE_VELOCITY: diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index b82521504dd..46ddce4b51b 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -223,8 +223,8 @@ int compare_property(bProperty *prop, const char *str) case GPROP_FLOAT: case GPROP_TIME: - // WARNING: untested for GPROP_TIME - // function isn't used currently + /* WARNING: untested for GPROP_TIME + * function isn't used currently */ fvalue = *((float *)&prop->data); ftest = (float)atof(str); if (fvalue > ftest) return 1; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index e0aed029451..4a5267be7b3 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -260,10 +260,10 @@ void BKE_scene_free(Scene *sce) /* do not free objects! */ if (sce->gpd) { -#if 0 // removed since this can be invalid memory when freeing everything - // since the grease pencil data is freed before the scene. - // since grease pencil data is not (yet?), shared between objects - // its probably safe not to do this, some save and reload will free this. +#if 0 /* removed since this can be invalid memory when freeing everything */ + /* since the grease pencil data is freed before the scene. + * since grease pencil data is not (yet?), shared between objects + * its probably safe not to do this, some save and reload will free this. */ sce->gpd->id.us--; #endif sce->gpd = NULL; @@ -494,7 +494,7 @@ Scene *BKE_scene_add(const char *name) BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); - BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); + BLI_rctf_init(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); sce->r.osa = 8; /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ @@ -959,9 +959,9 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) if (scene->adt && scene->adt->drivers.first) { BKE_animsys_evaluate_animdata(scene, &scene->id, scene->adt, ctime, ADT_RECALC_DRIVERS); } - + /* world */ - // TODO: what about world textures? but then those have nodes too... + /* TODO: what about world textures? but then those have nodes too... */ if (scene->world) { ID *wid = (ID *)scene->world; AnimData *adt = BKE_animdata_from_id(wid); @@ -1067,7 +1067,7 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) sound_set_cfra(sce->r.cfra); /* clear animation overrides */ - // XXX TODO... + /* XXX TODO... */ for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set) { if (sce_iter->theDag == NULL) diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 582034ae623..0d91dcb7faa 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -98,8 +98,7 @@ void seq_stripelem_cache_cleanup(void) { if (moviecache) { IMB_moviecache_free(moviecache); - moviecache = IMB_moviecache_create(sizeof(SeqCacheKey), seqcache_hashhash, - seqcache_hashcmp, NULL); + moviecache = IMB_moviecache_create("seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp); } } @@ -133,8 +132,7 @@ void seq_stripelem_cache_put( } if (!moviecache) { - moviecache = IMB_moviecache_create(sizeof(SeqCacheKey), seqcache_hashhash, - seqcache_hashcmp, NULL); + moviecache = IMB_moviecache_create("seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp); } key.seq = seq; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 6e5149d7924..2e2f0e54792 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1848,7 +1848,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x TransformVars *transform = (TransformVars *)seq->effectdata; float scale_x, scale_y, translate_x, translate_y, rotate_radians; - // Scale + /* Scale */ if (transform->uniform_scale) { scale_x = scale_y = transform->ScalexIni; } @@ -1857,7 +1857,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x scale_y = transform->ScaleyIni; } - // Translate + /* Translate */ if (!transform->percent) { float rd_s = (scene->r.size / 100.0f); @@ -1868,8 +1868,8 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x translate_x = x * (transform->xIni / 100.0f) + (x / 2.0f); translate_y = y * (transform->yIni / 100.0f) + (y / 2.0f); } - - // Rotate + + /* Rotate */ rotate_radians = DEG2RADF(transform->rotIni); transform_image(x, y, ibuf1, out, scale_x, scale_y, translate_x, translate_y, rotate_radians, transform->interpolation); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 78ccdc425e5..902eeefd934 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2528,7 +2528,7 @@ static ImBuf *seq_render_strip_stack( #if 0 /* commentind since this breaks keyframing, since it resets the value on draw */ if (scene->r.cfra != cfra) { - // XXX for prefetch and overlay offset!..., very bad!!! + /* XXX for prefetch and overlay offset!..., very bad!!! */ AnimData *adt = BKE_animdata_from_id(&scene->id); BKE_animsys_evaluate_animdata(scene, &scene->id, adt, cfra, ADT_RECALC_ANIM); } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 464b7fda51d..f9399946570 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -120,13 +120,13 @@ void space_transform_invert(const SpaceTransform *data, float co[3]) static void space_transform_apply_normal(const SpaceTransform *data, float no[3]) { mul_mat3_m4_v3(((SpaceTransform *)data)->local2target, no); - normalize_v3(no); // TODO: could we just determine de scale value from the matrix? + normalize_v3(no); /* TODO: could we just determine de scale value from the matrix? */ } static void space_transform_invert_normal(const SpaceTransform *data, float no[3]) { mul_mat3_m4_v3(((SpaceTransform *)data)->target2local, no); - normalize_v3(no); // TODO: could we just determine de scale value from the matrix? + normalize_v3(no); /* TODO: could we just determine de scale value from the matrix? */ } /* diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 7081a642b8a..5bad69c2e8d 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1413,11 +1413,11 @@ int BKE_texture_dependsOnTime(const struct Tex *texture) return 1; } else if (texture->adt) { - // assume anything in adt means the texture is animated + /* assume anything in adt means the texture is animated */ return 1; } else if (texture->type == TEX_NOISE) { - // noise always varies with time + /* noise always varies with time */ return 1; } return 0; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index f72942df8b3..f22fd74baf4 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -516,7 +516,7 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->qmax = 51; } - // Keep lossless encodes in the RGB domain. + /* Keep lossless encodes in the RGB domain. */ if (codec_id == CODEC_ID_HUFFYUV) { /* HUFFYUV was PIX_FMT_YUV422P before */ c->pix_fmt = PIX_FMT_RGB32; @@ -572,12 +572,12 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex } if (codec_id == CODEC_ID_QTRLE) { - // normally it should be enough to have buffer with actual image size, - // but some codecs like QTRLE might store extra information in this buffer, - // so it should be a way larger + /* normally it should be enough to have buffer with actual image size, + * but some codecs like QTRLE might store extra information in this buffer, + * so it should be a way larger */ - // maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664) - // (from FFmpeg sources) + /* maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664) + * (from FFmpeg sources) */ int size = c->width * c->height; video_buffersize = 7 * size + 10000; } diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index b5965838a30..a2028ff5fa1 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -383,7 +383,7 @@ int BKE_frameserver_append(RenderData *UNUSED(rd), int UNUSED(start_frame), int connsock = -1; } - return 0; + return 1; } void BKE_frameserver_end(void) diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index 5ec8247c03a..a2957b32824 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -104,7 +104,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata); -float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3]); +float BLI_bvhtree_bb_raycast(const float *bv, const float light_start[3], const float light_end[3], float pos[3]); /* range query */ int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata); diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 8ccc3159f78..50345237a9f 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -200,6 +200,8 @@ void barycentric_transform(float pt_tar[3], float const pt_src[3], void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]); +void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const float v3[2], const float v4[2], + const float co[2], float w[4]); int barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]); int barycentric_inside_triangle_v2(const float w[3]); diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 0cf32eeb276..8a9794b77c9 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -40,34 +40,35 @@ struct rcti; extern "C" { #endif -/* BLI_rct.c */ -/** - * Determine if a rect is empty. An empty - * rect is one with a zero (or negative) - * width or height. - * - * \return True if \a rect is empty. - */ -int BLI_rcti_is_empty(struct rcti *rect); -int BLI_rctf_is_empty(struct rctf *rect); -void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax); -void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax); +int BLI_rcti_is_empty(const struct rcti *rect); +int BLI_rctf_is_empty(const struct rctf *rect); +void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax); +void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax); +void BLI_rcti_init_minmax(struct rcti *rect); +void BLI_rctf_init_minmax(struct rctf *rect); +void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]); +void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]); + void BLI_translate_rctf(struct rctf *rect, float x, float y); void BLI_translate_rcti(struct rcti *rect, int x, int y); void BLI_resize_rcti(struct rcti *rect, int x, int y); void BLI_resize_rctf(struct rctf *rect, float x, float y); -int BLI_in_rcti(struct rcti *rect, int x, int y); -int BLI_in_rctf(struct rctf *rect, float x, float y); -int BLI_segment_in_rcti(struct rcti *rect, int s1[2], int s2[2]); -// int BLI_segment_in_rctf(struct rcti *rect, int s1[2], int s2[2]); // NOT NEEDED YET -int BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest); -int BLI_isect_rcti(struct rcti *src1, struct rcti *src2, struct rcti *dest); -void BLI_union_rctf(struct rctf *rcta, struct rctf *rctb); -void BLI_union_rcti(struct rcti *rcti1, struct rcti *rcti2); +int BLI_in_rcti(const struct rcti *rect, const int x, const int y); +int BLI_in_rcti_v(const struct rcti *rect, const int xy[2]); +int BLI_in_rctf(const struct rctf *rect, const float x, const float y); +int BLI_in_rctf_v(const struct rctf *rect, const float xy[2]); +int BLI_segment_in_rcti(const struct rcti *rect, const int s1[2], const int s2[2]); +#if 0 /* NOT NEEDED YET */ +int BLI_segment_in_rctf(struct rcti *rect, int s1[2], int s2[2]); +#endif +int BLI_isect_rctf(const struct rctf *src1, const struct rctf *src2, struct rctf *dest); +int BLI_isect_rcti(const struct rcti *src1, const struct rcti *src2, struct rcti *dest); +void BLI_union_rctf(struct rctf *rctf1, const struct rctf *rctf2); +void BLI_union_rcti(struct rcti *rcti1, const struct rcti *rcti2); void BLI_copy_rcti_rctf(struct rcti *tar, const struct rctf *src); -void print_rctf(const char *str, struct rctf *rect); -void print_rcti(const char *str, struct rcti *rect); +void print_rctf(const char *str, const struct rctf *rect); +void print_rcti(const char *str, const struct rcti *rect); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index ceef378358b..a6b1943cb4d 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -65,11 +65,12 @@ typedef struct ScanFillVert { union { struct ScanFillVert *v; void *p; - intptr_t l; + intptr_t l; + unsigned int u; } tmp; float co[3]; /* vertex location */ float xy[2]; /* 2D copy of vertex location (using dominant axis) */ - int keyindex; /* original index #, for restoring key information */ + unsigned int keyindex; /* original index #, for restoring key information */ short poly_nr; unsigned char f, h; } ScanFillVert; @@ -79,6 +80,9 @@ typedef struct ScanFillEdge { struct ScanFillVert *v1, *v2; short poly_nr; unsigned char f; + union { + unsigned char c; + } tmp; } ScanFillEdge; typedef struct ScanFillFace { diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index c8f439c677f..a74629e589c 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -43,7 +43,12 @@ extern "C" { * \param str The string to be duplicated * \retval Returns the duplicated string */ -char *BLI_strdup(const char *str); +char *BLI_strdup(const char *str) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Duplicates the first \a len bytes of cstring \a str @@ -54,7 +59,12 @@ char *BLI_strdup(const char *str); * \param len The number of bytes to duplicate * \retval Returns the duplicated string */ -char *BLI_strdupn(const char *str, const size_t len); +char *BLI_strdupn(const char *str, const size_t len) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Appends the two strings, and returns new mallocN'ed string @@ -62,7 +72,12 @@ char *BLI_strdupn(const char *str, const size_t len); * \param str2 second string for append * \retval Returns dst */ -char *BLI_strdupcat(const char *str1, const char *str2); +char *BLI_strdupcat(const char *str1, const char *str2) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Like strncpy but ensures dst is always @@ -74,9 +89,14 @@ char *BLI_strdupcat(const char *str1, const char *str2); * the size of dst) * \retval Returns dst */ -char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy); +char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; -/* Makes a copy of the text within the "" that appear after some text 'blahblah' +/** + *Makes a copy of the text within the "" that appear after some text 'blahblah' * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples" * * - str: is the entire string to chop @@ -85,7 +105,12 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy); * Assume that the strings returned must be freed afterwards, and that the inputs will contain * data we want... */ -char *BLI_getQuotedStr(const char *str, const char *prefix); +char *BLI_str_quoted_substrN(const char *str, const char *prefix) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Returns a copy of the cstring \a str into a newly mallocN'd @@ -97,7 +122,12 @@ char *BLI_getQuotedStr(const char *str, const char *prefix); * \param newText The text in the string to find and replace * \retval Returns the duplicated string */ -char *BLI_replacestr(char *str, const char *oldText, const char *newText); +char *BLI_replacestr(char *str, const char *oldText, const char *newText) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /* * Replacement for snprintf @@ -105,6 +135,7 @@ char *BLI_replacestr(char *str, const char *oldText, const char *newText); size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...) #ifdef __GNUC__ __attribute__ ((format(printf, 3, 4))) +__attribute__((nonnull)) #endif ; @@ -115,27 +146,75 @@ __attribute__ ((format(printf, 3, 4))) char *BLI_sprintfN(const char *format, ...) #ifdef __GNUC__ __attribute__ ((format(printf, 1, 2))) +__attribute__((warn_unused_result)) +__attribute__((nonnull)) #endif ; -size_t BLI_strescape(char *dst, const char *src, const size_t maxlen); +size_t BLI_strescape(char *dst, const char *src, const size_t maxlen) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** * Compare two strings without regard to case. * * \retval True if the strings are equal, false otherwise. */ -int BLI_strcaseeq(const char *a, const char *b); +int BLI_strcaseeq(const char *a, const char *b) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; -char *BLI_strcasestr(const char *s, const char *find); -int BLI_strcasecmp(const char *s1, const char *s2); -int BLI_strncasecmp(const char *s1, const char *s2, size_t len); -int BLI_natstrcmp(const char *s1, const char *s2); -size_t BLI_strnlen(const char *str, size_t maxlen); -void BLI_timestr(double _time, char *str); /* time var is global */ +char *BLI_strcasestr(const char *s, const char *find) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +int BLI_strcasecmp(const char *s1, const char *s2) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +int BLI_strncasecmp(const char *s1, const char *s2, size_t len) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +int BLI_natstrcmp(const char *s1, const char *s2) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +size_t BLI_strnlen(const char *str, size_t maxlen) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +void BLI_timestr(double _time, char *str) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /* time var is global */ -void BLI_ascii_strtolower(char *str, int len); -void BLI_ascii_strtoupper(char *str, int len); +void BLI_ascii_strtolower(char *str, int len) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; +void BLI_ascii_strtoupper(char *str, int len) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index fb8771722c1..902373bcd6b 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -31,6 +31,9 @@ /** \file BLI_threads.h * \ingroup bli */ +#ifdef __cplusplus +extern "C" { +#endif #include <pthread.h> @@ -67,7 +70,7 @@ int BLI_system_thread_count(void); /* gets the number of threads the system * One custom lock available now. can be extended. */ #define LOCK_IMAGE 0 -#define LOCK_PREVIEW 1 +#define LOCK_DRAW_IMAGE 1 #define LOCK_VIEWER 2 #define LOCK_CUSTOM1 3 #define LOCK_RCACHE 4 @@ -139,5 +142,9 @@ int BLI_thread_queue_size(ThreadQueue *queue); void BLI_thread_queue_wait_finish(ThreadQueue *queue); void BLI_thread_queue_nowait(ThreadQueue *queue); +#ifdef __cplusplus +} +#endif + #endif diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 4bcedb06fb0..844407f9e06 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -35,8 +35,6 @@ #include "MEM_guardedalloc.h" -// #include "BLI_blenlib.h" - #include "BLI_utildefines.h" #include "BLI_mempool.h" #include "BLI_ghash.h" diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 6a4ee64ebcd..a5b5065e023 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -29,15 +29,11 @@ * \ingroup bli */ - #include <assert.h> #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" - - - #include "BLI_kdopbvh.h" #include "BLI_math.h" @@ -45,14 +41,12 @@ #include <omp.h> #endif - - #define MAX_TREETYPE 32 #define DEFAULT_FIND_NEAREST_HEAP_SIZE 1024 typedef struct BVHNode { struct BVHNode **children; - struct BVHNode *parent; // some user defined traversed need that + struct BVHNode *parent; /* some user defined traversed need that */ struct BVHNode *skip[2]; float *bv; /* Bounding volume of all nodes, max 13 axis */ int index; /* face, edge, vertex index */ @@ -104,16 +98,15 @@ typedef struct BVHRayCastData { BVHTreeRayHit hit; } BVHRayCastData; -////////////////////////////////////////m -//////////////////////////////////////////////////////////////////////// -// Bounding Volume Hierarchy Definition -// -// Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below -// Notes: You have to choose the type at compile time ITM -// Notes: You can choose the tree type --> binary, quad, octree, choose below -//////////////////////////////////////////////////////////////////////// +/* + * Bounding Volume Hierarchy Definition + * + * Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below + * Notes: You have to choose the type at compile time ITM + * Notes: You can choose the tree type --> binary, quad, octree, choose below + */ static float KDOP_AXES[13][3] = { {1.0, 0, 0}, {0, 1.0, 0}, {0, 0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, @@ -188,13 +181,15 @@ static int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, in } #endif -////////////////////////////////////////////////////////////////////////////////////////////////////// -// Introsort -// with permission deriven from the following Java code: -// http://ralphunden.net/content/tutorials/a-guide-to-introsort/ -// and he derived it from the SUN STL -////////////////////////////////////////////////////////////////////////////////////////////////////// +/* + * Introsort + * with permission deriven from the following Java code: + * http://ralphunden.net/content/tutorials/a-guide-to-introsort/ + * and he derived it from the SUN STL + */ + //static int size_threshold = 16; + /* * Common methods for all algorithms */ @@ -336,9 +331,9 @@ static void sort_along_axis(BVHTree *tree, int start, int end, int axis) } #endif -//after a call to this function you can expect one of: -// every node to left of a[n] are smaller or equal to it -// every node to the right of a[n] are greater or equal to it +/* after a call to this function you can expect one of: + * - every node to left of a[n] are smaller or equal to it + * - every node to the right of a[n] are greater or equal to it */ static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int axis) { int begin = _begin, end = _end, cut; @@ -354,7 +349,7 @@ static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int a return n; } -////////////////////////////////////////////////////////////////////////////////////////////////////// +/* --- */ static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNode *right) { int i; @@ -381,8 +376,8 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int float *bv = node->bv; int i, k; - // don't init boudings for the moving case - if (!moving) { + /* don't init boudings for the moving case */ + if (!moving) { for (i = tree->start_axis; i < tree->stop_axis; i++) { bv[2 * i] = FLT_MAX; bv[2 * i + 1] = -FLT_MAX; @@ -401,7 +396,7 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int } } -// depends on the fact that the BVH's for each face is already build +/* depends on the fact that the BVH's for each face is already build */ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) { float newmin, newmax; @@ -429,31 +424,31 @@ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) } -// only supports x,y,z axis in the moment -// but we should use a plain and simple function here for speed sake +/* only supports x,y,z axis in the moment + * but we should use a plain and simple function here for speed sake */ static char get_largest_axis(float *bv) { float middle_point[3]; - middle_point[0] = (bv[1]) - (bv[0]); // x axis - middle_point[1] = (bv[3]) - (bv[2]); // y axis - middle_point[2] = (bv[5]) - (bv[4]); // z axis + middle_point[0] = (bv[1]) - (bv[0]); /* x axis */ + middle_point[1] = (bv[3]) - (bv[2]); /* y axis */ + middle_point[2] = (bv[5]) - (bv[4]); /* z axis */ if (middle_point[0] > middle_point[1]) { if (middle_point[0] > middle_point[2]) - return 1; // max x axis + return 1; /* max x axis */ else - return 5; // max z axis + return 5; /* max z axis */ } else { if (middle_point[1] > middle_point[2]) - return 3; // max y axis + return 3; /* max y axis */ else - return 5; // max z axis + return 5; /* max z axis */ } } -// bottom-up update of bvh node BV -// join the children on the parent BV +/* bottom-up update of bvh node BV + * join the children on the parent BV */ static void node_join(BVHTree *tree, BVHNode *node) { int i, j; @@ -466,11 +461,11 @@ static void node_join(BVHTree *tree, BVHNode *node) for (i = 0; i < tree->tree_type; i++) { if (node->children[i]) { for (j = tree->start_axis; j < tree->stop_axis; j++) { - // update minimum - if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) + /* update minimum */ + if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) node->bv[(2 * j)] = node->children[i]->bv[(2 * j)]; - - // update maximum + + /* update maximum */ if (node->children[i]->bv[(2 * j) + 1] > node->bv[(2 * j) + 1]) node->bv[(2 * j) + 1] = node->children[i]->bv[(2 * j) + 1]; } @@ -523,7 +518,7 @@ static void verify_tree(BVHTree *tree) { int i, j, check = 0; - // check the pointer list + /* check the pointer list */ for (i = 0; i < tree->totleaf; i++) { if (tree->nodes[i]->parent == NULL) { @@ -543,7 +538,7 @@ static void verify_tree(BVHTree *tree) } } - // check the leaf list + /* check the leaf list */ for (i = 0; i < tree->totleaf; i++) { if (tree->nodearray[i].parent == NULL) { @@ -567,8 +562,8 @@ static void verify_tree(BVHTree *tree) } #endif -//Helper data and structures to build a min-leaf generalized implicit tree -//This code can be easily reduced (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) +/* Helper data and structures to build a min-leaf generalized implicit tree + * This code can be easily reduced (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) */ typedef struct BVHBuildHelper { int tree_type; /* */ int totleafs; /* */ @@ -589,7 +584,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->totleafs = tree->totleaf; data->tree_type = tree->tree_type; - //Calculate the smallest tree_type^n such that tree_type^n >= num_leafs + /* Calculate the smallest tree_type^n such that tree_type^n >= num_leafs */ for (data->leafs_per_child[0] = 1; data->leafs_per_child[0] < data->totleafs; data->leafs_per_child[0] *= data->tree_type) @@ -599,7 +594,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->branches_on_level[0] = 1; - //We could stop the loop first (but I am lazy to find out when) + /* We could stop the loop first (but I am lazy to find out when) */ for (depth = 1; depth < 32; depth++) { data->branches_on_level[depth] = data->branches_on_level[depth - 1] * data->tree_type; data->leafs_per_child[depth] = data->leafs_per_child[depth - 1] / data->tree_type; @@ -700,18 +695,18 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int i; const int tree_type = tree->tree_type; - const int tree_offset = 2 - tree->tree_type; //this value is 0 (on binary trees) and negative on the others + const int tree_offset = 2 - tree->tree_type; /* this value is 0 (on binary trees) and negative on the others */ const int num_branches = implicit_needed_branches(tree_type, num_leafs); BVHBuildHelper data; int depth; - // set parent from root node to NULL + /* set parent from root node to NULL */ BVHNode *tmp = branches_array + 0; tmp->parent = NULL; - //Most of bvhtree code relies on 1-leaf trees having at least one branch - //We handle that special case here + /*Most of bvhtree code relies on 1-leaf trees having at least one branch + *We handle that special case here */ if (num_leafs == 1) { BVHNode *root = branches_array + 0; refit_kdop_hull(tree, root, 0, num_leafs); @@ -722,17 +717,17 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, return; } - branches_array--; //Implicit trees use 1-based indexs - + branches_array--; /* Implicit trees use 1-based indexs */ + build_implicit_tree_helper(tree, &data); - //Loop tree levels (log N) loops + /* Loop tree levels (log N) loops */ for (i = 1, depth = 1; i <= num_branches; i = i * tree_type + tree_offset, depth++) { const int first_of_next_level = i * tree_type + tree_offset; - const int end_j = MIN2(first_of_next_level, num_branches + 1); //index of last branch on this level + const int end_j = MIN2(first_of_next_level, num_branches + 1); /* index of last branch on this level */ int j; - //Loop all branches on this level + /* Loop all branches on this level */ #pragma omp parallel for private(j) schedule(static) for (j = i; j < end_j; j++) { int k; @@ -744,34 +739,34 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int parent_leafs_begin = implicit_leafs_index(&data, depth, parent_level_index); int parent_leafs_end = implicit_leafs_index(&data, depth, parent_level_index + 1); - //This calculates the bounding box of this branch - //and chooses the largest axis as the axis to divide leafs + /* This calculates the bounding box of this branch + * and chooses the largest axis as the axis to divide leafs */ refit_kdop_hull(tree, parent, parent_leafs_begin, parent_leafs_end); split_axis = get_largest_axis(parent->bv); - //Save split axis (this can be used on raytracing to speedup the query time) + /* Save split axis (this can be used on raytracing to speedup the query time) */ parent->main_axis = split_axis / 2; - //Split the childs along the split_axis, note: its not needed to sort the whole leafs array - //Only to assure that the elements are partioned on a way that each child takes the elements - //it would take in case the whole array was sorted. - //Split_leafs takes care of that "sort" problem. + /* Split the childs along the split_axis, note: its not needed to sort the whole leafs array + * Only to assure that the elements are partioned on a way that each child takes the elements + * it would take in case the whole array was sorted. + * Split_leafs takes care of that "sort" problem. */ nth_positions[0] = parent_leafs_begin; nth_positions[tree_type] = parent_leafs_end; for (k = 1; k < tree_type; k++) { int child_index = j * tree_type + tree_offset + k; - int child_level_index = child_index - first_of_next_level; //child level index + int child_level_index = child_index - first_of_next_level; /* child level index */ nth_positions[k] = implicit_leafs_index(&data, depth + 1, child_level_index); } split_leafs(leafs_array, nth_positions, tree_type, split_axis); - //Setup children and totnode counters - //Not really needed but currently most of BVH code relies on having an explicit children structure + /* Setup children and totnode counters + * Not really needed but currently most of BVH code relies on having an explicit children structure */ for (k = 0; k < tree_type; k++) { int child_index = j * tree_type + tree_offset + k; - int child_level_index = child_index - first_of_next_level; //child level index + int child_level_index = child_index - first_of_next_level; /* child level index */ int child_leafs_begin = implicit_leafs_index(&data, depth + 1, child_level_index); int child_leafs_end = implicit_leafs_index(&data, depth + 1, child_level_index + 1); @@ -803,20 +798,20 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) BVHTree *tree; int numnodes, i; - // theres not support for trees below binary-trees :P + /* theres not support for trees below binary-trees :P */ if (tree_type < 2) return NULL; - + if (tree_type > MAX_TREETYPE) return NULL; tree = (BVHTree *)MEM_callocN(sizeof(BVHTree), "BVHTree"); - //tree epsilon must be >= FLT_EPSILON - //so that tangent rays can still hit a bounding volume.. - //this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces + /* tree epsilon must be >= FLT_EPSILON + * so that tangent rays can still hit a bounding volume.. + * this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces */ epsilon = MAX2(FLT_EPSILON, epsilon); - + if (tree) { tree->epsilon = epsilon; tree->tree_type = tree_type; @@ -910,59 +905,59 @@ void BLI_bvhtree_balance(BVHTree *tree) BVHNode *branches_array = tree->nodearray + tree->totleaf; BVHNode **leafs_array = tree->nodes; - //This function should only be called once (some big bug goes here if its being called more than once per tree) + /* This function should only be called once (some big bug goes here if its being called more than once per tree) */ assert(tree->totbranch == 0); - //Build the implicit tree + /* Build the implicit tree */ non_recursive_bvh_div_nodes(tree, branches_array, leafs_array, tree->totleaf); - //current code expects the branches to be linked to the nodes array - //we perform that linkage here + /*current code expects the branches to be linked to the nodes array + *we perform that linkage here */ tree->totbranch = implicit_needed_branches(tree->tree_type, tree->totleaf); for (i = 0; i < tree->totbranch; i++) tree->nodes[tree->totleaf + i] = branches_array + i; build_skip_links(tree, tree->nodes[tree->totleaf], NULL, NULL); - //bvhtree_info(tree); + /* bvhtree_info(tree); */ } int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints) { int i; BVHNode *node = NULL; - - // insert should only possible as long as tree->totbranch is 0 + + /* insert should only possible as long as tree->totbranch is 0 */ if (tree->totbranch > 0) return 0; - + if (tree->totleaf + 1 >= MEM_allocN_len(tree->nodes) / sizeof(*(tree->nodes))) return 0; - - // TODO check if have enough nodes in array - + + /* TODO check if have enough nodes in array */ + node = tree->nodes[tree->totleaf] = &(tree->nodearray[tree->totleaf]); tree->totleaf++; - + create_kdop_hull(tree, node, co, numpoints, 0); node->index = index; - - // inflate the bv with some epsilon + + /* inflate the bv with some epsilon */ for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[(2 * i)] -= tree->epsilon; // minimum - node->bv[(2 * i) + 1] += tree->epsilon; // maximum + node->bv[(2 * i)] -= tree->epsilon; /* minimum */ + node->bv[(2 * i) + 1] += tree->epsilon; /* maximum */ } return 1; } -// call before BLI_bvhtree_update_tree() +/* call before BLI_bvhtree_update_tree() */ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints) { int i; BVHNode *node = NULL; - // check if index exists + /* check if index exists */ if (index > tree->totleaf) return 0; @@ -982,12 +977,12 @@ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const flo return 1; } -// call BLI_bvhtree_update_node() first for every node/point/triangle +/* call BLI_bvhtree_update_node() first for every node/point/triangle */ void BLI_bvhtree_update_tree(BVHTree *tree) { - //Update bottom=>top - //TRICKY: the way we build the tree all the childs have an index greater than the parent - //This allows us todo a bottom up update by starting on the biger numbered branch + /* Update bottom=>top + * TRICKY: the way we build the tree all the childs have an index greater than the parent + * This allows us todo a bottom up update by starting on the biger numbered branch */ BVHNode **root = tree->nodes + tree->totleaf; BVHNode **index = tree->nodes + tree->totleaf + tree->totbranch - 1; @@ -1004,8 +999,8 @@ float BLI_bvhtree_getepsilon(BVHTree *tree) /* * BLI_bvhtree_overlap - */ -// overlap - is it possbile for 2 bv's to collide ? + * + * overlap - is it possbile for 2 bv's to collide ? */ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop_axis) { float *bv1 = node1->bv; @@ -1016,31 +1011,31 @@ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop bv1 += start_axis << 1; bv2 += start_axis << 1; - // test all axis if min + max overlap + /* test all axis if min + max overlap */ for (; bv1 != bv1_end; bv1 += 2, bv2 += 2) { - if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) + if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) return 0; } - + return 1; } static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) { int j; - + if (tree_overlap(node1, node2, data->start_axis, data->stop_axis)) { - // check if node1 is a leaf + /* check if node1 is a leaf */ if (!node1->totnode) { - // check if node2 is a leaf + /* check if node2 is a leaf */ if (!node2->totnode) { - + if (node1 == node2) { return; } - + if (data->i >= data->max_overlap) { - // try to make alloc'ed memory bigger + /* try to make alloc'ed memory bigger */ data->overlap = realloc(data->overlap, sizeof(BVHTreeOverlap) * data->max_overlap * 2); if (!data->overlap) { @@ -1222,14 +1217,14 @@ PUSH_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) static void NodeDistance_pop_heap(NodeDistance *heap, int heap_size) POP_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) -//NN function that uses an heap.. this functions leads to an optimal number of min-distance -//but for normal tri-faces and BV 6-dop.. a simple dfs with local heuristics (as implemented -//in source/blender/blenkernel/intern/shrinkwrap.c) works faster. -// -//It may make sense to use this function if the callback queries are very slow.. or if its impossible -//to get a nice heuristic -// -//this function uses "malloc/free" instead of the MEM_* because it intends to be openmp safe +/* NN function that uses an heap.. this functions leads to an optimal number of min-distance + * but for normal tri-faces and BV 6-dop.. a simple dfs with local heuristics (as implemented + * in source/blender/blenkernel/intern/shrinkwrap.c) works faster. + * + * It may make sense to use this function if the callback queries are very slow.. or if its impossible + * to get a nice heuristic + * + * this function uses "malloc/free" instead of the MEM_* because it intends to be openmp safe */ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) { int i; @@ -1327,11 +1322,11 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n data.nearest.dist = FLT_MAX; } - //dfs search + /* dfs search */ if (root) dfs_find_nearest_begin(&data, root); - //copy back results + /* copy back results */ if (nearest) { memcpy(nearest, &data.nearest, sizeof(*nearest)); } @@ -1347,8 +1342,8 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n */ -//Determines the distance that the ray must travel to hit the bounding volume of the given node -static float ray_nearest_hit(BVHRayCastData *data, float *bv) +/* Determines the distance that the ray must travel to hit the bounding volume of the given node */ +static float ray_nearest_hit(BVHRayCastData *data, const float *bv) { int i; @@ -1382,11 +1377,11 @@ static float ray_nearest_hit(BVHRayCastData *data, float *bv) return low; } -//Determines the distance that the ray must travel to hit the bounding volume of the given node -//Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe -//[http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] -// -//TODO this doens't has data->ray.radius in consideration +/* Determines the distance that the ray must travel to hit the bounding volume of the given node + * Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe + * [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] + * + * TODO this doens't has data->ray.radius in consideration */ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *node) { const float *bv = node->bv; @@ -1413,8 +1408,8 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) { int i; - //ray-bv is really fast.. and simple tests revealed its worth to test it - //before calling the ray-primitive functions + /* ray-bv is really fast.. and simple tests revealed its worth to test it + * before calling the ray-primitive functions */ /* XXX: temporary solution for particles until fast_ray_nearest_hit supports ray.radius */ float dist = (data->ray.radius > 0.0f) ? ray_nearest_hit(data, node->bv) : fast_ray_nearest_hit(data, node); if (dist >= data->hit.dist) return; @@ -1430,7 +1425,7 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) } } else { - //pick loop direction to dive into the tree (based on ray direction and split axis) + /* pick loop direction to dive into the tree (based on ray direction and split axis) */ if (data->ray_dot_axis[(int)node->main_axis] > 0.0f) { for (i = 0; i != node->totnode; i++) { dfs_raycast(data, node->children[i]); @@ -1526,7 +1521,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], f return data.hit.index; } -float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3]) +float BLI_bvhtree_bb_raycast(const float *bv, const float light_start[3], const float light_end[3], float pos[3]) { BVHRayCastData data; float dist = 0.0; diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index bed5750ad44..c8c2ad35380 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -134,12 +134,12 @@ DLRBT_Node *BLI_dlrbTree_search(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, vo { DLRBT_Node *node = (tree) ? tree->root : NULL; short found = 0; - + /* check that there is a comparator to use */ - // TODO: if no comparator is supplied, try using the one supplied with the tree... + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; - + /* iteratively perform this search */ while (node && found == 0) { /* check if traverse further or not @@ -177,7 +177,7 @@ DLRBT_Node *BLI_dlrbTree_search_exact(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_ short found = 0; /* check that there is a comparator to use */ - // TODO: if no comparator is supplied, try using the one supplied with the tree... + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; @@ -217,7 +217,7 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c DLRBT_Node *node; /* check that there is a comparator to use */ - // TODO: if no comparator is supplied, try using the one supplied with the tree... + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; @@ -230,7 +230,7 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c return node; /* return the previous node otherwise */ - // NOTE: what happens if there is no previous node? + /* NOTE: what happens if there is no previous node? */ return node->prev; } @@ -242,9 +242,9 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c DLRBT_Node *BLI_dlrbTree_search_next(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void *search_data) { DLRBT_Node *node; - + /* check that there is a comparator to use */ - // TODO: if no comparator is supplied, try using the one supplied with the tree... + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; @@ -257,7 +257,7 @@ DLRBT_Node *BLI_dlrbTree_search_next(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c return node; /* return the previous node otherwise */ - // NOTE: what happens if there is no previous node? + /* NOTE: what happens if there is no previous node? */ return node->next; } @@ -512,18 +512,18 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, /* sanity checks */ if (tree == NULL) return NULL; - - // TODO: if no comparator is supplied, try using the one supplied with the tree... + + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; - // TODO: if no allocator is supplied, try using the one supplied with the tree... + /* TODO: if no allocator is supplied, try using the one supplied with the tree... */ if (new_cb == NULL) return NULL; - // TODO: if no updater is supplied, try using the one supplied with the tree... - + /* TODO: if no updater is supplied, try using the one supplied with the tree... */ + /* try to find the nearest node to this one */ parNode = BLI_dlrbTree_search(tree, cmp_cb, data); - + /* add new node to the BST in the 'standard way' as appropriate * NOTE: we do not support duplicates in our tree... */ @@ -586,6 +586,6 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, /* *********************************************** */ /* Remove */ -// TODO: this hasn't been coded yet, since this functionality was not needed by the author +/* TODO: this hasn't been coded yet, since this functionality was not needed by the author */ /* *********************************************** */ diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 5f564f71646..7aa956a0548 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -274,12 +274,12 @@ int BLI_move(const char *file, const char *to) { int err; - // windows doesn't support moveing to a directory - // it has to be 'mv filename filename' and not - // 'mv filename destdir' + /* windows doesn't support moveing to a directory + * it has to be 'mv filename filename' and not + * 'mv filename destdir' */ BLI_strncpy(str, to, sizeof(str)); - // points 'to' to a directory ? + /* points 'to' to a directory ? */ if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { strcat(str, BLI_last_slash(file) + 1); @@ -305,12 +305,12 @@ int BLI_copy(const char *file, const char *to) { int err; - // windows doesn't support copying to a directory - // it has to be 'cp filename filename' and not - // 'cp filename destdir' + /* windows doesn't support copying to a directory + * it has to be 'cp filename filename' and not + * 'cp filename destdir' */ BLI_strncpy(str, to, sizeof(str)); - // points 'to' to a directory ? + /* points 'to' to a directory ? */ if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { strcat(str, BLI_last_slash(file) + 1); diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 10eeda96b5d..a499f9a81ea 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -71,55 +71,55 @@ static FT_Error err; static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd) { - // Blender + /* Blender */ struct Nurb *nu; struct VChar *che; struct BezTriple *bezt; - - // Freetype2 + + /* Freetype2 */ FT_GlyphSlot glyph; FT_UInt glyph_index; FT_Outline ftoutline; float scale, height; float dx, dy; int j, k, l, m = 0; - - // adjust font size + + /* adjust font size */ height = ((double) face->bbox.yMax - (double) face->bbox.yMin); if (height != 0.0f) scale = 1.0f / height; else scale = 1.0f / 1000.0f; - - // - // Generate the character 3D data - // - // Get the FT Glyph index and load the Glyph + + /* + * Generate the character 3D data + * + * Get the FT Glyph index and load the Glyph */ glyph_index = FT_Get_Char_Index(face, charcode); err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP); - - // If loading succeeded, convert the FT glyph to the internal format + + /* If loading succeeded, convert the FT glyph to the internal format */ if (!err) { int *npoints; int *onpoints; - - // First we create entry for the new character to the character list + + /* First we create entry for the new character to the character list */ che = (VChar *) MEM_callocN(sizeof(struct VChar), "objfnt_char"); BLI_addtail(&vfd->characters, che); - - // Take some data for modifying purposes + + /* Take some data for modifying purposes */ glyph = face->glyph; ftoutline = glyph->outline; - - // Set the width and character code + + /* Set the width and character code */ che->index = charcode; che->width = glyph->advance.x * scale; - - // Start converting the FT data + + /* Start converting the FT data */ npoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "endpoints"); onpoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "onpoints"); - // calculate total points of each contour + /* calculate total points of each contour */ for (j = 0; j < ftoutline.n_contours; j++) { if (j == 0) npoints[j] = ftoutline.contours[j] + 1; @@ -127,7 +127,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf npoints[j] = ftoutline.contours[j] - ftoutline.contours[j - 1]; } - // get number of on-curve points for beziertriples (including conic virtual on-points) + /* get number of on-curve points for beziertriples (including conic virtual on-points) */ for (j = 0; j < ftoutline.n_contours; j++) { for (k = 0; k < npoints[j]; k++) { l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k; @@ -145,9 +145,9 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //contour loop, bezier & conic styles merged + /* contour loop, bezier & conic styles merged */ for (j = 0; j < ftoutline.n_contours; j++) { - // add new curve + /* add new curve */ nu = (Nurb *)MEM_callocN(sizeof(struct Nurb), "objfnt_nurb"); bezt = (BezTriple *)MEM_callocN((onpoints[j]) * sizeof(BezTriple), "objfnt_bezt"); BLI_addtail(&che->nurbsbase, nu); @@ -159,26 +159,26 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf nu->flagu = CU_NURB_CYCLIC; nu->bezt = bezt; - //individual curve loop, start-end + /* individual curve loop, start-end */ for (k = 0; k < npoints[j]; k++) { if (j > 0) l = k + ftoutline.contours[j - 1] + 1; else l = k; if (k == 0) m = l; - - //virtual conic on-curve points + + /* virtual conic on-curve points */ if (k < npoints[j] - 1) { if (ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) { dx = (ftoutline.points[l].x + ftoutline.points[l + 1].x) * scale / 2.0f; dy = (ftoutline.points[l].y + ftoutline.points[l + 1].y) * scale / 2.0f; - //left handle + /* left handle */ bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x) * scale) / 3.0f; bezt->vec[0][1] = (dy + (2 * ftoutline.points[l].y) * scale) / 3.0f; - //midpoint (virtual on-curve point) + /* midpoint (virtual on-curve point) */ bezt->vec[1][0] = dx; bezt->vec[1][1] = dy; - //right handle + /* right handle */ bezt->vec[2][0] = (dx + (2 * ftoutline.points[l + 1].x) * scale) / 3.0f; bezt->vec[2][1] = (dy + (2 * ftoutline.points[l + 1].y) * scale) / 3.0f; @@ -188,9 +188,9 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //on-curve points + /* on-curve points */ if (ftoutline.tags[l] == FT_Curve_Tag_On) { - //left handle + /* left handle */ if (k > 0) { if (ftoutline.tags[l - 1] == FT_Curve_Tag_Cubic) { bezt->vec[0][0] = ftoutline.points[l - 1].x * scale; @@ -208,7 +208,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->h1 = HD_VECT; } } - else { //first point on curve + else { /* first point on curve */ if (ftoutline.tags[ftoutline.contours[j]] == FT_Curve_Tag_Cubic) { bezt->vec[0][0] = ftoutline.points[ftoutline.contours[j]].x * scale; bezt->vec[0][1] = ftoutline.points[ftoutline.contours[j]].y * scale; @@ -226,11 +226,11 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //midpoint (on-curve point) + /* midpoint (on-curve point) */ bezt->vec[1][0] = ftoutline.points[l].x * scale; bezt->vec[1][1] = ftoutline.points[l].y * scale; - //right handle + /* right handle */ if (k < (npoints[j] - 1)) { if (ftoutline.tags[l + 1] == FT_Curve_Tag_Cubic) { bezt->vec[2][0] = ftoutline.points[l + 1].x * scale; @@ -248,7 +248,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->h2 = HD_VECT; } } - else { //last point on curve + else { /* last point on curve */ if (ftoutline.tags[m] == FT_Curve_Tag_Cubic) { bezt->vec[2][0] = ftoutline.points[m].x * scale; bezt->vec[2][1] = ftoutline.points[m].y * scale; @@ -294,17 +294,17 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) { - // Freetype2 + /* Freetype2 */ FT_Face face; struct TmpFont *tf; - - // Find the correct FreeType font + + /* Find the correct FreeType font */ tf = BKE_vfont_find_tmpfont(vfont); - - // What, no font found. Something strange here + + /* What, no font found. Something strange here */ if (!tf) return FALSE; - - // Load the font to memory + + /* Load the font to memory */ if (tf->pf) { err = FT_New_Memory_Face(library, tf->pf->data, @@ -318,17 +318,17 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) return FALSE; } - // Read the char + /* Read the char */ freetypechar_to_vchar(face, charcode, vfont->data); - // And everything went ok + /* And everything went ok */ return TRUE; } static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) { - // Variables + /* Variables */ FT_Face face; FT_ULong charcode = 0, lcode; FT_UInt glyph_index; @@ -343,7 +343,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) int n; #endif - // load the freetype font + /* load the freetype font */ err = FT_New_Memory_Face(library, pf->data, pf->size, @@ -366,22 +366,22 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) if (!found) { return NULL; } - // now, select the charmap for the face object + /* now, select the charmap for the face object */ err = FT_Set_Charmap(face, found); if (err) { return NULL; } #endif - // allocate blender font + /* allocate blender font */ vfd = MEM_callocN(sizeof(*vfd), "FTVFontData"); - // get the name + /* get the name */ fontname = FT_Get_Postscript_Name(face); BLI_strncpy(vfd->name, (fontname == NULL) ? "" : fontname, sizeof(vfd->name)); - // Extract the first 256 character from TTF + /* Extract the first 256 character from TTF */ lcode = charcode = FT_Get_First_Char(face, &glyph_index); - // No charmap found from the ttf so we need to figure it out + /* No charmap found from the ttf so we need to figure it out */ if (glyph_index == 0) { FT_CharMap found = NULL; FT_CharMap charmap; @@ -403,15 +403,15 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) lcode = charcode = FT_Get_First_Char(face, &glyph_index); } - // Load characters + /* Load characters */ while (charcode < 256) { - // Generate the font data + /* Generate the font data */ freetypechar_to_vchar(face, charcode, vfd); - // Next glyph + /* Next glyph */ charcode = FT_Get_Next_Char(face, charcode, &glyph_index); - // Check that we won't start infinite loop + /* Check that we won't start infinite loop */ if (charcode <= lcode) break; lcode = charcode; @@ -457,7 +457,7 @@ static int check_freetypefont(PackedFile *pf) if (!found) { return 0; } - // now, select the charmap for the face object + /* now, select the charmap for the face object */ err = FT_Set_Charmap(face, found); if (err) { return 0; } #endif @@ -511,21 +511,21 @@ int BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) if (!vfont) return FALSE; - // Init Freetype + /* Init Freetype */ err = FT_Init_FreeType(&library); if (err) { - //XXX error("Failed to load the Freetype font library"); + /* XXX error("Failed to load the Freetype font library"); */ return 0; } - // Load the character + /* Load the character */ success = objchr_to_ftvfontdata(vfont, character); if (success == FALSE) return FALSE; - // Free Freetype + /* Free Freetype */ FT_Done_FreeType(library); - // Ahh everything ok + /* Ahh everything ok */ return TRUE; } diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index a3835b5bb4a..6b90cbfe9c3 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -237,6 +237,10 @@ MINLINE float rgb_to_bw(const float rgb[3]) return 0.35f * rgb[0] + 0.45f * rgb[1] + 0.2f * rgb[2]; } +/* non-linear luma from ITU-R BT.601-2 + * see: http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC11 + * note: the values used for are not exact matches to those documented above, + * but they are from the same */ MINLINE float rgb_to_grayscale(const float rgb[3]) { return 0.3f * rgb[0] + 0.58f * rgb[1] + 0.12f * rgb[2]; diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 402aacf369a..f9acb6ae1dd 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -554,29 +554,29 @@ static short IsectLLPt2Df(const float x0, const float y0, const float x1, const * compute slopes, note the cludge for infinity, however, this will * be close enough */ - if (fabs(x1 - x0) > 0.000001) + if (fabs(x1 - x0) > 0.000001f) m1 = (y1 - y0) / (x1 - x0); else - return -1; /*m1 = (float)1e+10;*/ // close enough to infinity + return -1; /*m1 = (float)1e+10;*/ /* close enough to infinity */ - if (fabs(x3 - x2) > 0.000001) + if (fabs(x3 - x2) > 0.000001f) m2 = (y3 - y2) / (x3 - x2); else - return -1; /*m2 = (float)1e+10;*/ // close enough to infinity + return -1; /*m2 = (float)1e+10;*/ /* close enough to infinity */ - if (fabs(m1 - m2) < 0.000001) + if (fabs(m1 - m2) < 0.000001f) return -1; /* parallel lines */ - // compute constants + /* compute constants */ c1 = (y0 - m1 * x0); c2 = (y2 - m2 * x2); - // compute the inverse of the determinate + /* compute the inverse of the determinate */ det_inv = 1.0f / (-m1 + m2); - // use Kramers rule to compute xi and yi + /* use Kramers rule to compute xi and yi */ *xi = ((-c2 + c1) * det_inv); *yi = ((m2 * c1 - m1 * c2) * det_inv); @@ -1123,15 +1123,17 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3] float u, v, f; int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3; - //return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); +#if 0 + return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); - ///* first a simple bounding box test */ - //if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; - //if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; - //if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; - //if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; + /* first a simple bounding box test */ + if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; + if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; + if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; + if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; - ///* then a full intersection test */ + /* then a full intersection test */ +#endif sub_v3_v3v3(e1, v1, v0); sub_v3_v3v3(e2, v2, v0); @@ -1331,9 +1333,9 @@ int isect_ray_aabb(const IsectRayAABBData *data, const float bb_min[3], if (tzmin > tmin) tmin = tzmin; - // XXX jwilkins: tmax does not need to be updated since we don't use it - // keeping this here for future reference - //if (tzmax < tmax) tmax = tzmax; + /* XXX jwilkins: tmax does not need to be updated since we don't use it + * keeping this here for future reference */ + //if (tzmax < tmax) tmax = tzmax; if (tmin_out) (*tmin_out) = tmin; @@ -1940,6 +1942,46 @@ void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3 } } +/* same as #barycentric_weights_v2 but works with a quad, + * note: untested for values outside the quad's bounds. + * note: there may be a more efficient method to do this, just figured it out - campbell */ +void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const float v3[2], const float v4[2], + const float co[2], float w[4]) +{ + float wtot; + + const float areas_co[4] = { + area_tri_signed_v2(v1, v2, co), + area_tri_signed_v2(v2, v3, co), + area_tri_signed_v2(v3, v4, co), + area_tri_signed_v2(v4, v1, co), + }; + + const float areas_diag[4] = { + area_tri_signed_v2(v4, v1, v2), + area_tri_signed_v2(v1, v2, v3), + area_tri_signed_v2(v2, v3, v4), + area_tri_signed_v2(v3, v4, v1), + }; + + const float u = areas_co[3] / (areas_co[1] + areas_co[3]); + const float v = areas_co[0] / (areas_co[0] + areas_co[2]); + + w[0] = ((1.0f - u) * (1.0f - v)) * sqrtf(areas_diag[0] / areas_diag[2]); + w[1] = (( u) * (1.0f - v)) * sqrtf(areas_diag[1] / areas_diag[3]); + w[2] = (( u) * ( v)) * sqrtf(areas_diag[2] / areas_diag[0]); + w[3] = ((1.0f - u) * ( v)) * sqrtf(areas_diag[3] / areas_diag[1]); + + wtot = w[0] + w[1] + w[2] + w[3]; + + if (wtot != 0.0f) { + mul_v4_fl(w, 1.0f / wtot); + } + else { /* dummy values for zero area face */ + copy_v4_fl(w, 1.0f / 4.0f); + } +} + /* given 2 triangles in 3D space, and a point in relation to the first triangle. * calculate the location of a point in relation to the second triangle. * Useful for finding relative positions with geometry */ @@ -2803,21 +2845,21 @@ static int ff_visible_quad(const float p[3], const float n[3], if (sd[0] > 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // +++ + /* +++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // ++- + /* ++- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else { - // ++0 + /* ++0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2826,21 +2868,21 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // +-+ + /* +-+ */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, v2); } else if (sd[2] < 0) { - // +-- + /* +-- */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +-0 + /* +-0 */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q2, v2); @@ -2849,21 +2891,21 @@ static int ff_visible_quad(const float p[3], const float n[3], } else { if (sd[2] > 0) { - // +0+ + /* +0+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // +0- + /* +0- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +00 + /* +00 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2874,21 +2916,21 @@ static int ff_visible_quad(const float p[3], const float n[3], else if (sd[0] < 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // -++ + /* -++ */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else if (sd[2] < 0) { - // -+- + /* -+- */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // -+0 + /* -+0 */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2897,35 +2939,35 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // --+ + /* --+ */ vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // --- + /* --- */ return 0; } else { - // --0 + /* --0 */ return 0; } } else { if (sd[2] > 0) { - // -0+ + /* -0+ */ vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // -0- + /* -0- */ return 0; } else { - // -00 + /* -00 */ return 0; } } @@ -2933,21 +2975,21 @@ static int ff_visible_quad(const float p[3], const float n[3], else { if (sd[1] > 0) { if (sd[2] > 0) { - // 0++ + /* 0++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0+- + /* 0+- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // 0+0 + /* 0+0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2956,35 +2998,35 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // 0-+ + /* 0-+ */ copy_v3_v3(q0, v0); vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0-- + /* 0-- */ return 0; } else { - // 0-0 + /* 0-0 */ return 0; } } else { if (sd[2] > 0) { - // 00+ + /* 00+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 00- + /* 00- */ return 0; } else { - // 000 + /* 000 */ return 0; } } diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index b3b58dca1a6..f159a6b9d17 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1271,7 +1271,7 @@ int is_negative_m4(float mat[][4]) /* make a 4x4 matrix out of 3 transform components */ /* matrices are made in the order: scale * rot * loc */ -// TODO: need to have a version that allows for rotation order... +/* TODO: need to have a version that allows for rotation order... */ void loc_eul_size_to_mat4(float mat[4][4], const float loc[3], const float eul[3], const float size[3]) { diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index f1e08993825..ab5601fc2dc 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1199,12 +1199,12 @@ typedef struct RotOrderInfo { */ static RotOrderInfo rotOrders[] = { /* i, j, k, n */ - {{0, 1, 2}, 0}, // XYZ - {{0, 2, 1}, 1}, // XZY - {{1, 0, 2}, 1}, // YXZ - {{1, 2, 0}, 0}, // YZX - {{2, 0, 1}, 0}, // ZXY - {{2, 1, 0}, 1} // ZYX + {{0, 1, 2}, 0}, /* XYZ */ + {{0, 2, 1}, 1}, /* XZY */ + {{1, 0, 2}, 1}, /* YXZ */ + {{1, 2, 0}, 0}, /* YZX */ + {{2, 0, 1}, 0}, /* ZXY */ + {{2, 1, 0}, 1} /* ZYX */ }; /* Get relevant pointer to rotation order set from the array diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 2ff0b564592..859bb66073c 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -282,8 +282,8 @@ static float npfade(float t) static float grad(int hash, float x, float y, float z) { - int h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE - float u = h < 8 ? x : y, // INTO 12 GRADIENT DIRECTIONS. + int h = hash & 15; /* CONVERT LO 4 BITS OF HASH CODE */ + float u = h < 8 ? x : y, /* INTO 12 GRADIENT DIRECTIONS. */ v = h < 4 ? y : h == 12 || h == 14 ? x : z; return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); } @@ -293,21 +293,21 @@ static float newPerlin(float x, float y, float z) { int A, AA, AB, B, BA, BB; float u = floor(x), v = floor(y), w = floor(z); - int X = ((int)u) & 255, Y = ((int)v) & 255, Z = ((int)w) & 255; // FIND UNIT CUBE THAT CONTAINS POINT - x -= u; // FIND RELATIVE X,Y,Z - y -= v; // OF POINT IN CUBE. + int X = ((int)u) & 255, Y = ((int)v) & 255, Z = ((int)w) & 255; /* FIND UNIT CUBE THAT CONTAINS POINT */ + x -= u; /* FIND RELATIVE X,Y,Z */ + y -= v; /* OF POINT IN CUBE. */ z -= w; - u = npfade(x); // COMPUTE FADE CURVES - v = npfade(y); // FOR EACH OF X,Y,Z. + u = npfade(x); /* COMPUTE FADE CURVES */ + v = npfade(y); /* FOR EACH OF X,Y,Z. */ w = npfade(z); - A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; // HASH COORDINATES OF - B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; // THE 8 CUBE CORNERS, - return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), // AND ADD - grad(hash[BA ], x - 1, y, z )), // BLENDED - lerp(u, grad(hash[AB ], x, y - 1, z ), // RESULTS - grad(hash[BB ], x - 1, y - 1, z ))), // FROM 8 - lerp(v, lerp(u, grad(hash[AA + 1], x, y, z - 1), // CORNERS - grad(hash[BA + 1], x - 1, y, z - 1)), // OF CUBE + A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; /* HASH COORDINATES OF */ + B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; /* THE 8 CUBE CORNERS, */ + return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), /* AND ADD */ + grad(hash[BA ], x - 1, y, z )), /* BLENDED */ + lerp(u, grad(hash[AB ], x, y - 1, z ), /* RESULTS */ + grad(hash[BB ], x - 1, y - 1, z ))), /* FROM 8 */ + lerp(v, lerp(u, grad(hash[AA + 1], x, y, z - 1), /* CORNERS */ + grad(hash[BA + 1], x - 1, y, z - 1)), /* OF CUBE */ lerp(u, grad(hash[AB + 1], x, y - 1, z - 1), grad(hash[BB + 1], x - 1, y - 1, z - 1)))); } diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index b36c3c717c0..c1ef3e27291 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -35,20 +35,23 @@ #include <stdio.h> #include <math.h> +#include <limits.h> +#include <float.h> + #include "DNA_vec_types.h" #include "BLI_rect.h" -int BLI_rcti_is_empty(rcti *rect) +int BLI_rcti_is_empty(const rcti *rect) { return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin)); } -int BLI_rctf_is_empty(rctf *rect) +int BLI_rctf_is_empty(const rctf *rect) { return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin)); } -int BLI_in_rcti(rcti *rect, int x, int y) +int BLI_in_rcti(const rcti *rect, const int x, const int y) { if (x < rect->xmin) return 0; if (x > rect->xmax) return 0; @@ -57,7 +60,23 @@ int BLI_in_rcti(rcti *rect, int x, int y) return 1; } -int BLI_in_rctf(rctf *rect, float x, float y) +/** + * Determine if a rect is empty. An empty + * rect is one with a zero (or negative) + * width or height. + * + * \return True if \a rect is empty. + */ +int BLI_in_rcti_v(const rcti *rect, const int xy[2]) +{ + if (xy[0] < rect->xmin) return 0; + if (xy[0] > rect->xmax) return 0; + if (xy[1] < rect->ymin) return 0; + if (xy[1] > rect->ymax) return 0; + return 1; +} + +int BLI_in_rctf(const rctf *rect, const float x, const float y) { if (x < rect->xmin) return 0; if (x > rect->xmax) return 0; @@ -66,6 +85,15 @@ int BLI_in_rctf(rctf *rect, float x, float y) return 1; } +int BLI_in_rctf_v(const rctf *rect, const float xy[2]) +{ + if (xy[0] < rect->xmin) return 0; + if (xy[0] > rect->xmax) return 0; + if (xy[1] < rect->ymin) return 0; + if (xy[1] > rect->ymax) return 0; + return 1; +} + /* based closely on 'isect_line_line_v2_int', but in modified so corner cases are treated as intersections */ static int isect_segments(const int v1[2], const int v2[2], const int v3[2], const int v4[2]) { @@ -80,7 +108,7 @@ static int isect_segments(const int v1[2], const int v2[2], const int v3[2], con } } -int BLI_segment_in_rcti(rcti *rect, int s1[2], int s2[2]) +int BLI_segment_in_rcti(const rcti *rect, const int s1[2], const int s2[2]) { /* first do outside-bounds check for both points of the segment */ if (s1[0] < rect->xmin && s2[0] < rect->xmin) return 0; @@ -89,7 +117,7 @@ int BLI_segment_in_rcti(rcti *rect, int s1[2], int s2[2]) if (s1[1] > rect->ymax && s2[1] > rect->ymax) return 0; /* if either points intersect then we definetly intersect */ - if (BLI_in_rcti(rect, s1[0], s1[1]) || BLI_in_rcti(rect, s2[0], s2[1])) { + if (BLI_in_rcti_v(rect, s1) || BLI_in_rcti_v(rect, s2)) { return 1; } else { @@ -115,7 +143,7 @@ int BLI_segment_in_rcti(rcti *rect, int s1[2], int s2[2]) } } -void BLI_union_rctf(rctf *rct1, rctf *rct2) +void BLI_union_rctf(rctf *rct1, const rctf *rct2) { if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin; if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax; @@ -123,7 +151,7 @@ void BLI_union_rctf(rctf *rct1, rctf *rct2) if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax; } -void BLI_union_rcti(rcti *rct1, rcti *rct2) +void BLI_union_rcti(rcti *rct1, const rcti *rct2) { if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin; if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax; @@ -131,7 +159,7 @@ void BLI_union_rcti(rcti *rct1, rcti *rct2) if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax; } -void BLI_init_rctf(rctf *rect, float xmin, float xmax, float ymin, float ymax) +void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax) { if (xmin <= xmax) { rect->xmin = xmin; @@ -151,7 +179,7 @@ void BLI_init_rctf(rctf *rect, float xmin, float xmax, float ymin, float ymax) } } -void BLI_init_rcti(rcti *rect, int xmin, int xmax, int ymin, int ymax) +void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax) { if (xmin <= xmax) { rect->xmin = xmin; @@ -171,6 +199,34 @@ void BLI_init_rcti(rcti *rect, int xmin, int xmax, int ymin, int ymax) } } +void BLI_rcti_init_minmax(struct rcti *rect) +{ + rect->xmin = rect->ymin = INT_MAX; + rect->xmax = rect->ymax = INT_MIN; +} + +void BLI_rctf_init_minmax(struct rctf *rect) +{ + rect->xmin = rect->ymin = FLT_MAX; + rect->xmax = rect->ymax = FLT_MIN; +} + +void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]) +{ + if (xy[0] < rect->xmin) rect->xmin = xy[0]; + if (xy[0] > rect->xmax) rect->xmax = xy[0]; + if (xy[1] < rect->ymin) rect->ymin = xy[1]; + if (xy[1] > rect->ymax) rect->ymax = xy[1]; +} + +void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]) +{ + if (xy[0] < rect->xmin) rect->xmin = xy[0]; + if (xy[0] > rect->xmax) rect->xmax = xy[0]; + if (xy[1] < rect->ymin) rect->ymin = xy[1]; + if (xy[1] > rect->ymax) rect->ymax = xy[1]; +} + void BLI_translate_rcti(rcti *rect, int x, int y) { rect->xmin += x; @@ -207,7 +263,7 @@ void BLI_resize_rctf(rctf *rect, float x, float y) rect->ymax = rect->ymin + y; } -int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest) +int BLI_isect_rctf(const rctf *src1, const rctf *src2, rctf *dest) { float xmin, xmax; float ymin, ymax; @@ -237,7 +293,7 @@ int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest) } } -int BLI_isect_rcti(rcti *src1, rcti *src2, rcti *dest) +int BLI_isect_rcti(const rcti *src1, const rcti *src2, rcti *dest) { int xmin, xmax; int ymin, ymax; @@ -269,19 +325,19 @@ int BLI_isect_rcti(rcti *src1, rcti *src2, rcti *dest) void BLI_copy_rcti_rctf(rcti *tar, const rctf *src) { - tar->xmin = floor(src->xmin + 0.5f); - tar->xmax = floor((src->xmax - src->xmin) + 0.5f); - tar->ymin = floor(src->ymin + 0.5f); - tar->ymax = floor((src->ymax - src->ymin) + 0.5f); + tar->xmin = floorf(src->xmin + 0.5f); + tar->xmax = floorf((src->xmax - src->xmin) + 0.5f); + tar->ymin = floorf(src->ymin + 0.5f); + tar->ymax = floorf((src->ymax - src->ymin) + 0.5f); } -void print_rctf(const char *str, rctf *rect) +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, rect->xmax - rect->xmin, rect->ymax - rect->ymin); } -void print_rcti(const char *str, rcti *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, rect->xmax - rect->xmin, rect->ymax - rect->ymin); diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index e73899ce929..7a750a74a33 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -168,8 +168,10 @@ escape_finish: * * Assume that the strings returned must be freed afterwards, and that the inputs will contain * data we want... + * + * TODO, return the offset and a length so as to avoid doing an allocation. */ -char *BLI_getQuotedStr(const char *str, const char *prefix) +char *BLI_str_quoted_substrN(const char *str, const char *prefix) { size_t prefixLen = strlen(prefix); char *startMatch, *endMatch; @@ -178,8 +180,8 @@ char *BLI_getQuotedStr(const char *str, const char *prefix) startMatch = strstr(str, prefix) + prefixLen + 1; /* get the end point (i.e. where the next occurance of " is after the starting point) */ - endMatch = strchr(startMatch, '"'); // " NOTE: this comment here is just so that my text editor still shows the functions ok... - + endMatch = strchr(startMatch, '"'); /* " NOTE: this comment here is just so that my text editor still shows the functions ok... */ + /* return the slice indicated */ return BLI_strdupn(startMatch, (size_t)(endMatch - startMatch)); } @@ -187,8 +189,9 @@ char *BLI_getQuotedStr(const char *str, const char *prefix) /* Replaces all occurrences of oldText with newText in str, returning a new string that doesn't * contain the 'replaced' occurrences. */ -// A rather wasteful string-replacement utility, though this shall do for now... -// Feel free to replace this with an even safe + nicer alternative + +/* A rather wasteful string-replacement utility, though this shall do for now... + * Feel free to replace this with an even safe + nicer alternative */ char *BLI_replacestr(char *str, const char *oldText, const char *newText) { DynStr *ds = NULL; diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 348fa29eae7..9994f89acd5 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -106,7 +106,7 @@ static void *thread_tls_data; ************************************************ */ static pthread_mutex_t _malloc_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _image_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t _preview_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t _image_draw_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _viewer_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _custom1_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER; @@ -337,8 +337,8 @@ void BLI_lock_thread(int type) { if (type == LOCK_IMAGE) pthread_mutex_lock(&_image_lock); - else if (type == LOCK_PREVIEW) - pthread_mutex_lock(&_preview_lock); + else if (type == LOCK_DRAW_IMAGE) + pthread_mutex_lock(&_image_draw_lock); else if (type == LOCK_VIEWER) pthread_mutex_lock(&_viewer_lock); else if (type == LOCK_CUSTOM1) @@ -357,8 +357,8 @@ void BLI_unlock_thread(int type) { if (type == LOCK_IMAGE) pthread_mutex_unlock(&_image_lock); - else if (type == LOCK_PREVIEW) - pthread_mutex_unlock(&_preview_lock); + else if (type == LOCK_DRAW_IMAGE) + pthread_mutex_unlock(&_image_draw_lock); else if (type == LOCK_VIEWER) pthread_mutex_unlock(&_viewer_lock); else if (type == LOCK_CUSTOM1) diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index eeb0187b74c..dc76fb1493d 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -39,7 +39,7 @@ #include "BLI_voronoi.h" #include "BLI_utildefines.h" -#define VORONOI_EPS 1e-3 +#define VORONOI_EPS 1e-2 enum { voronoiEventType_Site = 0, diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 3a8705bbbba..bc775cb8f0c 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -56,15 +56,18 @@ float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]) return D(data, res, xi, yi, zi); } -// returns highest integer <= x as integer (slightly faster than floor()) +/* returns highest integer <= x as integer (slightly faster than floor()) */ BLI_INLINE int FLOORI(float x) { const int r = (int)x; return ((x >= 0.f) || (float)r == x) ? r : (r - 1); } -// clamp function, cannot use the CLAMPIS macro, it sometimes returns unwanted results apparently related to gcc optimization flag -fstrict-overflow which is enabled at -O2 -// this causes the test (x + 2) < 0 with int x == 2147483647 to return false (x being an integer, x + 2 should wrap around to -2147483647 so the test < 0 should return true, which it doesn't) +/* clamp function, cannot use the CLAMPIS macro, it sometimes returns unwanted results apparently related to + * gcc optimization flag -fstrict-overflow which is enabled at -O2 + * + * this causes the test (x + 2) < 0 with int x == 2147483647 to return false (x being an integer, + * x + 2 should wrap around to -2147483647 so the test < 0 should return true, which it doesn't) */ BLI_INLINE int _clamp(int a, int b, int c) { return (a < b) ? b : ((a > c) ? c : a); diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index e34150ee4f2..0dc4d3c2db6 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -98,10 +98,10 @@ void RegisterBlendExtension(void) printf("Registering file extension..."); GetModuleFileName(0, BlPath, MAX_PATH); - // root is HKLM by default + /* root is HKLM by default */ lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) { - // try HKCU on failure + /* try HKCU on failure */ usr_mode = TRUE; lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 735f1fcaa55..53b9f8064c4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3689,7 +3689,14 @@ static void lib_link_mesh(FileData *fd, Main *main) G.main = gmain; } - + } + } + + /* convert texface options to material */ + convert_tface_mt(fd, main); + + for (me = main->mesh.first; me; me = me->id.next) { + if (me->id.flag & LIB_NEEDLINK) { /* * Re-tessellate, even if the polys were just created from tessfaces, this * is important because it: @@ -3705,13 +3712,10 @@ static void lib_link_mesh(FileData *fd, Main *main) #else BKE_mesh_tessface_clear(me); #endif - + me->id.flag -= LIB_NEEDLINK; } } - - /* convert texface options to material */ - convert_tface_mt(fd, main); } static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts) @@ -7200,6 +7204,21 @@ static void do_version_ntree_dilateerode_264(void *UNUSED(data), ID *UNUSED(id), } } +static void do_version_ntree_keying_despill_balance(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) +{ + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_KEYING) { + NodeKeyingData *data = node->storage; + + if (data->despill_balance == 0.0f) { + data->despill_balance = 0.5f; + } + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -8014,6 +8033,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ntreetype->foreach_nodetree(main, NULL, do_version_ntree_dilateerode_264); } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 14)) { + bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT); + + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_ntree_keying_despill_balance); + } + /* default values in Freestyle settings */ { Scene *sce; @@ -8717,7 +8743,6 @@ static void expand_curve(FileData *fd, Main *mainvar, Curve *cu) static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me) { CustomDataLayer *layer; - MTFace *mtf; TFace *tf; int a, i; @@ -8739,14 +8764,34 @@ static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me) } } - for (a = 0; a < me->fdata.totlayer; a++) { - layer = &me->fdata.layers[a]; - - if (layer->type == CD_MTFACE) { - mtf = (MTFace*)layer->data; - for (i = 0; i < me->totface; i++, mtf++) { - if (mtf->tpage) - expand_doit(fd, mainvar, mtf->tpage); + if (me->mface && !me->mpoly) { + MTFace *mtf; + + for (a = 0; a < me->fdata.totlayer; a++) { + layer = &me->fdata.layers[a]; + + if (layer->type == CD_MTFACE) { + mtf = (MTFace *) layer->data; + for (i = 0; i < me->totface; i++, mtf++) { + if (mtf->tpage) + expand_doit(fd, mainvar, mtf->tpage); + } + } + } + } + else { + MTexPoly *mtp; + + for (a = 0; a < me->pdata.totlayer; a++) { + layer = &me->pdata.layers[a]; + + if (layer->type == CD_MTEXPOLY) { + mtp = (MTexPoly *) layer->data; + + for (i = 0; i < me->totpoly; i++, mtp++) { + if (mtp->tpage) + expand_doit(fd, mainvar, mtp->tpage); + } } } } diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index b6d9fbc85a2..c80a88d280e 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -99,11 +99,11 @@ */ static BMOpDefine bmo_smooth_vert_def = { "smooth_vert", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, //set vertices close to the x axis before the operation to 0 - {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, //set vertices close to the y axis before the operation to 0 - {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, //set vertices close to the z axis before the operation to 0 - {BMO_OP_SLOT_FLT, "clipdist"}, //clipping threshod for the above three slots + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ + {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, /* set vertices close to the x axis before the operation to 0 */ + {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, /* set vertices close to the y axis before the operation to 0 */ + {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, /* set vertices close to the z axis before the operation to 0 */ + {BMO_OP_SLOT_FLT, "clipdist"}, /* clipping threshod for the above three slots */ {0} /* null-terminating sentinel */, }, bmo_smooth_vert_exec, @@ -119,7 +119,7 @@ static BMOpDefine bmo_smooth_vert_def = { static BMOpDefine bmo_recalc_face_normals_def = { "recalc_face_normals", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, - {BMO_OP_SLOT_BOOL, "do_flip"}, //internal flag, used by bmesh_rationalize_normals + {BMO_OP_SLOT_BOOL, "do_flip"}, /* internal flag, used by bmesh_rationalize_normals */ {0} /* null-terminating sentinel */, }, bmo_recalc_face_normals_exec, @@ -138,10 +138,10 @@ static BMOpDefine bmo_recalc_face_normals_def = { */ static BMOpDefine bmo_region_extend_def = { "region_extend", - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output slot, computed boundary geometry. - {BMO_OP_SLOT_BOOL, "constrict"}, //find boundary inside the regions, not outside. - {BMO_OP_SLOT_BOOL, "use_faces"}, //extend from faces instead of edges + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ + {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output slot, computed boundary geometry. */ + {BMO_OP_SLOT_BOOL, "constrict"}, /* find boundary inside the regions, not outside. */ + {BMO_OP_SLOT_BOOL, "use_faces"}, /* extend from faces instead of edges */ {0} /* null-terminating sentinel */, }, bmo_region_extend_exec, @@ -156,9 +156,9 @@ static BMOpDefine bmo_region_extend_def = { */ static BMOpDefine bmo_rotate_edges_def = { "rotate_edges", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //newly spun edges - {BMO_OP_SLOT_BOOL, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ + {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly spun edges */ + {BMO_OP_SLOT_BOOL, "ccw"}, /* rotate edge counter-clockwise if true, othewise clockwise */ {0} /* null-terminating sentinel */, }, bmo_rotate_edges_exec, @@ -173,7 +173,7 @@ static BMOpDefine bmo_rotate_edges_def = { */ static BMOpDefine bmo_reverse_faces_def = { "reverse_faces", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */, }, bmo_reverse_faces_exec, @@ -188,9 +188,9 @@ static BMOpDefine bmo_reverse_faces_def = { */ static BMOpDefine bmo_bisect_edges_def = { "bisect_edges", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges - {BMO_OP_SLOT_INT, "numcuts"}, //number of cuts - {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, //newly created vertices and edges + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ + {BMO_OP_SLOT_INT, "numcuts"}, /* number of cuts */ + {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, /* newly created vertices and edges */ {0} /* null-terminating sentinel */, }, bmo_bisect_edges_exec, @@ -207,13 +207,13 @@ static BMOpDefine bmo_bisect_edges_def = { static BMOpDefine bmo_mirror_def = { "mirror", - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry - {BMO_OP_SLOT_MAT, "mat"}, //matrix defining the mirror transformation - {BMO_OP_SLOT_FLT, "mergedist"}, //maximum distance for merging. does no merging if 0. - {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, //output geometry, mirrored - {BMO_OP_SLOT_INT, "axis"}, //the axis to use, 0, 1, or 2 for x, y, z - {BMO_OP_SLOT_BOOL, "mirror_u"}, //mirror UVs across the u axis - {BMO_OP_SLOT_BOOL, "mirror_v"}, //mirror UVs across the v axis + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining the mirror transformation */ + {BMO_OP_SLOT_FLT, "mergedist"}, /* maximum distance for merging. does no merging if 0. */ + {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, /* output geometry, mirrored */ + {BMO_OP_SLOT_INT, "axis"}, /* the axis to use, 0, 1, or 2 for x, y, z */ + {BMO_OP_SLOT_BOOL, "mirror_u"}, /* mirror UVs across the u axis */ + {BMO_OP_SLOT_BOOL, "mirror_v"}, /* mirror UVs across the v axis */ {0, /* null-terminating sentinel */}}, bmo_mirror_exec, 0, @@ -230,9 +230,9 @@ static BMOpDefine bmo_mirror_def = { */ static BMOpDefine bmo_find_doubles_def = { "find_doubles", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, //list of verts to keep - {BMO_OP_SLOT_FLT, "dist"}, //minimum distance + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ + {BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, /* list of verts to keep */ + {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ {BMO_OP_SLOT_MAPPING, "targetmapout"}, {0, /* null-terminating sentinel */}}, bmo_find_doubles_exec, @@ -247,8 +247,8 @@ static BMOpDefine bmo_find_doubles_def = { */ static BMOpDefine bmo_remove_doubles_def = { "remove_doubles", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input verts - {BMO_OP_SLOT_FLT, "dist"}, //minimum distance + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */ + {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ {0, /* null-terminating sentinel */}}, bmo_remove_doubles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, @@ -263,8 +263,8 @@ static BMOpDefine bmo_remove_doubles_def = { */ static BMOpDefine bmo_automerge_def = { "automerge", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input verts - {BMO_OP_SLOT_FLT, "dist"}, //minimum distance + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */ + {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ {0, /* null-terminating sentinel */}}, bmo_automerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, @@ -916,11 +916,11 @@ static BMOpDefine bmo_split_edges_def = { */ static BMOpDefine bmo_create_grid_def = { "create_grid", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_INT, "xsegments"}, //number of x segments - {BMO_OP_SLOT_INT, "ysegments"}, //number of y segments - {BMO_OP_SLOT_FLT, "size"}, //size of the grid - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_INT, "xsegments"}, /* number of x segments */ + {BMO_OP_SLOT_INT, "ysegments"}, /* number of y segments */ + {BMO_OP_SLOT_FLT, "size"}, /* size of the grid */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ {0, /* null-terminating sentinel */}}, bmo_create_grid_exec, 0, @@ -933,11 +933,11 @@ static BMOpDefine bmo_create_grid_def = { */ static BMOpDefine bmo_create_uvsphere_def = { "create_uvsphere", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_INT, "segments"}, //number of u segments - {BMO_OP_SLOT_INT, "revolutions"}, //number of v segment - {BMO_OP_SLOT_FLT, "diameter"}, //diameter - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_INT, "segments"}, /* number of u segments */ + {BMO_OP_SLOT_INT, "revolutions"}, /* number of v segment */ + {BMO_OP_SLOT_FLT, "diameter"}, /* diameter */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_uvsphere_exec, 0, @@ -950,10 +950,10 @@ static BMOpDefine bmo_create_uvsphere_def = { */ static BMOpDefine bmo_create_icosphere_def = { "create_icosphere", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_INT, "subdivisions"}, //how many times to recursively subdivide the sphere - {BMO_OP_SLOT_FLT, "diameter"}, //diameter - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_INT, "subdivisions"}, /* how many times to recursively subdivide the sphere */ + {BMO_OP_SLOT_FLT, "diameter"}, /* diameter */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ {0, /* null-terminating sentinel */}}, bmo_create_icosphere_exec, 0, @@ -966,8 +966,8 @@ static BMOpDefine bmo_create_icosphere_def = { */ static BMOpDefine bmo_create_monkey_def = { "create_monkey", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_monkey_exec, 0, @@ -980,14 +980,14 @@ static BMOpDefine bmo_create_monkey_def = { */ static BMOpDefine bmo_create_cone_def = { "create_cone", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_BOOL, "cap_ends"}, //wheter or not to fill in the ends with faces - {BMO_OP_SLOT_BOOL, "cap_tris"}, //fill ends with triangles instead of ngons + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ + {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ {BMO_OP_SLOT_INT, "segments"}, - {BMO_OP_SLOT_FLT, "diameter1"}, //diameter of one end - {BMO_OP_SLOT_FLT, "diameter2"}, //diameter of the opposite - {BMO_OP_SLOT_FLT, "depth"}, //distance between ends - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {BMO_OP_SLOT_FLT, "diameter1"}, /* diameter of one end */ + {BMO_OP_SLOT_FLT, "diameter2"}, /* diameter of the opposite */ + {BMO_OP_SLOT_FLT, "depth"}, /* distance between ends */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_cone_exec, 0, @@ -998,12 +998,12 @@ static BMOpDefine bmo_create_cone_def = { */ static BMOpDefine bmo_create_circle_def = { "create_circle", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_BOOL, "cap_ends"}, //wheter or not to fill in the ends with faces - {BMO_OP_SLOT_BOOL, "cap_tris"}, //fill ends with triangles instead of ngons + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ + {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ {BMO_OP_SLOT_INT, "segments"}, - {BMO_OP_SLOT_FLT, "diameter"}, //diameter of one end - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {BMO_OP_SLOT_FLT, "diameter"}, /* diameter of one end */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_circle_exec, 0, @@ -1016,9 +1016,9 @@ static BMOpDefine bmo_create_circle_def = { */ static BMOpDefine bmo_create_cube_def = { "create_cube", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_FLT, "size"}, //size of the cube - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_FLT, "size"}, /* size of the cube */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_cube_exec, 0, diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index b6a56e64dcf..f22c25766df 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -193,12 +193,11 @@ BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v) * Get the first loop of a vert. Uses the same initialization code for the first loop of the * iterator API */ - BMLoop *BM_vert_find_first_loop(BMVert *v) { BMEdge *e; - if(!v || !v->e) + if (!v || !v->e) return NULL; e = bmesh_disk_faceedge_find_first(v->e, v); @@ -208,7 +207,6 @@ BMLoop *BM_vert_find_first_loop(BMVert *v) /** * Returns TRUE if the vertex is used in a given face. */ - int BM_vert_in_face(BMFace *f, BMVert *v) { BMLoop *l_iter, *l_first; diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index f11ecc7f16d..1eee797b51c 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -173,7 +173,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) { // create a list of indices to textures of type TEX_IMAGE std::vector<int> tex_indices; - if(this->export_settings->include_material_textures) + if (this->export_settings->include_material_textures) createTextureIndices(ma, tex_indices); openEffect(translate_id(id_name(ma)) + "-effect"); diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index b9e96445dcb..206dc09fe8b 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -63,6 +63,11 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) if (not_yet_exported) { ImBuf *imbuf = BKE_image_get_ibuf(image, NULL); + if(!imbuf) { + fprintf(stderr, "Collada export: image does not exist:\n%s\n", image->name); + return; + } + bool is_dirty = imbuf->userflags & IB_BITMAPDIRTY; ImageFormatData imageFormat; @@ -100,6 +105,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) { fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path); + return; } BLI_strncpy(export_path, export_file, sizeof(export_path)); } @@ -119,6 +125,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) if (BLI_copy(source_path, export_path) != 0) { fprintf(stderr, "Collada export: Cannot copy image:\n source:%s\ndest :%s\n", source_path, export_path); + return; } BLI_strncpy(export_path, export_file, sizeof(export_path)); @@ -153,8 +160,7 @@ void ImagesExporter::export_UV_Images() for (int i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; - MFace *mface = me->mface; - for (int j = 0; j < me->totpoly; j++, mface++, txface++) { + for (int j = 0; j < me->totpoly; j++, txface++) { Image *ima = txface->tpage; if (ima == NULL) diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index 9bad1b55d95..870e379b343 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -338,6 +338,11 @@ set(SRC operations/COM_KeyingScreenOperation.cpp operations/COM_KeyingScreenOperation.h + nodes/COM_TrackPositionNode.cpp + nodes/COM_TrackPositionNode.h + operations/COM_TrackPositionOperation.cpp + operations/COM_TrackPositionOperation.h + nodes/COM_KeyingNode.cpp nodes/COM_KeyingNode.h operations/COM_KeyingOperation.cpp diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h index 86390e5650a..c65ea771477 100644 --- a/source/blender/compositor/COM_compositor.h +++ b/source/blender/compositor/COM_compositor.h @@ -299,6 +299,19 @@ extern "C" { */ void COM_execute(RenderData* rd, bNodeTree *editingtree, int rendering); +/** + * @brief Return a list of highlighted bnodes pointers. + * @return + */ +void COM_startReadHighlights(void); + +/** + * @brief check if a bnode is highlighted + * @param bnode + * @return + */ +int COM_isHighlightedbNode(bNode* bnode); + #ifdef __cplusplus } #endif diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp index 95462b3c384..7029aa032cc 100644 --- a/source/blender/compositor/intern/COM_CPUDevice.cpp +++ b/source/blender/compositor/intern/COM_CPUDevice.cpp @@ -29,10 +29,9 @@ void CPUDevice::execute(WorkPackage *work) rcti rect; executionGroup->determineChunkRect(&rect, chunkNumber); - MemoryBuffer **inputBuffers = executionGroup->getInputBuffersCPU(); - executionGroup->getOutputNodeOperation()->executeRegion(&rect, chunkNumber, inputBuffers); + executionGroup->getOutputNodeOperation()->executeRegion(&rect, chunkNumber); - executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers); + executionGroup->finalizeChunkExecution(chunkNumber, NULL); } diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 4ed7ae7ca8a..37d38261ea5 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -110,6 +110,7 @@ #include "COM_TransformNode.h" #include "COM_TranslateNode.h" #include "COM_TranslateOperation.h" +#include "COM_TrackPositionNode.h" #include "COM_ValueNode.h" #include "COM_VectorBlurNode.h" #include "COM_VectorCurveNode.h" @@ -377,6 +378,9 @@ Node *Converter::convert(bNode *b_node, bool fast) case CMP_NODE_KEYING: node = new KeyingNode(b_node); break; + case CMP_NODE_TRACKPOS: + node = new TrackPositionNode(b_node); + break; /* not inplemented yet */ default: node = new MuteNode(b_node); diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 90f4ba85c78..46a0db7af2d 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -372,23 +372,6 @@ void ExecutionGroup::execute(ExecutionSystem *graph) delete[] chunkOrder; } -MemoryBuffer **ExecutionGroup::getInputBuffersCPU() -{ - vector<MemoryProxy *> memoryproxies; - unsigned int index; - - this->determineDependingMemoryProxies(&memoryproxies); - MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->m_cachedMaxReadBufferOffset]; - for (index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { - memoryBuffers[index] = NULL; - } - for (index = 0; index < this->m_cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; - memoryBuffers[readOperation->getOffset()] = readOperation->getMemoryProxy()->getBuffer(); - } - return memoryBuffers; -} - MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) { rcti rect; @@ -449,12 +432,12 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const { if (this->m_singleThreaded) { - BLI_init_rcti(rect, 0, this->m_width, 0, this->m_height); + BLI_rcti_init(rect, 0, this->m_width, 0, this->m_height); } else { const unsigned int minx = xChunk * this->m_chunkSize; const unsigned int miny = yChunk * this->m_chunkSize; - BLI_init_rcti(rect, minx, min(minx + this->m_chunkSize, this->m_width), miny, min(miny + this->m_chunkSize, this->m_height)); + BLI_rcti_init(rect, minx, min(minx + this->m_chunkSize, this->m_width), miny, min(miny + this->m_chunkSize, this->m_height)); } } @@ -551,7 +534,7 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChun for (index = 0; index < this->m_cachedReadOperations.size(); index++) { ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; - BLI_init_rcti(&area, 0, 0, 0, 0); + BLI_rcti_init(&area, 0, 0, 0, 0); MemoryProxy *memoryProxy = memoryProxies[index]; determineDependingAreaOfInterest(&rect, readOperation, &area); ExecutionGroup *group = memoryProxy->getExecutor(); diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index ff841092848..801505e9d39 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -129,6 +129,13 @@ void ExecutionSystem::execute() operation->setbNodeTree(this->m_context.getbNodeTree()); operation->initExecution(); } + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; + if (operation->isReadBufferOperation()) { + ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; + readOperation->updateMemoryBuffer(); + } + } for (index = 0; index < this->m_groups.size(); index++) { ExecutionGroup *executionGroup = this->m_groups[index]; executionGroup->setChunksize(this->m_context.getChunksize()); diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp index 8dd1e55274f..0aae8853795 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp @@ -22,8 +22,7 @@ #include "COM_MemoryBuffer.h" #include "MEM_guardedalloc.h" -#include "BLI_math.h" -#include "BKE_global.h" +//#include "BKE_global.h" unsigned int MemoryBuffer::determineBufferSize() { @@ -41,7 +40,7 @@ int MemoryBuffer::getHeight() const MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect) { - BLI_init_rcti(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); this->m_memoryProxy = memoryProxy; this->m_chunkNumber = chunkNumber; this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); @@ -52,7 +51,7 @@ MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, r MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect) { - BLI_init_rcti(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); this->m_memoryProxy = memoryProxy; this->m_chunkNumber = -1; this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); @@ -117,26 +116,12 @@ void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer) } } -void MemoryBuffer::read(float result[4], int x, int y) -{ - if (x >= this->m_rect.xmin && x < this->m_rect.xmax && - y >= this->m_rect.ymin && y < this->m_rect.ymax) - { - const int dx = x - this->m_rect.xmin; - const int dy = y - this->m_rect.ymin; - const int offset = (this->m_chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; - copy_v4_v4(result, &this->m_buffer[offset]); - } - else { - zero_v4(result); - } -} void MemoryBuffer::writePixel(int x, int y, const float color[4]) { if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin && y < this->m_rect.ymax) { - const int offset = (this->m_chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; + const int offset = (this->m_chunkWidth * (y-this->m_rect.ymin) + x-this->m_rect.xmin) * COM_NUMBER_OF_CHANNELS; copy_v4_v4(&this->m_buffer[offset], color); } } @@ -146,49 +131,11 @@ void MemoryBuffer::addPixel(int x, int y, const float color[4]) if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin && y < this->m_rect.ymax) { - const int offset = (this->m_chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; + const int offset = (this->m_chunkWidth * (y-this->m_rect.ymin) + x-this->m_rect.xmin) * COM_NUMBER_OF_CHANNELS; add_v4_v4(&this->m_buffer[offset], color); } } -void MemoryBuffer::readCubic(float result[4], float x, float y) -{ - int x1 = floor(x); - int x2 = x1 + 1; - int y1 = floor(y); - int y2 = y1 + 1; - - float valuex = x - x1; - float valuey = y - y1; - float mvaluex = 1.0f - valuex; - float mvaluey = 1.0f - valuey; - - float color1[4]; - float color2[4]; - float color3[4]; - float color4[4]; - - read(color1, x1, y1); - read(color2, x1, y2); - read(color3, x2, y1); - read(color4, x2, y2); - - color1[0] = color1[0] * mvaluey + color2[0] * valuey; - color1[1] = color1[1] * mvaluey + color2[1] * valuey; - color1[2] = color1[2] * mvaluey + color2[2] * valuey; - color1[3] = color1[3] * mvaluey + color2[3] * valuey; - - color3[0] = color3[0] * mvaluey + color4[0] * valuey; - color3[1] = color3[1] * mvaluey + color4[1] * valuey; - color3[2] = color3[2] * mvaluey + color4[2] * valuey; - color3[3] = color3[3] * mvaluey + color4[3] * valuey; - - result[0] = color1[0] * mvaluex + color3[0] * valuex; - result[1] = color1[1] * mvaluex + color3[1] * valuex; - result[2] = color1[2] * mvaluex + color3[2] * valuex; - result[3] = color1[3] * mvaluex + color3[3] * valuex; -} - // table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2 // used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index 63b41aeddde..eed0c796cd8 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -28,10 +28,12 @@ class MemoryBuffer; #include "COM_ExecutionGroup.h" #include "BLI_rect.h" #include "COM_MemoryProxy.h" + extern "C" { - #include "BLI_threads.h" + //#include "BLI_threads.h" + #include "BLI_math.h" } -#include <vector> +//#include <vector> /** * @brief state of a memory buffer @@ -124,10 +126,69 @@ public: this->m_state = COM_MB_AVAILABLE; } - void read(float result[4], int x, int y); + inline void read(float result[4], int x, int y) { + if (x >= this->m_rect.xmin && x < this->m_rect.xmax && + y >= this->m_rect.ymin && y < this->m_rect.ymax) + { + const int dx = x - this->m_rect.xmin; + const int dy = y - this->m_rect.ymin; + const int offset = (this->m_chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; + copy_v4_v4(result, &this->m_buffer[offset]); + } + else { + zero_v4(result); + } + } + + inline void readNoCheck(float result[4], int x, int y) { + const int dx = x - this->m_rect.xmin; + const int dy = y - this->m_rect.ymin; + const int offset = (this->m_chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; + copy_v4_v4(result, &this->m_buffer[offset]); + } + void writePixel(int x, int y, const float color[4]); void addPixel(int x, int y, const float color[4]); - void readCubic(float result[4], float x, float y); + inline void readCubic(float result[4], float x, float y) + { + int x1 = floor(x); + int x2 = x1 + 1; + int y1 = floor(y); + int y2 = y1 + 1; + + float valuex = x - x1; + float valuey = y - y1; + float mvaluex = 1.0f - valuex; + float mvaluey = 1.0f - valuey; + + float color1[4]; + float color2[4]; + float color3[4]; + float color4[4]; + + read(color1, x1, y1); + read(color2, x1, y2); + read(color3, x2, y1); + read(color4, x2, y2); + + color1[0] = color1[0] * mvaluey + color2[0] * valuey; + color1[1] = color1[1] * mvaluey + color2[1] * valuey; + color1[2] = color1[2] * mvaluey + color2[2] * valuey; + color1[3] = color1[3] * mvaluey + color2[3] * valuey; + + color3[0] = color3[0] * mvaluey + color4[0] * valuey; + color3[1] = color3[1] * mvaluey + color4[1] * valuey; + color3[2] = color3[2] * mvaluey + color4[2] * valuey; + color3[3] = color3[3] * mvaluey + color4[3] * valuey; + + result[0] = color1[0] * mvaluex + color3[0] * valuex; + result[1] = color1[1] * mvaluex + color3[1] * valuex; + result[2] = color1[2] * mvaluex + color3[2] * valuex; + result[3] = color1[3] * mvaluex + color3[3] * valuex; + } + + + void readEWA(float result[4], float fx, float fy, float dx, float dy); /** diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index c3fa308971c..9baab584d9e 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -120,7 +120,7 @@ void NodeOperation::getConnectedInputSockets(vector<InputSocket *> *sockets) bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { if (this->isInputNode()) { - BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax); + BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax); return false; } else { diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index d316cfa0aa4..0de2f6aef5d 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -134,7 +134,7 @@ public: * @param chunkNumber the chunkNumber to be calculated * @param memoryBuffers all input MemoryBuffer's needed */ - virtual void executeRegion(rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers) {} + virtual void executeRegion(rcti *rect, unsigned int chunkNumber) {} /** * @brief when a chunk is executed by an OpenCLDevice, this method is called diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp index eae1ffeb08a..63f75681779 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp @@ -65,11 +65,16 @@ void OpenCLDevice::execute(WorkPackage *work) executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers); } - cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader) { + return COM_clAttachMemoryBufferToKernelParameter(kernel, parameterIndex, offsetIndex, cleanup, inputMemoryBuffers, (ReadBufferOperation*)reader); +} + +cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, ReadBufferOperation *reader) +{ cl_int error; - MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers); + + MemoryBuffer *result = (MemoryBuffer *)reader->getInputMemoryBuffer(inputMemoryBuffers); const cl_image_format imageFormat = { CL_RGBA, diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h index 30a90dabc3e..577df5caf77 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.h +++ b/source/blender/compositor/intern/COM_OpenCLDevice.h @@ -28,6 +28,7 @@ class OpenCLDevice; #include "COM_Device.h" #include "OCL_opencl.h" #include "COM_WorkScheduler.h" +#include "COM_ReadBufferOperation.h" /** * @brief device representing an GPU OpenCL device. @@ -96,6 +97,7 @@ public: cl_command_queue getQueue(){ return this->m_queue; } cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); + cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, ReadBufferOperation *reader); void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer); void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation* operation); diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp index a6f81410b74..d14b8c48c89 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp +++ b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp @@ -33,9 +33,9 @@ void SingleThreadedNodeOperation::initExecution() initMutex(); } -void SingleThreadedNodeOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void SingleThreadedNodeOperation::executePixel(float *color, int x, int y, void *data) { - this->m_cachedInstance->read(color, x, y); + this->m_cachedInstance->readNoCheck(color, x, y); } void SingleThreadedNodeOperation::deinitExecution() @@ -46,14 +46,14 @@ void SingleThreadedNodeOperation::deinitExecution() this->m_cachedInstance = NULL; } } -void *SingleThreadedNodeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *SingleThreadedNodeOperation::initializeTileData(rcti *rect) { if (this->m_cachedInstance) return this->m_cachedInstance; lockMutex(); if (this->m_cachedInstance == NULL) { // - this->m_cachedInstance = createMemoryBuffer(rect, memoryBuffers); + this->m_cachedInstance = createMemoryBuffer(rect); } unlockMutex(); return this->m_cachedInstance; diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h index c6db5381f48..68951eab507 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h +++ b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution @@ -51,9 +51,9 @@ public: */ void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); - virtual MemoryBuffer *createMemoryBuffer(rcti *rect, MemoryBuffer **memoryBuffers) = 0; + virtual MemoryBuffer *createMemoryBuffer(rcti *rect) = 0; int isSingleThreaded() { return true; } }; diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h index 0f35fcfb0df..736dd2fc8b6 100644 --- a/source/blender/compositor/intern/COM_SocketReader.h +++ b/source/blender/compositor/intern/COM_SocketReader.h @@ -63,7 +63,7 @@ protected: * @param y the y-coordinate of the pixel to calculate in image space * @param inputBuffers chunks that can be read by their ReadBufferOperation. */ - virtual void executePixel(float *result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {} + virtual void executePixel(float *result, float x, float y, PixelSampler sampler) {} /** * @brief calculate a single pixel @@ -74,8 +74,8 @@ protected: * @param inputBuffers chunks that can be read by their ReadBufferOperation. * @param chunkData chunk specific data a during execution time. */ - virtual void executePixel(float *result, int x, int y, MemoryBuffer *inputBuffers[], void *chunkData) { - executePixel(result, x, y, COM_PS_NEAREST, inputBuffers); + virtual void executePixel(float *result, int x, int y, void *chunkData) { + executePixel(result, x, y, COM_PS_NEAREST); } /** @@ -88,21 +88,21 @@ protected: * @param dy * @param inputBuffers chunks that can be read by their ReadBufferOperation. */ - virtual void executePixel(float *result, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) {} + virtual void executePixel(float *result, float x, float y, float dx, float dy) {} public: - inline void read(float *result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - executePixel(result, x, y, sampler, inputBuffers); + inline void read(float *result, float x, float y, PixelSampler sampler) { + executePixel(result, x, y, sampler); } - inline void read(float *result, int x, int y, MemoryBuffer *inputBuffers[], void *chunkData) { - executePixel(result, x, y, inputBuffers, chunkData); + inline void read(float *result, int x, int y, void *chunkData) { + executePixel(result, x, y, chunkData); } - inline void read(float *result, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) { - executePixel(result, x, y, dx, dy, inputBuffers); + inline void read(float *result, float x, float y, float dx, float dy) { + executePixel(result, x, y, dx, dy); } - virtual void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { return 0; } - virtual void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) { + virtual void *initializeTileData(rcti *rect) { return 0; } + virtual void deinitializeTileData(rcti *rect, void *data) { } virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; } diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index 120b4d6d0f2..b10e99697e4 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -66,6 +66,12 @@ static bool g_openclActive = false; #endif #endif +#define MAX_HIGHLIGHT 8 +extern "C" { +int g_highlightIndex; +void ** g_highlightedNodes; +void ** g_highlightedNodesRead; + #define HIGHLIGHT(wp) \ { \ ExecutionGroup* group = wp->getExecutionGroup(); \ @@ -77,14 +83,38 @@ static bool g_openclActive = false; bNode *node = complexOperation->getbNode(); \ if (node) { \ if (node->original) { \ - node->original->highlight = 1;\ - } else {\ - node->highlight = 1; \ + node = node->original;\ + }\ + if (g_highlightIndex < MAX_HIGHLIGHT) {\ + g_highlightedNodes[g_highlightIndex++] = node;\ }\ } \ } \ } \ } +void COM_startReadHighlights() { + if (g_highlightedNodesRead) { + delete [] g_highlightedNodesRead; + } + + g_highlightedNodesRead = g_highlightedNodes; + g_highlightedNodes = new void*[MAX_HIGHLIGHT]; + g_highlightIndex = 0; + for (int i = 0 ; i < MAX_HIGHLIGHT; i++) { + g_highlightedNodes[i] = 0; + } +} + +int COM_isHighlightedbNode(bNode* bnode) { + if (!g_highlightedNodesRead) return false; + for (int i = 0 ; i < MAX_HIGHLIGHT; i++) { + void* p = g_highlightedNodesRead[i]; + if (!p) return false; + if (p == bnode) return true; + } + return false; +} +} // end extern "C" #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE void *WorkScheduler::thread_execute_cpu(void *data) @@ -219,6 +249,9 @@ extern void clContextError(const char *errinfo, const void *private_info, size_t void WorkScheduler::initialize() { + g_highlightedNodesRead = 0; + g_highlightedNodes = 0; + COM_startReadHighlights(); #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE int numberOfCPUThreads = BLI_system_thread_count(); @@ -313,3 +346,4 @@ void WorkScheduler::deinitialize() #endif #endif } + diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp index 0ea4b20c793..300193da842 100644 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp @@ -37,32 +37,24 @@ BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode) void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { -// Object *camob = context->getScene()->camera; + BokehBlurOperation *operation = new BokehBlurOperation(); + InputSocket *inputSizeSocket = this->getInputSocket(2); + bool connectedSizeSocket = inputSizeSocket->isConnected(); -// if (this->getInputSocket(2)->isConnected()) { -// VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); -// ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); -// converter->setfStop(this->getbNode()->custom3); -// converter->setCameraObject(camob); -// operation->setMaxBlur((int)this->getbNode()->custom4); -// operation->setQuality(context->getQuality()); -// this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); -// this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); -// this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), 2, graph); -// addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2)); -// graph->addOperation(operation); -// graph->addOperation(converter); -// this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); -// } -// else { - BokehBlurOperation *operation = new BokehBlurOperation(); - this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); - this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph); - operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value); - operation->setQuality(context->getQuality()); - operation->setbNode(this->getbNode()); - graph->addOperation(operation); - this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); -// } + const bNodeSocket *sock = this->getInputSocket(2)->getbNodeSocket(); + const float size = ((const bNodeSocketValueFloat *)sock->default_value)->value; + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(3), 2, graph); + this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph); + //operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value); + operation->setQuality(context->getQuality()); + operation->setbNode(this->getbNode()); + graph->addOperation(operation); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + if (!connectedSizeSocket) { + operation->setSize(size); + } } diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp index 4c6b3ad137b..65825a60b50 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -32,6 +32,7 @@ #include "COM_MathBaseOperation.h" #include "COM_SetValueOperation.h" #include "COM_GammaCorrectOperation.h" +#include "COM_FastGaussianBlurOperation.h" DefocusNode::DefocusNode(bNode *editorNode) : Node(editorNode) { @@ -46,7 +47,6 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext NodeDefocus *data = (NodeDefocus *)node->storage; NodeOperation *radiusOperation; - OutputSocket * depthOperation; if (data->no_zbuf) { MathMultiplyOperation *multiply = new MathMultiplyOperation(); SetValueOperation *multiplier = new SetValueOperation(); @@ -64,7 +64,6 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext graph->addOperation(maxRadius); graph->addOperation(minimize); radiusOperation = minimize; - depthOperation = minimize->getOutputSocket(0); } else { ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); @@ -73,8 +72,12 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext converter->setMaxRadius(data->maxblur); this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), 1, graph); graph->addOperation(converter); - radiusOperation = converter; - depthOperation = converter->getInputSocket(0)->getConnection()->getFromSocket(); + + FastGaussianBlurValueOperation * blur = new FastGaussianBlurValueOperation(); + addLink(graph, converter->getOutputSocket(0), blur->getInputSocket(0)); + graph->addOperation(blur); + radiusOperation = blur; + converter->setPostBlur(blur); } BokehImageOperation *bokeh = new BokehImageOperation(); @@ -96,9 +99,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext #ifdef COM_DEFOCUS_SEARCH InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation(); addLink(graph, radiusOperation->getOutputSocket(0), search->getInputSocket(0)); - addLink(graph, depthOperation, search->getInputSocket(1)); search->setMaxBlur(data->maxblur); - search->setThreshold(data->bthresh); graph->addOperation(search); #endif VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); @@ -112,9 +113,8 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext operation->setThreshold(data->bthresh); addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1)); addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2)); - addLink(graph, depthOperation, operation->getInputSocket(3)); #ifdef COM_DEFOCUS_SEARCH - addLink(graph, search->getOutputSocket(), operation->getInputSocket(4)); + addLink(graph, search->getOutputSocket(), operation->getInputSocket(3)); #endif if (data->gamco) { GammaCorrectOperation *correct = new GammaCorrectOperation(); diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp index dee0e6a88da..85fc63ae8cb 100644 --- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp @@ -37,6 +37,7 @@ void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, Compositor DirectionalBlurOperation *operation = new DirectionalBlurOperation(); operation->setQuality(context->getQuality()); operation->setData(data); + operation->setbNode(this->getbNode()); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); graph->addOperation(operation); diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp index 7c39765fbf1..efd50a44a51 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp @@ -184,11 +184,13 @@ OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext return operationy->getOutputSocket(); } -OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen, float factor) +OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen, + float factor, float colorBalance) { KeyingDespillOperation *despillOperation = new KeyingDespillOperation(); despillOperation->setDespillFactor(factor); + despillOperation->setColorBalance(colorBalance); addLink(graph, despillInput, despillOperation->getInputSocket(0)); addLink(graph, inputScreen, despillOperation->getInputSocket(1)); @@ -292,7 +294,8 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * if (keying_data->despill_factor > 0.0f) { postprocessedImage = setupDespill(graph, postprocessedImage, keyingOperation->getInputSocket(1)->getConnection()->getFromSocket(), - keying_data->despill_factor); + keying_data->despill_factor, + keying_data->despill_balance); } /* connect result to output sockets */ diff --git a/source/blender/compositor/nodes/COM_KeyingNode.h b/source/blender/compositor/nodes/COM_KeyingNode.h index 294a27bb52c..6ab6a60a44d 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.h +++ b/source/blender/compositor/nodes/COM_KeyingNode.h @@ -36,7 +36,8 @@ protected: OutputSocket *setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance); OutputSocket *setupFeather(ExecutionSystem *graph, CompositorContext *context, OutputSocket *featherInput, int falloff, int distance); - OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen, float factor); + OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen, + float factor, float colorBalance); OutputSocket *setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance, float clipBlack, float clipWhite, bool edgeMatte); public: diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp index 300c9967cc4..307590b977b 100644 --- a/source/blender/compositor/nodes/COM_MathNode.cpp +++ b/source/blender/compositor/nodes/COM_MathNode.cpp @@ -83,10 +83,14 @@ void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co } if (operation != NULL) { + bool useClamp = this->getbNode()->custom2; + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - + + operation->setUseClamp(useClamp); + graph->addOperation(operation); } } diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp index eb62ebd2635..7aeaaf56c98 100644 --- a/source/blender/compositor/nodes/COM_MixNode.cpp +++ b/source/blender/compositor/nodes/COM_MixNode.cpp @@ -58,6 +58,8 @@ void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *con InputSocket *color2Socket = this->getInputSocket(2); OutputSocket *outputSocket = this->getOutputSocket(0); bNode *editorNode = this->getbNode(); + bool useAlphaPremultiply = this->getbNode()->custom2 & 1; + bool useClamp = this->getbNode()->custom2 & 2; MixBaseOperation *convertProg; @@ -119,7 +121,8 @@ void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *con convertProg = new MixBlendOperation(); break; } - convertProg->setUseValueAlphaMultiply(this->getbNode()->custom2); + convertProg->setUseValueAlphaMultiply(useAlphaPremultiply); + convertProg->setUseClamp(useClamp); valueSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph); diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp index 89bd0e8549e..a250841b160 100644 --- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp +++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp @@ -81,6 +81,7 @@ void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContex operation->setMovieClip(movieClip); operation->setMovieClipUser(movieClipUser); operation->setFramenumber(context->getFramenumber()); + operation->setCacheFrame(!context->isRendering()); graph->addOperation(operation); MovieTrackingStabilization *stab = &movieClip->tracking.stabilization; diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp new file mode 100644 index 00000000000..243f63a0149 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp @@ -0,0 +1,68 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Sergey Sharybin + */ + +#include "COM_TrackPositionNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_TrackPositionOperation.h" + +extern "C" { + #include "DNA_movieclip_types.h" +} + +TrackPositionNode::TrackPositionNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void TrackPositionNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) +{ + OutputSocket *outputX = this->getOutputSocket(0); + OutputSocket *outputY = this->getOutputSocket(1); + + bNode *editorNode = this->getbNode(); + MovieClip *clip = (MovieClip *) editorNode->id; + + NodeTrackPosData *trackpos_data = (NodeTrackPosData *) editorNode->storage; + + TrackPositionOperation *operationX = new TrackPositionOperation(); + TrackPositionOperation *operationY = new TrackPositionOperation(); + + operationX->setMovieClip(clip); + operationX->setTrackingObject(trackpos_data->tracking_object); + operationX->setTrackName(trackpos_data->track_name); + operationX->setFramenumber(context->getFramenumber()); + operationX->setAxis(0); + operationX->setRelative(editorNode->custom1); + + operationY->setMovieClip(clip); + operationY->setTrackingObject(trackpos_data->tracking_object); + operationY->setTrackName(trackpos_data->track_name); + operationY->setFramenumber(context->getFramenumber()); + operationY->setAxis(1); + operationY->setRelative(editorNode->custom1); + + outputX->relinkConnections(operationX->getOutputSocket()); + outputY->relinkConnections(operationY->getOutputSocket()); + + graph->addOperation(operationX); +} diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.h b/source/blender/compositor/nodes/COM_TrackPositionNode.h new file mode 100644 index 00000000000..3d92ec3978c --- /dev/null +++ b/source/blender/compositor/nodes/COM_TrackPositionNode.h @@ -0,0 +1,36 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Sergey Sharybin + */ + +#include "COM_Node.h" +#include "DNA_node_types.h" + +/** + * @brief TrackPositionNode + * @ingroup Node + */ +class TrackPositionNode : public Node { +public: + TrackPositionNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); + +}; diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp index e688332a039..406a98f81e9 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp @@ -27,15 +27,15 @@ AlphaOverKeyOperation::AlphaOverKeyOperation() : MixBaseOperation() /* pass */ } -void AlphaOverKeyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void AlphaOverKeyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputOverColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler); if (inputOverColor[3] <= 0.0f) { copy_v4_v4(outputValue, inputColor1); diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h index 113ec245ee6..5f430efb98e 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h @@ -39,6 +39,6 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp index e56fb9151f2..b94486b5b4f 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp @@ -27,15 +27,15 @@ AlphaOverMixedOperation::AlphaOverMixedOperation() : MixBaseOperation() this->m_x = 0.0f; } -void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputOverColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler); if (inputOverColor[3] <= 0.0f) { copy_v4_v4(outputValue, inputColor1); diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h index 3c0b955e360..308f139884d 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h @@ -41,7 +41,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void setX(float x) { this->m_x = x; } }; diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp index b2c40a058ba..dad43f3b179 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp @@ -27,15 +27,15 @@ AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation() : MixBaseOperatio /* pass */ } -void AlphaOverPremultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void AlphaOverPremultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputOverColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler); /* Zero alpha values should still permit an add of RGB data */ if (inputOverColor[3] < 0.0f) { diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h index 7b7b9238794..37ddc6dcda5 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp index 46fa07893e8..27ba2ef51f6 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp @@ -42,7 +42,7 @@ void AntiAliasOperation::initExecution() NodeOperation::initMutex(); } -void AntiAliasOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void AntiAliasOperation::executePixel(float *color, int x, int y, void *data) { if (y < 0 || (unsigned int)y >= this->m_height || x < 0 || (unsigned int)x >= this->m_width) { color[0] = 0.0f; @@ -82,12 +82,12 @@ bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe return false; } -void *AntiAliasOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *AntiAliasOperation::initializeTileData(rcti *rect) { if (this->m_buffer) { return this->m_buffer; } lockMutex(); if (this->m_buffer == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)this->m_valueReader->initializeTileData(rect, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_valueReader->initializeTileData(rect); int size = tile->getHeight() * tile->getWidth(); float *input = tile->getBuffer(); char *valuebuffer = new char[size]; diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h index 3d9bcf6d90a..7489d2e393a 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.h +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h @@ -43,14 +43,14 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * Deinitialize the execution diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp index 4f7f5eea8a0..1db3ecb2db8 100644 --- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp @@ -46,7 +46,7 @@ void BilateralBlurOperation::initExecution() QualityStepHelper::initExecution(COM_QH_INCREASE); } -void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void BilateralBlurOperation::executePixel(float *color, int x, int y, void *data) { // read the determinator color at x, y, this will be used as the reference color for the determinator float determinatorReferenceColor[4]; @@ -61,20 +61,20 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int miny = floor(y - space); int maxy = ceil(y + space); float deltaColor; - this->m_inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data); + this->m_inputDeterminatorProgram->read(determinatorReferenceColor, x, y, data); zero_v4(blurColor); blurDivider = 0.0f; for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) { for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) { // read determinator - this->m_inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data); + this->m_inputDeterminatorProgram->read(determinator, xi, yi, data); deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) + fabsf(determinatorReferenceColor[1] - determinator[1]) + fabsf(determinatorReferenceColor[2] - determinator[2])); // do not take the alpha channel into account if (deltaColor < sigmacolor) { // add this to the blur - this->m_inputColorProgram->read(tempColor, xi, yi, inputBuffers, data); + this->m_inputColorProgram->read(tempColor, xi, yi, data); add_v4_v4(blurColor, tempColor); blurDivider += 1.0f; } diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.h b/source/blender/compositor/operations/COM_BilateralBlurOperation.h index be6ce7a221e..c1b5f764f01 100644 --- a/source/blender/compositor/operations/COM_BilateralBlurOperation.h +++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.h @@ -38,7 +38,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index 696c0748d69..98aeba41ecb 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -140,11 +140,11 @@ void BlurBaseOperation::deinitExecution() this->m_data = NULL; } -void BlurBaseOperation::updateSize(MemoryBuffer **memoryBuffers) +void BlurBaseOperation::updateSize() { if (!this->m_sizeavailable) { float result[4]; - this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers); + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST); this->m_size = result[0]; this->m_sizeavailable = true; } diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h index 6d60abf09bf..d8729ad4394 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.h +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h @@ -34,7 +34,7 @@ protected: float *make_gausstab(int rad); float *make_dist_fac_inverse(int rad, int falloff); - void updateSize(MemoryBuffer **memoryBuffers); + void updateSize(); /** * Cached reference to the inputProgram diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp index fb06f6d3761..ff9bfb73396 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp @@ -33,25 +33,32 @@ BokehBlurOperation::BokehBlurOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); this->setOpenCL(true); this->m_size = 1.0f; - + this->m_sizeavailable = false; this->m_inputProgram = NULL; this->m_inputBokehProgram = NULL; this->m_inputBoundingBoxReader = NULL; } -void *BokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *BokehBlurOperation::initializeTileData(rcti *rect) { - void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + lockMutex(); + if (!this->m_sizeavailable) { + updateSize(); + } + void *buffer = getInputOperation(0)->initializeTileData(NULL); + unlockMutex(); return buffer; } void BokehBlurOperation::initExecution() { + initMutex(); this->m_inputProgram = getInputSocketReader(0); this->m_inputBokehProgram = getInputSocketReader(1); this->m_inputBoundingBoxReader = getInputSocketReader(2); @@ -72,13 +79,13 @@ void BokehBlurOperation::initExecution() QualityStepHelper::initExecution(COM_QH_INCREASE); } -void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void BokehBlurOperation::executePixel(float *color, int x, int y, void *data) { float color_accum[4]; float tempBoundingBox[4]; float bokeh[4]; - this->m_inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST); if (tempBoundingBox[0] > 0.0f) { float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; @@ -87,7 +94,10 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; int pixelSize = this->m_size * this->getWidth() / 100.0f; - + if (pixelSize==0){ + this->m_inputProgram->read(color, x, y, COM_PS_NEAREST); + return; + } int miny = y - pixelSize; int maxy = y + pixelSize; int minx = x - pixelSize; @@ -108,7 +118,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * for (int nx = minx; nx < maxx; nx += step) { float u = this->m_bokehMidX - (nx - x) * m; float v = this->m_bokehMidY - (ny - y) * m; - this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); + this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST); madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]); add_v4_v4(multiplier_accum, bokeh); bufferindex += offsetadd; @@ -120,12 +130,13 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * color[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } else { - this->m_inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(color, x, y, COM_PS_NEAREST); } } void BokehBlurOperation::deinitExecution() { + deinitMutex(); this->m_inputProgram = NULL; this->m_inputBokehProgram = NULL; this->m_inputBoundingBoxReader = NULL; @@ -136,10 +147,17 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe rcti newInput; rcti bokehInput; - newInput.xmax = input->xmax + (this->m_size * this->getWidth() / 100.0f); - newInput.xmin = input->xmin - (this->m_size * this->getWidth() / 100.0f); - newInput.ymax = input->ymax + (this->m_size * this->getWidth() / 100.0f); - newInput.ymin = input->ymin - (this->m_size * this->getWidth() / 100.0f); + if (this->m_sizeavailable) { + newInput.xmax = input->xmax + (this->m_size * this->getWidth() / 100.0f); + newInput.xmin = input->xmin - (this->m_size * this->getWidth() / 100.0f); + newInput.ymax = input->ymax + (this->m_size * this->getWidth() / 100.0f); + newInput.ymin = input->ymin - (this->m_size * this->getWidth() / 100.0f); + } else { + newInput.xmax = input->xmax + (10.0f * this->getWidth() / 100.0f); + newInput.xmin = input->xmin - (10.0f * this->getWidth() / 100.0f); + newInput.ymax = input->ymax + (10.0f * this->getWidth() / 100.0f); + newInput.ymin = input->ymin - (10.0f * this->getWidth() / 100.0f); + } NodeOperation *operation = getInputOperation(1); bokehInput.xmax = operation->getWidth(); @@ -157,17 +175,28 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) { return true; } + if (!this->m_sizeavailable) { + rcti sizeInput; + sizeInput.xmin = 0; + sizeInput.ymin = 0; + sizeInput.xmax = 5; + sizeInput.ymax = 5; + operation = getInputOperation(3); + if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output) ) { + return true; + } + } return false; } -static cl_kernel kernel = 0; void BokehBlurOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { - if (!kernel) { - kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL); + cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL); + if (!this->m_sizeavailable) { + updateSize(); } cl_int radius = this->getWidth() * this->m_size / 100.0f; cl_int step = this->getStep(); @@ -183,3 +212,14 @@ void BokehBlurOperation::executeOpenCL(OpenCLDevice* device, device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this); } + +void BokehBlurOperation::updateSize() +{ + if (!this->m_sizeavailable) { + float result[4]; + this->getInputSocketReader(3)->read(result, 0, 0, COM_PS_NEAREST); + this->m_size = result[0]; + CLAMP(this->m_size, 0.0f, 10.0f); + this->m_sizeavailable = true; + } +} diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h index 0433a4156a8..eef5429c409 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h @@ -30,18 +30,20 @@ private: SocketReader *m_inputProgram; SocketReader *m_inputBokehProgram; SocketReader *m_inputBoundingBoxReader; + void updateSize(); float m_size; + bool m_sizeavailable; float m_bokehMidX; float m_bokehMidY; float m_bokehDimension; public: BokehBlurOperation(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution @@ -55,7 +57,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setSize(float size) { this->m_size = size; } + void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; } void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); }; diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp index 90e272438d6..d7de201e9df 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp @@ -87,7 +87,7 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y) } return insideBokeh; } -void BokehImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void BokehImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float shift = this->m_data->lensshift; float shift2 = shift / 2.0f; diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h index 085aaa471f0..a797d0fca53 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.h +++ b/source/blender/compositor/operations/COM_BokehImageOperation.h @@ -47,7 +47,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp index 96738a2920a..a0fb37f4310 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp @@ -44,7 +44,7 @@ void BoxMaskOperation::initExecution() this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight(); } -void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputMask[4]; float inputValue[4]; @@ -57,8 +57,8 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy); ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy); - this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); - this->m_inputValue->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputMask->read(inputMask, x, y, sampler); + this->m_inputValue->read(inputValue, x, y, sampler); float halfHeight = this->m_data->height / 2.0f; float halfWidth = this->m_data->width / 2.0f; diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h index cec680ef6c3..5a6745d9a9b 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.h +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp index 8c9fb6394a7..9a6a930c7c9 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp +++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp @@ -37,15 +37,15 @@ void BrightnessOperation::initExecution() this->m_inputContrastProgram = this->getInputSocketReader(2); } -void BrightnessOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void BrightnessOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputValue[4]; float a, b; float inputBrightness[4]; float inputContrast[4]; - this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); - this->m_inputBrightnessProgram->read(inputBrightness, x, y, sampler, inputBuffers); - this->m_inputContrastProgram->read(inputContrast, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler); + this->m_inputBrightnessProgram->read(inputBrightness, x, y, sampler); + this->m_inputContrastProgram->read(inputContrast, x, y, sampler); float brightness = inputBrightness[0]; float contrast = inputContrast[0]; brightness /= 100.0f; diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h index 61f667aa1be..2a6200ad9df 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.h +++ b/source/blender/compositor/operations/COM_BrightnessOperation.h @@ -40,7 +40,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp index a1c679b3e15..b0cfdb44736 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp @@ -42,7 +42,7 @@ void CalculateMeanOperation::initExecution() NodeOperation::initMutex(); } -void CalculateMeanOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void CalculateMeanOperation::executePixel(float *color, int x, int y, void *data) { color[0] = this->m_result; } @@ -70,11 +70,11 @@ bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti *input, ReadB return false; } -void *CalculateMeanOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *CalculateMeanOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_iscalculated) { - MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect); calculateMean(tile); this->m_iscalculated = true; } diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h index 2bd723c40a3..09727533306 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.h +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h @@ -46,14 +46,14 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * Deinitialize the execution diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp index 2d860df449c..de602ba1dd6 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp @@ -31,16 +31,16 @@ CalculateStandardDeviationOperation::CalculateStandardDeviationOperation() : Cal /* pass */ } -void CalculateStandardDeviationOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void CalculateStandardDeviationOperation::executePixel(float *color, int x, int y, void *data) { color[0] = this->m_standardDeviation; } -void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_iscalculated) { - MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect); CalculateMeanOperation::calculateMean(tile); this->m_standardDeviation = 0.0f; float *buffer = tile->getBuffer(); diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h index 506c5d6fe3a..311cedd7d32 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h @@ -39,9 +39,9 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); }; #endif diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp index 0812dd45bf6..7a6a22e5c05 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp @@ -39,11 +39,11 @@ void ChangeHSVOperation::deinitExecution() this->m_inputOperation = NULL; } -void ChangeHSVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ChangeHSVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; - this->m_inputOperation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor1, x, y, sampler); outputValue[0] = inputColor1[0] + (this->m_hue - 0.5f); if (outputValue[0] > 1.0f) outputValue[0] -= 1.0f; diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h index ee35fbe01d4..e5660e44f73 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h @@ -49,7 +49,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void setHue(float hue) { this->m_hue = hue; } void setSaturation(float saturation) { this->m_saturation = saturation; } diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp index b2de934e6d8..85f606fafdf 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp @@ -83,7 +83,7 @@ void ChannelMatteOperation::deinitExecution() this->m_inputImageProgram = NULL; } -void ChannelMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ChannelMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inColor[4]; float alpha; @@ -92,7 +92,7 @@ void ChannelMatteOperation::executePixel(float *outputValue, float x, float y, P const float limit_min = this->m_limit_min; const float limit_range = this->m_limit_range; - this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler); /* matte operation */ alpha = inColor[this->m_ids[0]] - max(inColor[this->m_ids[1]], inColor[this->m_ids[2]]); diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h index ee17036a78d..a02d0618a4c 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h @@ -59,7 +59,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp index e88feb6db9c..85a19d7c60f 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp @@ -44,7 +44,7 @@ void ChromaMatteOperation::deinitExecution() this->m_inputKeyProgram = NULL; } -void ChromaMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ChromaMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inKey[4]; float inImage[4]; @@ -57,8 +57,8 @@ void ChromaMatteOperation::executePixel(float *outputValue, float x, float y, Pi float theta, beta; float kfg; - this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); - this->m_inputImageProgram->read(inImage, x, y, sampler, inputBuffers); + this->m_inputKeyProgram->read(inKey, x, y, sampler); + this->m_inputImageProgram->read(inImage, x, y, sampler); /* store matte(alpha) value in [0] to go with * COM_SetAlphaOperation and the Value output diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h index eaca05e66ca..37b58fa45ed 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp index 66ce86234b7..33e6db22ef4 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp @@ -49,13 +49,13 @@ void ColorBalanceASCCDLOperation::initExecution() this->m_inputColorOperation = this->getInputSocketReader(1); } -void ColorBalanceASCCDLOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ColorBalanceASCCDLOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler) { float inputColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); - this->m_inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler); + this->m_inputColorOperation->read(inputColor, x, y, sampler); float fac = value[0]; fac = min(1.0f, fac); diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h index a9c0dff9ad4..d6361ea16ba 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h @@ -49,7 +49,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp index 13863a9ec5a..b0691925361 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp @@ -54,13 +54,13 @@ void ColorBalanceLGGOperation::initExecution() this->m_inputColorOperation = this->getInputSocketReader(1); } -void ColorBalanceLGGOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ColorBalanceLGGOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler) { float inputColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); - this->m_inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler); + this->m_inputColorOperation->read(inputColor, x, y, sampler); float fac = value[0]; fac = min(1.0f, fac); diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h index ffc78fae6f1..c3d44c53e53 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h @@ -50,7 +50,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp index 8008866752f..ebc818b0f7e 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp @@ -40,12 +40,12 @@ void ColorCorrectionOperation::initExecution() this->m_inputMask = this->getInputSocketReader(1); } -void ColorCorrectionOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ColorCorrectionOperation::executePixel(float *output, float x, float y, PixelSampler sampler) { float inputImageColor[4]; float inputMask[4]; - this->m_inputImage->read(inputImageColor, x, y, sampler, inputBuffers); - this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); + this->m_inputImage->read(inputImageColor, x, y, sampler); + this->m_inputMask->read(inputMask, x, y, sampler); float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f; float contrast = this->m_data->master.contrast; diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h index 8db3870709e..685413741fa 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index 9848d191c04..88bd673a19f 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -58,7 +58,7 @@ void ColorCurveOperation::initExecution() } -void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { CurveMapping *cumap = this->m_curveMapping; CurveMapping *workingCopy = (CurveMapping *)MEM_dupallocN(cumap); @@ -68,13 +68,13 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp float fac[4]; float image[4]; - this->m_inputBlackProgram->read(black, x, y, sampler, inputBuffers); - this->m_inputWhiteProgram->read(white, x, y, sampler, inputBuffers); + this->m_inputBlackProgram->read(black, x, y, sampler); + this->m_inputWhiteProgram->read(white, x, y, sampler); curvemapping_set_black_white(workingCopy, black, white); - this->m_inputFacProgram->read(fac, x, y, sampler, inputBuffers); - this->m_inputImageProgram->read(image, x, y, sampler, inputBuffers); + this->m_inputFacProgram->read(fac, x, y, sampler); + this->m_inputImageProgram->read(image, x, y, sampler); if (*fac >= 1.0f) curvemapping_evaluate_premulRGBF(workingCopy, color, image); @@ -126,14 +126,14 @@ void ConstantLevelColorCurveOperation::initExecution() curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white); } -void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float fac[4]; float image[4]; - this->m_inputFacProgram->read(fac, x, y, sampler, inputBuffers); - this->m_inputImageProgram->read(image, x, y, sampler, inputBuffers); + this->m_inputFacProgram->read(fac, x, y, sampler); + this->m_inputImageProgram->read(image, x, y, sampler); if (*fac >= 1.0f) curvemapping_evaluate_premulRGBF(this->m_curveMapping, color, image); diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h index 3bcbc31650c..beb2e16298a 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.h +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h @@ -41,7 +41,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution @@ -70,7 +70,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp index 4a01499b060..5326e397494 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp @@ -44,7 +44,7 @@ void ColorMatteOperation::deinitExecution() this->m_inputKeyProgram = NULL; } -void ColorMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ColorMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inColor[4]; float inKey[4]; @@ -55,8 +55,8 @@ void ColorMatteOperation::executePixel(float *outputValue, float x, float y, Pix float h_wrap; - this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); - this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler); + this->m_inputKeyProgram->read(inKey, x, y, sampler); /* store matte(alpha) value in [0] to go with diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h index d996ce34667..de7c4dd8ce2 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.h +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp index 95dca0dc410..edd7df89c81 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp @@ -43,11 +43,11 @@ void ColorRampOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void ColorRampOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ColorRampOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float values[4]; - this->m_inputProgram->read(values, x, y, sampler, inputBuffers); + this->m_inputProgram->read(values, x, y, sampler); do_colorband(this->m_colorBand, values[0], color); } diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h index 42bc6b943b7..c5f3fe449de 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.h +++ b/source/blender/compositor/operations/COM_ColorRampOperation.h @@ -38,7 +38,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp index e2773f3a6b4..2c0bfc10bb0 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp @@ -84,12 +84,12 @@ void ColorSpillOperation::deinitExecution() this->m_inputFacReader = NULL; } -void ColorSpillOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ColorSpillOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float fac[4]; float input[4]; - this->m_inputFacReader->read(fac, x, y, sampler, inputBuffers); - this->m_inputImageReader->read(input, x, y, sampler, inputBuffers); + this->m_inputFacReader->read(fac, x, y, sampler); + this->m_inputImageReader->read(input, x, y, sampler); float rfac = min(1.0f, fac[0]); float map = calculateMapValue(rfac, input); if (map > 0.0f) { diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h index 7aac612cb8c..ea443f2a5a1 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.h +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h @@ -46,7 +46,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp index 9f175a381a4..d05040c4c12 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp @@ -78,24 +78,24 @@ void CombineChannelsOperation::deinitExecution() } -void CombineChannelsOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void CombineChannelsOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float input[4]; /// @todo: remove if statements if (this->m_inputChannel1Operation) { - this->m_inputChannel1Operation->read(input, x, y, sampler, inputBuffers); + this->m_inputChannel1Operation->read(input, x, y, sampler); color[0] = input[0]; } if (this->m_inputChannel2Operation) { - this->m_inputChannel2Operation->read(input, x, y, sampler, inputBuffers); + this->m_inputChannel2Operation->read(input, x, y, sampler); color[1] = input[0]; } if (this->m_inputChannel3Operation) { - this->m_inputChannel3Operation->read(input, x, y, sampler, inputBuffers); + this->m_inputChannel3Operation->read(input, x, y, sampler); color[2] = input[0]; } if (this->m_inputChannel4Operation) { - this->m_inputChannel4Operation->read(input, x, y, sampler, inputBuffers); + this->m_inputChannel4Operation->read(input, x, y, sampler); color[3] = input[0]; } } diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.h b/source/blender/compositor/operations/COM_CombineChannelsOperation.h index 8e4c2120614..ff1251a3949 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.h +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.h @@ -33,7 +33,7 @@ private: SocketReader *m_inputChannel4Operation; public: CombineChannelsOperation(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 717b6ce76cc..43aad4f19d9 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -27,6 +27,7 @@ #include "BKE_image.h" extern "C" { + #include "BLI_threads.h" #include "RE_pipeline.h" #include "RE_shader_ext.h" #include "RE_render_ext.h" @@ -63,6 +64,7 @@ void CompositorOperation::deinitExecution() const RenderData *rd = this->m_rd; Render *re = RE_GetRender_FromData(rd); RenderResult *rr = RE_AcquireResultWrite(re); + if (rr) { if (rr->rectf != NULL) { MEM_freeN(rr->rectf); @@ -75,7 +77,9 @@ void CompositorOperation::deinitExecution() } } + BLI_lock_thread(LOCK_DRAW_IMAGE); BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE); + BLI_unlock_thread(LOCK_DRAW_IMAGE); if (re) { RE_ReleaseResult(re); @@ -94,7 +98,7 @@ void CompositorOperation::deinitExecution() } -void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float color[8]; // 7 is enough float *buffer = this->m_outputBuffer; @@ -111,9 +115,9 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2 && (!breaked); x++) { - this->m_imageInput->read(color, x, y, COM_PS_NEAREST, memoryBuffers); + this->m_imageInput->read(color, x, y, COM_PS_NEAREST); if (this->m_alphaInput != NULL) { - this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST); } copy_v4_v4(buffer + offset, color); offset += COM_NUMBER_OF_CHANNELS; diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h index 2719d376339..23d34abbfff 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -52,7 +52,7 @@ private: SocketReader *m_alphaInput; public: CompositorOperation(); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void setRenderData(const RenderData *rd) { this->m_rd = rd; } bool isOutputOperation(bool rendering) const { return true; } void initExecution(); diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp index 4d829eae7a0..c7272d461d6 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp @@ -38,10 +38,10 @@ void ConvertColorProfileOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertColorProfileOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertColorProfileOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float color[4]; - this->m_inputOperation->read(color, x, y, sampler, inputBuffers); + this->m_inputOperation->read(color, x, y, sampler); IMB_buffer_float_from_float(outputValue, color, 4, this->m_toProfile, this->m_fromProfile, this->m_predivided, 1, 1, 0, 0); } diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h index b237448d16e..09d96a92d95 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h @@ -59,7 +59,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp index a8c57449a2e..4da09a69a15 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp @@ -34,10 +34,10 @@ void ConvertColorToBWOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); + this->m_inputOperation->read(&inputColor[0], x, y, sampler); outputValue[0] = rgb_to_bw(inputColor); } diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h index 9c62ad8dd39..a9951af2e3b 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp b/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp index c09842b1aa9..17bd34d51b0 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp @@ -34,10 +34,10 @@ void ConvertColorToValueProg::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertColorToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertColorToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); + this->m_inputOperation->read(&inputColor[0], x, y, sampler); outputValue[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f; } diff --git a/source/blender/compositor/operations/COM_ConvertColorToValueProg.h b/source/blender/compositor/operations/COM_ConvertColorToValueProg.h index c1ac7ca69ce..6a20d4bf27a 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToValueProg.h +++ b/source/blender/compositor/operations/COM_ConvertColorToValueProg.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp index 6c79c4ea6a3..ec1f0fd37e4 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp @@ -34,9 +34,9 @@ void ConvertColorToVectorOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertColorToVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertColorToVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { - this->m_inputOperation->read(outputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(outputValue, x, y, sampler); } void ConvertColorToVectorOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h index 51fa3a677cd..861807db8db 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp index 91b68a90126..80416bbccdf 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp @@ -32,6 +32,7 @@ ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() : NodeOperation() this->m_fStop = 128.0f; this->m_cameraObject = NULL; this->m_maxRadius = 32.0f; + this->m_blurPostOperation = NULL; } float ConvertDepthToRadiusOperation::determineFocalDistance() @@ -68,14 +69,18 @@ void ConvertDepthToRadiusOperation::initExecution() this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * 32.0f)) / this->m_fStop; float minsz = MIN2(getWidth(), getHeight()); this->m_dof_sp = (float)minsz / (16.f / this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); + + if (this->m_blurPostOperation) { + m_blurPostOperation->setSigma(m_aperture*128.0f); + } } -void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue[4]; float z; float radius; - this->m_inputOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputValue, x, y, sampler); z = inputValue[0]; if (z != 0.f) { float iZ = (1.f / z); @@ -88,7 +93,7 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl #endif radius = 0.5f * fabsf(this->m_aperture * (this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.f)); // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem - if (radius < 0.5f) radius = 0.5f; + if (radius < 0.0f) radius = 0.0f; if (radius > this->m_maxRadius) { radius = this->m_maxRadius; } diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h index 415befea168..4f80ef69f43 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h @@ -24,7 +24,7 @@ #define _COM_ConvertDepthToRadiusOperation_h #include "COM_NodeOperation.h" #include "DNA_object_types.h" - +#include "COM_FastGaussianBlurOperation.h" /** * this program converts an input color to an output value. * it assumes we are in sRGB color space. @@ -43,6 +43,8 @@ private: float m_cam_lens; float m_dof_sp; Object *m_cameraObject; + + FastGaussianBlurValueOperation *m_blurPostOperation; public: /** * Default constructor @@ -52,7 +54,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution @@ -68,5 +70,7 @@ public: void setMaxRadius(float maxRadius) { this->m_maxRadius = maxRadius; } void setCameraObject(Object *camera) { this->m_cameraObject = camera; } float determineFocalDistance(); + void setPostBlur(FastGaussianBlurValueOperation *operation) {this->m_blurPostOperation = operation;} + }; #endif diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp index 5149e370208..4b42de26f59 100644 --- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp @@ -35,10 +35,10 @@ void ConvertHSVToRGBOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertHSVToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertHSVToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler); hsv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h index 3babbfb7c1d..28ce70170a0 100644 --- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp index b7db0a6a2c7..787b1a4547c 100644 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp @@ -35,12 +35,12 @@ void ConvertKeyToPremulOperation::initExecution() this->m_inputColor = getInputSocketReader(0); } -void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue[4]; float alpha; - this->m_inputColor->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor->read(inputValue, x, y, sampler); alpha = inputValue[3]; mul_v3_v3fl(outputValue, inputValue, alpha); diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h index 50b39928305..a1a8836a690 100644 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h +++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h @@ -40,7 +40,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp index 0ba23b2ec2e..22cfdd2f572 100644 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp @@ -35,12 +35,12 @@ void ConvertPremulToKeyOperation::initExecution() this->m_inputColor = getInputSocketReader(0); } -void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue[4]; float alpha; - this->m_inputColor->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor->read(inputValue, x, y, sampler); alpha = inputValue[3]; if (fabsf(alpha) < 1e-5f) { diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h index 173cbb4fc0a..fb83a06c25d 100644 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h +++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h @@ -40,7 +40,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp index dd5e9907642..8478eac75b0 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp @@ -35,10 +35,10 @@ void ConvertRGBToHSVOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertRGBToHSVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertRGBToHSVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler); rgb_to_hsv(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h index 42bd439c8c2..09f6c7e48a6 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp index 7f41a79b7f4..52aa1d7a123 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp @@ -50,12 +50,12 @@ void ConvertRGBToYCCOperation::setMode(int mode) } } -void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor[4]; float color[3]; - this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler); rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode); /* divided by 255 to normalize for viewing in */ diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h index 744e0657dc6..7f4eb6d7318 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h @@ -48,7 +48,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp index e87a765f2eb..2206a066a37 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp @@ -34,10 +34,10 @@ void ConvertRGBToYUVOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertRGBToYUVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertRGBToYUVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler); rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h index b470378704e..f7b3da800b3 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h @@ -43,7 +43,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp b/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp index 100a4931d69..330ffd00acb 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp @@ -33,10 +33,10 @@ void ConvertValueToColorProg::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void ConvertValueToColorProg::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertValueToColorProg::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputValue[4]; - this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler); color[0] = inputValue[0]; color[1] = inputValue[0]; color[2] = inputValue[0]; diff --git a/source/blender/compositor/operations/COM_ConvertValueToColorProg.h b/source/blender/compositor/operations/COM_ConvertValueToColorProg.h index d59964dd400..2fa5edcf09b 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColorProg.h +++ b/source/blender/compositor/operations/COM_ConvertValueToColorProg.h @@ -37,7 +37,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp index 37760fe26d7..54a5b0dbd0e 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp @@ -34,10 +34,10 @@ void ConvertValueToVectorOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertValueToVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertValueToVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float input[4]; - this->m_inputOperation->read(input, x, y, sampler, inputBuffers); + this->m_inputOperation->read(input, x, y, sampler); outputValue[0] = input[0]; outputValue[1] = input[0]; outputValue[2] = input[0]; diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h index 0e79c1ff3df..c0936a32eb5 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp index 395b96e8b25..9fb9a2e0705 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp @@ -34,9 +34,9 @@ void ConvertVectorToColorOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertVectorToColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertVectorToColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { - this->m_inputOperation->read(outputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(outputValue, x, y, sampler); outputValue[3] = 1.0f; } diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h index 8225d03d58e..a062c452a91 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp index 68842c5a055..23b552f1dbe 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp @@ -34,10 +34,10 @@ void ConvertVectorToValueOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertVectorToValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertVectorToValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float input[4]; - this->m_inputOperation->read(input, x, y, sampler, inputBuffers); + this->m_inputOperation->read(input, x, y, sampler); outputValue[0] = (input[0] + input[1] + input[2]) / 3.0f; } diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h index a7981e8dc59..b662f3eed6c 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp index 78b7a7af60d..88a7e7dedd9 100644 --- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp @@ -50,10 +50,10 @@ void ConvertYCCToRGBOperation::setMode(int mode) } } -void ConvertYCCToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertYCCToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler); /* need to un-normalize the data */ /* R,G,B --> Y,Cb,Cr */ diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h index e23dfd8a985..a8e03bcb807 100644 --- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h @@ -48,7 +48,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp index b4393c53b92..1a5e7cbf2a6 100644 --- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp @@ -34,10 +34,10 @@ void ConvertYUVToRGBOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertYUVToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertYUVToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler); yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h index 3368e0a24df..80321ae37d2 100644 --- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h @@ -43,7 +43,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp index cf3ffe6d8f4..90bda5c8d2c 100644 --- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp @@ -28,7 +28,7 @@ ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation() : ConvolutionFi /* pass */ } -void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, void *data) { float in1[4], in2[4], res1[4], res2[4]; @@ -46,7 +46,7 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, Me CLAMP(y3, 0, getHeight() - 1); float value[4]; - this->m_inputValueOperation->read(value, x2, y2, inputBuffers, NULL); + this->m_inputValueOperation->read(value, x2, y2, NULL); float mval = 1.0f - value[0]; res1[0] = 0.0f; @@ -58,39 +58,39 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, Me res2[2] = 0.0f; res2[3] = 0.0f; - this->m_inputOperation->read(in1, x1, y1, inputBuffers, NULL); + this->m_inputOperation->read(in1, x1, y1, NULL); madd_v3_v3fl(res1, in1, this->m_filter[0]); madd_v3_v3fl(res2, in1, this->m_filter[0]); - this->m_inputOperation->read(in1, x2, y1, inputBuffers, NULL); + this->m_inputOperation->read(in1, x2, y1, NULL); madd_v3_v3fl(res1, in1, this->m_filter[1]); madd_v3_v3fl(res2, in1, this->m_filter[3]); - this->m_inputOperation->read(in1, x3, y1, inputBuffers, NULL); + this->m_inputOperation->read(in1, x3, y1, NULL); madd_v3_v3fl(res1, in1, this->m_filter[2]); madd_v3_v3fl(res2, in1, this->m_filter[6]); - this->m_inputOperation->read(in1, x1, y2, inputBuffers, NULL); + this->m_inputOperation->read(in1, x1, y2, NULL); madd_v3_v3fl(res1, in1, this->m_filter[3]); madd_v3_v3fl(res2, in1, this->m_filter[1]); - this->m_inputOperation->read(in2, x2, y2, inputBuffers, NULL); + this->m_inputOperation->read(in2, x2, y2, NULL); madd_v3_v3fl(res1, in2, this->m_filter[4]); madd_v3_v3fl(res2, in2, this->m_filter[4]); - this->m_inputOperation->read(in1, x3, y2, inputBuffers, NULL); + this->m_inputOperation->read(in1, x3, y2, NULL); madd_v3_v3fl(res1, in1, this->m_filter[5]); madd_v3_v3fl(res2, in1, this->m_filter[7]); - this->m_inputOperation->read(in1, x1, y3, inputBuffers, NULL); + this->m_inputOperation->read(in1, x1, y3, NULL); madd_v3_v3fl(res1, in1, this->m_filter[6]); madd_v3_v3fl(res2, in1, this->m_filter[2]); - this->m_inputOperation->read(in1, x2, y3, inputBuffers, NULL); + this->m_inputOperation->read(in1, x2, y3, NULL); madd_v3_v3fl(res1, in1, this->m_filter[7]); madd_v3_v3fl(res2, in1, this->m_filter[5]); - this->m_inputOperation->read(in1, x3, y3, inputBuffers, NULL); + this->m_inputOperation->read(in1, x3, y3, NULL); madd_v3_v3fl(res1, in1, this->m_filter[8]); madd_v3_v3fl(res2, in1, this->m_filter[8]); diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h index 92e45c7104f..b96b8785524 100644 --- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h +++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h @@ -28,7 +28,7 @@ class ConvolutionEdgeFilterOperation : public ConvolutionFilterOperation { public: ConvolutionEdgeFilterOperation(); - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); }; #endif diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp index 3840e775fe3..6c1e434ab41 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp @@ -67,7 +67,7 @@ void ConvolutionFilterOperation::deinitExecution() } -void ConvolutionFilterOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void ConvolutionFilterOperation::executePixel(float *color, int x, int y, void *data) { float in1[4]; float in2[4]; @@ -84,27 +84,27 @@ void ConvolutionFilterOperation::executePixel(float *color, int x, int y, Memory CLAMP(y2, 0, getHeight() - 1); CLAMP(y3, 0, getHeight() - 1); float value[4]; - this->m_inputValueOperation->read(value, x2, y2, inputBuffers, NULL); + this->m_inputValueOperation->read(value, x2, y2, NULL); const float mval = 1.0f - value[0]; zero_v4(color); - this->m_inputOperation->read(in1, x1, y1, inputBuffers, NULL); + this->m_inputOperation->read(in1, x1, y1, NULL); madd_v4_v4fl(color, in1, this->m_filter[0]); - this->m_inputOperation->read(in1, x2, y1, inputBuffers, NULL); + this->m_inputOperation->read(in1, x2, y1, NULL); madd_v4_v4fl(color, in1, this->m_filter[1]); - this->m_inputOperation->read(in1, x3, y1, inputBuffers, NULL); + this->m_inputOperation->read(in1, x3, y1, NULL); madd_v4_v4fl(color, in1, this->m_filter[2]); - this->m_inputOperation->read(in1, x1, y2, inputBuffers, NULL); + this->m_inputOperation->read(in1, x1, y2, NULL); madd_v4_v4fl(color, in1, this->m_filter[3]); - this->m_inputOperation->read(in2, x2, y2, inputBuffers, NULL); + this->m_inputOperation->read(in2, x2, y2, NULL); madd_v4_v4fl(color, in2, this->m_filter[4]); - this->m_inputOperation->read(in1, x3, y2, inputBuffers, NULL); + this->m_inputOperation->read(in1, x3, y2, NULL); madd_v4_v4fl(color, in1, this->m_filter[5]); - this->m_inputOperation->read(in1, x1, y3, inputBuffers, NULL); + this->m_inputOperation->read(in1, x1, y3, NULL); madd_v4_v4fl(color, in1, this->m_filter[6]); - this->m_inputOperation->read(in1, x2, y3, inputBuffers, NULL); + this->m_inputOperation->read(in1, x2, y3, NULL); madd_v4_v4fl(color, in1, this->m_filter[7]); - this->m_inputOperation->read(in1, x3, y3, inputBuffers, NULL); + this->m_inputOperation->read(in1, x3, y3, NULL); madd_v4_v4fl(color, in1, this->m_filter[8]); color[0] = color[0] * value[0] + in2[0] * mval; diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h index 0b5dfb4d75a..88455730c0e 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h @@ -39,7 +39,7 @@ public: ConvolutionFilterOperation(); void set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp index 0a40f2370c8..efbc331e7d3 100644 --- a/source/blender/compositor/operations/COM_CropOperation.cpp +++ b/source/blender/compositor/operations/COM_CropOperation.cpp @@ -73,10 +73,10 @@ CropOperation::CropOperation() : CropBaseOperation() /* pass */ } -void CropOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void CropOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { if ((x < this->m_xmax && x >= this->m_xmin) && (y < this->m_ymax && y >= this->m_ymin)) { - this->m_inputOperation->read(color, x, y, sampler, inputBuffers); + this->m_inputOperation->read(color, x, y, sampler); } else { zero_v4(color); @@ -108,7 +108,7 @@ void CropImageOperation::determineResolution(unsigned int resolution[], unsigned resolution[1] = this->m_ymax - this->m_ymin; } -void CropImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void CropImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { - this->m_inputOperation->read(color, (x + this->m_xmin), (y + this->m_ymin), sampler, inputBuffers); + this->m_inputOperation->read(color, (x + this->m_xmin), (y + this->m_ymin), sampler); } diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h index 39dbb8aa873..78644536143 100644 --- a/source/blender/compositor/operations/COM_CropOperation.h +++ b/source/blender/compositor/operations/COM_CropOperation.h @@ -48,7 +48,7 @@ class CropOperation : public CropBaseOperation { private: public: CropOperation(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; class CropImageOperation : public CropBaseOperation { @@ -57,7 +57,7 @@ public: CropImageOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void determineResolution(unsigned int resolution[], unsigned int preferedResolution[]); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp index 3c4bdfe8e5b..ed3799fff5e 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp @@ -44,7 +44,7 @@ void DifferenceMatteOperation::deinitExecution() this->m_inputImage2Program = NULL; } -void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inColor1[4]; float inColor2[4]; @@ -54,8 +54,8 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y float difference; float alpha; - this->m_inputImage1Program->read(inColor1, x, y, sampler, inputBuffers); - this->m_inputImage2Program->read(inColor2, x, y, sampler, inputBuffers); + this->m_inputImage1Program->read(inColor1, x, y, sampler); + this->m_inputImage2Program->read(inColor2, x, y, sampler); difference = (fabsf(inColor2[0] - inColor1[0]) + fabsf(inColor2[1] - inColor1[1]) + diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h index c35550560e1..acec6ebf193 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h @@ -43,7 +43,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 338a3a0b59b..71be94bf2a7 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -54,13 +54,13 @@ void DilateErodeThresholdOperation::initExecution() } } -void *DilateErodeThresholdOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *DilateErodeThresholdOperation::initializeTileData(rcti *rect) { - void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL); return buffer; } -void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, void *data) { float inputValue[4]; const float sw = this->m__switch; @@ -80,7 +80,7 @@ void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, Mem const int bufferWidth = rect->xmax - rect->xmin; int offset; - this->m_inputProgram->read(inputValue, x, y, inputBuffers, NULL); + this->m_inputProgram->read(inputValue, x, y, NULL); if (inputValue[0] > sw) { for (int yi = miny; yi < maxy; yi++) { const float dy = yi - y; @@ -179,13 +179,13 @@ void DilateDistanceOperation::initExecution() } } -void *DilateDistanceOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *DilateDistanceOperation::initializeTileData(rcti *rect) { - void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL); return buffer; } -void DilateDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void DilateDistanceOperation::executePixel(float *color, int x, int y, void *data) { const float distance = this->m_distance; const float mindist = distance * distance; @@ -234,15 +234,13 @@ bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, Read return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } -static cl_kernel dilateKernel = 0; void DilateDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { - if (!dilateKernel) { - dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL); - } + cl_kernel dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL); + cl_int distanceSquared = this->m_distance * this->m_distance; cl_int scope = this->m_scope; @@ -261,7 +259,7 @@ ErodeDistanceOperation::ErodeDistanceOperation() : DilateDistanceOperation() /* pass */ } -void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void ErodeDistanceOperation::executePixel(float *color, int x, int y, void *data) { const float distance = this->m_distance; const float mindist = distance * distance; @@ -293,15 +291,13 @@ void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuff color[0] = value; } -static cl_kernel erodeKernel = 0; void ErodeDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { - if (!erodeKernel) { - erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL); - } + cl_kernel erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL); + cl_int distanceSquared = this->m_distance * this->m_distance; cl_int scope = this->m_scope; @@ -329,14 +325,14 @@ void DilateStepOperation::initExecution() this->initMutex(); } -void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *DilateStepOperation::initializeTileData(rcti *rect) { if (this->m_cached_buffer != NULL) { return this->m_cached_buffer; } lockMutex(); if (this->m_cached_buffer == NULL) { - MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL, memoryBuffers); + MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL); float *rectf = buffer->convertToValueBuffer(); int x, y, i; float *p; @@ -378,7 +374,7 @@ void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB } -void DilateStepOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void DilateStepOperation::executePixel(float *color, int x, int y, void *data) { color[0] = this->m_cached_buffer[y * this->getWidth() + x]; } @@ -416,14 +412,14 @@ ErodeStepOperation::ErodeStepOperation() : DilateStepOperation() /* pass */ } -void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *ErodeStepOperation::initializeTileData(rcti *rect) { if (this->m_cached_buffer != NULL) { return this->m_cached_buffer; } lockMutex(); if (this->m_cached_buffer == NULL) { - MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL, memoryBuffers); + MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL); float *rectf = buffer->convertToValueBuffer(); int x, y, i; float *p; diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h index bc6049bf992..8c3eefb97e4 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.h +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h @@ -47,14 +47,14 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * Deinitialize the execution */ @@ -83,14 +83,14 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * Deinitialize the execution */ @@ -111,7 +111,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, @@ -135,14 +135,14 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * Deinitialize the execution */ @@ -157,7 +157,7 @@ class ErodeStepOperation : public DilateStepOperation { public: ErodeStepOperation(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); }; #endif diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp index da7336afc07..5e6ff2c7da1 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp @@ -22,7 +22,7 @@ #include "COM_DirectionalBlurOperation.h" #include "BLI_math.h" - +#include "COM_OpenCLDevice.h" extern "C" { #include "RE_pipeline.h" } @@ -33,6 +33,7 @@ DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); + this->setOpenCL(true); this->m_inputProgram = NULL; } @@ -65,12 +66,12 @@ void DirectionalBlurOperation::initExecution() } -void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void DirectionalBlurOperation::executePixel(float *color, int x, int y, void *data) { const int iterations = pow(2.0f, this->m_data->iter); float col[4] = {0, 0, 0, 0}; float col2[4] = {0, 0, 0, 0}; - this->m_inputProgram->read(col2, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(col2, x, y, COM_PS_NEAREST); float ltx = this->m_tx; float lty = this->m_ty; float lsc = this->m_sc; @@ -86,7 +87,7 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu this->m_inputProgram->read(col, cs * u + ss * v + this->m_center_x_pix, cs * v - ss * u + this->m_center_y_pix, - COM_PS_NEAREST, inputBuffers); + COM_PS_NEAREST); add_v4_v4(col2, col); @@ -97,9 +98,35 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu lsc += this->m_sc; } - mul_v4_v4fl(color, col2, 1.0f / iterations); + mul_v4_v4fl(color, col2, 1.0f / (iterations+1)); } +void DirectionalBlurOperation::executeOpenCL(OpenCLDevice* device, + MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, + MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, + list<cl_kernel> *clKernelsToCleanUp) +{ + cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", NULL); + + cl_int iterations = pow(2.0f, this->m_data->iter); + cl_float2 ltxy = {this->m_tx, this->m_ty}; + cl_float2 centerpix = {this->m_center_x_pix, this->m_center_y_pix}; + cl_float lsc = this->m_sc; + cl_float lrot = this->m_rot; + + device->COM_clAttachMemoryBufferToKernelParameter(directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(directionalBlurKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(directionalBlurKernel, 2, outputMemoryBuffer); + clSetKernelArg(directionalBlurKernel, 3, sizeof(cl_int), &iterations); + clSetKernelArg(directionalBlurKernel, 4, sizeof(cl_float), &lsc); + clSetKernelArg(directionalBlurKernel, 5, sizeof(cl_float), &lrot); + clSetKernelArg(directionalBlurKernel, 6, sizeof(cl_float2), <xy); + clSetKernelArg(directionalBlurKernel, 7, sizeof(cl_float2), ¢erpix); + + device->COM_clEnqueueRange(directionalBlurKernel, outputMemoryBuffer, 8, this); +} + + void DirectionalBlurOperation::deinitExecution() { this->m_inputProgram = NULL; diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h index 329f855871e..cc49e947f95 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h @@ -40,7 +40,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution @@ -55,5 +55,11 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void setData(NodeDBlurData *data) { this->m_data = data; } + + void executeOpenCL(OpenCLDevice* device, + MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, + MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, + list<cl_kernel> *clKernelsToCleanUp); + }; #endif diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp index c7df53770c5..018df78cb65 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp @@ -54,7 +54,7 @@ void DisplaceOperation::initExecution() * in order to take effect */ #define DISPLACE_EPSILON 0.01f -void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void DisplaceOperation::executePixel(float *color, int x, int y, void *data) { float inVector[4]; float inScale[4]; @@ -64,9 +64,9 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i float dxt, dyt; float u, v; - this->m_inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST); float xs = inScale[0]; - this->m_inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST); float ys = inScale[0]; /* clamp x and y displacement to triple image resolution - @@ -74,7 +74,7 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i CLAMP(xs, -this->m_width_x4, this->m_width_x4); CLAMP(ys, -this->m_height_x4, this->m_height_x4); - this->m_inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST); p_dx = inVector[0] * xs; p_dy = inVector[1] * ys; @@ -83,10 +83,10 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i v = y - p_dy + 0.5f; /* calc derivatives */ - this->m_inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST, inputBuffers); + this->m_inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST); d_dx = inVector[0] * xs; - this->m_inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST, inputBuffers); - d_dy = inVector[0] * ys; + this->m_inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST); + d_dy = inVector[1] * ys; /* clamp derivatives to minimum displacement distance in UV space */ dxt = p_dx - d_dx; @@ -96,7 +96,7 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i dyt = signf(dyt) * maxf(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight(); /* EWA filtering */ - this->m_inputColorProgram->read(color, u, v, dxt, dyt, inputBuffers); + this->m_inputColorProgram->read(color, u, v, dxt, dyt); } void DisplaceOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.h b/source/blender/compositor/operations/COM_DisplaceOperation.h index e01c9190396..0e5b042aea5 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.h +++ b/source/blender/compositor/operations/COM_DisplaceOperation.h @@ -48,7 +48,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp index d21fc62abd7..a93e39085c5 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp @@ -53,7 +53,7 @@ void DisplaceSimpleOperation::initExecution() * in order to take effect */ #define DISPLACE_EPSILON 0.01f -void DisplaceSimpleOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void DisplaceSimpleOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inVector[4]; float inScale[4]; @@ -61,9 +61,9 @@ void DisplaceSimpleOperation::executePixel(float *color, float x, float y, Pixel float p_dx, p_dy; /* main displacement in pixel space */ float u, v; - this->m_inputScaleXProgram->read(inScale, x, y, sampler, inputBuffers); + this->m_inputScaleXProgram->read(inScale, x, y, sampler); float xs = inScale[0]; - this->m_inputScaleYProgram->read(inScale, x, y, sampler, inputBuffers); + this->m_inputScaleYProgram->read(inScale, x, y, sampler); float ys = inScale[0]; /* clamp x and y displacement to triple image resolution - @@ -71,7 +71,7 @@ void DisplaceSimpleOperation::executePixel(float *color, float x, float y, Pixel CLAMP(xs, -this->m_width_x4, this->m_width_x4); CLAMP(ys, -this->m_height_x4, this->m_height_x4); - this->m_inputVectorProgram->read(inVector, x, y, sampler, inputBuffers); + this->m_inputVectorProgram->read(inVector, x, y, sampler); p_dx = inVector[0] * xs; p_dy = inVector[1] * ys; @@ -82,7 +82,7 @@ void DisplaceSimpleOperation::executePixel(float *color, float x, float y, Pixel CLAMP(u, 0.f, this->getWidth() - 1.f); CLAMP(v, 0.f, this->getHeight() - 1.f); - this->m_inputColorProgram->read(color, u, v, sampler, inputBuffers); + this->m_inputColorProgram->read(color, u, v, sampler); } void DisplaceSimpleOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h index 25afbafe335..81adc7be366 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h @@ -48,7 +48,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp index 5bdc616fed7..197e8b07918 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp @@ -44,7 +44,7 @@ void DistanceMatteOperation::deinitExecution() this->m_inputKeyProgram = NULL; } -void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inKey[4]; float inImage[4]; @@ -55,8 +55,8 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, float distance; float alpha; - this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); - this->m_inputImageProgram->read(inImage, x, y, sampler, inputBuffers); + this->m_inputKeyProgram->read(inKey, x, y, sampler); + this->m_inputImageProgram->read(inImage, x, y, sampler); distance = sqrt(pow((inKey[0] - inImage[0]), 2) + pow((inKey[1] - inImage[1]), 2) + diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.h b/source/blender/compositor/operations/COM_DistanceMatteOperation.h index 267aa1fca7a..6fe16c7fdff 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp index 53ab5f97518..559d97d6056 100644 --- a/source/blender/compositor/operations/COM_DotproductOperation.cpp +++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp @@ -45,11 +45,11 @@ void DotproductOperation::deinitExecution() /** @todo: current implementation is the inverse of a dotproduct. not 'logically' correct */ -void DotproductOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void DotproductOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float input1[4]; float input2[4]; - this->m_input1Operation->read(input1, x, y, sampler, inputBuffers); - this->m_input2Operation->read(input2, x, y, sampler, inputBuffers); + this->m_input1Operation->read(input1, x, y, sampler); + this->m_input2Operation->read(input2, x, y, sampler); color[0] = -(input1[0] * input2[0] + input1[1] * input2[1] + input1[2] * input2[2]); } diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h index 7ca540983d9..6ff6f622a50 100644 --- a/source/blender/compositor/operations/COM_DotproductOperation.h +++ b/source/blender/compositor/operations/COM_DotproductOperation.h @@ -31,7 +31,7 @@ private: SocketReader *m_input2Operation; public: DotproductOperation(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index e5a145bab2e..bcad974da70 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -1260,15 +1260,15 @@ void DoubleEdgeMaskOperation::initExecution() this->m_cachedInstance = NULL; } -void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect) { if (this->m_cachedInstance) return this->m_cachedInstance; lockMutex(); if (this->m_cachedInstance == NULL) { - MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect, memoryBuffers); - MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect, memoryBuffers); + MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect); + MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect); float *data = new float[this->getWidth() * this->getHeight()]; float *imask = innerMask->convertToValueBuffer(); float *omask = outerMask->convertToValueBuffer(); @@ -1280,7 +1280,7 @@ void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect, MemoryBuffer **mem unlockMutex(); return this->m_cachedInstance; } -void DoubleEdgeMaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void DoubleEdgeMaskOperation::executePixel(float *color, int x, int y, void *data) { float *buffer = (float *) data; int index = (y * this->getWidth() + x); diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h index 442680e320e..32e5a07cfdc 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution @@ -54,7 +54,7 @@ public: */ void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp index 1aa1b89ee76..c3cbaaaf2fc 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp @@ -44,7 +44,7 @@ void EllipseMaskOperation::initExecution() this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight(); } -void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputMask[4]; float inputValue[4]; @@ -57,8 +57,8 @@ void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSam rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy); ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy); - this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); - this->m_inputValue->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputMask->read(inputMask, x, y, sampler); + this->m_inputValue->read(inputValue, x, y, sampler); const float halfHeight = (this->m_data->height) / 2.0f; const float halfWidth = this->m_data->width / 2.0f; diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h index 0b0ffa023cb..fce3c93bba6 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 8f0ebd9b8d2..7ef363f5c4a 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -31,7 +31,7 @@ FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_D this->m_iirgaus = NULL; } -void FastGaussianBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void FastGaussianBlurOperation::executePixel(float *color, int x, int y, void *data) { MemoryBuffer *newData = (MemoryBuffer *)data; newData->read(color, x, y); @@ -79,13 +79,13 @@ void FastGaussianBlurOperation::deinitExecution() BlurBaseOperation::deinitMutex(); } -void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *FastGaussianBlurOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_iirgaus) { - MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect, memoryBuffers); + MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect); MemoryBuffer *copy = newBuf->duplicate(); - updateSize(memoryBuffers); + updateSize(); int c; this->m_sx = this->m_data->sizex * this->m_size / 2.0f; @@ -220,3 +220,66 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign #undef YVV } + + +/// +FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_VALUE); + this->addOutputSocket(COM_DT_VALUE); + this->m_iirgaus = NULL; + this->m_inputprogram = NULL; + this->m_sigma = 1.0f; + setComplex(true); +} + +void FastGaussianBlurValueOperation::executePixel(float *color, int x, int y, void *data) +{ + MemoryBuffer *newData = (MemoryBuffer *)data; + newData->read(color, x, y); +} + +bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newInput; + + if (this->m_iirgaus) { + return false; + } + else { + newInput.xmin = 0; + newInput.ymin = 0; + newInput.xmax = this->getWidth(); + newInput.ymax = this->getHeight(); + } + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); +} + +void FastGaussianBlurValueOperation::initExecution() +{ + this->m_inputprogram = getInputSocketReader(0); + initMutex(); +} + +void FastGaussianBlurValueOperation::deinitExecution() +{ + if (this->m_iirgaus) { + delete this->m_iirgaus; + this->m_iirgaus = NULL; + } + deinitMutex(); +} + +void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect) +{ + lockMutex(); + if (!this->m_iirgaus) { + MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect); + MemoryBuffer *copy = newBuf->duplicate(); + FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3); + this->m_iirgaus = copy; + } + unlockMutex(); + return this->m_iirgaus; +} + diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h index 1e303b23869..4560e1b25e3 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h @@ -34,13 +34,29 @@ private: public: FastGaussianBlurOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); static void IIR_gauss(MemoryBuffer *src, float sigma, unsigned int channel, unsigned int xy); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); void deinitExecution(); void initExecution(); +}; + +class FastGaussianBlurValueOperation : public NodeOperation { +private: + float m_sigma; + MemoryBuffer *m_iirgaus; + SocketReader *m_inputprogram; +public: + FastGaussianBlurValueOperation(); + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void executePixel(float *color, int x, int y, void *data); + void *initializeTileData(rcti *rect); + void deinitExecution(); + void initExecution(); + void setSigma(float sigma) { this->m_sigma = sigma; } }; + #endif diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp index 60dabb86bb5..939d05fffbf 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.cpp +++ b/source/blender/compositor/operations/COM_FlipOperation.cpp @@ -42,12 +42,12 @@ void FlipOperation::deinitExecution() } -void FlipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void FlipOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float nx = this->m_flipX ? this->getWidth() - 1 - x : x; float ny = this->m_flipY ? this->getHeight() - 1 - y : y; - this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); + this->m_inputOperation->read(color, nx, ny, sampler); } bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h index 5442774c94c..a13f7ecf752 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.h +++ b/source/blender/compositor/operations/COM_FlipOperation.h @@ -33,7 +33,7 @@ private: public: FlipOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp index db8d54a2f3c..a4cc03ac380 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp @@ -34,10 +34,10 @@ void GammaCorrectOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void GammaCorrectOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void GammaCorrectOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputColor, x, y, sampler); if (inputColor[3] > 0.0f) { inputColor[0] /= inputColor[3]; inputColor[1] /= inputColor[3]; @@ -75,10 +75,10 @@ void GammaUncorrectOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void GammaUncorrectOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void GammaUncorrectOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputColor, x, y, sampler); if (inputColor[3] > 0.0f) { inputColor[0] /= inputColor[3]; diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h index 4db911bb9b5..2d4f2ea89d9 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h @@ -38,7 +38,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution @@ -64,7 +64,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp index 9ccc76f4392..40c2ee0a1d4 100644 --- a/source/blender/compositor/operations/COM_GammaOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaOperation.cpp @@ -37,13 +37,13 @@ void GammaOperation::initExecution() this->m_inputGammaProgram = this->getInputSocketReader(1); } -void GammaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void GammaOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputValue[4]; float inputGamma[4]; - this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); - this->m_inputGammaProgram->read(inputGamma, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler); + this->m_inputGammaProgram->read(inputGamma, x, y, sampler); const float gamma = inputGamma[0]; /* check for negative to avoid nan's */ color[0] = inputValue[0] > 0.0f ? powf(inputValue[0], gamma) : inputValue[0]; diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h index 758f7bda04d..8fc2599cba9 100644 --- a/source/blender/compositor/operations/COM_GammaOperation.h +++ b/source/blender/compositor/operations/COM_GammaOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp index a138d4be1d9..9865c87cb07 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp @@ -34,13 +34,13 @@ GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(C this->m_rad = 0; } -void *GaussianAlphaXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *GaussianAlphaXBlurOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_sizeavailable) { - updateGauss(memoryBuffers); + updateGauss(); } - void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + void *buffer = getInputOperation(0)->initializeTileData(NULL); unlockMutex(); return buffer; } @@ -62,10 +62,10 @@ void GaussianAlphaXBlurOperation::initExecution() } } -void GaussianAlphaXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +void GaussianAlphaXBlurOperation::updateGauss() { if (this->m_gausstab == NULL) { - updateSize(memoryBuffers); + updateSize(); float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; @@ -75,7 +75,7 @@ void GaussianAlphaXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) } if (this->m_distbuf_inv == NULL) { - updateSize(memoryBuffers); + updateSize(); float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; @@ -90,7 +90,7 @@ BLI_INLINE float finv_test(const float f, const bool test) return (LIKELY(test == false)) ? f : 1.0f - f; } -void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, void *data) { const bool do_invert = this->m_do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h index 59797c27952..6ea8b7e4371 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h @@ -33,14 +33,14 @@ private: int m_falloff; /* falloff for distbuf_inv */ bool m_do_subtract; int m_rad; - void updateGauss(MemoryBuffer **memoryBuffers); + void updateGauss(); public: GaussianAlphaXBlurOperation(); /** * @brief the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * @brief initialize the execution @@ -52,7 +52,7 @@ public: */ void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); /** diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp index ab5f8d33850..323a381c869 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp @@ -34,13 +34,13 @@ GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(C this->m_rad = 0; } -void *GaussianAlphaYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *GaussianAlphaYBlurOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_sizeavailable) { - updateGauss(memoryBuffers); + updateGauss(); } - void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + void *buffer = getInputOperation(0)->initializeTileData(NULL); unlockMutex(); return buffer; } @@ -62,10 +62,10 @@ void GaussianAlphaYBlurOperation::initExecution() } } -void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +void GaussianAlphaYBlurOperation::updateGauss() { if (this->m_gausstab == NULL) { - updateSize(memoryBuffers); + updateSize(); float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; @@ -75,7 +75,7 @@ void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) } if (this->m_distbuf_inv == NULL) { - updateSize(memoryBuffers); + updateSize(); float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; @@ -90,7 +90,7 @@ BLI_INLINE float finv_test(const float f, const bool test) return (LIKELY(test == false)) ? f : 1.0f - f; } -void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, void *data) { const bool do_invert = this->m_do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h index e0789db7815..050b0c384cb 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h @@ -33,14 +33,14 @@ private: bool m_do_subtract; int m_falloff; int m_rad; - void updateGauss(MemoryBuffer **memoryBuffers); + void updateGauss(); public: GaussianAlphaYBlurOperation(); /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * @brief initialize the execution @@ -52,7 +52,7 @@ public: */ void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); /** diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index ac91d3336e2..93cc39849a2 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -32,13 +32,13 @@ GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM this->m_gausstab = NULL; } -void *GaussianBokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *GaussianBokehBlurOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_sizeavailable) { - updateGauss(memoryBuffers); + updateGauss(); } - void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + void *buffer = getInputOperation(0)->initializeTileData(NULL); unlockMutex(); return buffer; } @@ -50,11 +50,11 @@ void GaussianBokehBlurOperation::initExecution() initMutex(); if (this->m_sizeavailable) { - updateGauss(NULL); + updateGauss(); } } -void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +void GaussianBokehBlurOperation::updateGauss() { if (this->m_gausstab == NULL) { float radxf; @@ -67,7 +67,7 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) const float width = this->getWidth(); const float height = this->getHeight(); if (!this->m_sizeavailable) { - updateSize(memoryBuffers); + updateSize(); } radxf = this->m_size * (float)this->m_data->sizex; if (radxf > width / 2.0f) @@ -112,7 +112,7 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) } } -void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, void *data) { float tempColor[4]; tempColor[0] = 0; @@ -138,8 +138,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory int index; int step = QualityStepHelper::getStep(); int offsetadd = QualityStepHelper::getOffsetAdd(); + const int addConst = (minx - x + this->m_radx); + const int mulConst = (this->m_radx * 2 + 1); for (int ny = miny; ny < maxy; ny += step) { - index = ((ny - y) + this->m_rady) * (this->m_radx * 2 + 1) + (minx - x + this->m_radx); + index = ((ny - y) + this->m_rady) * mulConst + addConst; int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { const float multiplier = this->m_gausstab[index]; @@ -194,3 +196,156 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, R return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } } + +// reference image +GaussianBokehBlurReferenceOperation::GaussianBokehBlurReferenceOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); + this->addOutputSocket(COM_DT_COLOR); + this->setComplex(true); + this->m_gausstab = NULL; + this->m_inputImage = NULL; + this->m_inputSize = NULL; +} + +void *GaussianBokehBlurReferenceOperation::initializeTileData(rcti *rect) +{ + void *buffer = getInputOperation(0)->initializeTileData(NULL); + return buffer; +} + +void GaussianBokehBlurReferenceOperation::initExecution() +{ + // setup gaustab + this->m_data->image_in_width = this->getWidth(); + this->m_data->image_in_height = this->getHeight(); + if (this->m_data->relative) { + switch (this->m_data->aspect) { + case CMP_NODE_BLUR_ASPECT_NONE: + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height); + break; + case CMP_NODE_BLUR_ASPECT_Y: + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_width); + break; + case CMP_NODE_BLUR_ASPECT_X: + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_height); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height); + break; + } + } + + updateGauss(); + this->m_inputImage = this->getInputSocketReader(0); + this->m_inputSize = this->getInputSocketReader(1); +} + +void GaussianBokehBlurReferenceOperation::updateGauss() +{ + int n; + float *dgauss; + float *ddgauss; + int j, i; + + n = (2 * radx + 1) * (2 * rady + 1); + + /* create a full filter image */ + ddgauss = new float[n]; + dgauss = ddgauss; + for (j = -rady; j <= rady; j++) { + for (i = -radx; i <= radx; i++, dgauss++) { + float fj = (float)j / radyf; + float fi = (float)i / radxf; + float dist = sqrt(fj * fj + fi * fi); + *dgauss = RE_filter_value(this->m_data->filtertype, dist); + } + } + this->m_gausstab = ddgauss; +} + +void GaussianBokehBlurReferenceOperation::executePixel(float *color, int x, int y, void *data) +{ + float tempColor[4]; + float tempSize[4]; + tempColor[0] = 0; + tempColor[1] = 0; + tempColor[2] = 0; + tempColor[3] = 0; + float multiplier_accum = 0; + MemoryBuffer *inputBuffer = (MemoryBuffer *)data; + float *buffer = inputBuffer->getBuffer(); + int bufferwidth = inputBuffer->getWidth(); + int bufferstartx = inputBuffer->getRect()->xmin; + int bufferstarty = inputBuffer->getRect()->ymin; + this->m_inputSize->read(tempSize, x, y, data); + float size = tempSize[0]; + CLAMP(size, 0.0f, 1.0f); + float sizeX = ceil(this->m_data->sizex * size); + float sizeY = ceil(this->m_data->sizey * size); + + if (sizeX <= 0.5f && sizeY <= 0.5f) { + this->m_inputImage->read(color, x, y, data); + return; + } + + int miny = y - sizeY; + int maxy = y + sizeY; + int minx = x - sizeX; + int maxx = x + sizeX; + miny = max(miny, inputBuffer->getRect()->ymin); + minx = max(minx, inputBuffer->getRect()->xmin); + maxy = min(maxy, inputBuffer->getRect()->ymax); + maxx = min(maxx, inputBuffer->getRect()->xmax); + + int step = QualityStepHelper::getStep(); + int offsetadd = QualityStepHelper::getOffsetAdd(); + for (int ny = miny; ny < maxy; ny += step) { + int u = ny - y; + float uf = ((u/sizeY)*radyf)+radyf; + int indexu = uf * (radx*2+1); + int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); + for (int nx = minx; nx < maxx; nx += step) { + int v = nx - x; + float vf = ((v/sizeX)*radxf)+radxf; + int index = indexu + vf; + const float multiplier = this->m_gausstab[index]; + madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier); + multiplier_accum += multiplier; + index += step; + bufferindex += offsetadd; + } + } + + mul_v4_v4fl(color, tempColor, 1.0f / multiplier_accum); +} + +void GaussianBokehBlurReferenceOperation::deinitExecution() +{ + delete [] this->m_gausstab; + this->m_gausstab = NULL; + this->m_inputImage = NULL; + this->m_inputSize = NULL; + +} + +bool GaussianBokehBlurReferenceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newInput; + NodeOperation *operation = this->getInputOperation(1); + + if (operation->determineDependingAreaOfInterest(input, readOperation, output)) { + return true; + } + else { + int addx = this->m_data->sizex+2; + int addy = this->m_data->sizey+2; + newInput.xmax = input->xmax + addx; + newInput.xmin = input->xmin - addx; + newInput.ymax = input->ymax + addy; + newInput.ymin = input->ymin - addy; + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + } +} + diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h index 54dc8caed53..1a134c20e63 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h @@ -30,16 +30,16 @@ class GaussianBokehBlurOperation : public BlurBaseOperation { private: float *m_gausstab; int m_radx, m_rady; - void updateGauss(MemoryBuffer **memoryBuffers); + void updateGauss(); public: GaussianBokehBlurOperation(); void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Deinitialize the execution @@ -48,4 +48,38 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; + +class GaussianBokehBlurReferenceOperation : public NodeOperation, public QualityStepHelper { +private: + SocketReader * m_inputImage; + SocketReader * m_inputSize; + float *m_gausstab; + NodeBlurData *m_data; + + void updateGauss(); + + static const int radxf = 256.0f; + static const int radyf = 256.0f; + static const int radx = 256; + static const int rady = 256; + +public: + GaussianBokehBlurReferenceOperation(); + void initExecution(); + void *initializeTileData(rcti *rect); + /** + * the inner loop of this program + */ + void executePixel(float *color, int x, int y, void *data); + + /** + * Deinitialize the execution + */ + void deinitExecution(); + + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + + void setData(NodeBlurData *data) { this->m_data = data; } +}; + #endif diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index d18dd17528d..1cf675a769a 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp @@ -33,13 +33,13 @@ GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLO this->m_rad = 0; } -void *GaussianXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *GaussianXBlurOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_sizeavailable) { - updateGauss(memoryBuffers); + updateGauss(); } - void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + void *buffer = getInputOperation(0)->initializeTileData(NULL); unlockMutex(); return buffer; } @@ -60,10 +60,10 @@ void GaussianXBlurOperation::initExecution() } } -void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +void GaussianXBlurOperation::updateGauss() { if (this->m_gausstab == NULL) { - updateSize(memoryBuffers); + updateSize(); float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; @@ -73,7 +73,7 @@ void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) } } -void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void GaussianXBlurOperation::executePixel(float *color, int x, int y, void *data) { float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float multiplier_accum = 0.0f; @@ -92,12 +92,10 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); - int index; int step = getStep(); int offsetadd = getOffsetAdd(); int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth); - for (int nx = minx; nx < maxx; nx += step) { - index = (nx - x) + this->m_rad; + for (int nx = minx, index = (minx - x) + this->m_rad; nx < maxx; nx += step, index += step) { const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; @@ -118,17 +116,19 @@ void GaussianXBlurOperation::deinitExecution() bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - rcti sizeInput; - sizeInput.xmin = 0; - sizeInput.ymin = 0; - sizeInput.xmax = 5; - sizeInput.ymax = 5; - NodeOperation *operation = this->getInputOperation(1); - if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { - return true; + if (!this->m_sizeavailable) { + rcti sizeInput; + sizeInput.xmin = 0; + sizeInput.ymin = 0; + sizeInput.xmax = 5; + sizeInput.ymax = 5; + NodeOperation *operation = this->getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { + return true; + } } - else { + { if (this->m_sizeavailable && this->m_gausstab != NULL) { newInput.xmax = input->xmax + this->m_rad; newInput.xmin = input->xmin - this->m_rad; diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h index 9b5c2131b74..a4a0dc655e2 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h @@ -29,14 +29,14 @@ class GaussianXBlurOperation : public BlurBaseOperation { private: float *m_gausstab; int m_rad; - void updateGauss(MemoryBuffer **memoryBuffers); + void updateGauss(); public: GaussianXBlurOperation(); /** * @brief the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * @brief initialize the execution @@ -48,7 +48,7 @@ public: */ void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; #endif diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index d2d30da8ddf..135dcf60872 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -33,13 +33,13 @@ GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(COM_DT_COLO this->m_rad = 0; } -void *GaussianYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *GaussianYBlurOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_sizeavailable) { - updateGauss(memoryBuffers); + updateGauss(); } - void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + void *buffer = getInputOperation(0)->initializeTileData(NULL); unlockMutex(); return buffer; } @@ -60,10 +60,10 @@ void GaussianYBlurOperation::initExecution() } } -void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +void GaussianYBlurOperation::updateGauss() { if (this->m_gausstab == NULL) { - updateSize(memoryBuffers); + updateSize(); float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; @@ -73,7 +73,7 @@ void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) } } -void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void GaussianYBlurOperation::executePixel(float *color, int x, int y, void *data) { float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float multiplier_accum = 0.0f; @@ -94,9 +94,10 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int index; int step = getStep(); + const int bufferIndexx = ((minx - bufferstartx) * 4) ; for (int ny = miny; ny < maxy; ny += step) { index = (ny - y) + this->m_rad; - int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); + int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth); const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; @@ -116,17 +117,19 @@ void GaussianYBlurOperation::deinitExecution() bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - rcti sizeInput; - sizeInput.xmin = 0; - sizeInput.ymin = 0; - sizeInput.xmax = 5; - sizeInput.ymax = 5; - NodeOperation *operation = this->getInputOperation(1); - if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { - return true; + if (!m_sizeavailable) { + rcti sizeInput; + sizeInput.xmin = 0; + sizeInput.ymin = 0; + sizeInput.xmax = 5; + sizeInput.ymax = 5; + NodeOperation *operation = this->getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { + return true; + } } - else { + { if (this->m_sizeavailable && this->m_gausstab != NULL) { newInput.xmax = input->xmax; newInput.xmin = input->xmin; diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h index f4d40c231dc..e3e0d8891d3 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h @@ -29,14 +29,14 @@ class GaussianYBlurOperation : public BlurBaseOperation { private: float *m_gausstab; int m_rad; - void updateGauss(MemoryBuffer **memoryBuffers); + void updateGauss(); public: GaussianYBlurOperation(); /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * @brief initialize the execution @@ -48,7 +48,7 @@ public: */ void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; #endif diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp index a6678fdecef..8bfc3e436df 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp @@ -41,9 +41,9 @@ void GlareBaseOperation::deinitExecution() SingleThreadedNodeOperation::deinitExecution(); } -MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2, MemoryBuffer **memoryBuffers) +MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2) { - MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect2, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect2); rcti rect; rect.xmin = 0; rect.ymin = 0; diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h index 6104ec7a81e..f6a8f6879da 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.h +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h @@ -68,7 +68,7 @@ protected: virtual void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) = 0; - MemoryBuffer *createMemoryBuffer(rcti *rect, MemoryBuffer **memoryBuffers); + MemoryBuffer *createMemoryBuffer(rcti *rect); }; #endif diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp index cb4c27a4c80..5452e779968 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp @@ -379,7 +379,7 @@ void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile, // temp. src image // make the convolution kernel rcti kernelRect; - BLI_init_rcti(&kernelRect, 0, sz, 0, sz); + BLI_rcti_init(&kernelRect, 0, sz, 0, sz); ckrn = new MemoryBuffer(NULL, &kernelRect); scale = 0.25f * sqrtf((float)(sz * sz)); diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp index 6d8c567c1b5..7f32618d2af 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp @@ -42,11 +42,11 @@ void GlareThresholdOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void GlareThresholdOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void GlareThresholdOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { const float threshold = this->m_settings->threshold; - this->m_inputProgram->read(color, x, y, sampler, inputBuffers); + this->m_inputProgram->read(color, x, y, sampler); if (rgb_to_luma_y(color) >= threshold) { color[0] -= threshold, color[1] -= threshold, color[2] -= threshold; color[0] = MAX2(color[0], 0.0f); diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h index d89f3a0f29d..faba6c6c47c 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp index 02914487072..df3d00278c3 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp @@ -45,11 +45,11 @@ void HueSaturationValueCorrectOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void HueSaturationValueCorrectOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void HueSaturationValueCorrectOperation::executePixel(float *output, float x, float y, PixelSampler sampler) { float hsv[4], f; - this->m_inputProgram->read(hsv, x, y, sampler, inputBuffers); + this->m_inputProgram->read(hsv, x, y, sampler); /* adjust hue, scaling returned default 0.5 up to 1 */ f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]); diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h index 7ae5f53e370..ba565a9f752 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h @@ -37,7 +37,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *Vector, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *Vector, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp index c84124368be..daa2ac9299e 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp @@ -33,11 +33,11 @@ void IDMaskOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void IDMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void IDMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputValue[4]; - this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler); const float a = (inputValue[0] == this->m_objectIndex) ? 1.0f : 0.0f; color[0] = a; } diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h index 23e8ec704e8..9d356536499 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.h +++ b/source/blender/compositor/operations/COM_IDMaskOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp index eb2eaa8167a..729b3f8f18f 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cpp +++ b/source/blender/compositor/operations/COM_ImageOperation.cpp @@ -108,7 +108,7 @@ void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned } } -void ImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { if (this->m_imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { zero_v4(color); @@ -128,7 +128,7 @@ void ImageOperation::executePixel(float *color, float x, float y, PixelSampler s } } -void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float tempcolor[4]; @@ -152,7 +152,7 @@ void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSamp } } -void ImageDepthOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ImageDepthOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { if (this->m_depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { color[0] = 0.0f; diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h index c87b06b9c4d..847096c7d43 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.h +++ b/source/blender/compositor/operations/COM_ImageOperation.h @@ -73,7 +73,7 @@ public: * Constructor */ ImageOperation(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; class ImageAlphaOperation : public BaseImageOperation { public: @@ -81,7 +81,7 @@ public: * Constructor */ ImageAlphaOperation(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; class ImageDepthOperation : public BaseImageOperation { public: @@ -89,6 +89,6 @@ public: * Constructor */ ImageDepthOperation(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp index 9e9c2522d66..0802d2d2523 100644 --- a/source/blender/compositor/operations/COM_InvertOperation.cpp +++ b/source/blender/compositor/operations/COM_InvertOperation.cpp @@ -39,12 +39,12 @@ void InvertOperation::initExecution() this->m_inputColorProgram = this->getInputSocketReader(1); } -void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sampler) { float inputValue[4]; float inputColor[4]; - this->m_inputValueProgram->read(inputValue, x, y, sampler, inputBuffers); - this->m_inputColorProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueProgram->read(inputValue, x, y, sampler); + this->m_inputColorProgram->read(inputColor, x, y, sampler); const float value = inputValue[0]; const float invertedValue = 1.0f - value; diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h index f00a3fb739d..46a5d80b04a 100644 --- a/source/blender/compositor/operations/COM_InvertOperation.h +++ b/source/blender/compositor/operations/COM_InvertOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp index 3285bd32039..00ea5877d63 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp @@ -39,14 +39,14 @@ KeyingBlurOperation::KeyingBlurOperation() : NodeOperation() this->setComplex(true); } -void *KeyingBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *KeyingBlurOperation::initializeTileData(rcti *rect) { - void *buffer = getInputOperation(0)->initializeTileData(rect, memoryBuffers); + void *buffer = getInputOperation(0)->initializeTileData(rect); return buffer; } -void KeyingBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void KeyingBlurOperation::executePixel(float *color, int x, int y, void *data) { MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.h b/source/blender/compositor/operations/COM_KeyingBlurOperation.h index 6e08712bf39..84406c33c28 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.h +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.h @@ -45,9 +45,9 @@ public: void setSize(int value) {this->m_size = value;} void setAxis(int value) {this->m_axis = value;} - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); - void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp index 8f7d7fbf625..d8afaceb37b 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp @@ -44,14 +44,14 @@ KeyingClipOperation::KeyingClipOperation() : NodeOperation() this->setComplex(true); } -void *KeyingClipOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *KeyingClipOperation::initializeTileData(rcti *rect) { - void *buffer = getInputOperation(0)->initializeTileData(rect, memoryBuffers); + void *buffer = getInputOperation(0)->initializeTileData(rect); return buffer; } -void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void KeyingClipOperation::executePixel(float *color, int x, int y, void *data) { const int delta = this->m_kernelRadius; const float tolerance = this->m_kernelTolerance; diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.h b/source/blender/compositor/operations/COM_KeyingClipOperation.h index 1a8e71a306b..eacbccc0818 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.h +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.h @@ -49,9 +49,9 @@ public: void setIsEdgeMatte(bool value) {this->m_isEdgeMatte = value;} - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); - void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp index 081d9f723e8..2f3fa2bd72a 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp @@ -47,6 +47,7 @@ KeyingDespillOperation::KeyingDespillOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->m_despillFactor = 0.5f; + this->m_colorBalance = 0.5f; this->m_pixelReader = NULL; this->m_screenReader = NULL; @@ -64,25 +65,31 @@ void KeyingDespillOperation::deinitExecution() this->m_screenReader = NULL; } -void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float pixelColor[4]; float screenColor[4]; - this->m_pixelReader->read(pixelColor, x, y, sampler, inputBuffers); - this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers); + this->m_pixelReader->read(pixelColor, x, y, sampler); + this->m_screenReader->read(screenColor, x, y, sampler); int screen_primary_channel = get_pixel_primary_channel(screenColor); + int other_1 = (screen_primary_channel + 1) % 3; + int other_2 = (screen_primary_channel + 2) % 3; + + int min_channel = MIN2(other_1, other_2); + int max_channel = MAX2(other_1, other_2); + float average_value, amount; - average_value = (pixelColor[0] + pixelColor[1] + pixelColor[2] - pixelColor[screen_primary_channel]) / 2.0f; - amount = pixelColor[screen_primary_channel] - average_value; + average_value = this->m_colorBalance * pixelColor[min_channel] + (1.0f - this->m_colorBalance) * pixelColor[max_channel]; + amount = (pixelColor[screen_primary_channel] - average_value); color[0] = pixelColor[0]; color[1] = pixelColor[1]; color[2] = pixelColor[2]; color[3] = pixelColor[3]; - + if (this->m_despillFactor * amount > 0) { color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->m_despillFactor * amount; } diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h index 4fea9b578a1..c6e489057c3 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h @@ -34,6 +34,7 @@ protected: SocketReader *m_pixelReader; SocketReader *m_screenReader; float m_despillFactor; + float m_colorBalance; public: KeyingDespillOperation(); @@ -42,8 +43,9 @@ public: void deinitExecution(); void setDespillFactor(float value) {this->m_despillFactor = value;} + void setColorBalance(float value) {this->m_colorBalance = value;} - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index e92e5c84c2d..5912c206a84 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -45,9 +45,10 @@ static float get_pixel_saturation(float pixelColor[4], float screen_balance, int int other_1 = (primary_channel + 1) % 3; int other_2 = (primary_channel + 2) % 3; - float min = MIN2(pixelColor[other_1], pixelColor[other_2]); - float max = MAX2(pixelColor[other_1], pixelColor[other_2]); - float val = screen_balance * min + (1.0f - screen_balance) * max; + int min_channel = MIN2(other_1, other_2); + int max_channel = MAX2(other_1, other_2); + + float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel]; return (pixelColor[primary_channel] - val) * fabsf(1.0f - val); } @@ -84,17 +85,17 @@ void KeyingOperation::deinitExecution() this->m_coreReader = NULL; } -void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float pixelColor[4]; float screenColor[4]; float garbageValue[4]; float coreValue[4]; - this->m_pixelReader->read(pixelColor, x, y, sampler, inputBuffers); - this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers); - this->m_garbageReader->read(garbageValue, x, y, sampler, inputBuffers); - this->m_coreReader->read(coreValue, x, y, sampler, inputBuffers); + this->m_pixelReader->read(pixelColor, x, y, sampler); + this->m_screenReader->read(screenColor, x, y, sampler); + this->m_garbageReader->read(garbageValue, x, y, sampler); + this->m_coreReader->read(coreValue, x, y, sampler); int primary_channel = get_pixel_primary_channel(screenColor); diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h index 736db54850a..413aaf6a81e 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.h +++ b/source/blender/compositor/operations/COM_KeyingOperation.h @@ -51,7 +51,7 @@ public: void setScreenBalance(float value) {this->m_screenBalance = value;} - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index 53572162b9e..fd3a8d64357 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -104,10 +104,20 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri /* count sites */ for (track = (MovieTrackingTrack *) tracksbase->first, sites_total = 0; track; track = track->next) { MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); + float pos[2]; - if ((marker->flag & MARKER_DISABLED) == 0) { - sites_total++; + if (marker->flag & MARKER_DISABLED) + continue; + + add_v2_v2v2(pos, marker->pos, track->offset); + + if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) || + !IN_RANGE_INCL(pos[1], 0.0f, 1.0f)) + { + continue; } + + sites_total++; } if (!sites_total) @@ -128,10 +138,19 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri VoronoiSite *site; ImBuf *pattern_ibuf; int j; + float pos[2]; if (marker->flag & MARKER_DISABLED) continue; + add_v2_v2v2(pos, marker->pos, track->offset); + + if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) || + !IN_RANGE_INCL(pos[1], 0.0f, 1.0f)) + { + continue; + } + site = &sites[i]; pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); @@ -153,8 +172,8 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y)); IMB_freeImBuf(pattern_ibuf); - site->co[0] = marker->pos[0] * width; - site->co[1] = marker->pos[1] * height; + site->co[0] = pos[0] * width; + site->co[1] = pos[1] * height; } IMB_freeImBuf(ibuf); @@ -198,7 +217,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri return triangulation; } -void *KeyingScreenOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *KeyingScreenOperation::initializeTileData(rcti *rect) { TileData *tile_data; TriangulationData *triangulation; @@ -223,7 +242,7 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect, MemoryBuffer **memor if (!triangulation) return NULL; - BLI_init_rctf(&rect_float, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + BLI_rctf_init(&rect_float, rect->xmin, rect->xmax, rect->ymin, rect->ymax); tile_data = (TileData *) MEM_callocN(sizeof(TileData), "keying screen tile data"); @@ -253,7 +272,7 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect, MemoryBuffer **memor return tile_data; } -void KeyingScreenOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +void KeyingScreenOperation::deinitializeTileData(rcti *rect, void *data) { TileData *tile_data = (TileData *) data; @@ -282,7 +301,7 @@ void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsig } } -void KeyingScreenOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void KeyingScreenOperation::executePixel(float *color, int x, int y, void *data) { color[0] = 0.0f; color[1] = 0.0f; @@ -308,9 +327,11 @@ void KeyingScreenOperation::executePixel(float *color, int x, int y, MemoryBuffe if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) { if (barycentric_inside_triangle_v2(w)) { - color[0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; - color[1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; - color[2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + color[0] = a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; + color[1] = a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; + color[2] = a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + + break; } } } diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.h b/source/blender/compositor/operations/COM_KeyingScreenOperation.h index 95815cd3930..f6982ef09f3 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.h +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.h @@ -73,14 +73,14 @@ public: void initExecution(); void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + void *initializeTileData(rcti *rect); + void deinitializeTileData(rcti *rect, void *data); void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;} void setTrackingObject(const char *object) {strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));} void setFramenumber(int framenumber) {this->m_framenumber = framenumber;} - void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); }; #endif diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp index 233f903c3e3..7f637c127c1 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp @@ -40,7 +40,7 @@ void LuminanceMatteOperation::deinitExecution() this->m_inputImageProgram = NULL; } -void LuminanceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void LuminanceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inColor[4]; @@ -49,7 +49,7 @@ void LuminanceMatteOperation::executePixel(float *outputValue, float x, float y, float alpha; - this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler); /* one line thread-friend algorithm: * outputValue[0] = max(inputValue[3], min(high, max(low, ((inColor[0]-low)/(high-low)))) diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h index 041fd0d7ee9..c1ab628f787 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h @@ -41,7 +41,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp index dec2d0849c9..a5f503a669b 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.cpp +++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp @@ -40,7 +40,7 @@ void MapUVOperation::initExecution() this->m_inputUVProgram = this->getInputSocketReader(1); } -void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float inputUV[4]; float uv_a[4], uv_b[4]; @@ -50,30 +50,30 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s float uv_l, uv_r; float uv_u, uv_d; - this->m_inputUVProgram->read(inputUV, x, y, sampler, inputBuffers); + this->m_inputUVProgram->read(inputUV, x, y, sampler); if (inputUV[2] == 0.f) { zero_v4(color); return; } /* adaptive sampling, red (U) channel */ - this->m_inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST, inputBuffers); - this->m_inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST); + this->m_inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; dx = 0.5f * (uv_l + uv_r); /* adaptive sampling, green (V) channel */ - this->m_inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST, inputBuffers); - this->m_inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST); + this->m_inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST); uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; uv_d = uv_b[2] != 0.f ? fabsf(inputUV[1] - uv_b[1]) : 0.f; dy = 0.5f * (uv_u + uv_d); /* more adaptive sampling, red and green (UV) channels */ - this->m_inputUVProgram->read(uv_a, x - 1, y - 1, COM_PS_NEAREST, inputBuffers); - this->m_inputUVProgram->read(uv_b, x - 1, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x - 1, y - 1, COM_PS_NEAREST); + this->m_inputUVProgram->read(uv_b, x - 1, y + 1, COM_PS_NEAREST); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; @@ -82,8 +82,8 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s dx += 0.25f * (uv_l + uv_r); dy += 0.25f * (uv_u + uv_d); - this->m_inputUVProgram->read(uv_a, x + 1, y - 1, COM_PS_NEAREST, inputBuffers); - this->m_inputUVProgram->read(uv_b, x + 1, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x + 1, y - 1, COM_PS_NEAREST); + this->m_inputUVProgram->read(uv_b, x + 1, y + 1, COM_PS_NEAREST); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; @@ -107,7 +107,7 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s u = inputUV[0] * this->m_inputColorProgram->getWidth(); v = inputUV[1] * this->m_inputColorProgram->getHeight(); - this->m_inputColorProgram->read(color, u, v, dx, dy, inputBuffers); + this->m_inputColorProgram->read(color, u, v, dx, dy); /* "premul" */ if (alpha < 1.0f) { diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h index c14640da61c..ae042f60789 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.h +++ b/source/blender/compositor/operations/COM_MapUVOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp index 17d82e85723..96e586ccef8 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.cpp +++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp @@ -34,10 +34,10 @@ void MapValueOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void MapValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MapValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float src[4]; - this->m_inputOperation->read(src, x, y, sampler, inputBuffers); + this->m_inputOperation->read(src, x, y, sampler); TexMapping *texmap = this->m_settings; float value = (src[0] + texmap->loc[0]) * texmap->size[0]; if (texmap->flag & TEXMAP_CLIP_MIN) diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h index fb50d0fbe4d..a2664c32a4e 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.h +++ b/source/blender/compositor/operations/COM_MapValueOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index 2b45cd53fd5..d2a4854efee 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -30,8 +30,10 @@ #include "DNA_scene_types.h" + +#ifdef USE_RASKTER + extern "C" { - #include "BKE_mask.h" #include "../../../../intern/raskter/raskter.h" } @@ -68,7 +70,7 @@ void MaskOperation::deinitExecution() } } -void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *MaskOperation::initializeTileData(rcti *rect) { if (this->m_rasterizedMask) return this->m_rasterizedMask; @@ -115,7 +117,7 @@ void MaskOperation::determineResolution(unsigned int resolution[], unsigned int } } -void MaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void MaskOperation::executePixel(float *color, int x, int y, void *data) { if (!data) { color[0] = 0.0f; @@ -127,3 +129,79 @@ void MaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *input color[0] = buffer[index]; } } + +#else /* mask rasterizer by campbell wip */ + +MaskOperation::MaskOperation() : NodeOperation() +{ + this->addOutputSocket(COM_DT_VALUE); + this->m_mask = NULL; + this->m_maskWidth = 0; + this->m_maskHeight = 0; + this->m_framenumber = 0; + this->m_rasterMaskHandle = NULL; + setComplex(true); +} + +void MaskOperation::initExecution() +{ + initMutex(); + + if (this->m_mask) { + if (this->m_rasterMaskHandle == NULL) { + const int width = this->getWidth(); + const int height = this->getHeight(); + + this->m_rasterMaskHandle = BLI_maskrasterize_handle_new(); + + BLI_maskrasterize_handle_init(this->m_rasterMaskHandle, this->m_mask, width, height, TRUE, this->m_do_smooth, this->m_do_feather); + } + } +} + +void MaskOperation::deinitExecution() +{ + if (this->m_rasterMaskHandle) { + BLI_maskrasterize_handle_free(this->m_rasterMaskHandle); + this->m_rasterMaskHandle = NULL; + } + + deinitMutex(); +} + +void *MaskOperation::initializeTileData(rcti *rect) +{ + /* pass */ + return NULL; +} + +void MaskOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) +{ + if (this->m_maskWidth == 0 || this->m_maskHeight == 0) { + NodeOperation::determineResolution(resolution, preferredResolution); + } + else { + unsigned int nr[2]; + + nr[0] = this->m_maskWidth; + nr[1] = this->m_maskHeight; + + NodeOperation::determineResolution(resolution, nr); + + resolution[0] = this->m_maskWidth; + resolution[1] = this->m_maskHeight; + } +} + +void MaskOperation::executePixel(float *color, int x, int y, void *data) +{ + const float xy[2] = {x / (float)this->m_maskWidth, y / (float)this->m_maskHeight}; + if (this->m_rasterMaskHandle) { + color[0] = BLI_maskrasterize_handle_sample(this->m_rasterMaskHandle, xy); + } + else { + color[0] = 0.0f; + } +} + +#endif /* USE_RASKTER */ diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index df1cad3c0f6..d761ee58cb9 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -25,12 +25,21 @@ #ifndef _COM_MaskOperation_h #define _COM_MaskOperation_h +/* XXX, remove when the USE_RASKTER option is also removed */ +extern "C" { + #include "BKE_mask.h" +} + #include "COM_NodeOperation.h" #include "DNA_scene_types.h" #include "DNA_mask_types.h" #include "BLI_listbase.h" #include "IMB_imbuf_types.h" +#ifdef __PLX_RASKTER_MT__ +#include "../../../../intern/raskter/raskter.h" +#endif + /** * Class with implementation of mask rasterization */ @@ -42,9 +51,16 @@ protected: int m_framenumber; bool m_do_smooth; bool m_do_feather; + +#ifdef USE_RASKTER float *m_rasterizedMask; + ListBase m_maskLayers; +#else /* USE_RASKTER */ + struct MaskRasterHandle *m_rasterMaskHandle; +#endif /* USE_RASKTER */ + /** * Determine the output resolution. The resolution is retrieved from the Renderer */ @@ -56,7 +72,7 @@ public: void initExecution(); void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); void setMask(Mask *mask) { this->m_mask = mask; } void setMaskWidth(int width) { this->m_maskWidth = width; } @@ -65,7 +81,7 @@ public: void setSmooth(bool smooth) { this->m_do_smooth = smooth; } void setFeather(bool feather) { this->m_do_feather = feather; } - void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); }; #endif diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp index 1bf89be57b5..6c0c27c2522 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp @@ -64,132 +64,159 @@ void MathBaseOperation::determineResolution(unsigned int resolution[], unsigned NodeOperation::determineResolution(resolution, preferredResolution); } -void MathAddOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathBaseOperation::clampIfNeeded(float *color) +{ + if (this->m_useClamp) { + CLAMP(color[0], 0.0f, 1.0f); + } +} + +void MathAddOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = inputValue1[0] + inputValue2[0]; + + clampIfNeeded(outputValue); } -void MathSubtractOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathSubtractOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = inputValue1[0] - inputValue2[0]; + + clampIfNeeded(outputValue); } -void MathMultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathMultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = inputValue1[0] * inputValue2[0]; + + clampIfNeeded(outputValue); } -void MathDivideOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathDivideOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); if (inputValue2[0] == 0) /* We don't want to divide by zero. */ outputValue[0] = 0.0; else outputValue[0] = inputValue1[0] / inputValue2[0]; + + clampIfNeeded(outputValue); } -void MathSineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathSineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = sin(inputValue1[0]); + + clampIfNeeded(outputValue); } -void MathCosineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathCosineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = cos(inputValue1[0]); + + clampIfNeeded(outputValue); } -void MathTangentOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathTangentOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = tan(inputValue1[0]); + + clampIfNeeded(outputValue); } -void MathArcSineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathArcSineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) outputValue[0] = asin(inputValue1[0]); else outputValue[0] = 0.0; + + clampIfNeeded(outputValue); } -void MathArcCosineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathArcCosineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) outputValue[0] = acos(inputValue1[0]); else outputValue[0] = 0.0; + + clampIfNeeded(outputValue); } -void MathArcTangentOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathArcTangentOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = atan(inputValue1[0]); + + clampIfNeeded(outputValue); } -void MathPowerOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathPowerOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); if (inputValue1[0] >= 0) { outputValue[0] = pow(inputValue1[0], inputValue2[0]); @@ -204,75 +231,89 @@ void MathPowerOperation::executePixel(float *outputValue, float x, float y, Pixe outputValue[0] = 0.0; } } + + clampIfNeeded(outputValue); } -void MathLogarithmOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathLogarithmOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); if (inputValue1[0] > 0 && inputValue2[0] > 0) outputValue[0] = log(inputValue1[0]) / log(inputValue2[0]); else outputValue[0] = 0.0; + + clampIfNeeded(outputValue); } -void MathMinimumOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathMinimumOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = min(inputValue1[0], inputValue2[0]); + + clampIfNeeded(outputValue); } -void MathMaximumOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathMaximumOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = max(inputValue1[0], inputValue2[0]); + + clampIfNeeded(outputValue); } -void MathRoundOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathRoundOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = round(inputValue1[0]); + + clampIfNeeded(outputValue); } -void MathLessThanOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathLessThanOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f; + + clampIfNeeded(outputValue); } -void MathGreaterThanOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MathGreaterThanOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); outputValue[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h index be06537cbf0..8fc6c762b16 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.h +++ b/source/blender/compositor/operations/COM_MathBaseOperation.h @@ -37,16 +37,20 @@ protected: SocketReader *m_inputValue1Operation; SocketReader *m_inputValue2Operation; + bool m_useClamp; + protected: /** * Default constructor */ MathBaseOperation(); + + void clampIfNeeded(float *color); public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]) = 0; + void executePixel(float *color, float x, float y, PixelSampler sampler) = 0; /** * Initialize the execution @@ -62,93 +66,95 @@ public: * Determine resolution */ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); + + void setUseClamp(bool value) { this->m_useClamp = value; } }; class MathAddOperation : public MathBaseOperation { public: MathAddOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathSubtractOperation : public MathBaseOperation { public: MathSubtractOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathMultiplyOperation : public MathBaseOperation { public: MathMultiplyOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathDivideOperation : public MathBaseOperation { public: MathDivideOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathSineOperation : public MathBaseOperation { public: MathSineOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathCosineOperation : public MathBaseOperation { public: MathCosineOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathTangentOperation : public MathBaseOperation { public: MathTangentOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathArcSineOperation : public MathBaseOperation { public: MathArcSineOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathArcCosineOperation : public MathBaseOperation { public: MathArcCosineOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathArcTangentOperation : public MathBaseOperation { public: MathArcTangentOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathPowerOperation : public MathBaseOperation { public: MathPowerOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathLogarithmOperation : public MathBaseOperation { public: MathLogarithmOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathMinimumOperation : public MathBaseOperation { public: MathMinimumOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathMaximumOperation : public MathBaseOperation { public: MathMaximumOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathRoundOperation : public MathBaseOperation { public: MathRoundOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathLessThanOperation : public MathBaseOperation { public: MathLessThanOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; class MathGreaterThanOperation : public MathBaseOperation { public: MathGreaterThanOperation() : MathBaseOperation() {} - void executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *outputValue, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixAddOperation.cpp b/source/blender/compositor/operations/COM_MixAddOperation.cpp index 7f7315fb3ff..b49c65cc010 100644 --- a/source/blender/compositor/operations/COM_MixAddOperation.cpp +++ b/source/blender/compositor/operations/COM_MixAddOperation.cpp @@ -27,15 +27,15 @@ MixAddOperation::MixAddOperation() : MixBaseOperation() /* pass */ } -void MixAddOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixAddOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler); float value = inputValue[0]; @@ -46,5 +46,7 @@ void MixAddOperation::executePixel(float *outputValue, float x, float y, PixelSa outputValue[1] = inputColor1[1] + value * inputColor2[1]; outputValue[2] = inputColor1[2] + value * inputColor2[2]; outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixAddOperation.h b/source/blender/compositor/operations/COM_MixAddOperation.h index c5eaf0a4d77..8fc41706073 100644 --- a/source/blender/compositor/operations/COM_MixAddOperation.h +++ b/source/blender/compositor/operations/COM_MixAddOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.cpp b/source/blender/compositor/operations/COM_MixBaseOperation.cpp index fbe92f54aa8..e9dd7078f83 100644 --- a/source/blender/compositor/operations/COM_MixBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBaseOperation.cpp @@ -41,16 +41,17 @@ void MixBaseOperation::initExecution() this->m_inputColor2Operation = this->getInputSocketReader(2); } -void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; - float value; + float inputValue[4]; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } @@ -93,4 +94,3 @@ void MixBaseOperation::determineResolution(unsigned int resolution[], unsigned i } NodeOperation::determineResolution(resolution, preferredResolution); } - diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.h b/source/blender/compositor/operations/COM_MixBaseOperation.h index 268d4832243..0a8ed4fa0e1 100644 --- a/source/blender/compositor/operations/COM_MixBaseOperation.h +++ b/source/blender/compositor/operations/COM_MixBaseOperation.h @@ -38,6 +38,18 @@ protected: SocketReader *m_inputColor1Operation; SocketReader *m_inputColor2Operation; bool m_valueAlphaMultiply; + bool m_useClamp; + + inline void clampIfNeeded(float *color) + { + if (m_useClamp) { + CLAMP(color[0], 0.0f, 1.0f); + CLAMP(color[1], 0.0f, 1.0f); + CLAMP(color[2], 0.0f, 1.0f); + CLAMP(color[3], 0.0f, 1.0f); + } + } + public: /** * Default constructor @@ -47,7 +59,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); /** * Initialize the execution @@ -63,5 +75,6 @@ public: void setUseValueAlphaMultiply(const bool value) { this->m_valueAlphaMultiply = value; } bool useValueAlphaMultiply() { return this->m_valueAlphaMultiply; } + void setUseClamp(bool value) { this->m_useClamp = value; } }; #endif diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.cpp b/source/blender/compositor/operations/COM_MixBlendOperation.cpp index 341aba0e7fc..090343e8450 100644 --- a/source/blender/compositor/operations/COM_MixBlendOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBlendOperation.cpp @@ -27,16 +27,16 @@ MixBlendOperation::MixBlendOperation() : MixBaseOperation() /* pass */ } -void MixBlendOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixBlendOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; float value; - this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler); value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -47,4 +47,6 @@ void MixBlendOperation::executePixel(float *outputValue, float x, float y, Pixel outputValue[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]); outputValue[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]); outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.h b/source/blender/compositor/operations/COM_MixBlendOperation.h index 16ad635bebd..6073ca1fc52 100644 --- a/source/blender/compositor/operations/COM_MixBlendOperation.h +++ b/source/blender/compositor/operations/COM_MixBlendOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.cpp b/source/blender/compositor/operations/COM_MixBurnOperation.cpp index 039915ab66a..fbb3cb7b27b 100644 --- a/source/blender/compositor/operations/COM_MixBurnOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBurnOperation.cpp @@ -27,16 +27,16 @@ MixBurnOperation::MixBurnOperation() : MixBaseOperation() /* pass */ } -void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; float tmp; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -83,5 +83,7 @@ void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelS } outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.h b/source/blender/compositor/operations/COM_MixBurnOperation.h index 7412f651ab3..88435f05503 100644 --- a/source/blender/compositor/operations/COM_MixBurnOperation.h +++ b/source/blender/compositor/operations/COM_MixBurnOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixColorOperation.cpp b/source/blender/compositor/operations/COM_MixColorOperation.cpp index cb5791c02bb..378cfbd9b6c 100644 --- a/source/blender/compositor/operations/COM_MixColorOperation.cpp +++ b/source/blender/compositor/operations/COM_MixColorOperation.cpp @@ -31,15 +31,15 @@ MixColorOperation::MixColorOperation() : MixBaseOperation() /* pass */ } -void MixColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -58,5 +58,7 @@ void MixColorOperation::executePixel(float *outputValue, float x, float y, Pixel outputValue[2] = valuem * (inputColor1[2]) + value * tmpb; } outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixColorOperation.h b/source/blender/compositor/operations/COM_MixColorOperation.h index 028ff517132..fb91a426f40 100644 --- a/source/blender/compositor/operations/COM_MixColorOperation.h +++ b/source/blender/compositor/operations/COM_MixColorOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp index db243cf4a87..68f9c023733 100644 --- a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp @@ -27,15 +27,15 @@ MixDarkenOperation::MixDarkenOperation() : MixBaseOperation() /* pass */ } -void MixDarkenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixDarkenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -53,5 +53,7 @@ void MixDarkenOperation::executePixel(float *outputValue, float x, float y, Pixe else outputValue[2] = inputColor1[2]; outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.h b/source/blender/compositor/operations/COM_MixDarkenOperation.h index 337fa1a7024..8b5afaecbd5 100644 --- a/source/blender/compositor/operations/COM_MixDarkenOperation.h +++ b/source/blender/compositor/operations/COM_MixDarkenOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp index 9fe1a3cb94b..48964e8b78b 100644 --- a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp @@ -28,15 +28,15 @@ MixDifferenceOperation::MixDifferenceOperation() : MixBaseOperation() /* pass */ } -void MixDifferenceOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixDifferenceOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -46,5 +46,7 @@ void MixDifferenceOperation::executePixel(float *outputValue, float x, float y, outputValue[1] = valuem * inputColor1[1] + value *fabsf(inputColor1[1] - inputColor2[1]); outputValue[2] = valuem * inputColor1[2] + value *fabsf(inputColor1[2] - inputColor2[2]); outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.h b/source/blender/compositor/operations/COM_MixDifferenceOperation.h index 503fbb691d3..f4ad5d07586 100644 --- a/source/blender/compositor/operations/COM_MixDifferenceOperation.h +++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.cpp b/source/blender/compositor/operations/COM_MixDivideOperation.cpp index 0e1bd408b89..d9d2383001b 100644 --- a/source/blender/compositor/operations/COM_MixDivideOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDivideOperation.cpp @@ -27,15 +27,15 @@ MixDivideOperation::MixDivideOperation() : MixBaseOperation() /* pass */ } -void MixDivideOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixDivideOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -56,5 +56,7 @@ void MixDivideOperation::executePixel(float *outputValue, float x, float y, Pixe outputValue[2] = 0.0f; outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.h b/source/blender/compositor/operations/COM_MixDivideOperation.h index db60a39f93f..8f94fc2d510 100644 --- a/source/blender/compositor/operations/COM_MixDivideOperation.h +++ b/source/blender/compositor/operations/COM_MixDivideOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp index ea01806267b..34c6e4043f2 100644 --- a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp @@ -27,16 +27,16 @@ MixDodgeOperation::MixDodgeOperation() : MixBaseOperation() /* pass */ } -void MixDodgeOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixDodgeOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; float tmp; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -88,5 +88,7 @@ void MixDodgeOperation::executePixel(float *outputValue, float x, float y, Pixel outputValue[2] = 0.0f; outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.h b/source/blender/compositor/operations/COM_MixDodgeOperation.h index 32aa8593657..f99a82dca8d 100644 --- a/source/blender/compositor/operations/COM_MixDodgeOperation.h +++ b/source/blender/compositor/operations/COM_MixDodgeOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixGlareOperation.cpp b/source/blender/compositor/operations/COM_MixGlareOperation.cpp index 7cd24b3bf06..4a569404ddc 100644 --- a/source/blender/compositor/operations/COM_MixGlareOperation.cpp +++ b/source/blender/compositor/operations/COM_MixGlareOperation.cpp @@ -27,16 +27,16 @@ MixGlareOperation::MixGlareOperation() : MixBaseOperation() /* pass */ } -void MixGlareOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixGlareOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; float value; - this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler); value = inputValue[0]; float mf = 2.f - 2.f * fabsf(value - 0.5f); @@ -44,4 +44,6 @@ void MixGlareOperation::executePixel(float *outputValue, float x, float y, Pixel outputValue[1] = mf * ((inputColor1[1]) + value * (inputColor2[1] - inputColor1[1])); outputValue[2] = mf * ((inputColor1[2]) + value * (inputColor2[2] - inputColor1[2])); outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixGlareOperation.h b/source/blender/compositor/operations/COM_MixGlareOperation.h index 1c715d7414b..23b9f2420a0 100644 --- a/source/blender/compositor/operations/COM_MixGlareOperation.h +++ b/source/blender/compositor/operations/COM_MixGlareOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixHueOperation.cpp b/source/blender/compositor/operations/COM_MixHueOperation.cpp index e7b444616f4..3745f502709 100644 --- a/source/blender/compositor/operations/COM_MixHueOperation.cpp +++ b/source/blender/compositor/operations/COM_MixHueOperation.cpp @@ -31,15 +31,15 @@ MixHueOperation::MixHueOperation() : MixBaseOperation() /* pass */ } -void MixHueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixHueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -58,4 +58,6 @@ void MixHueOperation::executePixel(float *outputValue, float x, float y, PixelSa outputValue[2] = valuem * (inputColor1[2]) + value * tmpb; } outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixHueOperation.h b/source/blender/compositor/operations/COM_MixHueOperation.h index ff1ef369440..1c8eadabbbd 100644 --- a/source/blender/compositor/operations/COM_MixHueOperation.h +++ b/source/blender/compositor/operations/COM_MixHueOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.cpp b/source/blender/compositor/operations/COM_MixLightenOperation.cpp index 89166637f9f..868459db8bf 100644 --- a/source/blender/compositor/operations/COM_MixLightenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixLightenOperation.cpp @@ -27,15 +27,15 @@ MixLightenOperation::MixLightenOperation() : MixBaseOperation() /* pass */ } -void MixLightenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixLightenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -51,5 +51,7 @@ void MixLightenOperation::executePixel(float *outputValue, float x, float y, Pix if (tmp > inputColor1[2]) outputValue[2] = tmp; else outputValue[2] = inputColor1[2]; outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.h b/source/blender/compositor/operations/COM_MixLightenOperation.h index dd51215b26a..d03ab317035 100644 --- a/source/blender/compositor/operations/COM_MixLightenOperation.h +++ b/source/blender/compositor/operations/COM_MixLightenOperation.h @@ -39,6 +39,6 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp index 5406a3cbcc1..2fff05fbbc9 100644 --- a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp +++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp @@ -27,15 +27,15 @@ MixLinearLightOperation::MixLinearLightOperation() : MixBaseOperation() /* pass */ } -void MixLinearLightOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixLinearLightOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -54,4 +54,6 @@ void MixLinearLightOperation::executePixel(float *outputValue, float x, float y, outputValue[2] = inputColor1[2] + value * (2.0f * (inputColor2[2]) - 1.0f); outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.h b/source/blender/compositor/operations/COM_MixLinearLightOperation.h index e96e2b7eaf7..7a9acbe00b0 100644 --- a/source/blender/compositor/operations/COM_MixLinearLightOperation.h +++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp index 978e96eb2f6..911c0c83b90 100644 --- a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp +++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp @@ -27,15 +27,15 @@ MixMultiplyOperation::MixMultiplyOperation() : MixBaseOperation() /* pass */ } -void MixMultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixMultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -46,5 +46,7 @@ void MixMultiplyOperation::executePixel(float *outputValue, float x, float y, Pi outputValue[1] = inputColor1[1] * (valuem + value * inputColor2[1]); outputValue[2] = inputColor1[2] * (valuem + value * inputColor2[2]); outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.h b/source/blender/compositor/operations/COM_MixMultiplyOperation.h index 4c89a8f2957..ab7d06aecf6 100644 --- a/source/blender/compositor/operations/COM_MixMultiplyOperation.h +++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp index f4f96747acd..ba7a86a80a7 100644 --- a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp +++ b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp @@ -27,15 +27,15 @@ MixOverlayOperation::MixOverlayOperation() : MixBaseOperation() /* pass */ } -void MixOverlayOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixOverlayOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -62,5 +62,7 @@ void MixOverlayOperation::executePixel(float *outputValue, float x, float y, Pix outputValue[2] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]); } outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.h b/source/blender/compositor/operations/COM_MixOverlayOperation.h index 7de955b9f4f..d31396f471b 100644 --- a/source/blender/compositor/operations/COM_MixOverlayOperation.h +++ b/source/blender/compositor/operations/COM_MixOverlayOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp index c9c6f691fdb..403dac57615 100644 --- a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp @@ -31,15 +31,15 @@ MixSaturationOperation::MixSaturationOperation() : MixBaseOperation() /* pass */ } -void MixSaturationOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixSaturationOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -54,4 +54,6 @@ void MixSaturationOperation::executePixel(float *outputValue, float x, float y, hsv_to_rgb(rH, (valuem * rS + value * colS), rV, &outputValue[0], &outputValue[1], &outputValue[2]); } outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.h b/source/blender/compositor/operations/COM_MixSaturationOperation.h index 241009e2645..f89f03c0e18 100644 --- a/source/blender/compositor/operations/COM_MixSaturationOperation.h +++ b/source/blender/compositor/operations/COM_MixSaturationOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.cpp b/source/blender/compositor/operations/COM_MixScreenOperation.cpp index 9bc9144f4ff..781bc87ece7 100644 --- a/source/blender/compositor/operations/COM_MixScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixScreenOperation.cpp @@ -27,15 +27,15 @@ MixScreenOperation::MixScreenOperation() : MixBaseOperation() /* pass */ } -void MixScreenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixScreenOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float valuev[4]; - this->m_inputValueOperation->read(valuev, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(valuev, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); float value = valuev[0]; if (this->useValueAlphaMultiply()) { @@ -47,5 +47,7 @@ void MixScreenOperation::executePixel(float *outputValue, float x, float y, Pixe outputValue[1] = 1.0f - (valuem + value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]); outputValue[2] = 1.0f - (valuem + value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]); outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.h b/source/blender/compositor/operations/COM_MixScreenOperation.h index 4d0c1fded3d..843adc870f8 100644 --- a/source/blender/compositor/operations/COM_MixScreenOperation.h +++ b/source/blender/compositor/operations/COM_MixScreenOperation.h @@ -39,6 +39,6 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp index 52c2e8829dc..b1374aa7f32 100644 --- a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp @@ -27,15 +27,15 @@ MixSoftLightOperation::MixSoftLightOperation() : MixBaseOperation() /* pass */ } -void MixSoftLightOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) \ - { +void MixSoftLightOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) \ +{ float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -52,5 +52,7 @@ void MixSoftLightOperation::executePixel(float *outputValue, float x, float y, P outputValue[1] = valuem * (inputColor1[1]) + value * (((1.0f - inputColor1[1]) * inputColor2[1] * (inputColor1[1])) + (inputColor1[1] * scg)); outputValue[2] = valuem * (inputColor1[2]) + value * (((1.0f - inputColor1[2]) * inputColor2[2] * (inputColor1[2])) + (inputColor1[2] * scb)); outputValue[3] = inputColor1[3]; - } + + clampIfNeeded(outputValue); +} diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.h b/source/blender/compositor/operations/COM_MixSoftLightOperation.h index bcb718027b2..570cf2cb6ef 100644 --- a/source/blender/compositor/operations/COM_MixSoftLightOperation.h +++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp index 60f54ab478d..f7b558e5c7a 100644 --- a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp @@ -27,15 +27,15 @@ MixSubtractOperation::MixSubtractOperation() : MixBaseOperation() /* pass */ } -void MixSubtractOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixSubtractOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -44,5 +44,7 @@ void MixSubtractOperation::executePixel(float *outputValue, float x, float y, Pi outputValue[1] = inputColor1[1] - value * (inputColor2[1]); outputValue[2] = inputColor1[2] - value * (inputColor2[2]); outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.h b/source/blender/compositor/operations/COM_MixSubtractOperation.h index 3c8112b0e36..a9198cf3400 100644 --- a/source/blender/compositor/operations/COM_MixSubtractOperation.h +++ b/source/blender/compositor/operations/COM_MixSubtractOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixValueOperation.cpp b/source/blender/compositor/operations/COM_MixValueOperation.cpp index 2651b0d7dee..8f8d3305ee9 100644 --- a/source/blender/compositor/operations/COM_MixValueOperation.cpp +++ b/source/blender/compositor/operations/COM_MixValueOperation.cpp @@ -31,15 +31,15 @@ MixValueOperation::MixValueOperation() : MixBaseOperation() /* pass */ } -void MixValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MixValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; - this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); - this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -52,4 +52,6 @@ void MixValueOperation::executePixel(float *outputValue, float x, float y, Pixel rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV); hsv_to_rgb(rH, rS, (valuem * rV + value * colV), &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor1[3]; + + clampIfNeeded(outputValue); } diff --git a/source/blender/compositor/operations/COM_MixValueOperation.h b/source/blender/compositor/operations/COM_MixValueOperation.h index c0f3ce10f29..06316afcd73 100644 --- a/source/blender/compositor/operations/COM_MixValueOperation.h +++ b/source/blender/compositor/operations/COM_MixValueOperation.h @@ -39,6 +39,6 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp index 1af206920c5..14d7fa7e649 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp @@ -33,7 +33,7 @@ MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation() this->m_attribute = MCA_X; } -void MovieClipAttributeOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MovieClipAttributeOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { if (!this->m_valueSet) { float loc[2], scale, angle; diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h index c6422fbbfc2..28028ab6fd4 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h @@ -51,7 +51,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); void setMovieClip(MovieClip *clip) { this->m_clip = clip; } diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp index f53bb66d478..8b88f5c7d14 100644 --- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp @@ -48,7 +48,16 @@ void MovieClipOperation::initExecution() if (this->m_movieClip) { BKE_movieclip_user_set_frame(this->m_movieClipUser, this->m_framenumber); ImBuf *ibuf; - ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser); + + if (this->m_cacheFrame) { + ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser); + } + else { + int flag = this->m_movieClip->flag & MCLIP_TIMECODE_FLAGS; + + ibuf = BKE_movieclip_get_ibuf_flag(this->m_movieClip, this->m_movieClipUser, flag, MOVIECLIP_CACHE_SKIP); + } + if (ibuf) { this->m_movieClipBuffer = ibuf; if (ibuf->rect_float == NULL || ibuf->userflags & IB_RECT_INVALID) { @@ -83,7 +92,7 @@ void MovieClipOperation::determineResolution(unsigned int resolution[], unsigned } } -void MovieClipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MovieClipOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { if (this->m_movieClipBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { zero_v4(color); diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h index 2e824009ab6..f3e95818bd7 100644 --- a/source/blender/compositor/operations/COM_MovieClipOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipOperation.h @@ -43,6 +43,7 @@ protected: int m_movieClipheight; int m_movieClipwidth; int m_framenumber; + bool m_cacheFrame; /** * Determine the output resolution. The resolution is retrieved from the Renderer @@ -56,9 +57,10 @@ public: void deinitExecution(); void setMovieClip(MovieClip *image) { this->m_movieClip = image; } void setMovieClipUser(MovieClipUser *imageuser) { this->m_movieClipUser = imageuser; } + void setCacheFrame(bool value) { this->m_cacheFrame = value; } void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index 6b423cadcc6..964d4352bc0 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -78,16 +78,16 @@ void MovieDistortionOperation::deinitExecution() } -void MovieDistortionOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MovieDistortionOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { if (this->m_cache != NULL) { float u, v; this->m_cache->getUV(&this->m_movieClip->tracking, x, y, &u, &v); - this->m_inputOperation->read(color, u, v, sampler, inputBuffers); + this->m_inputOperation->read(color, u, v, sampler); } else { - this->m_inputOperation->read(color, x, y, sampler, inputBuffers); + this->m_inputOperation->read(color, x, y, sampler); } } diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h index ab81ae44597..8cd9e98da2d 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h @@ -130,7 +130,7 @@ protected: public: MovieDistortionOperation(bool distortion); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp index 363c0379770..27214acd0d4 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp @@ -43,7 +43,7 @@ ImBuf *MultilayerBaseOperation::getImBuf() return NULL; } -void MultilayerColorOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MultilayerColorOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { int yi = y; int xi = x; @@ -74,7 +74,7 @@ void MultilayerColorOperation::executePixel(float *color, float x, float y, Pixe } } -void MultilayerValueOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MultilayerValueOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { int yi = y; int xi = x; @@ -87,7 +87,7 @@ void MultilayerValueOperation::executePixel(float *color, float x, float y, Pixe } } -void MultilayerVectorOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void MultilayerVectorOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { int yi = y; int xi = x; diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h index f946c44dd35..82bd8c455df 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h @@ -46,7 +46,7 @@ public: MultilayerColorOperation(int pass) : MultilayerBaseOperation(pass) { this->addOutputSocket(COM_DT_COLOR); } - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; class MultilayerValueOperation : public MultilayerBaseOperation { @@ -54,7 +54,7 @@ public: MultilayerValueOperation(int pass) : MultilayerBaseOperation(pass) { this->addOutputSocket(COM_DT_VALUE); } - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; class MultilayerVectorOperation : public MultilayerBaseOperation { @@ -62,7 +62,7 @@ public: MultilayerVectorOperation(int pass) : MultilayerBaseOperation(pass) { this->addOutputSocket(COM_DT_VECTOR); } - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp index 8a83ef7f3ae..02ea7f2b257 100644 --- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp +++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp @@ -35,13 +35,13 @@ void NormalizeOperation::initExecution() NodeOperation::initMutex(); } -void NormalizeOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void NormalizeOperation::executePixel(float *color, int x, int y, void *data) { /* using generic two floats struct to store x: min y: mult */ NodeTwoFloats *minmult = (NodeTwoFloats *)data; float output[4]; - this->m_imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, NULL); color[0] = (output[0] - minmult->x) * minmult->y; } @@ -75,11 +75,11 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe /* The code below assumes all data is inside range +- this, and that input buffer is single channel */ #define BLENDER_ZMAX 10000.0f -void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *NormalizeOperation::initializeTileData(rcti *rect) { lockMutex(); if (this->m_cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect); /* using generic two floats struct to store x: min y: mult */ NodeTwoFloats *minmult = new NodeTwoFloats(); @@ -113,7 +113,7 @@ void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu return this->m_cachedInstance; } -void NormalizeOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +void NormalizeOperation::deinitializeTileData(rcti *rect, void *data) { /* pass */ } diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.h b/source/blender/compositor/operations/COM_NormalizeOperation.h index 1f4a403434e..f36d69a3018 100644 --- a/source/blender/compositor/operations/COM_NormalizeOperation.h +++ b/source/blender/compositor/operations/COM_NormalizeOperation.h @@ -47,15 +47,15 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + void *initializeTileData(rcti *rect); + void deinitializeTileData(rcti *rect, void *data); /** * Deinitialize the execution diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl index ce197915360..4f43650370d 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl @@ -1,7 +1,30 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + /// This file contains all opencl kernels for node-operation implementations // Global SAMPLERS -const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; +const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; +const sampler_t SAMPLER_NEAREST_CLAMP = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST; __constant const int2 zero = {0,0}; @@ -21,7 +44,7 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima tempBoundingBox = read_imagef(boundingBox, SAMPLER_NEAREST, coords).s0; - if (tempBoundingBox > 0.0f) { + if (tempBoundingBox > 0.0f && radius > 0 ) { const int2 bokehImageDim = get_image_dim(bokehImage); const int2 bokehImageCenter = bokehImageDim/2; const int2 minXY = max(realCoordinate - radius, zero); @@ -53,7 +76,7 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima //KERNEL --- DEFOCUS /VARIABLESIZEBOKEHBLUR --- __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2d_t bokehImage, - __read_only image2d_t inputDepth, __read_only image2d_t inputSize, + __read_only image2d_t inputSize, __write_only image2d_t output, int2 offsetInput, int2 offsetOutput, int step, int maxBlur, float threshold, int2 dimension, int2 offset) { @@ -65,7 +88,6 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 float4 readColor; float4 bokeh; float tempSize; - float tempDepth; float4 multiplier_accum = {1.0f, 1.0f, 1.0f, 1.0f}; float4 color_accum; @@ -77,35 +99,30 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 { int2 inputCoordinate = realCoordinate - offsetInput; float size = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; - float depth = read_imagef(inputDepth, SAMPLER_NEAREST, inputCoordinate).s0 + threshold; color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate); - for (int ny = miny; ny < maxy; ny += step) { - for (int nx = minx; nx < maxx; nx += step) { - if (nx >= 0 && nx < dimension.s0 && ny >= 0 && ny < dimension.s1) { - inputCoordinate.s0 = nx - offsetInput.s0; - inputCoordinate.s1 = ny - offsetInput.s1; - tempDepth = read_imagef(inputDepth, SAMPLER_NEAREST, inputCoordinate).s0; - if (tempDepth < depth) { + if (size > threshold) { + for (int ny = miny; ny < maxy; ny += step) { + inputCoordinate.s1 = ny - offsetInput.s1; + float dy = ny - realCoordinate.s1; + for (int nx = minx; nx < maxx; nx += step) { + float dx = nx - realCoordinate.s0; + if (dx != 0 || dy != 0) { + inputCoordinate.s0 = nx - offsetInput.s0; tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0; - - if ((size > threshold && tempSize > threshold) || tempSize <= threshold) { - float dx = nx - realCoordinate.s0; - float dy = ny - realCoordinate.s1; - if (dx != 0 || dy != 0) { - if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) { - float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize}; - bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv); - readColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate); - color_accum += bokeh*readColor; - multiplier_accum += bokeh; - } + if (tempSize > threshold) { + if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) { + float2 uv = { 256.0f + dx * 255.0f / tempSize, 256.0f + dy * 255.0f / tempSize}; + bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv); + readColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate); + color_accum += bokeh*readColor; + multiplier_accum += bokeh; } } } } - } - } + } + } } color = color_accum * (1.0f / multiplier_accum); @@ -174,3 +191,44 @@ __kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2 float4 color = {value,0.0f,0.0f,0.0f}; write_imagef(output, coords, color); } + +// KERNEL --- DIRECTIONAL BLUR --- +__kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_only image2d_t output, + int2 offsetOutput, int iterations, float scale, float rotation, float2 translate, + float2 center, int2 offset) +{ + int2 coords = {get_global_id(0), get_global_id(1)}; + coords += offset; + const int2 realCoordinate = coords + offsetOutput; + + float4 col; + float2 ltxy = translate; + float lsc = scale; + float lrot = rotation; + + col = read_imagef(inputImage, SAMPLER_NEAREST, realCoordinate); + + /* blur the image */ + for (int i = 0; i < iterations; ++i) { + const float cs = cos(lrot), ss = sin(lrot); + const float isc = 1.0f / (1.0f + lsc); + + const float v = isc * (realCoordinate.s1 - center.s1) + ltxy.s1; + const float u = isc * (realCoordinate.s0 - center.s0) + ltxy.s0; + float2 uv = { + cs * u + ss * v + center.s0, + cs * v - ss * u + center.s1 + }; + + col += read_imagef(inputImage, SAMPLER_NEAREST_CLAMP, uv); + + /* double transformations */ + ltxy += translate; + lrot += rotation; + lsc += scale; + } + + col *= (1.0f/(iterations+1)); + + write_imagef(output, coords, col); +} diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h index ca66ab85802..cc18039c5b1 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h @@ -1,9 +1,32 @@ /* clkernelstoh output of file <COM_OpenCLKernels_cl> */ -const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all opencl kernels for node-operation implementations\n" \ +const char * clkernelstoh_COM_OpenCLKernels_cl = "/*\n" \ +" * Copyright 2011, Blender Foundation.\n" \ +" *\n" \ +" * This program is free software; you can redistribute it and/or\n" \ +" * modify it under the terms of the GNU General Public License\n" \ +" * as published by the Free Software Foundation; either version 2\n" \ +" * of the License, or (at your option) any later version.\n" \ +" *\n" \ +" * This program is distributed in the hope that it will be useful,\n" \ +" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \ +" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \ +" * GNU General Public License for more details.\n" \ +" *\n" \ +" * You should have received a copy of the GNU General Public License\n" \ +" * along with this program; if not, write to the Free Software Foundation,\n" \ +" * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" \ +" *\n" \ +" * Contributor:\n" \ +" * Jeroen Bakker\n" \ +" * Monique Dewanchand\n" \ +" */\n" \ +"\n" \ +"/// This file contains all opencl kernels for node-operation implementations\n" \ "\n" \ "// Global SAMPLERS\n" \ -"const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n" \ +"const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n" \ +"const sampler_t SAMPLER_NEAREST_CLAMP = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;\n" \ "\n" \ "__constant const int2 zero = {0,0};\n" \ "\n" \ @@ -23,7 +46,7 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope "\n" \ " tempBoundingBox = read_imagef(boundingBox, SAMPLER_NEAREST, coords).s0;\n" \ "\n" \ -" if (tempBoundingBox > 0.0f) {\n" \ +" if (tempBoundingBox > 0.0f && radius > 0 ) {\n" \ " const int2 bokehImageDim = get_image_dim(bokehImage);\n" \ " const int2 bokehImageCenter = bokehImageDim/2;\n" \ " const int2 minXY = max(realCoordinate - radius, zero);\n" \ @@ -55,7 +78,7 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope "\n" \ "//KERNEL --- DEFOCUS /VARIABLESIZEBOKEHBLUR ---\n" \ "__kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2d_t bokehImage,\n" \ -" __read_only image2d_t inputDepth, __read_only image2d_t inputSize,\n" \ +" __read_only image2d_t inputSize,\n" \ " __write_only image2d_t output, int2 offsetInput, int2 offsetOutput,\n" \ " int step, int maxBlur, float threshold, int2 dimension, int2 offset)\n" \ "{\n" \ @@ -67,7 +90,6 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " float4 readColor;\n" \ " float4 bokeh;\n" \ " float tempSize;\n" \ -" float tempDepth;\n" \ " float4 multiplier_accum = {1.0f, 1.0f, 1.0f, 1.0f};\n" \ " float4 color_accum;\n" \ "\n" \ @@ -79,29 +101,24 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " {\n" \ " int2 inputCoordinate = realCoordinate - offsetInput;\n" \ " float size = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ -" float depth = read_imagef(inputDepth, SAMPLER_NEAREST, inputCoordinate).s0 + threshold;\n" \ " color_accum = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);\n" \ "\n" \ -" for (int ny = miny; ny < maxy; ny += step) {\n" \ -" for (int nx = minx; nx < maxx; nx += step) {\n" \ -" if (nx >= 0 && nx < dimension.s0 && ny >= 0 && ny < dimension.s1) {\n" \ -" inputCoordinate.s0 = nx - offsetInput.s0;\n" \ -" inputCoordinate.s1 = ny - offsetInput.s1;\n" \ -" tempDepth = read_imagef(inputDepth, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ -" if (tempDepth < depth) {\n" \ +" if (size > threshold) {\n" \ +" for (int ny = miny; ny < maxy; ny += step) {\n" \ +" inputCoordinate.s1 = ny - offsetInput.s1;\n" \ +" float dy = ny - realCoordinate.s1;\n" \ +" for (int nx = minx; nx < maxx; nx += step) {\n" \ +" float dx = nx - realCoordinate.s0;\n" \ +" if (dx != 0 || dy != 0) {\n" \ +" inputCoordinate.s0 = nx - offsetInput.s0;\n" \ " tempSize = read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0;\n" \ -"\n" \ -" if ((size > threshold && tempSize > threshold) || tempSize <= threshold) {\n" \ -" float dx = nx - realCoordinate.s0;\n" \ -" float dy = ny - realCoordinate.s1;\n" \ -" if (dx != 0 || dy != 0) {\n" \ -" if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) {\n" \ -" float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize};\n" \ -" bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);\n" \ -" readColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);\n" \ -" color_accum += bokeh*readColor;\n" \ -" multiplier_accum += bokeh;\n" \ -" }\n" \ +" if (tempSize > threshold) {\n" \ +" if (tempSize >= fabs(dx) && tempSize >= fabs(dy)) {\n" \ +" float2 uv = { 256.0f + dx * 256.0f / tempSize, 256.0f + dy * 256.0f / tempSize};\n" \ +" bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);\n" \ +" readColor = read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate);\n" \ +" color_accum += bokeh*readColor;\n" \ +" multiplier_accum += bokeh;\n" \ " }\n" \ " }\n" \ " }\n" \ @@ -176,4 +193,45 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " float4 color = {value,0.0f,0.0f,0.0f};\n" \ " write_imagef(output, coords, color);\n" \ "}\n" \ +"\n" \ +"// KERNEL --- DIRECTIONAL BLUR ---\n" \ +"__kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_only image2d_t output,\n" \ +" int2 offsetOutput, int iterations, float scale, float rotation, float2 translate,\n" \ +" float2 center, int2 offset)\n" \ +"{\n" \ +" int2 coords = {get_global_id(0), get_global_id(1)};\n" \ +" coords += offset;\n" \ +" const int2 realCoordinate = coords + offsetOutput;\n" \ +"\n" \ +" float4 col;\n" \ +" float2 ltxy = translate;\n" \ +" float lsc = scale;\n" \ +" float lrot = rotation;\n" \ +"\n" \ +" col = read_imagef(inputImage, SAMPLER_NEAREST, realCoordinate);\n" \ +"\n" \ +" /* blur the image */\n" \ +" for (int i = 0; i < iterations; ++i) {\n" \ +" const float cs = cos(lrot), ss = sin(lrot);\n" \ +" const float isc = 1.0f / (1.0f + lsc);\n" \ +"\n" \ +" const float v = isc * (realCoordinate.s1 - center.s1) + ltxy.s1;\n" \ +" const float u = isc * (realCoordinate.s0 - center.s0) + ltxy.s0;\n" \ +" float2 uv = {\n" \ +" cs * u + ss * v + center.s0,\n" \ +" cs * v - ss * u + center.s1\n" \ +" };\n" \ +"\n" \ +" col += read_imagef(inputImage, SAMPLER_NEAREST_CLAMP, uv);\n" \ +"\n" \ +" /* double transformations */\n" \ +" ltxy += translate;\n" \ +" lrot += rotation;\n" \ +" lsc += scale;\n" \ +" }\n" \ +"\n" \ +" col *= (1.0f/(iterations+1));\n" \ +"\n" \ +" write_imagef(output, coords, col);\n" \ +"}\n" \ "\0"; diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index 087e7a15e39..83dae7475fb 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -59,7 +59,7 @@ static float *init_buffer(unsigned int width, unsigned int height, DataType data return NULL; } -static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bNodeTree *tree, +static void write_buffer_rect(rcti *rect, const bNodeTree *tree, SocketReader *reader, float *buffer, unsigned int width, DataType datatype) { float color[4]; @@ -77,7 +77,7 @@ static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bN for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2 && (!breaked); x++) { - reader->read(color, x, y, COM_PS_NEAREST, memoryBuffers); + reader->read(color, x, y, COM_PS_NEAREST); for (i = 0; i < size; ++i) buffer[offset + i] = color[i]; @@ -113,9 +113,9 @@ void OutputSingleLayerOperation::initExecution() this->m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_datatype); } -void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { - write_buffer_rect(rect, memoryBuffers, this->m_tree, this->m_imageInput, this->m_outputBuffer, this->getWidth(), this->m_datatype); + write_buffer_rect(rect, this->m_tree, this->m_imageInput, this->m_outputBuffer, this->getWidth(), this->m_datatype); } void OutputSingleLayerOperation::deinitExecution() @@ -183,10 +183,10 @@ void OutputOpenExrMultiLayerOperation::initExecution() } } -void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { for (unsigned int i = 0; i < this->m_layers.size(); ++i) { - write_buffer_rect(rect, memoryBuffers, this->m_tree, this->m_layers[i].imageInput, this->m_layers[i].outputBuffer, this->getWidth(), this->m_layers[i].datatype); + write_buffer_rect(rect, this->m_tree, this->m_layers[i].imageInput, this->m_layers[i].outputBuffer, this->getWidth(), this->m_layers[i].datatype); } } diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h index 60244a8bf72..0d6e5bfa61a 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileOperation.h @@ -45,7 +45,7 @@ private: public: OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); @@ -79,7 +79,7 @@ public: void add_layer(const char *name, DataType datatype); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index 55e94568688..8008c95c734 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -79,7 +79,7 @@ void PreviewOperation::deinitExecution() this->m_input = NULL; } -void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber) { int offset; float color[4]; @@ -93,7 +93,7 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, Memory color[1] = 0.0f; color[2] = 0.0f; color[3] = 1.0f; - this->m_input->read(color, rx, ry, COM_PS_NEAREST, memoryBuffers); + this->m_input->read(color, rx, ry, COM_PS_NEAREST); linearrgb_to_srgb_v4(color, color); F4TOCHAR4(color, this->m_outputBuffer + offset); offset += 4; diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h index e7b8ba55ae0..7183ea64fff 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.h +++ b/source/blender/compositor/operations/COM_PreviewOperation.h @@ -44,7 +44,7 @@ public: void deinitExecution(); const CompositorPriority getRenderPriority() const; - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); void setbNode(bNode *node) { this->m_node = node; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index 12674153bc8..daf517876e5 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -40,14 +40,14 @@ void ProjectorLensDistortionOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void *ProjectorLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *ProjectorLensDistortionOperation::initializeTileData(rcti *rect) { - updateDispersion(memoryBuffers); - void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); + updateDispersion(); + void *buffer = this->m_inputProgram->initializeTileData(NULL); return buffer; } -void ProjectorLensDistortionOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void ProjectorLensDistortionOperation::executePixel(float *color, int x, int y, void *data) { float inputValue[4]; const float height = this->getHeight(); @@ -87,13 +87,13 @@ bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *in return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } -void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuffers) +void ProjectorLensDistortionOperation::updateDispersion() { if (this->m_dispersionAvailable) return; this->lockMutex(); if (!this->m_dispersionAvailable) { float result[4]; - this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST); this->m_dispersion = result[0]; this->m_kr = 0.25f * MAX2(MIN2(this->m_dispersion, 1.f), 0.f); this->m_kr2 = this->m_kr * 20; diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h index c658d66429a..ac64b35ed32 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h @@ -44,14 +44,14 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * Deinitialize the execution */ @@ -61,7 +61,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void updateDispersion(MemoryBuffer **inputBuffers); + void updateDispersion(); }; #endif diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index 76e6921503e..2473ad8303e 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -28,11 +28,12 @@ ReadBufferOperation::ReadBufferOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); this->m_offset = 0; + this->m_buffer = NULL; } -void *ReadBufferOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *ReadBufferOperation::initializeTileData(rcti *rect) { - return getInputMemoryBuffer(memoryBuffers); + return m_buffer; } void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -48,38 +49,25 @@ void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigne } } } -void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { - if (inputBuffers) { - MemoryBuffer *inputBuffer = inputBuffers[this->m_offset]; - if (inputBuffer) { - if (sampler == COM_PS_NEAREST) { - inputBuffer->read(color, x, y); - } - else { - inputBuffer->readCubic(color, x, y); - } - } - } else { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.0f; + if (sampler == COM_PS_NEAREST) { + m_buffer->read(color, x, y); + } + else { + m_buffer->readCubic(color, x, y); } } -void ReadBufferOperation::executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) +void ReadBufferOperation::executePixel(float *color, float x, float y, float dx, float dy) { - MemoryBuffer *inputBuffer = inputBuffers[this->m_offset]; - if (inputBuffer) { - inputBuffer->readEWA(color, x, y, dx, dy); - } + m_buffer->readEWA(color, x, y, dx, dy); } bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { if (this == readOperation) { - BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax); + BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax); return true; } return false; @@ -93,3 +81,9 @@ void ReadBufferOperation::readResolutionFromWriteBuffer() this->setHeight(operation->getHeight()); } } + +void ReadBufferOperation::updateMemoryBuffer() +{ + this->m_buffer = this->getMemoryProxy()->getBuffer(); + +} diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h index de0c69c0ecc..f52b732b076 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.h +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h @@ -30,6 +30,7 @@ class ReadBufferOperation : public NodeOperation { private: MemoryProxy *m_memoryProxy; unsigned int m_offset; + MemoryBuffer *m_buffer; public: ReadBufferOperation(); int isBufferOperation() { return true; } @@ -37,15 +38,16 @@ public: MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; } void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); - void executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer * inputBuffers[]); + void *initializeTileData(rcti *rect); + void executePixel(float *color, float x, float y, PixelSampler sampler); + void executePixel(float *color, float x, float y, float dx, float dy); const bool isReadBufferOperation() const { return true; } void setOffset(unsigned int offset) { this->m_offset = offset; } unsigned int getOffset() { return this->m_offset; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return memoryBuffers[this->m_offset]; } void readResolutionFromWriteBuffer(); + void updateMemoryBuffer(); }; #endif diff --git a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp index 35f787cb59f..908c3d11b06 100644 --- a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp @@ -27,7 +27,7 @@ RenderLayersAlphaProg::RenderLayersAlphaProg() : RenderLayersBaseProg(SCE_PASS_C this->addOutputSocket(COM_DT_VALUE); } -void RenderLayersAlphaProg::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void RenderLayersAlphaProg::executePixel(float *output, float x, float y, PixelSampler sampler) { int ix = x; int iy = y; diff --git a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h index 846e337c572..1733f3bd3ba 100644 --- a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h @@ -28,7 +28,7 @@ class RenderLayersAlphaProg : public RenderLayersBaseProg { public: RenderLayersAlphaProg(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp index e4543c06d9b..a036e8e7231 100644 --- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp @@ -69,7 +69,7 @@ void RenderLayersBaseProg::initExecution() } } -void RenderLayersBaseProg::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void RenderLayersBaseProg::executePixel(float *output, float x, float y, PixelSampler sampler) { int ix = x; int iy = y; diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h index a18b515bd7b..ead1eb183b3 100644 --- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h @@ -92,7 +92,7 @@ public: short getLayerId() { return this->m_layerId; } void initExecution(); void deinitExecution(); - void executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); + void executePixel(float *output, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp index 086ce917e7e..a39828e4560 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cpp +++ b/source/blender/compositor/operations/COM_RotateOperation.cpp @@ -52,7 +52,7 @@ inline void RotateOperation::ensureDegree() { if (!this->m_isDegreeSet) { float degree[4]; - this->m_degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); + this->m_degreeSocket->read(degree, 0, 0, COM_PS_NEAREST); double rad; if (this->m_doDegree2RadConversion) { rad = DEG2RAD((double)degree[0]); @@ -68,14 +68,14 @@ inline void RotateOperation::ensureDegree() } -void RotateOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void RotateOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { ensureDegree(); const float dy = y - this->m_centerY; const float dx = x - this->m_centerX; const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy); const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy); - this->m_imageSocket->read(color, nx, ny, sampler, inputBuffers); + this->m_imageSocket->read(color, nx, ny, sampler); } bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h index 9e6dd3987d1..d011ac0ecc9 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.h +++ b/source/blender/compositor/operations/COM_RotateOperation.h @@ -38,7 +38,7 @@ private: public: RotateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); void setDoDegree2RadConversion(bool abool) { this->m_doDegree2RadConversion = abool; } diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp index 6a1f7b62203..f4a3dc5fa25 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.cpp +++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp @@ -54,7 +54,7 @@ void ScaleOperation::deinitExecution() } -void ScaleOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ScaleOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { #ifdef USE_FORCE_BICUBIC sampler = COM_PS_BICUBIC; @@ -63,15 +63,15 @@ void ScaleOperation::executePixel(float *color, float x, float y, PixelSampler s float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, x, y, sampler, inputBuffers); - this->m_inputYOperation->read(scaleY, x, y, sampler, inputBuffers); + this->m_inputXOperation->read(scaleX, x, y, sampler); + this->m_inputYOperation->read(scaleY, x, y, sampler); const float scx = scaleX[0]; const float scy = scaleY[0]; float nx = this->m_centerX + (x - this->m_centerX) / scx; float ny = this->m_centerY + (y - this->m_centerY) / scy; - this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); + this->m_inputOperation->read(color, nx, ny, sampler); } bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -80,8 +80,8 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); - this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST); + this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST); const float scx = scaleX[0]; const float scy = scaleY[0]; @@ -124,7 +124,7 @@ void ScaleAbsoluteOperation::deinitExecution() } -void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { #ifdef USE_FORCE_BICUBIC sampler = COM_PS_BICUBIC; @@ -133,8 +133,8 @@ void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelS float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, x, y, sampler, inputBuffers); - this->m_inputYOperation->read(scaleY, x, y, sampler, inputBuffers); + this->m_inputXOperation->read(scaleX, x, y, sampler); + this->m_inputYOperation->read(scaleY, x, y, sampler); const float scx = scaleX[0]; // target absolute scale const float scy = scaleY[0]; // target absolute scale @@ -148,7 +148,7 @@ void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelS float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale; float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale; - this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); + this->m_inputOperation->read(color, nx, ny, sampler); } bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -157,8 +157,8 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); - this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST); + this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST); const float scx = scaleX[0]; const float scy = scaleY[0]; @@ -244,7 +244,7 @@ void ScaleFixedSizeOperation::deinitExecution() } -void ScaleFixedSizeOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ScaleFixedSizeOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { #ifdef USE_FORCE_BICUBIC sampler = COM_PS_BICUBIC; @@ -253,10 +253,10 @@ void ScaleFixedSizeOperation::executePixel(float *color, float x, float y, Pixel if (this->m_is_offset) { float nx = ((x - this->m_offsetX) * this->m_relX); float ny = ((y - this->m_offsetY) * this->m_relY); - this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); + this->m_inputOperation->read(color, nx, ny, sampler); } else { - this->m_inputOperation->read(color, x * this->m_relX, y * this->m_relY, sampler, inputBuffers); + this->m_inputOperation->read(color, x * this->m_relX, y * this->m_relY, sampler); } } diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h index 8cd44810bbd..075fb6e7064 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.h +++ b/source/blender/compositor/operations/COM_ScaleOperation.h @@ -35,7 +35,7 @@ private: public: ScaleOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); @@ -51,7 +51,7 @@ class ScaleAbsoluteOperation : public NodeOperation { public: ScaleAbsoluteOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); @@ -76,7 +76,7 @@ public: ScaleFixedSizeOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index e70185f8fba..d431ce29554 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -48,14 +48,14 @@ void ScreenLensDistortionOperation::initExecution() } -void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *ScreenLensDistortionOperation::initializeTileData(rcti *rect) { - void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); - updateDispersionAndDistortion(memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL); + updateDispersionAndDistortion(); return buffer; } -void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int y, void *data) { const float height = this->getHeight(); const float width = this->getWidth(); @@ -316,16 +316,16 @@ void ScreenLensDistortionOperation::updateVariables(float distortion, float disp this->m_kb4 = this->m_kb * 4.0f; } -void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers) +void ScreenLensDistortionOperation::updateDispersionAndDistortion() { if (this->m_valuesAvailable) return; this->lockMutex(); if (!this->m_valuesAvailable) { float result[4]; - this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST); this->m_distortion = result[0]; - this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST); this->m_dispersion = result[0]; updateVariables(this->m_distortion, this->m_dispersion); this->m_valuesAvailable = true; diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h index f80b938818c..a88717a116e 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h @@ -49,14 +49,14 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); /** * Deinitialize the execution */ @@ -81,7 +81,7 @@ public: private: void determineUV(float result[4], float x, float y) const; void determineUV(float result[4], float x, float y, float distortion, float dispersion); - void updateDispersionAndDistortion(MemoryBuffer **inputBuffers); + void updateDispersionAndDistortion(); void updateVariables(float distortion, float dispersion); }; diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp index 6ae4fc4cfe5..0b080dcc426 100644 --- a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp +++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp @@ -39,9 +39,9 @@ void SeparateChannelOperation::deinitExecution() } -void SeparateChannelOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void SeparateChannelOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float input[4]; - this->m_inputOperation->read(input, x, y, sampler, inputBuffers); + this->m_inputOperation->read(input, x, y, sampler); color[0] = input[this->m_channel]; } diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.h b/source/blender/compositor/operations/COM_SeparateChannelOperation.h index 65a54f91252..01fee3ca57d 100644 --- a/source/blender/compositor/operations/COM_SeparateChannelOperation.h +++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.h @@ -31,7 +31,7 @@ private: int m_channel; public: SeparateChannelOperation(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp index d383fb638ae..0f707473f9d 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp @@ -38,12 +38,12 @@ void SetAlphaOperation::initExecution() this->m_inputAlpha = getInputSocketReader(1); } -void SetAlphaOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void SetAlphaOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float alphaInput[4]; - this->m_inputColor->read(outputValue, x, y, sampler, inputBuffers); - this->m_inputAlpha->read(alphaInput, x, y, sampler, inputBuffers); + this->m_inputColor->read(outputValue, x, y, sampler); + this->m_inputAlpha->read(alphaInput, x, y, sampler); outputValue[3] = alphaInput[0]; } diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h index 21968c930e7..3d8eb5b9493 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.h +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h @@ -43,7 +43,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp index 55a6a3800ca..0665073840c 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp @@ -27,7 +27,7 @@ SetColorOperation::SetColorOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); } -void SetColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void SetColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { outputValue[0] = this->m_channel1; outputValue[1] = this->m_channel2; diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h index a51311837ee..72708800f1e 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.h +++ b/source/blender/compositor/operations/COM_SetColorOperation.h @@ -61,7 +61,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); const bool isSetOperation() const { return true; } diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp index c235bd81e58..f7c1ef8f6f5 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp @@ -37,7 +37,7 @@ void SetSamplerOperation::deinitExecution() this->m_reader = NULL; } -void SetSamplerOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void SetSamplerOperation::executePixel(float *output, float x, float y, PixelSampler sampler) { - this->m_reader->read(output, x, y, this->m_sampler, inputBuffers); + this->m_reader->read(output, x, y, this->m_sampler); } diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h index 273eac159bc..7b53cd8d38e 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.h +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); }; diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp index 98a21112c5b..d88257226f5 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.cpp +++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp @@ -27,7 +27,7 @@ SetValueOperation::SetValueOperation() : NodeOperation() this->addOutputSocket(COM_DT_VALUE); } -void SetValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void SetValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { outputValue[0] = this->m_value; } diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h index 642940e03cd..a2c3e8eaa0b 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.h +++ b/source/blender/compositor/operations/COM_SetValueOperation.h @@ -46,7 +46,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); const bool isSetOperation() const { return true; } diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp index f37bc489e75..651add0453f 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp @@ -28,7 +28,7 @@ SetVectorOperation::SetVectorOperation() : NodeOperation() this->addOutputSocket(COM_DT_VECTOR); } -void SetVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void SetVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { outputValue[0] = this->m_x; outputValue[1] = this->m_y; diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h index d1b9fe25085..0868213a109 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.h +++ b/source/blender/compositor/operations/COM_SetVectorOperation.h @@ -54,7 +54,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); const bool isSetOperation() const { return true; } diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp index 8b39406fd83..0e670d9268e 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp @@ -39,9 +39,9 @@ void SocketProxyOperation::deinitExecution() this->m_inputOperation = NULL; } -void SocketProxyOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void SocketProxyOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { if (this->m_inputOperation) { - this->m_inputOperation->read(color, x, y, sampler, inputBuffers); + this->m_inputOperation->read(color, x, y, sampler); } } diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h index a4177efbd8e..219483aa92d 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.h +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h @@ -30,7 +30,7 @@ private: SocketReader *m_inputOperation; public: SocketProxyOperation(DataType type); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp index 00f854b2ba9..80de4e71fce 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp @@ -60,7 +60,7 @@ void SplitViewerOperation::deinitExecution() } -void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float *buffer = this->m_outputBuffer; unsigned char *bufferDisplay = this->m_outputBufferDisplay; @@ -80,10 +80,10 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me float srgb[4]; image1 = this->m_xSplit ? x > perc : y > perc; if (image1) { - this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST); } else { - this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + 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) { diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.h b/source/blender/compositor/operations/COM_SplitViewerOperation.h index 92275606105..c759e14e1dd 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.h +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.h @@ -35,7 +35,7 @@ private: bool m_xSplit; public: SplitViewerOperation(); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void initExecution(); void deinitExecution(); void setSplitPercentage(float splitPercentage) { this->m_splitPercentage = splitPercentage; } diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp index 6098cfc3e5c..4cf935799cb 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cpp +++ b/source/blender/compositor/operations/COM_TextureOperation.cpp @@ -68,16 +68,16 @@ void TextureBaseOperation::determineResolution(unsigned int resolution[], unsign } } -void TextureAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void TextureAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { - TextureBaseOperation::executePixel(color, x, y, sampler, inputBuffers); + TextureBaseOperation::executePixel(color, x, y, sampler); color[0] = color[3]; color[1] = 0.0f; color[2] = 0.0f; color[3] = 0.0f; } -void TextureBaseOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void TextureBaseOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; float textureSize[4]; @@ -89,8 +89,8 @@ void TextureBaseOperation::executePixel(float *color, float x, float y, PixelSam const float u = (cx - x) / this->getWidth() * 2; const float v = (cy - y) / this->getHeight() * 2; - this->m_inputSize->read(textureSize, x, y, sampler, inputBuffers); - this->m_inputOffset->read(textureOffset, x, y, sampler, inputBuffers); + this->m_inputSize->read(textureSize, x, y, sampler); + this->m_inputOffset->read(textureOffset, x, y, sampler); vec[0] = textureSize[0] * (u + textureOffset[0]); vec[1] = textureSize[1] * (v + textureOffset[1]); diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h index d42da697b08..8735aff19dc 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.h +++ b/source/blender/compositor/operations/COM_TextureOperation.h @@ -60,7 +60,7 @@ protected: TextureBaseOperation(); public: - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void setTexture(Tex *texture) { this->m_texture = texture; } void initExecution(); @@ -76,7 +76,7 @@ public: class TextureAlphaOperation : public TextureBaseOperation { public: TextureAlphaOperation(); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp index b5daf85b390..0dc30ebfcb9 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.cpp +++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp @@ -41,12 +41,12 @@ void TonemapOperation::initExecution() NodeOperation::initMutex(); } -void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void TonemapOperation::executePixel(float *color, int x, int y, void *data) { AvgLogLum *avg = (AvgLogLum *)data; float output[4]; - this->m_imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, NULL); mul_v3_fl(output, avg->al); float dr = output[0] + this->m_data->offset; float dg = output[1] + this->m_data->offset; @@ -63,7 +63,7 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in copy_v4_v4(color, output); } -void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, void *data) { AvgLogLum *avg = (AvgLogLum *)data; NodeTonemap *ntm = this->m_data; @@ -73,7 +73,7 @@ void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, Mem const float ic = 1.0f - ntm->c, ia = 1.0f - ntm->a; float output[4]; - this->m_imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, NULL); const float L = rgb_to_luma_y(output); float I_l = output[0] + ic * (L - output[0]); @@ -116,11 +116,11 @@ bool TonemapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferO return false; } -void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *TonemapOperation::initializeTileData(rcti *rect) { lockMutex(); if (this->m_cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect); AvgLogLum *data = new AvgLogLum(); float *buffer = tile->getBuffer(); @@ -154,7 +154,7 @@ void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuff return this->m_cachedInstance; } -void TonemapOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +void TonemapOperation::deinitializeTileData(rcti *rect, void *data) { /* pass */ } diff --git a/source/blender/compositor/operations/COM_TonemapOperation.h b/source/blender/compositor/operations/COM_TonemapOperation.h index ed9018d0a09..4e591276c76 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.h +++ b/source/blender/compositor/operations/COM_TonemapOperation.h @@ -64,15 +64,15 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + void *initializeTileData(rcti *rect); + void deinitializeTileData(rcti *rect, void *data); /** * Deinitialize the execution @@ -97,7 +97,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); }; #endif diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp new file mode 100644 index 00000000000..cf516401a3c --- /dev/null +++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp @@ -0,0 +1,100 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Sergey Sharybin + */ + +#include "COM_TrackPositionOperation.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_math_color.h" + +#include "DNA_scene_types.h" + +extern "C" { + #include "BKE_movieclip.h" + #include "BKE_tracking.h" +} + +TrackPositionOperation::TrackPositionOperation() : NodeOperation() +{ + this->addOutputSocket(COM_DT_VALUE); + this->movieClip = NULL; + this->framenumber = 0; + this->trackingObject[0] = 0; + this->trackName[0] = 0; + this->axis = 0; + this->relative = false; +} + +void TrackPositionOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +{ + MovieClipUser user = {0}; + MovieTracking *tracking = &movieClip->tracking; + MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->trackingObject); + MovieTrackingTrack *track; + MovieTrackingMarker *marker; + int width, height; + + outputValue[0] = 0.0f; + + if (!object) + return; + + track = BKE_tracking_track_get_named(tracking, object, this->trackName); + + if (!track) + return; + + BKE_movieclip_user_set_frame(&user, this->framenumber); + BKE_movieclip_get_size(this->movieClip, &user, &width, &height); + + marker = BKE_tracking_marker_get(track, this->framenumber); + + outputValue[0] = marker->pos[this->axis]; + + if (this->relative) { + int i; + + for (i = 0; i < track->markersnr; i++) { + marker = &track->markers[i]; + + if ((marker->flag & MARKER_DISABLED) == 0) { + outputValue[0] -= marker->pos[this->axis]; + + break; + } + } + } + + if (this->axis == 0) + outputValue[0] *= width; + else + outputValue[0] *= height; +} + +void TrackPositionOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) +{ + resolution[0] = preferredResolution[0]; + resolution[1] = preferredResolution[1]; +} diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.h b/source/blender/compositor/operations/COM_TrackPositionOperation.h new file mode 100644 index 00000000000..caf444db0d5 --- /dev/null +++ b/source/blender/compositor/operations/COM_TrackPositionOperation.h @@ -0,0 +1,69 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Sergey Sharybin + */ + + +#ifndef _COM_TrackPositionOperation_h +#define _COM_TrackPositionOperation_h + +#include <string.h> + +#include "COM_NodeOperation.h" + +#include "DNA_scene_types.h" +#include "DNA_movieclip_types.h" + +#include "BLI_listbase.h" + +/** + * Class with implementation of green screen gradient rasterization + */ +class TrackPositionOperation : public NodeOperation { +protected: + MovieClip *movieClip; + int framenumber; + char trackingObject[64]; + char trackName[64]; + int axis; + bool relative; + + /** + * Determine the output resolution. The resolution is retrieved from the Renderer + */ + void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); + +public: + TrackPositionOperation(); + + void setMovieClip(MovieClip *clip) {this->movieClip = clip;} + void setTrackingObject(char *object) {strncpy(this->trackingObject, object, sizeof(this->trackingObject));} + void setTrackName(char *track) {strncpy(this->trackName, track, sizeof(this->trackName));} + void setFramenumber(int framenumber) {this->framenumber = framenumber;} + void setAxis(int value) {this->axis = value;} + void setRelative(bool value) {this->relative = value;} + + void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + + const bool isSetOperation() const { return true; } +}; + +#endif diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp index e43a8e55130..fda50ac24d1 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.cpp +++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp @@ -50,10 +50,10 @@ void TranslateOperation::deinitExecution() } -void TranslateOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void TranslateOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { ensureDelta(); - this->m_inputOperation->read(color, x - this->getDeltaX(), y - this->getDeltaY(), sampler, inputBuffers); + this->m_inputOperation->read(color, x - this->getDeltaX(), y - this->getDeltaY(), sampler); } bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h index 8af4ffe8967..83e3befdfeb 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.h +++ b/source/blender/compositor/operations/COM_TranslateOperation.h @@ -36,7 +36,7 @@ private: public: TranslateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); @@ -47,9 +47,9 @@ public: inline void ensureDelta() { if (!this->m_isDeltaSet) { float tempDelta[4]; - this->m_inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST); this->m_deltaX = tempDelta[0]; - this->m_inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST); this->m_deltaY = tempDelta[0]; this->m_isDeltaSet = true; } diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 7ddcb78b61f..8faa571dc38 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -33,7 +33,6 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image. this->addInputSocket(COM_DT_VALUE); // radius - this->addInputSocket(COM_DT_VALUE); // depth #ifdef COM_DEFOCUS_SEARCH this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // inverse search radius optimization structure. #endif @@ -44,7 +43,6 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->m_inputProgram = NULL; this->m_inputBokehProgram = NULL; this->m_inputSizeProgram = NULL; - this->m_inputDepthProgram = NULL; this->m_maxBlur = 32.0f; this->m_threshold = 1.0f; #ifdef COM_DEFOCUS_SEARCH @@ -58,25 +56,44 @@ void VariableSizeBokehBlurOperation::initExecution() this->m_inputProgram = getInputSocketReader(0); this->m_inputBokehProgram = getInputSocketReader(1); this->m_inputSizeProgram = getInputSocketReader(2); - this->m_inputDepthProgram = getInputSocketReader(3); #ifdef COM_DEFOCUS_SEARCH - this->m_inputSearchProgram = getInputSocketReader(4); + this->m_inputSearchProgram = getInputSocketReader(3); #endif QualityStepHelper::initExecution(COM_QH_INCREASE); } -void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void *VariableSizeBokehBlurOperation::initializeTileData(rcti *rect) { + MemoryBuffer** result = new MemoryBuffer*[3]; + result[0] = (MemoryBuffer*)this->m_inputProgram->initializeTileData(rect); + result[1] = (MemoryBuffer*)this->m_inputBokehProgram->initializeTileData(rect); + result[2] = (MemoryBuffer*)this->m_inputSizeProgram->initializeTileData(rect); + return result; +} + +void VariableSizeBokehBlurOperation::deinitializeTileData(rcti *rect, void *data) +{ + MemoryBuffer** result = (MemoryBuffer**)data; + delete[] result; +} + +void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, void *data) +{ + MemoryBuffer** buffers = (MemoryBuffer**)data; + MemoryBuffer* inputProgramBuffer = buffers[0]; + MemoryBuffer* inputBokehBuffer = buffers[1]; + MemoryBuffer* inputSizeBuffer = buffers[2]; + float* inputSizeFloatBuffer = inputSizeBuffer->getBuffer(); + float* inputProgramFloatBuffer = inputProgramBuffer->getBuffer(); float readColor[4]; float bokeh[4]; float tempSize[4]; - float tempDepth[4]; float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; #ifdef COM_DEFOCUS_SEARCH float search[4]; - this->inputSearchProgram->read(search, x/InverseSearchRadiusOperation::DIVIDER, y / InverseSearchRadiusOperation::DIVIDER, inputBuffers, NULL); + this->m_inputSearchProgram->read(search, x/InverseSearchRadiusOperation::DIVIDER, y / InverseSearchRadiusOperation::DIVIDER, NULL); int minx = search[0]; int miny = search[1]; int maxx = search[2]; @@ -88,73 +105,71 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me int maxy = MIN2(y + this->m_maxBlur, m_height); #endif { - this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); - this->m_inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); - this->m_inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); + inputSizeBuffer->readNoCheck(tempSize, x, y); + inputProgramBuffer->readNoCheck(readColor, x, y); + add_v4_v4(color_accum, readColor); add_v4_fl(multiplier_accum, 1.0f); float sizeCenter = tempSize[0]; - float centerDepth = tempDepth[0] + this->m_threshold; - for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) { - for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { - if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { - this->m_inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); - if (tempDepth[0] < centerDepth) { - this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); - float size = tempSize[0]; - if ((sizeCenter > this->m_threshold && size > this->m_threshold) || size <= this->m_threshold) { + const int addXStep = QualityStepHelper::getStep()*COM_NUMBER_OF_CHANNELS; + + if (sizeCenter > this->m_threshold) { + for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) { + float dy = ny - y; + int offsetNy = ny * inputSizeBuffer->getWidth() * COM_NUMBER_OF_CHANNELS; + int offsetNxNy = offsetNy + (minx*COM_NUMBER_OF_CHANNELS); + for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { + if (nx != x || ny != y) + { + float size = inputSizeFloatBuffer[offsetNxNy]; + if (size > this->m_threshold) { + float fsize = fabsf(size); float dx = nx - x; - float dy = ny - y; - if (nx == x && ny == y) { - } - else if (size >= fabsf(dx) && size >= fabsf(dy)) { - float u = 256 + dx * 256 / size; - float v = 256 + dy * 256 / size; - this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - this->m_inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); - madd_v4_v4v4(color_accum, bokeh, readColor); + if (fsize > fabsf(dx) && fsize > fabsf(dy)) { + float u = (256.0f + (dx/size) * 255.0f); + float v = (256.0f + (dy/size) * 255.0f); + inputBokehBuffer->readNoCheck(bokeh, u, v); + madd_v4_v4v4(color_accum, bokeh, &inputProgramFloatBuffer[offsetNxNy]); add_v4_v4(multiplier_accum, bokeh); } } } + offsetNxNy += addXStep; } } } - color[0] = color_accum[0] * (1.0f / multiplier_accum[0]); - color[1] = color_accum[1] * (1.0f / multiplier_accum[1]); - color[2] = color_accum[2] * (1.0f / multiplier_accum[2]); - color[3] = color_accum[3] * (1.0f / multiplier_accum[3]); + color[0] = color_accum[0] / multiplier_accum[0]; + color[1] = color_accum[1] / multiplier_accum[1]; + color[2] = color_accum[2] / multiplier_accum[2]; + color[3] = color_accum[3] / multiplier_accum[3]; } } -static cl_kernel defocusKernel = 0; void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { - if (!defocusKernel) { - defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL); - } + cl_kernel defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL); + cl_int step = this->getStep(); cl_int maxBlur = this->m_maxBlur; cl_float threshold = this->m_threshold; device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram); - device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 2, 5, clMemToCleanUp, inputMemoryBuffers, this->m_inputDepthProgram); - device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 3, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputSizeProgram); - device->COM_clAttachOutputMemoryBufferToKernelParameter(defocusKernel, 4, clOutputBuffer); - device->COM_clAttachMemoryBufferOffsetToKernelParameter(defocusKernel, 6, outputMemoryBuffer); - clSetKernelArg(defocusKernel, 7, sizeof(cl_int), &step); - clSetKernelArg(defocusKernel, 8, sizeof(cl_int), &maxBlur); - clSetKernelArg(defocusKernel, 9, sizeof(cl_float), &threshold); - device->COM_clAttachSizeToKernelParameter(defocusKernel, 10, this); + device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 2, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputSizeProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(defocusKernel, 3, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(defocusKernel, 5, outputMemoryBuffer); + clSetKernelArg(defocusKernel, 6, sizeof(cl_int), &step); + clSetKernelArg(defocusKernel, 7, sizeof(cl_int), &maxBlur); + clSetKernelArg(defocusKernel, 8, sizeof(cl_float), &threshold); + device->COM_clAttachSizeToKernelParameter(defocusKernel, 9, this); - device->COM_clEnqueueRange(defocusKernel, outputMemoryBuffer, 11, this); + device->COM_clEnqueueRange(defocusKernel, outputMemoryBuffer, 10, this); } void VariableSizeBokehBlurOperation::deinitExecution() @@ -162,7 +177,6 @@ void VariableSizeBokehBlurOperation::deinitExecution() this->m_inputProgram = NULL; this->m_inputBokehProgram = NULL; this->m_inputSizeProgram = NULL; - this->m_inputDepthProgram = NULL; #ifdef COM_DEFOCUS_SEARCH this->m_inputSearchProgram = NULL; #endif @@ -191,17 +205,13 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) { return true; } - operation = getInputOperation(3); - if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { - return true; - } #ifdef COM_DEFOCUS_SEARCH rcti searchInput; searchInput.xmax = (input->xmax / InverseSearchRadiusOperation::DIVIDER) + 1; searchInput.xmin = (input->xmin / InverseSearchRadiusOperation::DIVIDER) - 1; searchInput.ymax = (input->ymax / InverseSearchRadiusOperation::DIVIDER) + 1; searchInput.ymin = (input->ymin / InverseSearchRadiusOperation::DIVIDER) - 1; - operation = getInputOperation(4); + operation = getInputOperation(3); if (operation->determineDependingAreaOfInterest(&searchInput, readOperation, output) ) { return true; } @@ -218,68 +228,77 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu InverseSearchRadiusOperation::InverseSearchRadiusOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius - this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // depth this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputRadius = NULL; - this->inputDepth = NULL; + this->m_inputRadius = NULL; } void InverseSearchRadiusOperation::initExecution() { - this->inputRadius = this->getInputSocketReader(0); - this->inputDepth = this->getInputSocketReader(1); + this->m_inputRadius = this->getInputSocketReader(0); } -void* InverseSearchRadiusOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void* InverseSearchRadiusOperation::initializeTileData(rcti *rect) { MemoryBuffer * data = new MemoryBuffer(NULL, rect); + float* buffer = data->getBuffer(); int x, y; - float width = this->inputRadius->getWidth(); - float height = this->inputRadius->getHeight(); - - for (x = rect->xmin; x < rect->xmax ; x++) { - for (y = rect->ymin; y < rect->ymax ; y++) { - float[4] temp; + int width = this->m_inputRadius->getWidth(); + int height = this->m_inputRadius->getHeight(); + float temp[4]; + int offset = 0; + for (y = rect->ymin; y < rect->ymax ; y++) { + for (x = rect->xmin; x < rect->xmax ; x++) { int rx = x * DIVIDER; int ry = y * DIVIDER; - this->inputRadius->read(temp, rx, ry, memoryBuffers, NULL); - float centerRadius = temp[0]; - this->inputDepth->read(temp, rx, ry, memoryBuffers, NULL); - float centerDepth = temp[0]; - t[0] = MAX2(rx - this->maxBlur, 0.0f); - t[1] = MAX2(ry - this->maxBlur, 0.0f); - t[2] = MIN2(rx + this->maxBlur, width); - t[3] = MIN2(ry + this->maxBlur, height); - int minx = t[0]; - int miny = t[1]; - int maxx = t[2]; - int maxy = t[3]; - int sminx = rx; - int smaxx = rx; - int sminy = ry; - int smaxy = ry; - for (int nx = minx ; nx < maxx ; nx ++) { - for (int ny = miny ; ny < maxy ; ny ++) { - this->inputRadius->read(temp, nx, ny, memoryBuffers, NULL); - if (nx < rx && temp[0]) - - } - } - float t[4]; - data->writePixel(x, y, t); + buffer[offset] = MAX2(rx - m_maxBlur, 0); + buffer[offset+1] = MAX2(ry- m_maxBlur, 0); + buffer[offset+2] = MIN2(rx+DIVIDER + m_maxBlur, width); + buffer[offset+3] = MIN2(ry+DIVIDER + m_maxBlur, height); + offset += 4; } } +// for (x = rect->xmin; x < rect->xmax ; x++) { +// for (y = rect->ymin; y < rect->ymax ; y++) { +// int rx = x * DIVIDER; +// int ry = y * DIVIDER; +// float radius = 0.0f; +// float maxx = x; +// float maxy = y; + +// for (int x2 = 0 ; x2 < DIVIDER ; x2 ++) { +// for (int y2 = 0 ; y2 < DIVIDER ; y2 ++) { +// this->m_inputRadius->read(temp, rx+x2, ry+y2, COM_PS_NEAREST); +// if (radius < temp[0]) { +// radius = temp[0]; +// maxx = x2; +// maxy = y2; +// } +// } +// } +// int impactRadius = ceil(radius / DIVIDER); +// for (int x2 = x - impactRadius ; x2 < x + impactRadius ; x2 ++) { +// for (int y2 = y - impactRadius ; y2 < y + impactRadius ; y2 ++) { +// data->read(temp, x2, y2); +// temp[0] = MIN2(temp[0], maxx); +// temp[1] = MIN2(temp[1], maxy); +// temp[2] = MAX2(temp[2], maxx); +// temp[3] = MAX2(temp[3], maxy); +// data->writePixel(x2, y2, temp); +// } +// } +// } +// } return data; } -void InverseSearchRadiusOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void InverseSearchRadiusOperation::executePixel(float *color, int x, int y, void *data) { MemoryBuffer *buffer = (MemoryBuffer*)data; - buffer->read(color, x, y); + buffer->readNoCheck(color, x, y); } -void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, void *data) { if (data) { MemoryBuffer* mb = (MemoryBuffer*)data; @@ -289,8 +308,7 @@ void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, MemoryBuffer void InverseSearchRadiusOperation::deinitExecution() { - this->inputRadius = NULL; - this->inputDepth = NULL; + this->m_inputRadius = NULL; } void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -303,10 +321,10 @@ void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[] bool InverseSearchRadiusOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newRect; - newRect.ymin = input->ymin*DIVIDER; - newRect.ymax = input->ymax*DIVIDER; - newRect.xmin = input->xmin*DIVIDER; - newRect.xmax = input->xmax*DIVIDER; + newRect.ymin = input->ymin*DIVIDER - m_maxBlur; + newRect.ymax = input->ymax*DIVIDER + m_maxBlur; + newRect.xmin = input->xmin*DIVIDER - m_maxBlur; + newRect.xmax = input->xmax*DIVIDER + m_maxBlur; return NodeOperation::determineDependingAreaOfInterest(&newRect, readOperation, output); } #endif diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index 8e5589fafec..e5430545323 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -25,6 +25,7 @@ #include "COM_NodeOperation.h" #include "COM_QualityStepHelper.h" +//#define COM_DEFOCUS_SEARCH class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper { private: @@ -33,9 +34,8 @@ private: SocketReader *m_inputProgram; SocketReader *m_inputBokehProgram; SocketReader *m_inputSizeProgram; - SocketReader *m_inputDepthProgram; #ifdef COM_DEFOCUS_SEARCH - SocketReader *inputSearchProgram; + SocketReader *m_inputSearchProgram; #endif public: @@ -44,13 +44,17 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution */ void initExecution(); + void *initializeTileData(rcti *rect); + + void deinitializeTileData(rcti *rect, void *data); + /** * Deinitialize the execution */ @@ -68,10 +72,8 @@ public: #ifdef COM_DEFOCUS_SEARCH class InverseSearchRadiusOperation : public NodeOperation { private: - int maxBlur; - float threshold; - SocketReader *inputDepth; - SocketReader *inputRadius; + int m_maxBlur; + SocketReader *m_inputRadius; public: static const int DIVIDER = 4; @@ -86,8 +88,8 @@ public: * Initialize the execution */ void initExecution(); - void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + void* initializeTileData(rcti *rect); + void deinitializeTileData(rcti *rect, void *data); /** * Deinitialize the execution @@ -97,9 +99,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; } - - void setThreshold(float threshold) { this->threshold = threshold; } + void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; } }; #endif #endif diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index 48be72561ba..8934dd80ad8 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -52,7 +52,7 @@ void VectorBlurOperation::initExecution() } -void VectorBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +void VectorBlurOperation::executePixel(float *color, int x, int y, void *data) { float *buffer = (float *) data; int index = (y * this->getWidth() + x) * COM_NUMBER_OF_CHANNELS; @@ -70,7 +70,7 @@ void VectorBlurOperation::deinitExecution() this->m_cachedInstance = NULL; } } -void *VectorBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void *VectorBlurOperation::initializeTileData(rcti *rect) { if (this->m_cachedInstance) { return this->m_cachedInstance; @@ -78,9 +78,9 @@ void *VectorBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB lockMutex(); if (this->m_cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect, memoryBuffers); - MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect, memoryBuffers); - MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect); + MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect); + MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect); float *data = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS]; memcpy(data, tile->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float)); this->generateVectorBlur(data, tile, speed, z); diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.h b/source/blender/compositor/operations/COM_VectorBlurOperation.h index a2e72fa3232..2743baf8500 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.h +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.h @@ -48,7 +48,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + void executePixel(float *color, int x, int y, void *data); /** * Initialize the execution @@ -60,7 +60,7 @@ public: */ void deinitExecution(); - void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void *initializeTileData(rcti *rect); void setVectorBlurSettings(NodeBlurData *settings) { this->m_settings = settings; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp index ee3f44d8979..ed86c842fc9 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp @@ -43,12 +43,12 @@ void VectorCurveOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void VectorCurveOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void VectorCurveOperation::executePixel(float *output, float x, float y, PixelSampler sampler) { float input[4]; - this->m_inputProgram->read(input, x, y, sampler, inputBuffers); + this->m_inputProgram->read(input, x, y, sampler); curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input); output[3] = input[3]; diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h index 2fbaf170986..b76f8880fc6 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.h +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h @@ -37,7 +37,7 @@ public: /** * the inner loop of this program */ - void executePixel(float *Vector, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *Vector, float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp index 446b169763c..2470b239987 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp @@ -62,6 +62,8 @@ void ViewerBaseOperation::initImage() if (!ibuf) return; if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) { + BLI_lock_thread(LOCK_DRAW_IMAGE); + imb_freerectImBuf(ibuf); imb_freerectfloatImBuf(ibuf); IMB_freezbuffloatImBuf(ibuf); @@ -70,6 +72,8 @@ void ViewerBaseOperation::initImage() imb_addrectImBuf(ibuf); imb_addrectfloatImBuf(ibuf); anImage->ok = IMA_OK_LOADED; + + BLI_unlock_thread(LOCK_DRAW_IMAGE); } /* now we combine the input with ibuf */ diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index 9278ddd6ead..f7c2ff93b3e 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -64,7 +64,7 @@ void ViewerOperation::deinitExecution() } -void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) { float *buffer = this->m_outputBuffer; unsigned char *bufferDisplay = this->m_outputBufferDisplay; @@ -82,12 +82,11 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryB for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2; x++) { - this->m_imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST); if (this->m_alphaInput != NULL) { - this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST, memoryBuffers); + this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST); buffer[offset + 3] = alpha[0]; } - /// @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); diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h index fd83c3957f1..d900d8db408 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.h +++ b/source/blender/compositor/operations/COM_ViewerOperation.h @@ -34,7 +34,7 @@ private: public: ViewerOperation(); - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void initExecution(); void deinitExecution(); }; diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index 8decb73615b..0a31a6e170b 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -40,9 +40,9 @@ WriteBufferOperation::~WriteBufferOperation() } } -void WriteBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void WriteBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { - this->m_input->read(color, x, y, sampler, inputBuffers); + this->m_input->read(color, x, y, sampler); } void WriteBufferOperation::initExecution() @@ -57,13 +57,12 @@ void WriteBufferOperation::deinitExecution() this->m_memoryProxy->free(); } -void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) +void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber) { - //MemoryBuffer *memoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), tileNumber); MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer(); float *buffer = memoryBuffer->getBuffer(); if (this->m_input->isComplex()) { - void *data = this->m_input->initializeTileData(rect, memoryBuffers); + void *data = this->m_input->initializeTileData(rect); int x1 = rect->xmin; int y1 = rect->ymin; int x2 = rect->xmax; @@ -74,7 +73,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - this->m_input->read(&(buffer[offset4]), x, y, memoryBuffers, data); + this->m_input->read(&(buffer[offset4]), x, y, data); offset4 += COM_NUMBER_OF_CHANNELS; } @@ -84,7 +83,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me } if (data) { - this->m_input->deinitializeTileData(rect, memoryBuffers, data); + this->m_input->deinitializeTileData(rect, data); data = NULL; } } @@ -100,7 +99,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - this->m_input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST); offset4 += COM_NUMBER_OF_CHANNELS; } if (isBreaked()) { diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index d77814a9dc4..1aa93c658cb 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -38,10 +38,10 @@ public: ~WriteBufferOperation(); int isBufferOperation() { return true; } MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; } - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); const bool isWriteBufferOperation() const { return true; } - void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); + void executeRegion(rcti *rect, unsigned int tileNumber); void initExecution(); void deinitExecution(); void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer); diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp index c1ea63432b9..28dbcd9f017 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp +++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp @@ -46,36 +46,36 @@ void ZCombineOperation::initExecution() this->m_depth2Reader = this->getInputSocketReader(3); } -void ZCombineOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ZCombineOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float depth1[4]; float depth2[4]; - this->m_depth1Reader->read(depth1, x, y, sampler, inputBuffers); - this->m_depth2Reader->read(depth2, x, y, sampler, inputBuffers); + this->m_depth1Reader->read(depth1, x, y, sampler); + this->m_depth2Reader->read(depth2, x, y, sampler); if (depth1[0] < depth2[0]) { - this->m_image1Reader->read(color, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color, x, y, sampler); } else { - this->m_image2Reader->read(color, x, y, sampler, inputBuffers); + this->m_image2Reader->read(color, x, y, sampler); } } -void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { float depth1[4]; float depth2[4]; float color1[4]; float color2[4]; - this->m_depth1Reader->read(depth1, x, y, sampler, inputBuffers); - this->m_depth2Reader->read(depth2, x, y, sampler, inputBuffers); + this->m_depth1Reader->read(depth1, x, y, sampler); + this->m_depth2Reader->read(depth2, x, y, sampler); if (depth1[0] < depth2[0]) { - this->m_image1Reader->read(color1, x, y, sampler, inputBuffers); - this->m_image2Reader->read(color2, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color1, x, y, sampler); + this->m_image2Reader->read(color2, x, y, sampler); } else { - this->m_image1Reader->read(color2, x, y, sampler, inputBuffers); - this->m_image2Reader->read(color1, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color2, x, y, sampler); + this->m_image2Reader->read(color1, x, y, sampler); } float fac = color1[3]; float ifac = 1.0f - fac; diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h index 422a946b98f..9ee0899ee28 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.h +++ b/source/blender/compositor/operations/COM_ZCombineOperation.h @@ -47,11 +47,11 @@ public: /** * the inner loop of this program */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; class ZCombineAlphaOperation : public ZCombineOperation { - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + void executePixel(float *color, float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 9be0ab37510..6331dd51527 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3088,28 +3088,28 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float offset += ICON_WIDTH; } } - + /* step 5) draw name ............................................... */ - // TODO: when renaming, we might not want to draw this, especially if name happens to be longer than channel + /* 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? + /* 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! + /* FIXME: replace hardcoded color here, and check on extents! */ glColor3f(1.0f, 0.0f, 0.0f); glLineWidth(2.0); fdrawline((float)(offset), yminc, @@ -3117,13 +3117,13 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float glLineWidth(1.0); } } - + /* step 6) draw backdrops behidn mute+protection toggles + (sliders) ....................... */ /* reset offset - now goes from RHS of panel */ offset = 0; - - // TODO: when drawing sliders, make those draw instead of these toggles if not enough space - + + /* TODO: when drawing sliders, make those draw instead of these toggles if not enough space */ + if (v2d) { short draw_sliders = 0; float color[3]; diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index c2beeb17fe0..3b0234b5424 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -404,7 +404,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn /* compare data, and type as main way of identifying the channel */ if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) { /* we also have to check the ID, this is assigned to, since a block may have multiple users */ - // TODO: is the owner-data more revealing? + /* TODO: is the owner-data more revealing? */ if (ale->id == ale_setting->id) { match = ale; break; @@ -580,13 +580,13 @@ static int animedit_poll_channels_active(bContext *C) ScrArea *sa = CTX_wm_area(C); /* channels region test */ - // TODO: could enhance with actually testing if channels region? + /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; /* animation editor test */ if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0) return 0; - + return 1; } @@ -595,9 +595,9 @@ static int animedit_poll_channels_nla_tweakmode_off(bContext *C) { ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); - + /* channels region test */ - // TODO: could enhance with actually testing if channels region? + /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; /* animation editor test */ @@ -1318,16 +1318,16 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) /* make all the selected channels visible */ filter = (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ - // TODO: find out why this is the case, and fix that + /* TODO: find out why this is the case, and fix that */ if (ale->type == ANIMTYPE_OBJECT) continue; - + /* enable the setting */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD); - + /* now, also flush selection status up/down as appropriate */ ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 1); } @@ -1398,13 +1398,13 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o /* Now set the flags */ for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ - // TODO: find out why this is the case, and fix that + /* TODO: find out why this is the case, and fix that */ if (ale->type == ANIMTYPE_OBJECT) continue; - + /* change the setting */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, vis); - + /* now, also flush selection status up/down as appropriate */ ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, (vis == ACHANNEL_SETFLAG_ADD)); } @@ -1738,9 +1738,9 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot) static int animchannels_enable_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + /* channels region test */ - // TODO: could enhance with actually testing if channels region? + /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; @@ -2107,17 +2107,17 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in BLI_freelistN(&anim_data); return 0; } - + /* selectmode -1 is a special case for ActionGroups only, which selects all of the channels underneath it only... */ - // TODO: should this feature be extended to work with other channel types too? + /* TODO: should this feature be extended to work with other channel types too? */ if ((selectmode == -1) && (ale->type != ANIMTYPE_GROUP)) { /* normal channels should not behave normally in this case */ BLI_freelistN(&anim_data); return 0; } - + /* action to take depends on what channel we've got */ - // WARNING: must keep this in sync with the equivalent function in nla_channels.c + /* WARNING: must keep this in sync with the equivalent function in nla_channels.c */ switch (ale->type) { case ANIMTYPE_SCENE: { @@ -2156,9 +2156,9 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in } else { Base *b; - + /* deselect all */ - // TODO: should this deselect all other types of channels too? + /* TODO: should this deselect all other types of channels too? */ for (b = sce->base.first; b; b = b->next) { b->flag &= ~SELECT; b->object->flag = b->flag; @@ -2443,10 +2443,10 @@ void ED_operatortypes_animchannels(void) WM_operatortype_append(ANIM_OT_channels_setting_enable); WM_operatortype_append(ANIM_OT_channels_setting_disable); WM_operatortype_append(ANIM_OT_channels_setting_toggle); - + WM_operatortype_append(ANIM_OT_channels_delete); - - // XXX does this need to be a separate operator? + + /* XXX does this need to be a separate operator? */ WM_operatortype_append(ANIM_OT_channels_editable_toggle); WM_operatortype_append(ANIM_OT_channels_move); @@ -2468,11 +2468,11 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) /* selection */ /* click-select */ - // XXX for now, only leftmouse.... + /* XXX for now, only leftmouse.... */ WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", TRUE); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "children_only", TRUE); - + /* rename */ WM_keymap_add_item(keymap, "ANIM_OT_channels_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 32cbbc79496..50bdbd6673c 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -178,7 +178,7 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) char *bone_name; /* get bone-name, and check if this bone is selected */ - bone_name = BLI_getQuotedStr(fcu->rna_path, "pose.bones["); + bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["); pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); @@ -201,7 +201,7 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) char *seq_name; /* get strip name, and check if this strip is selected */ - seq_name = BLI_getQuotedStr(fcu->rna_path, "sequences_all["); + seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["); seq = get_seq_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); @@ -223,7 +223,7 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) char *node_name; /* get strip name, and check if this strip is selected */ - node_name = BLI_getQuotedStr(fcu->rna_path, "nodes["); + node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index ddc4f4d943c..0d48bf19c9e 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -381,11 +381,11 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest return RAD2DEGF(1.0f); /* radians to degrees */ } } - - // TODO: other rotation types here as necessary + + /* TODO: other rotation types here as necessary */ } } - + /* no mapping needs to occur... */ return 1.0f; } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 7f957d49fa3..81b6d77dd82 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -165,21 +165,21 @@ 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... + + 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... + + 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) */ { - // TODO, other methods to get the mask + /* 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; @@ -894,7 +894,7 @@ static short skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_i char *bone_name; /* get bone-name, and check if this bone is selected */ - bone_name = BLI_getQuotedStr(fcu->rna_path, "pose.bones["); + bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["); pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); @@ -930,7 +930,7 @@ static short skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_i char *seq_name; /* get strip name, and check if this strip is selected */ - seq_name = BLI_getQuotedStr(fcu->rna_path, "sequences_all["); + seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["); seq = get_seq_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); @@ -950,7 +950,7 @@ static short skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_i char *node_name; /* get strip name, and check if this strip is selected */ - node_name = BLI_getQuotedStr(fcu->rna_path, "nodes["); + node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); @@ -1952,9 +1952,9 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b AnimData *adt = ob->adt; short type = 0, expanded = 1; void *cdata = NULL; - + /* determine the type of expander channels to use */ - // this is the best way to do this for now... + /* this is the best way to do this for now... */ ANIMDATA_FILTER_CASES(ob, { /* AnimData - no channel, but consider data */ }, { /* NLA - no channel, but consider data */ }, @@ -2190,10 +2190,10 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d tmp_items += animdata_filter_ds_linestyle(ac, &tmp_data, ads, sce, filter_mode); } - // TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here + /* TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here */ } END_ANIMFILTER_SUBCHANNELS; - + /* if we collected some channels, add these to the new list... */ if (tmp_items) { /* firstly add object expander if required */ diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index a73651d7664..5295950546d 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -104,8 +104,8 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) */ if (strstr(fcu->rna_path, "bones") && strstr(fcu->rna_path, "constraints")) { /* perform string 'chopping' to get "Bone Name : Constraint Name" */ - char *pchanName = BLI_getQuotedStr(fcu->rna_path, "bones["); - char *constName = BLI_getQuotedStr(fcu->rna_path, "constraints["); + char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones["); + char *constName = BLI_str_quoted_substrN(fcu->rna_path, "constraints["); /* assemble the string to display in the UI... */ structname = BLI_sprintfN("%s : %s", pchanName, constName); @@ -143,15 +143,15 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* no array index */ arrayname = ""; } - + /* putting this all together into the buffer */ - // XXX we need to check for invalid names... - // XXX the name length limit needs to be passed in or as some define + /* XXX we need to check for invalid names... + * XXX the name length limit needs to be passed in or as some define */ if (structname) - BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname); + BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname); else - BLI_snprintf(name, 256, "%s%s", arrayname, propname); - + BLI_snprintf(name, 256, "%s%s", arrayname, propname); + /* free temp name if nameprop is set */ if (free_structname) MEM_freeN((void *)structname); @@ -170,11 +170,11 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) else { /* invalid path */ BLI_snprintf(name, 256, "\"%s[%d]\"", fcu->rna_path, fcu->array_index); - + /* icon for this should be the icon for the base ID */ - // TODO: or should we just use the error icon? + /* TODO: or should we just use the error icon? */ icon = RNA_struct_ui_icon(id_ptr.type); - + /* tag F-Curve as disabled - as not usable path */ fcu->flag |= FCURVE_DISABLED; } diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 8c1e2bedd86..91cc602c838 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -506,10 +506,10 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); - + /* control points header */ - // TODO: move this control-point control stuff to using the new special widgets for lists - // the current way is far too cramped + /* TODO: move this control-point control stuff to using the new special widgets for lists + * the current way is far too cramped */ row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 46a89963ad9..84711b97729 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -673,23 +673,23 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa /* draw keys */ if (keys) { /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */ - // TODO: allow this opacity factor to be themed? + /* TODO: allow this opacity factor to be themed? */ float kalpha = (channelLocked) ? 0.35f : 1.0f; - + for (ak = keys->first; ak; ak = ak->next) { - /* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw + /* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw * - this might give some improvements, since we current have to flip between view/region matrices */ if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax) == 0) continue; - + /* draw using OpenGL - uglier but faster */ - // NOTE1: a previous version of this didn't work nice for some intel cards - // NOTE2: if we wanted to go back to icons, these are icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; + /* NOTE1: a previous version of this didn't work nice for some intel cards + * NOTE2: if we wanted to go back to icons, these are icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; */ draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, kalpha); - } + } } - + glDisable(GL_BLEND); } diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 88627a6dabd..78ac729f16e 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -505,7 +505,7 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) if (ked->data) { short ok = 0; - #define KEY_CHECK_OK(_index) BLI_in_rctf(ked->data, bezt->vec[_index][0], bezt->vec[_index][1]) + #define KEY_CHECK_OK(_index) BLI_in_rctf_v(ked->data, bezt->vec[_index]) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 0c9a6ff6bf1..7600e1d4690 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -134,9 +134,9 @@ bAction *verify_adt_action(ID *id, short add) printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : "<None>"); return NULL; } - + /* init action if none available yet */ - // TODO: need some wizardry to handle NLA stuff correct + /* TODO: need some wizardry to handle NLA stuff correct */ if ((adt->action == NULL) && (add)) { char actname[sizeof(id->name) - 2]; BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); @@ -256,8 +256,8 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) dst->f1 = bezt->f1; dst->f2 = bezt->f2; dst->f3 = bezt->f3; - - // TODO: perform some other operations? + + /* TODO: perform some other operations? */ } } /* keyframing modes allow to not replace keyframe */ @@ -1691,11 +1691,11 @@ static short object_frame_has_keyframe(Object *ob, float frame, short filter) /* 1. test for relative (with keyframes) */ if (id_frame_has_keyframe((ID *)key, frame, filter)) return 1; - + /* 2. test for time */ - // TODO... yet to be implemented (this feature may evolve before then anyway) + /* TODO... yet to be implemented (this feature may evolve before then anyway) */ } - + /* try materials */ if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT) ) { /* if only active, then we can skip a lot of looping */ diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index cd914f9ff9a..04fd7f677b0 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -597,13 +597,13 @@ void ANIM_keyingset_info_register(KeyingSetInfo *ksi) void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) { KeyingSet *ks, *ksn; - + /* find relevant builtin KeyingSets which use this, and remove them */ - // TODO: this isn't done now, since unregister is really only used atm when we - // reload the scripts, which kindof defeats the purpose of "builtin"? + /* TODO: this isn't done now, since unregister is really only used atm when we + * reload the scripts, which kindof defeats the purpose of "builtin"? */ for (ks = builtin_keyingsets.first; ks; ks = ksn) { ksn = ks->next; - + /* remove if matching typeinfo name */ if (strcmp(ks->typeinfo, ksi->idname) == 0) { Scene *scene; @@ -791,8 +791,8 @@ short ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) return 0; - // TODO: check for missing callbacks! - + /* TODO: check for missing callbacks! */ + /* check if it can be used in the current context */ return (ksi->poll(ksi, C)); } @@ -878,8 +878,8 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) return MODIFYKEY_MISSING_TYPEINFO; - // TODO: check for missing callbacks! - + /* TODO: check for missing callbacks! */ + /* check if it can be used in the current context */ if (ksi->poll(ksi, C)) { /* if a list of data sources are provided, run a special iterator over them, diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 59ee90c553b..c19904d39ac 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -191,8 +191,8 @@ void ED_operatormacros_armature(void) RNA_enum_set(otmacro->ptr, "proportional", 0); } - // XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? - // that would require fixing a properties bug 19733 + /* XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? + * that would require fixing a properties bug 19733 */ ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", "Create new bones from the selected joints and move them", OPTYPE_UNDO | OPTYPE_REGISTER); @@ -218,7 +218,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SKETCH_OT_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_finish_stroke", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_cancel_stroke", ESCKEY, KM_PRESS, 0, 0); - // Already part of view3d select + /* Already part of view3d select */ //WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); /* sketch poll checks mode */ @@ -321,7 +321,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_apply", AKEY, KM_PRESS, KM_CTRL, 0); - // TODO: clear pose + /* TODO: clear pose */ WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 6cef843d828..2a3f2182fdf 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -657,12 +657,12 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata(); return OPERATOR_CANCELLED; } - + /* helpful warnings... */ - // TODO: add warnings to be careful about actions, applying deforms first, etc. - if (ob->adt && ob->adt->action) + /* TODO: add warnings to be careful about actions, applying deforms first, etc. */ + if (ob->adt && ob->adt->action) BKE_report(op->reports, RPT_WARNING, "Actions on this armature will be destroyed by this new rest pose as the transforms stored are relative to the old rest pose"); - + /* Get editbones of active armature to alter */ ED_armature_to_edit(ob); @@ -1192,9 +1192,9 @@ static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op)) * 4. fix constraint links * 5. make original armature active and enter editmode */ - + /* 1) only edit-base selected */ - // TODO: use context iterators for this? + /* TODO: use context iterators for this? */ CTX_DATA_BEGIN(C, Base *, base, visible_bases) { if (base->object == obedit) base->flag |= 1; @@ -1402,7 +1402,7 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend) if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) return; - // XXX old cruft! use notifiers instead + /* XXX old cruft! use notifiers instead */ //select_actionchannel_by_name (ob->action, bone->name, !(shift)); if (extend) @@ -5404,7 +5404,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr bArmature *arm = ob->data; if (arm->layer & bone->layer) { - // hrm... typo here? + /* hrm... typo here? */ if ((bone->flag & BONE_SELECTED) == 0) { bone->flag |= BONE_HIDDEN_P; if (arm->act_bone == bone) diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 51700793791..cdcb3ab4683 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -243,32 +243,32 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) * - numerator should be larger than denominator to 'expand' the result * - perform this weighting a number of times given by the percentage... */ - int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed - + int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ + while (iters-- > 0) { (*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f; } } break; - + case POSESLIDE_RELAX: /* make the current pose more like its surrounding ones */ { /* perform a weighted average here, favoring the middle pose * - numerator should be smaller than denominator to 'relax' the result * - perform this weighting a number of times given by the percentage... */ - int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed - + int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ + while (iters-- > 0) { (*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f; } } break; - + case POSESLIDE_BREAKDOWN: /* make the current pose slide around between the endpoints */ { /* perform simple linear interpolation - coefficient for start must come from pso->percentage... */ - // TODO: make this use some kind of spline interpolation instead? + /* TODO: make this use some kind of spline interpolation instead? */ (*val) = ((sVal * w2) + (eVal * w1)); } break; @@ -415,11 +415,11 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) } else if (pso->mode == POSESLIDE_PUSH) { float quat_diff[4], quat_orig[4]; - + /* calculate the delta transform from the previous to the current */ - // TODO: investigate ways to favour one transform more? + /* TODO: investigate ways to favour one transform more? */ sub_qt_qtqt(quat_diff, pchan->quat, quat_prev); - + /* make a copy of the original rotation */ copy_qt_qt(quat_orig, pchan->quat); @@ -428,8 +428,8 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) } else { float quat_interp[4], quat_orig[4]; - int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed - + int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ + /* perform this blending several times until a satisfactory result is reached */ while (iters-- > 0) { /* calculate the interpolation between the endpoints */ diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 4e0398168d3..e2e3c49e7e0 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -185,7 +185,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ - // FIXME: shouldn't this use the builtin stuff? + /* FIXME: shouldn't this use the builtin stuff? */ if ((arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index ee54fc2c6fe..23c987c3536 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -306,11 +306,11 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op) BLI_dlrbTree_init(&keys); action_to_keylist(NULL, act, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); - + /* for each key, make sure there is a corresponding pose */ for (ak = keys.first; ak; ak = ak->next) { /* check if any pose matches this */ - // TODO: don't go looking through the list like this every time... + /* TODO: don't go looking through the list like this every time... */ for (marker = act->markers.first; marker; marker = marker->next) { if (IS_EQ(marker->frame, (double)ak->cfra)) { marker->flag = -1; @@ -472,8 +472,8 @@ static int poselib_add_exec(bContext *C, wmOperator *op) BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name)); /* use Keying Set to determine what to store for the pose */ - // FIXME: in the past, the Keying Set respected selections (LocRotScale), but the current one doesn't (WholeCharacter) - // so perhaps we need either a new Keying Set, or just to add overrides here... + /* FIXME: in the past, the Keying Set respected selections (LocRotScale), but the current one doesn't + * (WholeCharacter) so perhaps we need either a new Keying Set, or just to add overrides here... */ ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame); /* store new 'active' pose number */ @@ -819,12 +819,12 @@ static void poselib_backup_restore(tPoseLib_PreviewData *pld) for (plb = pld->backups.first; plb; plb = plb->next) { /* copy most of data straight back */ memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel)); - + /* just overwrite values of properties from the stored copies (there should be some) */ if (plb->oldprops) IDP_SyncGroupValues(plb->pchan->prop, plb->oldprops); - - // TODO: constraints settings aren't restored yet, even though these could change (though not that likely) + + /* TODO: constraints settings aren't restored yet, even though these could change (though not that likely) */ } } @@ -832,10 +832,10 @@ static void poselib_backup_restore(tPoseLib_PreviewData *pld) static void poselib_backup_free_data(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb, *plbn; - + for (plb = pld->backups.first; plb; plb = plbn) { plbn = plb->next; - + /* free custom data */ if (plb->oldprops) { IDP_FreeProperty(plb->oldprops); @@ -1658,11 +1658,11 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot) /* callbacks */ ot->exec = poselib_preview_exec; ot->poll = has_poselib_pose_data_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ - // TODO: make the pose_index into a proper enum instead of a cryptic int... + + /* properties */ + /* TODO: make the pose_index into a proper enum instead of a cryptic int... */ ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); } diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 9bcbf313f13..cd2ca16fec5 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -103,7 +103,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base) return; } - // XXX: disabled as this would otherwise cause a nasty loop... + /* XXX: disabled as this would otherwise cause a nasty loop... */ //ED_object_toggle_modes(C, ob->mode); } @@ -253,14 +253,14 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) animviz_verify_motionpaths(op->reports, scene, ob, pchan); } CTX_DATA_END; - + /* calculate the bones that now have motionpaths... */ - // TODO: only make for the selected bones? + /* TODO: only make for the selected bones? */ ED_pose_recalculate_paths(scene, ob); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -299,9 +299,9 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) if (ELEM(NULL, ob, scene)) return OPERATOR_CANCELLED; - + /* calculate the bones that now have motionpaths... */ - // TODO: only make for the selected bones? + /* TODO: only make for the selected bones? */ ED_pose_recalculate_paths(scene, ob); /* notifiers for updates */ @@ -694,7 +694,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) /* only items related to this object will be relevant */ if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) { if (strstr(ksp->rna_path, "bones")) { - char *boneName = BLI_getQuotedStr(ksp->rna_path, "bones["); + char *boneName = BLI_str_quoted_substrN(ksp->rna_path, "bones["); if (boneName) { bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName); diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 20b95ea55d6..af252ffe60c 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -1753,18 +1753,18 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) #endif arc->angle = avg_angle; - + if (avg_angle > threshold) merging = 1; - + if (merging) { ReebNode *terminalNode = NULL; ReebNode *middleNode = NULL; ReebNode *newNode = NULL; ReebNode *removedNode = NULL; int merging = 0; - - // Assign terminal and middle nodes + + /* Assign terminal and middle nodes */ if (arc->head->degree == 1) { terminalNode = arc->head; middleNode = arc->tail; @@ -1773,31 +1773,31 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) terminalNode = arc->tail; middleNode = arc->head; } - - // If middle node is a normal node, merge to terminal node + + /* If middle node is a normal node, merge to terminal node */ if (middleNode->degree == 2) { merging = 1; newNode = terminalNode; removedNode = middleNode; } - // Otherwise, just plain remove of the arc + /* Otherwise, just plain remove of the arc */ else { merging = 0; newNode = middleNode; removedNode = terminalNode; } - - // Merging arc + + /* Merging arc */ if (merging) { filterArc(rg, newNode, removedNode, arc, 1); } else { - // removing arc, so we need to decrease the degree of the remaining node - //newNode->degree--; + /* removing arc, so we need to decrease the degree of the remaining node + *newNode->degree--; */ NodeDegreeDecrement(rg, newNode); } - - // Reset nextArc, it might have changed + + /* Reset nextArc, it might have changed */ nextArc = arc->next; BLI_remlink(&rg->arcs, arc); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 83f6b1d1824..bb66b1f4347 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -215,16 +215,16 @@ static void update_string(Curve *cu) EditFont *ef = cu->editfont; int len; - // Free the old curve string + /* Free the old curve string */ MEM_freeN(cu->str); - // Calculate the actual string length in UTF-8 variable characters + /* Calculate the actual string length in UTF-8 variable characters */ len = BLI_wstrlen_utf8(ef->textbuf); - // Alloc memory for UTF-8 variable char length string + /* Alloc memory for UTF-8 variable char length string */ cu->str = MEM_callocN(len + sizeof(wchar_t), "str"); - // Copy the wchar to UTF-8 + /* Copy the wchar to UTF-8 */ BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, len + 1); } @@ -362,8 +362,8 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename) strp = MEM_callocN(filelen + 4, "tempstr"); - // fread() instead of read(), because windows read() converts text - // to DOS \r\n linebreaks, causing double linebreaks in the 3d text + /* fread() instead of read(), because windows read() converts text + * to DOS \r\n linebreaks, causing double linebreaks in the 3d text */ filelen = fread(strp, 1, filelen, fp); fclose(fp); strp[filelen] = 0; @@ -753,7 +753,7 @@ static int paste_selection(Object *obedit, ReportList *reports) EditFont *ef = cu->editfont; int len = wcslen(ef->copybuf); - // Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT + /* Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT */ if (cu->len + len <= MAXTEXT) { if (len) { int size = (cu->len * sizeof(wchar_t)) - (cu->pos * sizeof(wchar_t)) + sizeof(wchar_t); @@ -1452,12 +1452,12 @@ void make_editText(Object *obedit) ef->oldstrinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "oldstrbuf"); } - // Convert the original text to wchar_t + /* Convert the original text to wchar_t */ BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4); /* length is bogus */ wcscpy(ef->oldstr, ef->textbuf); - + cu->len = wcslen(ef->textbuf); - + memcpy(ef->textbufinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); memcpy(ef->oldstrinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); @@ -1467,8 +1467,8 @@ void make_editText(Object *obedit) cu->curinfo = ef->textbufinfo[cu->pos - 1]; else cu->curinfo = ef->textbufinfo[0]; - - // Convert to UTF-8 + + /* Convert to UTF-8 */ update_string(cu); } @@ -1773,10 +1773,10 @@ static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata)) EditFont *ef = cu->editfont; char *str; - // The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo + /* The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo */ str = MEM_callocN((MAXTEXT + 6) * sizeof(wchar_t) + (MAXTEXT + 4) * sizeof(CharInfo), "string undo"); - // Copy the string and string information + /* Copy the string and string information */ memcpy(str + 4, ef->textbuf, (cu->len + 1) * sizeof(wchar_t)); memcpy(str + 4 + (cu->len + 1) * sizeof(wchar_t), ef->textbufinfo, cu->len * sizeof(CharInfo)); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 6d113cbb924..bc912fc8c76 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -683,7 +683,7 @@ void draw_gpencil_2dimage(const bContext *C) { /* just draw using standard scaling (settings here are currently ignored anyways) */ - // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled + /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ offsx = 0; offsy = 0; sizex = ar->winx; @@ -740,7 +740,7 @@ void draw_gpencil_view2d(const bContext *C, short onlyv2d) if (gpd == NULL) return; /* special hack for Image Editor */ - // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled + /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) dflag |= GP_DRAWDATA_IEDITHACK; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 3f53f0403d7..949f92c68e9 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -93,8 +93,8 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) { Object *ob = CTX_data_active_object(C); - // TODO: we can include other data-types such as bones later if need be... - + /* TODO: we can include other data-types such as bones later if need be... */ + /* just in case no active object */ if (ob) { /* for now, as long as there's an object, default to using that in 3D-View */ @@ -126,18 +126,18 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C); /* for now, Grease Pencil data is associated with the space (actually preview region only) */ - // XXX our convention for everything else is to link to data though... + /* XXX our convention for everything else is to link to data though... */ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, ptr); return &sseq->gpd; } break; - + case SPACE_IMAGE: /* Image/UV Editor */ { SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); - + /* for now, Grease Pencil data is associated with the space... */ - // XXX our convention for everything else is to link to data though... + /* XXX our convention for everything else is to link to data though... */ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, ptr); return &sima->gpd; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 12b002ef612..fd98dd83a7d 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1623,12 +1623,12 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) } else p = op->customdata; - - // TODO: set any additional settings that we can take from the events? - // TODO? if tablet is erasing, force eraser to be on? - - // TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... - + + /* TODO: set any additional settings that we can take from the events? + * TODO? if tablet is erasing, force eraser to be on? */ + + /* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */ + /* if eraser is on, draw radial aid */ if (p->paintmode == GP_PAINTMODE_ERASER) { gpencil_draw_toggle_eraser_cursor(C, p, TRUE); @@ -1692,8 +1692,8 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) //printf("\t\tGP - start stroke\n"); /* we may need to set up paint env again if we're resuming */ - // XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions - // XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support + /* XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions */ + /* XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support */ if (gp_session_initdata(C, p)) gp_paint_initstroke(p, p->paintmode); @@ -1727,17 +1727,17 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) tGPsdata *p = op->customdata; int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ - // if (event->type == NDOF_MOTION) - // return OPERATOR_PASS_THROUGH; - // ------------------------------- - // [mce] Not quite what I was looking - // for, but a good start! GP continues to - // draw on the screen while the 3D mouse - // moves the viewpoint. Problem is that - // the stroke is converted to 3D only after - // it is finished. This approach should work - // better in tools that immediately apply - // in 3D space. + /* if (event->type == NDOF_MOTION) + * return OPERATOR_PASS_THROUGH; + * ------------------------------- + * [mce] Not quite what I was looking + * for, but a good start! GP continues to + * draw on the screen while the 3D mouse + * moves the viewpoint. Problem is that + * the stroke is converted to 3D only after + * it is finished. This approach should work + * better in tools that immediately apply + * in 3D space. */ //printf("\tGP - handle modal event...\n"); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index eb02fc97596..07f3498580c 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -180,6 +180,3 @@ void mesh_deform_bind(struct Scene *scene, #endif #endif /* __ED_ARMATURE_H__ */ - - - diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index bb6f9fad771..9715fb93c27 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -515,6 +515,34 @@ struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but); void uiButSetUnitType(uiBut *but, const int unit_type); int uiButGetUnitType(uiBut *but); +enum { + BUT_GET_RNAPROP_IDENTIFIER = 1, + BUT_GET_RNASTRUCT_IDENTIFIER, + BUT_GET_RNAENUM_IDENTIFIER, + BUT_GET_LABEL, + BUT_GET_RNA_LABEL, + BUT_GET_RNAENUM_LABEL, + BUT_GET_RNA_LABEL_CONTEXT, /* Context specified in CTX_XXX_ macros are just unreachable! */ + BUT_GET_TIP, + BUT_GET_RNA_TIP, + BUT_GET_RNAENUM_TIP, + BUT_GET_OP_KEYMAP, +}; + +typedef struct uiStringInfo { + int type; + char *strinfo; +} uiStringInfo; + +/* Note: Expects pointers to uiStringInfo structs as parameters. + * Will fill them with translated strings, when possible. + * Strings in uiStringInfo must be MEM_freeN'ed by caller. */ +void uiButGetStrInfo(struct bContext *C, uiBut *but, const int nbr, ...); + +/* Edit i18n stuff. */ +/* Name of the main py op from i18n addon. */ +#define EDTSRC_I18N_OP_NAME "UI_OT_edittranslation" + /* Special Buttons * * Buttons with a more specific purpose: diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 5039a30b61a..f0bdb2fc2ea 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -120,8 +120,8 @@ enum { /* Macros: */ /* test if mouse in a scrollbar (assume that scroller availability has been tested) */ -#define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti(&v2d->vert, co[0], co[1])) -#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti(&v2d->hor, co[0], co[1])) +#define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti_v(&v2d->vert, co)) +#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti_v(&v2d->hor, co)) /* ------------------------------------------ */ /* Type definitions: */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 49d56d427ba..60f071f2ad2 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -524,8 +524,8 @@ static void ui_draw_links(uiBlock *block) uiBut *but; uiLinkLine *line; - // Draw the inactive lines (lines with neither button being hovered over). - // As we go, remember if we see any active or selected lines. + /* Draw the inactive lines (lines with neither button being hovered over). + * As we go, remember if we see any active or selected lines. */ int foundselectline = 0; int foundactiveline = 0; for (but = block->buttons.first; but; but = but->next) { @@ -542,8 +542,8 @@ static void ui_draw_links(uiBlock *block) } } - // Draw any active lines (lines with either button being hovered over). - // Do this last so they appear on top of inactive lines. + /* Draw any active lines (lines with either button being hovered over). + * Do this last so they appear on top of inactive lines. */ if (foundactiveline) { for (but = block->buttons.first; but; but = but->next) { if (but->type == LINK && but->link) { @@ -2486,7 +2486,7 @@ static void ui_block_do_align_but(uiBut *first, short nr) /* merge coordinates */ if (prev) { - // simple cases + /* simple cases */ if (rows == 0) { but->x1 = (prev->x2 + but->x1) / 2.0f; prev->x2 = but->x1; @@ -3432,7 +3432,7 @@ int uiButGetUnitType(uiBut *but) /* own unit define always takes precedence over RNA provided, allowing for overriding * default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit) */ - // XXX: this doesn't allow clearing unit completely, though the same could be said for icons + /* XXX: this doesn't allow clearing unit completely, though the same could be said for icons */ if ((ownUnit != 0) || (but->rnaprop == NULL)) { return ownUnit << 16; } @@ -3691,6 +3691,136 @@ void uiButSetFocusOnEnter(wmWindow *win, uiBut *but) wm_event_add(win, &event); } +void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...) +{ + va_list args; + + EnumPropertyItem *items = NULL, *item = NULL; + int totitems, free_items = FALSE; + + va_start(args, nbr); + while (nbr--) { + uiStringInfo *si = (uiStringInfo*) va_arg(args, void*); + int type = si->type; + char *tmp = NULL; + + if (type == BUT_GET_LABEL) { + if (but->str) { + /* Menu labels can have some complex formating stuff marked by pipes, we don't want those here! */ + char *tc = strchr(but->str, '|'); + if (tc) + tmp = BLI_strdupn(but->str, tc - but->str); + else + tmp = BLI_strdup(but->str); + } + else + type = BUT_GET_RNA_LABEL; /* Fail-safe solution... */ + } + else if (type == BUT_GET_TIP) { + if (but->tip && but->tip[0]) + tmp = BLI_strdup(but->tip); + else + type = BUT_GET_RNA_TIP; /* Fail-safe solution... */ + } + if (type == BUT_GET_RNAPROP_IDENTIFIER) { + if (but->rnaprop) + tmp = BLI_strdup(RNA_property_identifier(but->rnaprop)); + } + else if (type == BUT_GET_RNASTRUCT_IDENTIFIER) { + if (but->rnaprop) + tmp = BLI_strdup(RNA_struct_identifier(but->rnapoin.type)); + else if (but->optype) + tmp = BLI_strdup(but->optype->idname); + else if (ELEM(but->type, MENU, PULLDOWN)) { + MenuType *mt = uiButGetMenuType(but); + if (mt) + tmp = BLI_strdup(mt->idname); + } + } + else if (ELEM(type, BUT_GET_RNA_LABEL, BUT_GET_RNA_TIP)) { + if (but->rnaprop) { + if (type == BUT_GET_RNA_LABEL) + tmp = BLI_strdup(RNA_property_ui_name(but->rnaprop)); + else { + const char *t = RNA_property_ui_description(but->rnaprop); + if (t && t[0]) + tmp = BLI_strdup(t); + } + } + else if (but->optype) { + if (type == BUT_GET_RNA_LABEL) + tmp = BLI_strdup(RNA_struct_ui_name(but->optype->srna)); + else { + const char *t = RNA_struct_ui_description(but->optype->srna); + if (t && t[0]) + tmp = BLI_strdup(t); + } + } + else if (ELEM(but->type, MENU, PULLDOWN)) { + MenuType *mt = uiButGetMenuType(but); + if (mt) { + if (type == BUT_GET_RNA_LABEL) + tmp = BLI_strdup(RNA_struct_ui_name(mt->ext.srna)); + else { + const char *t = RNA_struct_ui_description(mt->ext.srna); + if (t && t[0]) + tmp = BLI_strdup(t); + } + } + } + } + else if (type == BUT_GET_RNA_LABEL_CONTEXT) { + if (but->rnaprop) + tmp = BLI_strdup(RNA_property_translation_context(but->rnaprop)); + else if (but->optype) + tmp = BLI_strdup(RNA_struct_translation_context(but->optype->srna)); + else if (ELEM(but->type, MENU, PULLDOWN)) { + MenuType *mt = uiButGetMenuType(but); + if (mt) + tmp = BLI_strdup(RNA_struct_translation_context(mt->ext.srna)); + } + } + else if (ELEM3(type, BUT_GET_RNAENUM_IDENTIFIER, BUT_GET_RNAENUM_LABEL, BUT_GET_RNAENUM_TIP)) { + if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { + if (!item) { + int i; + int value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but); + RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &items, &totitems, &free_items); + + for (i = 0, item = items; i < totitems; i++, item++) { + if (item->identifier[0] && item->value == value) + break; + } + } + if (item && item->identifier) { + if (type == BUT_GET_RNAENUM_IDENTIFIER) + tmp = BLI_strdup(item->identifier); + else if (type == BUT_GET_RNAENUM_LABEL) + tmp = BLI_strdup(item->name); + else if (item->description && item->description[0]) + tmp = BLI_strdup(item->description); + } + } + } + else if (type == BUT_GET_OP_KEYMAP) { + if (but->optype && !(but->block->flag & UI_BLOCK_LOOP)) { + /* operator keymap (not menus, they already have it) */ + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + char buf[512]; + + if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, + buf, sizeof(buf))) + tmp = BLI_strdup(buf); + } + } + + si->strinfo = tmp; + } + + if (free_items && items) + MEM_freeN(items); +} + /* Program Init/Exit */ void UI_init(void) diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index c7f8ad521fa..3099fcb2b40 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -141,7 +141,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str) } /* make sure we have animdata for this */ - // FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them + /* FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them */ id = (ID *)but->rnapoin.id.data; if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) { if (G.debug & G_DEBUG) @@ -160,9 +160,9 @@ int ui_but_anim_expression_create(uiBut *but, const char *str) if (driver) { /* set type of driver */ driver->type = DRIVER_TYPE_PYTHON; - + /* set the expression */ - // TODO: need some way of identifying variables used + /* TODO: need some way of identifying variables used */ BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression)); /* updates */ @@ -187,12 +187,12 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) if (fcu && !driven) { id = but->rnapoin.id.data; - - // TODO: this should probably respect the keyingset only option for anim + + /* TODO: this should probably respect the keyingset only option for anim */ if (autokeyframe_cfra_can_key(scene, id)) { ReportList *reports = CTX_wm_reports(C); short flag = ANIM_get_keyframing_flags(scene, 1); - + fcu->flag &= ~FCURVE_SELECTED; insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag); WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index f173e7ce630..e576b71e442 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -441,7 +441,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w w = (rect->xmax - rect->xmin); h = (rect->ymax - rect->ymin); - // prevent drawing outside widget area + /* prevent drawing outside widget area */ glGetIntegerv(GL_SCISSOR_BOX, scissor); glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h); #endif @@ -509,7 +509,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) /* Set the font, in case it is not FO_BUILTIN_NAME font */ if (G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME)) { - // Is the font file packed, if so then use the packed file + /* Is the font file packed, if so then use the packed file */ if (G.selfont->packedfile) { pf = G.selfont->packedfile; FTF_SetFont(pf->data, pf->size, 14.0); @@ -537,27 +537,27 @@ static void ui_draw_but_CHARTAB(uiBut *but) glColor3ub(0, 0, 0); for (y = 0; y < 6; y++) { - // Do not draw more than the category allows + /* Do not draw more than the category allows */ if (cs > charmax) break; for (x = 0; x < 12; x++) { - // Do not draw more than the category allows + /* Do not draw more than the category allows */ if (cs > charmax) break; - // Draw one grid cell + /* Draw one grid cell */ glBegin(GL_LINE_LOOP); glVertex2f(sx, sy); glVertex2f(ex, sy); glVertex2f(ex, ey); glVertex2f(sx, ey); - glEnd(); + glEnd(); - // Draw character inside the cell + /* Draw character inside the cell */ memset(wstr, 0, sizeof(wchar_t) * 2); memset(ustr, 0, 16); - // Set the font to be either unicode or FO_BUILTIN_NAME + /* Set the font to be either unicode or FO_BUILTIN_NAME */ wstr[0] = cs; if (strcmp(G.selfont->name, FO_BUILTIN_NAME)) { BLI_strncpy_wchar_as_utf8((char *)ustr, (wchar_t *)wstr, sizeof(ustr)); @@ -580,17 +580,17 @@ static void ui_draw_but_CHARTAB(uiBut *but) float dx, dy; float px, py; - // Calculate the position + /* Calculate the position */ wid = FTF_GetStringWidth((char *) ustr, FTF_USE_GETTEXT | FTF_INPUT_UTF8); FTF_GetBoundingBox((char *) ustr, &llx, &lly, &llz, &urx, &ury, &urz, FTF_USE_GETTEXT | FTF_INPUT_UTF8); dx = urx - llx; dy = ury - lly; - // This isn't fully functional since the but->aspect isn't working like I suspected + /* This isn't fully functional since the but->aspect isn't working like I suspected */ px = sx + ((butw / but->aspect) - dx) / 2; py = sy + ((buth / but->aspect) - dy) / 2; - // Set the position and draw the character + /* Set the position and draw the character */ ui_rasterpos_safe(px, py, but->aspect); FTF_DrawString((char *) ustr, FTF_USE_GETTEXT | FTF_INPUT_UTF8); } @@ -598,8 +598,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) ui_rasterpos_safe(sx + butw / 2, sy + buth / 2, but->aspect); UI_DrawString(but->font, (char *) ustr, 0); } - - // Calculate the next position and character + + /* Calculate the next position and character */ sx += butw; ex += butw; cs++; } @@ -1571,9 +1571,9 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc if (tmpibuf->rect_float) IMB_rect_from_float(tmpibuf); - // XXX: for debug only - // tmpibuf->ftype = PNG; - // IMB_saveiff(tmpibuf, "sample.png", IB_rect); + /* XXX: for debug only + * tmpibuf->ftype = PNG; + * IMB_saveiff(tmpibuf, "sample.png", IB_rect); */ if (tmpibuf->rect) scopes->track_preview = tmpibuf; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 3a64ad22062..613ab2fa6c8 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -804,7 +804,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) break; } - // only works if the sensor and the actuator are from the same object + /* only works if the sensor and the actuator are from the same object */ if (!act_iter) return; /* (3) add a new controller */ @@ -3478,13 +3478,13 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle else if (event->type == WHEELDOWNMOUSE) { float *hsv = ui_block_hsv_get(but->block); hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f); - ui_set_but_hsv(but); // converts to rgb + ui_set_but_hsv(but); /* converts to rgb */ ui_numedit_apply(C, block, but, data); } else if (event->type == WHEELUPMOUSE) { float *hsv = ui_block_hsv_get(but->block); hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f); - ui_set_but_hsv(but); // converts to rgb + ui_set_but_hsv(but); /* converts to rgb */ ui_numedit_apply(C, block, but, data); } else if (event->type == MOUSEMOVE) { @@ -3810,7 +3810,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt static int in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) { - // bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); + /* bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); */ return (y < but->y1 + SCOPE_RESIZE_PAD); } @@ -4399,23 +4399,32 @@ static int ui_but_menu(bContext *C, uiBut *but) uiPopupMenu *pup; uiLayout *layout; int length; - const char *name; + char *name; + uiStringInfo label = {BUT_GET_LABEL, NULL}; - if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL) - return 0; +/* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/ +/* return 0;*/ 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); - + + if (label.strinfo) + MEM_freeN(label.strinfo); + uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); if (but->rnapoin.data && but->rnaprop) { @@ -4505,7 +4514,7 @@ static int ui_but_menu(bContext *C, uiBut *but) } /* Keying Sets */ - // TODO: check on modifyability of Keying Set when doing this + /* TODO: check on modifyability of Keying Set when doing this */ if (is_anim) { uiItemS(layout); @@ -4529,8 +4538,8 @@ static int ui_but_menu(bContext *C, uiBut *but) /* Property Operators */ - //Copy Property Value - //Paste Property Value + /*Copy Property Value + *Paste Property Value */ if (length) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), @@ -4566,7 +4575,7 @@ static int ui_but_menu(bContext *C, uiBut *but) /* keyboard shortcuts */ if ((kmi) && ISKEYBOARD(kmi->type)) { - // would rather use a block but, but gets weirdly positioned... + /* would rather use a block but, but gets weirdly positioned... */ //uiDefBlockBut(block, menu_change_shortcut, but, "Change Shortcut", 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, ""); but2 = uiDefIconTextBut(block, BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), @@ -4642,8 +4651,8 @@ static int ui_but_menu(bContext *C, uiBut *but) } /* perhaps we should move this into (G.debug & G_DEBUG) - campbell */ - uiItemFullO(layout, "UI_OT_editsource", CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Source"), - ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0); + uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0); + uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0); uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 1c3b642b63b..b76907bc3ba 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -43,6 +43,9 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" +#include "BLF_api.h" +#include "BLF_translation.h" + #include "BKE_context.h" #include "BKE_screen.h" #include "BKE_global.h" @@ -732,8 +735,6 @@ void UI_editsource_active_but_test(uiBut *but) BLI_ghash_insert(ui_editsource_info->hash, but, but_store); } -/* editsource operator component */ - static int editsource_text_edit(bContext *C, wmOperator *op, char filepath[FILE_MAX], int line) { @@ -843,16 +844,170 @@ static int editsource_exec(bContext *C, wmOperator *op) static void UI_OT_editsource(wmOperatorType *ot) { /* identifiers */ - ot->name = "Reports to Text Block"; + ot->name = "Edit Source"; ot->idname = "UI_OT_editsource"; - ot->description = "Edit source code for a button"; + ot->description = "Edit UI source code of the active button"; /* callbacks */ ot->exec = editsource_exec; } +/* ------------------------------------------------------------------------- */ +/* EditTranslation utility funcs and operator, + * 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) +{ + char t[32]; /* Should be more than enough! */ + /* First, full lang code. */ + sprintf(t, "%s.po", uilng); + BLI_join_dirfile(path, maxlen, root, uilng); + BLI_join_dirfile(path, maxlen, path, t); + if (BLI_is_file(path)) + return; + /* Now try without the second iso code part (_ES in es_ES). */ + strncpy(t, uilng, 2); + strcpy(t + 2, uilng + 5); /* Because of some codes like sr_SR@latin... */ + BLI_join_dirfile(path, maxlen, root, t); + sprintf(t, "%s.po", t); + BLI_join_dirfile(path, maxlen, path, t); + if (BLI_is_file(path)) + return; + path[0] = '\0'; +} + +static int edittranslation_exec(bContext *C, wmOperator *op) +{ + uiBut *but = uiContextActiveButton(C); + int ret = OPERATOR_CANCELLED; + + if (but) { + PointerRNA ptr; + char popath[FILE_MAX]; + const char *root = U.i18ndir; + const char *uilng = BLF_lang_get(); + + const int bufs_nbr = 10; + uiStringInfo but_label = {BUT_GET_LABEL, NULL}; + uiStringInfo rna_label = {BUT_GET_RNA_LABEL, NULL}; + uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL}; + uiStringInfo but_tip = {BUT_GET_TIP, NULL}; + uiStringInfo rna_tip = {BUT_GET_RNA_TIP, NULL}; + uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL}; + uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL}; + uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL}; + uiStringInfo rna_enum = {BUT_GET_RNAENUM_IDENTIFIER, NULL}; + uiStringInfo rna_ctxt = {BUT_GET_RNA_LABEL_CONTEXT, NULL}; + + if (!BLI_is_dir(root)) { + BKE_report(op->reports, RPT_ERROR, "Please set your User Preferences' \"Translation Branches " + "Directory\" path to a valid directory."); + return OPERATOR_CANCELLED; + } + if (!WM_operatortype_find(EDTSRC_I18N_OP_NAME, 0)) { + BKE_reportf(op->reports, RPT_ERROR, "Could not find operator \"%s\"! Please enable ui_translate addon " + "in the User Preferences.", EDTSRC_I18N_OP_NAME); + return OPERATOR_CANCELLED; + } + /* Try to find a valid po file for current language... */ + edittranslation_find_po_file(root, uilng, popath, FILE_MAX); + printf("po path: %s\n", popath); + if (popath[0] == '\0') { + BKE_reportf(op->reports, RPT_ERROR, "No valid po found for language '%s' under %s.", uilng, root); + return OPERATOR_CANCELLED; + } + + uiButGetStrInfo(C, but, bufs_nbr, &but_label, &rna_label, &enum_label, &but_tip, &rna_tip, &enum_tip, + &rna_struct, &rna_prop, &rna_enum, &rna_ctxt); + + WM_operator_properties_create(&ptr, EDTSRC_I18N_OP_NAME); + RNA_string_set(&ptr, "lang", uilng); + RNA_string_set(&ptr, "po_file", popath); + RNA_string_set(&ptr, "but_label", but_label.strinfo); + RNA_string_set(&ptr, "rna_label", rna_label.strinfo); + RNA_string_set(&ptr, "enum_label", enum_label.strinfo); + RNA_string_set(&ptr, "but_tip", but_tip.strinfo); + RNA_string_set(&ptr, "rna_tip", rna_tip.strinfo); + RNA_string_set(&ptr, "enum_tip", enum_tip.strinfo); + RNA_string_set(&ptr, "rna_struct", rna_struct.strinfo); + RNA_string_set(&ptr, "rna_prop", rna_prop.strinfo); + RNA_string_set(&ptr, "rna_enum", rna_enum.strinfo); + RNA_string_set(&ptr, "rna_ctxt", rna_ctxt.strinfo); + ret = WM_operator_name_call(C, EDTSRC_I18N_OP_NAME, WM_OP_INVOKE_DEFAULT, &ptr); + + /* Clean up */ + if (but_label.strinfo) + MEM_freeN(but_label.strinfo); + if (rna_label.strinfo) + MEM_freeN(rna_label.strinfo); + if (enum_label.strinfo) + MEM_freeN(enum_label.strinfo); + if (but_tip.strinfo) + MEM_freeN(but_tip.strinfo); + if (rna_tip.strinfo) + MEM_freeN(rna_tip.strinfo); + if (enum_tip.strinfo) + MEM_freeN(enum_tip.strinfo); + if (rna_struct.strinfo) + MEM_freeN(rna_struct.strinfo); + if (rna_prop.strinfo) + MEM_freeN(rna_prop.strinfo); + if (rna_enum.strinfo) + MEM_freeN(rna_enum.strinfo); + if (rna_ctxt.strinfo) + MEM_freeN(rna_ctxt.strinfo); + + return ret; + } + else { + BKE_report(op->reports, RPT_ERROR, "Active button not found"); + return OPERATOR_CANCELLED; + } +} + +#if 0 +static int edittranslation_poll(bContext *UNUSED(C)) +{ + /* We need the i18n py addon to be enabled! */ + return WM_operatortype_find(EDTSRC_I18N_OP_NAME, 0) ? TRUE : FALSE; +} +#endif + +static void UI_OT_edittranslation_init(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Edit Translation"; + ot->idname = "UI_OT_edittranslation_init"; + ot->description = "Edit i18n in current language for the active button"; + + /* callbacks */ + ot->exec = edittranslation_exec; +/* ot->poll = edittranslation_poll;*/ +} + #endif /* WITH_PYTHON */ +static int reloadtranslation_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) +{ + BLF_lang_init(); + BLF_cache_clear(); + BLF_lang_set(NULL); + UI_reinit_font(); + return OPERATOR_FINISHED; +} + +static void UI_OT_reloadtranslation(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Reload Translation"; + ot->idname = "UI_OT_reloadtranslation"; + ot->description = "Force a full reload of UI translation"; + + /* callbacks */ + ot->exec = reloadtranslation_exec; +} + /* ********************************************************* */ /* Registration */ @@ -867,6 +1022,8 @@ void UI_buttons_operatortypes(void) #ifdef WITH_PYTHON WM_operatortype_append(UI_OT_editsource); + WM_operatortype_append(UI_OT_edittranslation_init); #endif + WM_operatortype_append(UI_OT_reloadtranslation); } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 7f9a998e6d0..76485571096 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -978,7 +978,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) short align = panel_aligned(sa, ar), dx = 0, dy = 0; /* first clip for window, no dragging outside */ - if (!BLI_in_rcti(&ar->winrct, event->x, event->y)) + if (!BLI_in_rcti_v(&ar->winrct, &event->x)) return; dx = (event->x - data->startx) & ~(PNL_GRID - 1); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 40f28de50fa..83366ec204b 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -417,20 +417,31 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) static ARegionType type; ARegion *ar; uiTooltipData *data; - IDProperty *prop; +/* IDProperty *prop;*/ char buf[512]; float fonth, fontw, aspect = but->block->aspect; float x1f, x2f, y1f, y2f; int x1, x2, y1, y2, winx, winy, ofsx, ofsy, w, h, a; + const int nbr_info = 6; + uiStringInfo but_tip = {BUT_GET_TIP, NULL}; + uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL}; + uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL}; + uiStringInfo op_keymap = {BUT_GET_OP_KEYMAP, NULL}; + uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL}; + uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL}; + if (but->flag & UI_BUT_NO_TOOLTIP) return NULL; /* create tooltip data */ data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); + uiButGetStrInfo(C, but, nbr_info, &but_tip, &enum_label, &enum_tip, &op_keymap, &rna_struct, &rna_prop); + /* special case, enum rna buttons only have enum item description, * use general enum description too before the specific one */ +#if 0 if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { const char *descr = RNA_property_description(but->rnaprop); if (descr && descr[0]) { @@ -441,7 +452,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) if (ELEM(but->type, ROW, MENU)) { EnumPropertyItem *item; - int i, totitem, free; + int totitem, free; int value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but); RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &item, &totitem, &free); @@ -469,7 +480,23 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->color_id[data->totline] = UI_TIP_LC_MAIN; data->totline++; } +#else + /* Tip */ + if (but_tip.strinfo) { + BLI_strncpy(data->lines[data->totline], but_tip.strinfo, sizeof(data->lines[0])); + data->color_id[data->totline] = UI_TIP_LC_MAIN; + data->totline++; + } + /* Enum item label & tip */ + if (enum_label.strinfo && enum_tip.strinfo) { + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), + "%s: %s", enum_label.strinfo, enum_tip.strinfo); + data->color_id[data->totline] = UI_TIP_LC_SUBMENU; + data->totline++; + } +#endif +#if 0 if (but->optype && !(but->block->flag & UI_BLOCK_LOOP)) { /* operator keymap (not menus, they already have it) */ prop = (but->opptr) ? but->opptr->data : NULL; @@ -482,6 +509,14 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->totline++; } } +#else + /* Op shortcut */ + if (op_keymap.strinfo) { + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), op_keymap.strinfo); + data->color_id[data->totline] = UI_TIP_LC_NORMAL; + data->totline++; + } +#endif if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { /* full string */ @@ -515,7 +550,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->totline++; } } - +#if 0 /* rna info */ if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s.%s"), @@ -523,7 +558,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->color_id[data->totline] = UI_TIP_LC_PYTHON; data->totline++; } - +#endif if (but->rnapoin.id.data) { ID *id = but->rnapoin.id.data; if (id->lib && id->lib->name) { @@ -558,10 +593,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) if (poll_msg) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Disabled: %s"), poll_msg); data->color_id[data->totline] = UI_TIP_LC_ALERT; /* alert */ - data->totline++; + data->totline++; } } } +#if 0 else if (ELEM(but->type, MENU, PULLDOWN)) { if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { MenuType *mt = uiButGetMenuType(but); @@ -571,8 +607,34 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->totline++; } } - } +#else + if ((U.flag & USER_TOOLTIPS_PYTHON) == 0 && !but->optype && rna_struct.strinfo) { + if (rna_prop.strinfo) + /* Struct and prop */ + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), + TIP_("Python: %s.%s"), rna_struct.strinfo, rna_prop.strinfo); + else + /* Only struct (e.g. menus) */ + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), rna_struct.strinfo); + data->color_id[data->totline] = UI_TIP_LC_PYTHON; + data->totline++; + } +#endif + + /* Free strinfo's... */ + if (but_tip.strinfo) + MEM_freeN(but_tip.strinfo); + if (enum_label.strinfo) + MEM_freeN(enum_label.strinfo); + if (enum_tip.strinfo) + MEM_freeN(enum_tip.strinfo); + if (op_keymap.strinfo) + MEM_freeN(op_keymap.strinfo); + if (rna_struct.strinfo) + MEM_freeN(rna_struct.strinfo); + if (rna_prop.strinfo) + MEM_freeN(rna_prop.strinfo); assert(data->totline < MAX_TOOLTIP_LINES); @@ -1454,21 +1516,21 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* when you are outside parent button, safety there should be smaller */ - // parent button to left + /* parent button to left */ if (midx < block->minx) block->safety.xmin = block->minx - 3; else block->safety.xmin = block->minx - 40; - // parent button to right + /* parent button to right */ if (midx > block->maxx) block->safety.xmax = block->maxx + 3; else block->safety.xmax = block->maxx + 40; - - // parent button on bottom + + /* parent button on bottom */ if (midy < block->miny) block->safety.ymin = block->miny - 3; else block->safety.ymin = block->miny - 40; - // parent button on top + /* parent button on top */ if (midy > block->maxy) block->safety.ymax = block->maxy + 3; else block->safety.ymax = block->maxy + 40; - - // exception for switched pulldowns... + + /* exception for switched pulldowns... */ if (dir1 && (dir1 & block->direction) == 0) { if (dir2 == UI_RIGHT) block->safety.xmax = block->maxx + 3; if (dir2 == UI_LEFT) block->safety.xmin = block->minx - 3; @@ -1862,7 +1924,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3]) */ rgb_to_hsv_compat_v(rgb, hsv); - // this updates button strings, is hackish... but button pointers are on stack of caller function + /* this updates button strings, is hackish... but button pointers are on stack of caller function */ for (bt = block->buttons.first; bt; bt = bt->next) { if (bt->rnaprop) { @@ -2130,8 +2192,8 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("B "), 0, -100, butwidth, UI_UNIT_Y, ptr, prop, 2, 0.0, 0.0, 0, 3, TIP_("Blue")); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); - // could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE); - // but need to use uiButSetFunc for updating other fake buttons + /* could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE); + * but need to use uiButSetFunc for updating other fake buttons */ /* HSV values */ uiBlockBeginAlign(block); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 5d527667170..779341160c5 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -374,7 +374,7 @@ void uiStyleInit(void) ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT); } - // XXX, this should be moved into a style, but for now best only load the monospaced font once. + /* XXX, this should be moved into a style, but for now best only load the monospaced font once. */ if (blf_mono_font == -1) blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index eb89fd66b77..cbc76137ae1 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -588,7 +588,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co uiItemL(row, "ID-Block:", ICON_NONE); /* ID-Type Selector - just have a menu of icons */ - // FIXME: the icon-only setting doesn't work when we supply a blank name + /* FIXME: the icon-only setting doesn't work when we supply a blank name */ uiItemFullR(row, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* ID-Block Selector - just use pointer widget... */ @@ -623,7 +623,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna /* Path (existing string) Widget */ uiItemR(row, ptr, propname, 0, text, ICON_RNA); - // TODO: attach something to this to make allow searching of nested properties to 'build' the path + /* TODO: attach something to this to make allow searching of nested properties to 'build' the path */ } /************************ Modifier Template *************************/ @@ -742,7 +742,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* VIRTUAL MODIFIER */ - // XXX this is not used now, since these cannot be accessed via RNA + /* XXX this is not used now, since these cannot be accessed via RNA */ BLI_snprintf(str, sizeof(str), "%s parent deform", md->name); uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); @@ -822,7 +822,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiBlockEndAlign(block); uiBlockSetEmboss(block, UI_EMBOSSN); - // When Modifier is a simulation, show button to switch to context rather than the delete button. + /* When Modifier is a simulation, show button to switch to context rather than the delete button. */ if (modifier_can_delete(md) && !modifier_is_simulation(md)) uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove"); if (modifier_is_simulation(md) == 1) @@ -909,7 +909,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) /* find modifier and draw it */ cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0); - // XXX virtual modifiers are not accesible for python + /* XXX virtual modifiers are not accesible for python */ vmd = modifiers_getVirtualModifierList(ob); for (i = 0; vmd; i++, vmd = vmd->next) { @@ -946,20 +946,20 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) switch (event) { case B_CONSTRAINT_TEST: - break; // no handling + break; /* no handling */ case B_CONSTRAINT_CHANGETARGET: - if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels + if (ob->pose) ob->pose->flag |= POSE_RECALC; /* checks & sorts pose channels */ DAG_scene_sort(bmain, scene); break; default: break; } - // note: RNA updates now call this, commenting else it gets called twice. - // if there are problems because of this, then rna needs changed update functions. - // - // object_test_constraints(ob); - // if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); + /* note: RNA updates now call this, commenting else it gets called twice. + * if there are problems because of this, then rna needs changed update functions. + * + * object_test_constraints(ob); + * if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */ if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); else DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -1985,14 +1985,14 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, i, FALSE); } } - + /* view3d layer change should update depsgraph (invisible object changed maybe) */ /* see view3d_header.c */ } -// TODO: -// - for now, grouping of layers is determined by dividing up the length of -// the array of layer bitflags +/* TODO: + * - for now, grouping of layers is determined by dividing up the length of + * the array of layer bitflags */ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 5ee89bb418f..7b139d81a1c 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1952,8 +1952,8 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa int a; float h = hsv[0], s = hsv[1], v = hsv[2]; float dx, dy, sx1, sx2, sy; - float col0[4][3]; // left half, rect bottom to top - float col1[4][3]; // right half, rect bottom to top + float col0[4][3]; /* left half, rect bottom to top */ + float col1[4][3]; /* right half, rect bottom to top */ /* draw series of gouraud rects */ glShadeModel(GL_SMOOTH); @@ -2542,12 +2542,12 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat round_box_edges(&wtb, roundboxalign, rect, 5.0f); ui_get_but_vectorf(but, col); - + if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) { - // draw based on state - color for keyed etc + /* draw based on state - color for keyed etc */ widgetbase_draw(&wtb, wcol); - - // inset to draw swatch color + + /* inset to draw swatch color */ rect->xmin += SWATCH_KEYED_BORDER; rect->xmax -= SWATCH_KEYED_BORDER; rect->ymin += SWATCH_KEYED_BORDER; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index b202672a2c7..6c03feeb26a 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -91,7 +91,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo if (btheme) { - // first check for ui buttons theme + /* first check for ui buttons theme */ if (colorid < TH_THEMEUI) { switch (colorid) { @@ -942,7 +942,7 @@ void UI_SetTheme(int spacetype, int regionid) theme_regionid = RGN_TYPE_WINDOW; } else { - // later on, a local theme can be found too + /* later on, a local theme can be found too */ theme_active = U.themes.first; theme_spacetype = spacetype; theme_regionid = regionid; @@ -1301,8 +1301,8 @@ void init_userdef_do_versions(void) /* transform widget settings */ if (U.tw_hotspot == 0) { U.tw_hotspot = 14; - U.tw_size = 20; // percentage of window size - U.tw_handlesize = 16; // percentage of widget radius + U.tw_size = 20; /* percentage of window size */ + U.tw_handlesize = 16; /* percentage of widget radius */ } if (U.pad_rot_angle == 0) U.pad_rot_angle = 15; @@ -1359,7 +1359,7 @@ void init_userdef_do_versions(void) for (btheme = U.themes.first; btheme; btheme = btheme->next) { /* check for (alpha == 0) is safe, then color was never set */ if (btheme->ttime.back[3] == 0) { - // copied from ui_theme_init_default + /* copied from ui_theme_init_default */ btheme->ttime = btheme->tv3d; rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0); rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 392aae1632d..47e91f4c659 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -91,7 +91,7 @@ static void view2d_masks(View2D *v2d) v2d->mask.ymax = v2d->winy - 1; #if 0 - // XXX see above + /* XXX see above */ v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE); /* check size if: */ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) @@ -203,7 +203,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->cur = v2d->tot; /* scrollers - should we have these by default? */ - // XXX for now, we don't override this, or set it either! + /* XXX for now, we don't override this, or set it either! */ } break; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 129a47c7063..3be41d1f46e 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1133,7 +1133,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) */ float zoom, center, size; - // TODO: is this zoom factor calculation valid? It seems to produce same results everytime... + /* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { size = (v2d->cur.xmax - v2d->cur.xmin); zoom = size / (rect.xmax - rect.xmin); @@ -1266,7 +1266,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ } /* check if mouse is in or past either handle */ - // TODO: check if these extents are still valid or not + /* TODO: check if these extents are still valid or not */ in_max = ( (mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)) ); in_min = ( (mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE)) && (mouse >= (sh_min - V2D_SCROLLER_HANDLE_SIZE)) ); in_bar = ( (mouse < (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse > (sh_min + V2D_SCROLLER_HANDLE_SIZE)) ); diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 77808d0a00d..6e4da6b7e88 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -174,7 +174,7 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - // Texture options + /* Texture options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA); @@ -192,7 +192,7 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE); - // Armature options + /* Armature options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c index b724db6e737..d2b0ddd4e7e 100644 --- a/source/blender/editors/io/io_ops.c +++ b/source/blender/editors/io/io_ops.c @@ -37,7 +37,7 @@ void ED_operatortypes_io(void) { #ifdef WITH_COLLADA - // Collada operators: + /* Collada operators: */ WM_operatortype_append(WM_OT_collada_export); WM_operatortype_append(WM_OT_collada_import); #endif diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index cce7e26115e..b9522540e67 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -238,6 +238,9 @@ void ED_operatortypes_mask(void) WM_operatortype_append(MASK_OT_shape_key_clear); WM_operatortype_append(MASK_OT_shape_key_feather_reset); WM_operatortype_append(MASK_OT_shape_key_rekey); + + /* layers */ + WM_operatortype_append(MASK_OT_layer_move); } void ED_keymap_mask(wmKeyConfig *keyconf) diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 3836b393bf8..6124947e3b9 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -243,7 +243,7 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay) mask_shape_dupe = BKE_mask_layer_shape_duplicate(masklay_shape); masklay_shape->flag &= ~MASK_SHAPE_SELECT; - // XXX - how to handle duplicate frames? + /* XXX - how to handle duplicate frames? */ BLI_insertlinkafter(&masklay->splines_shapes, masklay_shape, mask_shape_dupe); } } diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index f1d72f59078..bad0a9c28a8 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -70,6 +70,8 @@ struct MaskSplinePoint *ED_mask_point_find_nearest( struct MaskLayer **masklay_r, struct MaskSpline **spline_r, int *is_handle_r, float *score); +void MASK_OT_layer_move(struct wmOperatorType *ot); + /* mask_relationships.c */ void MASK_OT_parent_set(struct wmOperatorType *ot); void MASK_OT_parent_clear(struct wmOperatorType *ot); diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 91ba05c1ab2..902d065e87b 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -1341,3 +1341,74 @@ void MASK_OT_feather_weight_clear(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + +/******************** move mask layer operator *********************/ + +static int mask_layer_move_poll(bContext *C) +{ + if (ED_maskedit_mask_poll(C)) { + Mask *mask = CTX_data_edit_mask(C); + + return mask->masklay_tot > 0; + } + + return FALSE; +} + +static int mask_layer_move_exec(bContext *C, wmOperator *op) +{ + Mask *mask = CTX_data_edit_mask(C); + MaskLayer *mask_layer = BLI_findlink(&mask->masklayers, mask->masklay_act); + MaskLayer *mask_layer_other; + int direction = RNA_enum_get(op->ptr, "direction"); + + if (!mask_layer) + return OPERATOR_CANCELLED; + + if (direction == -1) { + mask_layer_other = mask_layer->prev; + + if (!mask_layer_other) + return OPERATOR_CANCELLED; + + BLI_remlink(&mask->masklayers, mask_layer); + BLI_insertlinkbefore(&mask->masklayers, mask_layer_other, mask_layer); + mask->masklay_act--; + } + else if (direction == 1) { + mask_layer_other = mask_layer->next; + + if (!mask_layer_other) + return OPERATOR_CANCELLED; + + BLI_remlink(&mask->masklayers, mask_layer); + BLI_insertlinkafter(&mask->masklayers, mask_layer_other, mask_layer); + mask->masklay_act++; + } + + return OPERATOR_FINISHED; +} + +void MASK_OT_layer_move(wmOperatorType *ot) +{ + static EnumPropertyItem direction_items[] = { + {-1, "UP", 0, "Up", ""}, + {1, "DOWN", 0, "Down", ""}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name = "Move Layer"; + ot->description = "Move the active layer up/down in the list"; + ot->idname = "MASK_OT_layer_move"; + + /* api callbacks */ + ot->exec = mask_layer_move_exec; + ot->poll = mask_layer_move_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move the active layer"); +} diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index e619277456e..a2a7a07d089 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -418,7 +418,7 @@ static int border_select_exec(bContext *C, wmOperator *op) /* TODO: handles? */ /* TODO: uw? */ - if (BLI_in_rctf(&rectf, point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1])) { + if (BLI_in_rctf_v(&rectf, point_deform->bezt.vec[1])) { BKE_mask_point_select_set(point, mode == GESTURE_MODAL_SELECT); BKE_mask_point_select_set_handle(point, mode == GESTURE_MODAL_SELECT); } diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index b592449fff5..addd0b14916 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -329,7 +329,7 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2] if (me == NULL || me->totpoly == 0) return; if (mode == 0 || mode == 1) { - // XXX - Causes glitches, not sure why + /* XXX - Causes glitches, not sure why */ #if 0 if (!facesel_face_pick(C, me, mval, &index, 1)) return; diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index 2cb03104874..549032f7286 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -55,7 +55,7 @@ typedef struct BMBVHTree { BMesh *bm; BVHTree *tree; float epsilon; - float maxdist; //for nearest point search + float maxdist; /* for nearest point search */ float uv[2]; /* stuff for topological vert search */ diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index fa637b6d6ce..cb8b2c076e2 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1508,25 +1508,25 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho BMVert *eve = NULL; BMEdge *eed = NULL; BMFace *efa = NULL; - + /* setup view context for argument to callbacks */ em_setup_viewcontext(C, &vc); vc.mval[0] = mval[0]; vc.mval[1] = mval[1]; - + if (unified_findnearest(&vc, &eve, &eed, &efa)) { - - // Deselect everything + + /* Deselect everything */ if (extend == 0 && deselect == 0 && toggle == 0) EDBM_flag_disable_all(vc.em, BM_ELEM_SELECT); - + if (efa) { if (extend) { - // set the last selected face + /* set the last selected face */ BM_active_face_set(vc.em->bm, efa); - - // Work-around: deselect first, so we can guarantee it will - // be active even if it was already selected + + /* Work-around: deselect first, so we can guarantee it will */ + /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, efa); BM_face_select_set(vc.em->bm, efa, FALSE); BM_select_history_store(vc.em->bm, efa); @@ -1537,9 +1537,9 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho BM_face_select_set(vc.em->bm, efa, FALSE); } else { - // set the last selected face + /* set the last selected face */ BM_active_face_set(vc.em->bm, efa); - + if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_select_history_store(vc.em->bm, efa); BM_face_select_set(vc.em->bm, efa, TRUE); @@ -1552,8 +1552,8 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho } else if (eed) { if (extend) { - // Work-around: deselect first, so we can guarantee it will - // be active even if it was already selected + /* Work-around: deselect first, so we can guarantee it will */ + /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, eed); BM_edge_select_set(vc.em->bm, eed, FALSE); BM_select_history_store(vc.em->bm, eed); @@ -1576,8 +1576,8 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho } else if (eve) { if (extend) { - // Work-around: deselect first, so we can guarantee it will - // be active even if it was already selected + /* Work-around: deselect first, so we can guarantee it will */ + /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, eve); BM_vert_select_set(vc.em->bm, eve, FALSE); BM_select_history_store(vc.em->bm, eve); @@ -1598,9 +1598,9 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho } } } - + EDBM_selectmode_flush(vc.em); - + /* change active material on object */ if (efa && efa->mat_nr != vc.obedit->actcol - 1) { vc.obedit->actcol = efa->mat_nr + 1; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 208aa2f9b12..1432985d290 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -443,7 +443,7 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe nr = 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4"); else if (em->bm->totfacesel == 1) nr = 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4"); - else + else nr = 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4"); } else if (em->selectmode & SCE_SELECT_EDGE) { diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index cdbf5751ea1..044c23092bd 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -265,11 +265,11 @@ int join_mesh_exec(bContext *C, wmOperator *op) key->totkey++; if (key->totkey == 1) key->refkey = kbn; - // XXX 2.5 Animato + /* XXX 2.5 Animato */ #if 0 /* also, copy corresponding ipo-curve to ipo-block if applicable */ if (me->key->ipo && key->ipo) { - // FIXME... this is a luxury item! + /* FIXME... this is a luxury item! */ puts("FIXME: ignoring IPO's when joining shapekeys on Meshes for now..."); } #endif @@ -530,7 +530,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* free temp copy of destination shapekeys (if applicable) */ if (nkey) { - // XXX 2.5 Animato + /* XXX 2.5 Animato */ #if 0 /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ if (nkey->ipo) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ba26b92f354..7ab20033239 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -558,8 +558,8 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) unsigned int layer; float loc[3], rot[3]; float mat[4][4]; - - object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called + + object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -629,7 +629,7 @@ static int object_add_text_exec(bContext *C, wmOperator *op) unsigned int layer; float loc[3], rot[3]; - object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called + object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -669,18 +669,18 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) int enter_editmode; unsigned int layer; float loc[3], rot[3]; - - object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called + + object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; - + if ((obedit == NULL) || (obedit->type != OB_ARMATURE)) { obedit = ED_object_add_type(C, OB_ARMATURE, loc, rot, TRUE, layer); ED_object_enter_editmode(C, 0); newob = 1; } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); - + if (obedit == NULL) { BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature"); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index a38c69fba8a..be25c79ba25 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -462,7 +462,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) if (type == CONSTRAINT_OBTYPE_BONE) { if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), ct->subtarget)) { /* bone must exist in armature... */ - // TODO: clear subtarget? + /* TODO: clear subtarget? */ curcon->flag |= CONSTRAINT_DISABLE; } else if (strcmp(pchan->name, ct->subtarget) == 0) { @@ -718,7 +718,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, unit_m4(invmat); /* try to find a pose channel - assume that this is the constraint owner */ - // TODO: get from context instead? + /* TODO: get from context instead? */ if (ob && ob->pose) pchan = BKE_pose_channel_active(ob); @@ -974,7 +974,7 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) ListBase *lb = get_constraint_lb(ob, con, NULL); /* lets be nice and escape if its active already */ - // NOTE: this assumes that the stack doesn't have other active ones set... + /* NOTE: this assumes that the stack doesn't have other active ones set... */ if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE)) return; @@ -1518,16 +1518,16 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* do type-specific tweaking to the constraint settings */ switch (type) { - case CONSTRAINT_TYPE_PYTHON: // FIXME: this code is not really valid anymore + case CONSTRAINT_TYPE_PYTHON: /* FIXME: this code is not really valid anymore */ { #ifdef WITH_PYTHON char *menustr; int scriptint = 0; /* popup a list of usable scripts */ menustr = buildmenu_pyconstraints(NULL, &scriptint); - // XXX scriptint = pupmenu(menustr); + /* XXX scriptint = pupmenu(menustr); */ MEM_freeN(menustr); - + /* only add constraint if a script was chosen */ if (scriptint) { /* add constraint */ @@ -1787,7 +1787,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { bConstraint *con, *next; - // TODO: should we be checking if these contraints were local before we try and remove them? + /* TODO: should we be checking if these contraints were local before we try and remove them? */ for (con = pchan->constraints.first; con; con = next) { next = con->next; if (con->type == CONSTRAINT_TYPE_KINEMATIC) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 35ee641d2c1..b5e85c3712b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -408,12 +408,12 @@ void ED_object_enter_editmode(bContext *C, int flag) ScrArea *sa = CTX_wm_area(C); View3D *v3d = NULL; int ok = 0; - + if (scene->id.lib) return; - + if (sa && sa->spacetype == SPACE_VIEW3D) v3d = sa->spacedata.first; - + if ((flag & EM_IGNORE_LAYER) == 0) { base = CTX_data_active_base(C); /* active layer checked here for view3d */ @@ -428,12 +428,12 @@ void ED_object_enter_editmode(bContext *C, int flag) if (ELEM3(NULL, base, base->object, base->object->data)) return; ob = base->object; - + if (BKE_object_obdata_is_libdata(ob)) { error_libdata(); return; } - + if (flag & EM_WAITCURSOR) waitcursor(1); ob->restore_mode = ob->mode; @@ -444,7 +444,7 @@ void ED_object_enter_editmode(bContext *C, int flag) ED_object_toggle_modes(C, ob->mode); ob->mode = OB_MODE_EDIT; - + if (ob->type == OB_MESH) { BMEditMesh *em; ok = 1; @@ -457,7 +457,7 @@ void ED_object_enter_editmode(bContext *C, int flag) /* order doesn't matter */ EDBM_mesh_normals_update(em); BMEdit_RecalcTessellation(em); - + BM_mesh_select_mode_flush(em->bm); } @@ -482,48 +482,48 @@ void ED_object_enter_editmode(bContext *C, int flag) scene->obedit = ob; ED_armature_to_edit(ob); /* to ensure all goes in restposition and without striding */ - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX: should this be OB_RECALC_DATA? + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene); } else if (ob->type == OB_FONT) { - scene->obedit = ob; // XXX for context + scene->obedit = ob; /* XXX for context */ ok = 1; make_editText(ob); WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene); } else if (ob->type == OB_MBALL) { - scene->obedit = ob; // XXX for context + scene->obedit = ob; /* XXX for context */ ok = 1; make_editMball(ob); WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene); } else if (ob->type == OB_LATTICE) { - scene->obedit = ob; // XXX for context + scene->obedit = ob; /* XXX for context */ ok = 1; make_editLatt(ob); - + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene); } else if (ob->type == OB_SURF || ob->type == OB_CURVE) { ok = 1; - scene->obedit = ob; // XXX for context + scene->obedit = ob; /* XXX for context */ make_editNurb(ob); - + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene); } - + if (ok) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { - scene->obedit = NULL; // XXX for context + scene->obedit = NULL; /* XXX for context */ ob->mode &= ~OB_MODE_EDIT; WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene); } - + if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode"); if (flag & EM_WAITCURSOR) waitcursor(0); } @@ -1145,7 +1145,7 @@ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *U } /* show popup dialog to allow editing of range... */ - // FIXME: hardcoded dimensions here are just arbitrary + /* FIXME: hardcoded dimensions here are just arbitrary */ return WM_operator_props_dialog_popup(C, op, 200, 200); } diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index e9341d90e86..65dd9a12d3b 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -397,7 +397,7 @@ static void object_hook_select(Object *ob, HookModifierData *hmd) } /* special poll operators for hook operators */ -// TODO: check for properties window modifier context too as alternative? +/* TODO: check for properties window modifier context too as alternative? */ static int hook_op_edit_poll(bContext *C) { Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index aab3d8afb22..3d9e62b1a16 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1353,7 +1353,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->description = "Save displacements to an external file"; ot->idname = "OBJECT_OT_multires_external_save"; - // XXX modifier no longer in context after file browser .. ot->poll = multires_poll; + /* XXX modifier no longer in context after file browser .. ot->poll = multires_poll; */ ot->exec = multires_external_save_exec; ot->invoke = multires_external_save_invoke; ot->poll = multires_poll; @@ -1375,7 +1375,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) if (!CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; - // XXX don't remove.. + /* XXX don't remove.. */ CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 07557d8ea4c..83d92b9df27 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -119,7 +119,7 @@ static void object_clear_rot(Object *ob) if ((ob->protectflag & OB_LOCK_ROTZ) == 0) ob->quat[3] = ob->dquat[3] = 0.0f; - // TODO: does this quat need normalizing now? + /* TODO: does this quat need normalizing now? */ } else { /* the flag may have been set for the other modes, so just ignore the extra flag... */ @@ -133,7 +133,7 @@ static void object_clear_rot(Object *ob) } else { /* perform clamping using euler form (3-components) */ - // FIXME: deltas are not handled for these cases yet... + /* FIXME: deltas are not handled for these cases yet... */ float eul[3], oldeul[3], quat1[4] = {0}; if (ob->rotmode == ROT_MODE_QUAT) { diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index b5a0451b507..2e9652686da 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1007,7 +1007,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } } bestIndex = -1; - // find the best change with an acceptable horizontal change + /* find the best change with an acceptable horizontal change */ for (i = 0; i < totweight; i++) { if (fabs(changes[i][0]) > fabs(changes[i][1] * 2.0f)) { bestIndex = i; @@ -1016,8 +1016,8 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } if (bestIndex != -1) { wasChange = TRUE; - // it is a good place to stop if it tries to move the opposite direction - // (relative to the plane) of last time + /* it is a good place to stop if it tries to move the opposite direction + * (relative to the plane) of last time */ if (lastIndex != -1) { if (wasUp != upDown[bestIndex]) { wasChange = FALSE; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 2e58fa85a11..1fe533eb23f 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -203,7 +203,7 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char elbeemSimplifyChannelFloat(channel, &channelSize); } else { - // invalid, cant happen? + /* invalid, cant happen? */ } fprintf(file, " CHANNEL %s =\n", str); @@ -651,16 +651,16 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF FluidsimSettings *domainSettings= fluidmd->fss; FILE *fileCfg; int dirExist = 0; - char newSurfdataPath[FILE_MAX]; // modified output settings + char newSurfdataPath[FILE_MAX]; /* modified output settings */ const char *suffixConfigTmp = FLUID_SUFFIX_CONFIG_TMP; int outStringsChanged = 0; - // prepare names... + /* prepare names... */ const char *relbase= modifier_path_relbase(fsDomain); BLI_strncpy(targetDir, domainSettings->surfdataPath, FILE_MAXDIR); BLI_strncpy(newSurfdataPath, domainSettings->surfdataPath, FILE_MAXDIR); /* if 0'd out below, this value is never used! */ - BLI_path_abs(targetDir, relbase); // fixed #frame-no + BLI_path_abs(targetDir, relbase); /* fixed #frame-no */ /* .tmp: don't overwrite/delete original file */ BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index d37a16cb1bb..538b4b3884a 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -477,11 +477,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) const short view_context = (oglrender->v3d != NULL); Object *camera = NULL; - /* update animated image textures for gpu, etc, - * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ - ED_image_update_frame(bmain, scene->r.cfra); - /* go to next frame */ + if (CFRA < oglrender->nfra) + CFRA++; while (CFRA < oglrender->nfra) { unsigned int lay = screen_opengl_layers(oglrender); @@ -492,6 +490,10 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) CFRA++; } + /* update animated image textures for gpu, etc, + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + ED_image_update_frame(bmain, CFRA); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); if (view_context) { @@ -569,10 +571,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) /* go to next frame */ oglrender->nfra += scene->r.frame_step; - scene->r.cfra++; /* stop at the end or on error */ - if (scene->r.cfra > PEFRA || !ok) { + if (CFRA >= PEFRA || !ok) { screen_opengl_render_end(C, op->customdata); return 0; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 9771fef2d58..714700ec8f1 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -607,7 +607,7 @@ static void area_azone_initialize(ScrArea *sa) az->y1 = sa->totrct.ymin - 1; az->x2 = sa->totrct.xmin + (AZONESPOT - 1); az->y2 = sa->totrct.ymin + (AZONESPOT - 1); - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); @@ -616,7 +616,7 @@ static void area_azone_initialize(ScrArea *sa) az->y1 = sa->totrct.ymax + 1; az->x2 = sa->totrct.xmax - (AZONESPOT - 1); az->y2 = sa->totrct.ymax - (AZONESPOT - 1); - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } #define AZONEPAD_EDGE 4 @@ -650,7 +650,7 @@ static void region_azone_edge(AZone *az, ARegion *ar) break; } - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) @@ -692,7 +692,7 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) break; } - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); /* if more azones on 1 spot, set offset */ for (azt = sa->actionzones.first; azt; azt = azt->next) { @@ -706,7 +706,7 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) az->y1 -= AZONESPOT; az->y2 -= AZONESPOT; } - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } } } @@ -753,7 +753,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) break; } /* rect needed for mouse pointer test */ - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } @@ -798,7 +798,7 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) break; } /* rect needed for mouse pointer test */ - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } #define AZONEPAD_TRIAW 16 @@ -843,7 +843,7 @@ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) break; } /* rect needed for mouse pointer test */ - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } @@ -911,7 +911,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int return; /* no returns in function, winrct gets set in the end again */ - BLI_init_rcti(&ar->winrct, 0, 0, 0, 0); + BLI_rcti_init(&ar->winrct, 0, 0, 0, 0); /* for test; allow split of previously defined region */ if (ar->alignment & RGN_SPLIT_PREV) @@ -947,7 +947,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int else if (alignment == RGN_ALIGN_NONE) { /* typically last region */ ar->winrct = *remainder; - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); } else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) { @@ -1007,7 +1007,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int remainder->xmin = ar->winrct.xmax + 1; } else { - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); } } else { @@ -1016,7 +1016,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int remainder->ymin = ar->winrct.ymax + 1; } else { - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); } } } @@ -1036,7 +1036,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int if (count != 4) { /* let's stop adding regions */ - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); if (G.debug & G_DEBUG) printf("region quadsplit failed\n"); } @@ -1058,7 +1058,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int else { /* right top */ ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; - BLI_init_rcti(remainder, 0, 0, 0, 0); + BLI_rcti_init(remainder, 0, 0, 0, 0); } quad++; @@ -1149,7 +1149,7 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand { /* note, add-handler checks if it already exists */ - // XXX it would be good to have boundbox checks for some of these... + /* XXX it would be good to have boundbox checks for some of these... */ if (flag & ED_KEYMAP_UI) { /* user interface widgets */ UI_add_region_handlers(handlers); @@ -1654,7 +1654,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE; - // don't jump back when panels close or hide + /* don't jump back when panels close or hide */ if (!newcontext) y = MAX2(-y, -v2d->cur.ymin); else @@ -1669,14 +1669,14 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * //v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_KEEPOFS_Y); v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE; v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_HIDE; - - // don't jump back when panels close or hide + + /* don't jump back when panels close or hide */ if (!newcontext) x = MAX2(x, v2d->cur.xmax); y = -y; } - // +V2D_SCROLL_HEIGHT is workaround to set the actual height + /* +V2D_SCROLL_HEIGHT is workaround to set the actual height */ UI_view2d_totRect_set(v2d, x + V2D_SCROLL_WIDTH, y + V2D_SCROLL_HEIGHT); /* set the view */ @@ -1698,17 +1698,17 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) - // scrollbars for button regions + /* XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) + * scrollbars for button regions */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); ar->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE; ar->v2d.scroll &= ~V2D_SCROLL_VERTICAL_HIDE; ar->v2d.keepzoom |= V2D_KEEPZOOM; - // correctly initialized User-Prefs? + /* correctly initialized User-Prefs? */ if (!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) ar->v2d.flag &= ~V2D_IS_INITIALISED; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index a638aac9423..48532c83e4c 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1219,7 +1219,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) ScrArea *sa; for (sa = win->screen->areabase.first; sa; sa = sa->next) - if ((az = is_in_area_actionzone(sa, event->x, event->y))) + if ((az = is_in_area_actionzone(sa, &event->x))) break; if (sa) { @@ -1262,12 +1262,12 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) for (sa = scr->areabase.first; sa; sa = sa->next) { if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) - if (NULL == is_in_area_actionzone(sa, event->x, event->y)) + if (NULL == is_in_area_actionzone(sa, &event->x)) break; } if (sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (BLI_in_rcti(&ar->winrct, event->x, event->y)) + if (BLI_in_rcti_v(&ar->winrct, &event->x)) scr->subwinactive = ar->swinid; } } @@ -1314,7 +1314,7 @@ int ED_screen_area_active(const bContext *C) ScrArea *sa = CTX_wm_area(C); if (win && sc && sa) { - AZone *az = is_in_area_actionzone(sa, win->eventstate->x, win->eventstate->y); + AZone *az = is_in_area_actionzone(sa, &win->eventstate->x); ARegion *ar; if (az && az->type == AZONE_REGION) diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index aa11c3eecdd..86d99777e98 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -54,7 +54,7 @@ void removenotused_scredges(bScreen *sc); int scredge_is_horizontal(ScrEdge *se); ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my); -struct AZone *is_in_area_actionzone(ScrArea *sa, int x, int y); +struct AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]); /* screen_context.c */ int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 6be276dea14..547e7bc8e5a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -524,15 +524,15 @@ static int actionzone_area_poll(bContext *C) return 0; } -AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) +AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) { AZone *az = NULL; for (az = sa->actionzones.first; az; az = az->next) { - if (BLI_in_rcti(&az->rect, x, y)) { + if (BLI_in_rcti_v(&az->rect, xy)) { if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ - int radius = (x - az->x1) * (x - az->x1) + (y - az->y1) * (y - az->y1); + int radius = (xy[0] - az->x1) * (xy[0] - az->x1) + (xy[1] - az->y1) * (xy[1] - az->y1); if (radius <= AZONESPOT * AZONESPOT) break; @@ -577,7 +577,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) { - AZone *az = is_in_area_actionzone(CTX_wm_area(C), event->x, event->y); + AZone *az = is_in_area_actionzone(CTX_wm_area(C), &event->x); sActionzoneData *sad; /* quick escape */ diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 5ca436b07b2..7f51f54ee4b 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -294,7 +294,7 @@ static int project_brush_radius(ViewContext *vc, ED_view3d_global_to_vector(vc->rv3d, location, view); - // create a vector that is not orthogonal to view + /* create a vector that is not orthogonal to view */ if (fabsf(view[0]) < 0.1f) { nonortho[0] = view[0] + 1.0f; @@ -312,19 +312,19 @@ static int project_brush_radius(ViewContext *vc, nonortho[2] = view[2] + 1.0f; } - // get a vector in the plane of the view + /* get a vector in the plane of the view */ cross_v3_v3v3(ortho, nonortho, view); normalize_v3(ortho); - // make a point on the surface of the brush tagent to the view + /* make a point on the surface of the brush tagent to the view */ mul_v3_fl(ortho, radius); add_v3_v3v3(offset, location, ortho); - // project the center of the brush, and the tangent point to the view onto the screen + /* 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); - // the distance between these points is the size of the projected brush in pixels + /* the distance between these points is the size of the projected brush in pixels */ return len_v2v2(p1, p2); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 6a8f7db5fc9..5e46a28a3b7 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -583,7 +583,7 @@ static int project_bucket_offset_safe(const ProjPaintState *ps, const float proj } /* still use 2D X,Y space but this works for verts transformed by a perspective matrix, using their 4th component as a weight */ -static void barycentric_weights_v2_persp(float v1[4], float v2[4], float v3[4], float co[2], float w[3]) +static void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const float v3[4], const float co[2], float w[3]) { float wtot_inv, wtot; @@ -603,13 +603,17 @@ static void barycentric_weights_v2_persp(float v1[4], float v2[4], float v3[4], w[0] = w[1] = w[2] = 1.0f / 3.0f; } -static float VecZDepthOrtho(float pt[2], float v1[3], float v2[3], float v3[3], float w[3]) +static float VecZDepthOrtho(const float pt[2], + const float v1[3], const float v2[3], const float v3[3], + float w[3]) { barycentric_weights_v2(v1, v2, v3, pt, w); return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]); } -static float VecZDepthPersp(float pt[2], float v1[4], float v2[4], float v3[4], float w[3]) +static float VecZDepthPersp(const float pt[2], + const float v1[4], const float v2[4], const float v3[4], + float w[3]) { float wtot_inv, wtot; float w_tmp[3]; @@ -1455,8 +1459,8 @@ static float project_paint_uvpixel_mask( } /* otherwise no mask normal is needed, were within the limit */ } - // This only works when the opacity dosnt change while painting, stylus pressure messes with this - // so don't use it. + /* This only works when the opacity dosnt change while painting, stylus pressure messes with this + * so don't use it. */ // if (ps->is_airbrush==0) mask *= BKE_brush_alpha_get(ps->brush); return mask; @@ -1611,7 +1615,7 @@ static int line_clip_rect2f( if (fabsf(l1[0] - l2[0]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/ - if (BLI_in_rctf(rect, l1[0], l1[1])) { + if (BLI_in_rctf_v(rect, l1)) { copy_v2_v2(l1_clip, l1); copy_v2_v2(l2_clip, l2); return 1; @@ -1639,7 +1643,7 @@ static int line_clip_rect2f( } if (fabsf(l1[1] - l2[1]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/ - if (BLI_in_rctf(rect, l1[0], l1[1])) { + if (BLI_in_rctf_v(rect, l1)) { copy_v2_v2(l1_clip, l1); copy_v2_v2(l2_clip, l2); return 1; @@ -1663,12 +1667,12 @@ static int line_clip_rect2f( /* Done with vertical lines */ /* are either of the points inside the rectangle ? */ - if (BLI_in_rctf(rect, l1[0], l1[1])) { + if (BLI_in_rctf_v(rect, l1)) { copy_v2_v2(l1_clip, l1); ok1 = 1; } - if (BLI_in_rctf(rect, l2[0], l2[1])) { + if (BLI_in_rctf_v(rect, l2)) { copy_v2_v2(l2_clip, l2); ok2 = 1; } @@ -1816,7 +1820,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s * this is even less work then an intersection test */ #if 0 - if (BLI_in_rctf(bucket_bounds, cent[0], cent[1])) + if (BLI_in_rctf_v(bucket_bounds, cent)) return 1; #endif @@ -1983,9 +1987,9 @@ static void project_bucket_clip_face( float bucket_bounds_ss[4][2]; /* get the UV space bounding box */ - inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v1coSS[0], v1coSS[1]); - inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v2coSS[0], v2coSS[1]) << 1; - inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v3coSS[0], v3coSS[1]) << 2; + inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v1coSS); + inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v2coSS) << 1; + inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v3coSS) << 2; if (inside_bucket_flag == ISECT_ALL3) { /* all screenspace points are inside the bucket bounding box, this means we don't need to clip and can simply return the UVs */ @@ -2812,7 +2816,7 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke fidx = mf->v4 ? 3 : 2; do { v = ps->screenCoords[(*(&mf->v1 + fidx))]; - if (BLI_in_rctf(&bucket_bounds, v[0], v[1])) { + if (BLI_in_rctf_v(&bucket_bounds, v)) { return 1; } } while (fidx--); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 082e40f8e4c..3c8f39a44b1 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -41,6 +41,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_rect.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -80,8 +81,7 @@ int paint_convert_bb_to_rect(rcti *rect, float projection_mat[4][4]; int i, j, k; - rect->xmin = rect->ymin = INT_MAX; - rect->xmax = rect->ymax = INT_MIN; + BLI_rcti_init_minmax(rect); /* return zero if the bounding box has non-positive volume */ if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) @@ -93,16 +93,19 @@ int paint_convert_bb_to_rect(rcti *rect, for (j = 0; j < 2; ++j) { for (k = 0; k < 2; ++k) { float vec[3], proj[2]; + int proj_i[2]; vec[0] = i ? bb_min[0] : bb_max[0]; 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); /* expand 2D rectangle */ - rect->xmin = MIN2(rect->xmin, proj[0]); - rect->xmax = MAX2(rect->xmax, proj[0]); - rect->ymin = MIN2(rect->ymin, proj[1]); - rect->ymax = MAX2(rect->ymax, proj[1]); + + /* we could project directly to int? */ + proj_i[0] = proj[0]; + proj_i[1] = proj[1]; + + BLI_rcti_do_minmax_v(rect, proj_i); } } } diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index b5cd49cc15c..dbde950188d 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -489,15 +489,15 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* copy keyframes */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { - // FIXME... + /* FIXME... */ BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for Grease Pencil mode"); return OPERATOR_CANCELLED; } else if (ac.datatype == ANIMCONT_MASK) { - // FIXME... + /* FIXME... */ BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for mask mode"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index b13ba9a1aa3..199875fdc7b 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -116,8 +116,8 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSS); xco -= UI_UNIT_X; - - // Default panels + + /* Default panels */ uiBlockBeginAlign(block); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 9d1f52568b4..86d74ef4c78 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -62,6 +62,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "UI_view2d.h" @@ -239,12 +240,12 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) strncpy(path, U.textudir, sizeof(path)); } + if (RNA_struct_property_is_set(op->ptr, "files")) + return open_exec(C, op); + if (!RNA_struct_property_is_set(op->ptr, "relative_path")) RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); - if (RNA_struct_property_is_set(op->ptr, "filepath")) - return open_exec(C, op); - open_init(C, op); clip_filesel(C, op, path); @@ -1074,15 +1075,8 @@ static int mode_set_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); int mode = RNA_enum_get(op->ptr, "mode"); - int toggle = RNA_boolean_get(op->ptr, "toggle"); - if (sc->mode == mode) { - if (toggle) - sc->mode = SC_MODE_TRACKING; - } - else { - sc->mode = mode; - } + sc->mode = mode; WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CLIP, NULL); @@ -1091,13 +1085,6 @@ static int mode_set_exec(bContext *C, wmOperator *op) void CLIP_OT_mode_set(wmOperatorType *ot) { - static EnumPropertyItem mode_items[] = { - {SC_MODE_TRACKING, "TRACKING", 0, "Tracking", "Show tracking and solving tools"}, - {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", 0, "Reconstruction", "Show tracking/reconstruction tools"}, - {SC_MODE_DISTORTION, "DISTORTION", 0, "Distortion", "Show distortion tools"}, - {0, NULL, 0, NULL, NULL}}; - - /* identifiers */ ot->name = "Set Clip Mode"; ot->description = "Set the clip interaction mode"; @@ -1109,8 +1096,7 @@ void CLIP_OT_mode_set(wmOperatorType *ot) ot->poll = ED_space_clip_poll; /* properties */ - RNA_def_enum(ot->srna, "mode", mode_items, SC_MODE_TRACKING, "Mode", ""); - RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); + RNA_def_enum(ot->srna, "mode", clip_editor_mode_items, SC_MODE_TRACKING, "Mode", ""); } /********************** macroses *********************/ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 0a6a4af6960..3623cd1d58b 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -559,13 +559,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "sequence", TRUE); /* mode */ - kmi = WM_keymap_add_item(keymap, "CLIP_OT_mode_set", TABKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "mode", SC_MODE_RECONSTRUCTION); - RNA_boolean_set(kmi->ptr, "toggle", TRUE); - - kmi = WM_keymap_add_item(keymap, "CLIP_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "mode", SC_MODE_DISTORTION); - RNA_boolean_set(kmi->ptr, "toggle", TRUE); + WM_keymap_add_menu(keymap, "CLIP_MT_select_mode", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CLIP_OT_solve_camera", SKEY, KM_PRESS, KM_SHIFT, 0); @@ -792,8 +786,16 @@ static int clip_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve static void clip_drop_copy(wmDrag *drag, wmDropBox *drop) { - /* copy drag path to properties */ - RNA_string_set(drop->ptr, "filepath", drag->path); + PointerRNA itemptr; + char dir[FILE_MAX], file[FILE_MAX]; + + BLI_split_dirfile(drag->path, dir, file, sizeof(dir), sizeof(file)); + + RNA_string_set(drop->ptr, "directory", dir); + + RNA_collection_clear(drop->ptr, "files"); + RNA_collection_add(drop->ptr, "files", &itemptr); + RNA_string_set(&itemptr, "name", file); } /* area+region dropbox definition */ diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 0ebb84b3953..0d933c1dff3 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -361,7 +361,7 @@ static int border_select_exec(bContext *C, wmOperator *op) MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { - if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { + if (BLI_in_rctf_v(&rectf, marker->pos)) { if (mode == GESTURE_MODAL_SELECT) BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); else diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 2d778b94216..9591e624296 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -81,7 +81,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion *ar, UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin, &fxmin, &fymin); UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax, &fxmax, &fymax); - BLI_init_rcti(&rect_view, (int)(v2d->tot.xmin + fxmin), (int)(v2d->tot.xmin + fxmax), (int)(v2d->tot.ymax - fymin), (int)(v2d->tot.ymax - fymax)); + BLI_rcti_init(&rect_view, (int)(v2d->tot.xmin + fxmin), (int)(v2d->tot.xmin + fxmax), (int)(v2d->tot.ymax - fymin), (int)(v2d->tot.ymax - fymax)); sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 6d2c8657f0b..ec16fa539e9 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -351,11 +351,11 @@ void filelist_filter(FileList *filelist) { int num_filtered = 0; int i, j; - + if (!filelist->filelist) return; - // How many files are left after filter ? + /* How many files are left after filter ? */ for (i = 0; i < filelist->numfiles; ++i) { struct direntry *file = &filelist->filelist[i]; if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { @@ -428,7 +428,7 @@ void folderlist_popdir(struct ListBase *folderlist, char *dir) folder = folderlist->last; if (folder) { - // remove the current directory + /* remove the current directory */ MEM_freeN(folder->foldername); BLI_freelinkN(folderlist, folder); @@ -438,7 +438,7 @@ void folderlist_popdir(struct ListBase *folderlist, char *dir) BLI_strncpy(dir, prev_dir, FILE_MAXDIR); } } - // delete the folder next or use setdir directly before PREVIOUS OP + /* delete the folder next or use setdir directly before PREVIOUS OP */ } void folderlist_pushdir(ListBase *folderlist, const char *dir) @@ -446,21 +446,21 @@ void folderlist_pushdir(ListBase *folderlist, const char *dir) struct FolderList *folder, *previous_folder; previous_folder = folderlist->last; - // check if already exists + /* check if already exists */ if (previous_folder && previous_folder->foldername) { if (BLI_path_cmp(previous_folder->foldername, dir) == 0) { return; } } - // create next folder element + /* create next folder element */ folder = (FolderList *)MEM_mallocN(sizeof(FolderList), "FolderList"); folder->foldername = (char *)MEM_mallocN(sizeof(char) * (strlen(dir) + 1), "foldername"); folder->foldername[0] = '\0'; BLI_strncpy(folder->foldername, dir, FILE_MAXDIR); - // add it to the end of the list + /* add it to the end of the list */ BLI_addtail(folderlist, folder); } @@ -468,16 +468,16 @@ int folderlist_clear_next(struct SpaceFile *sfile) { struct FolderList *folder; - // if there is no folder_next there is nothing we can clear + /* if there is no folder_next there is nothing we can clear */ if (!sfile->folders_next) return 0; - // if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next + /* if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next */ folder = sfile->folders_prev->last; if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) return 0; - // eventually clear flist->folders_next + /* eventually clear flist->folders_next */ return 1; } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index adb3e7acca5..ef3e150b034 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -117,7 +117,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) const short is_directory = (RNA_struct_find_property(op->ptr, "directory") != NULL); const short is_relative_path = (RNA_struct_find_property(op->ptr, "relative_path") != NULL); - BLI_strncpy(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title)); + BLI_strncpy_utf8(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title)); if (RNA_struct_find_property(op->ptr, "filemode")) params->type = RNA_int_get(op->ptr, "filemode"); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 0366043aaa0..a127e2ca2bc 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -179,15 +179,15 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c } } else { - // if we're bookmarking this, file should come - // before the last separator, only automatically added - // current dir go after the last sep. + /* if we're bookmarking this, file should come + * before the last separator, only automatically added + * current dir go after the last sep. */ if (save) { break; } } } - + fsme = MEM_mallocN(sizeof(*fsme), "fsme"); fsme->path = BLI_strdup(path); fsme->save = save; @@ -247,7 +247,7 @@ void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename) } fprintf(fp, "[Recent]\n"); nskip = fsmenu_get_nentries(fsmenu, FS_CATEGORY_RECENT) - FSMENU_RECENT_MAX; - // skip first entries if list too long + /* skip first entries if list too long */ for (fsme = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsme && (nskip > 0); fsme = fsme->next, --nskip) { /* pass */ } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index dbc66b81874..b1e1b6e411a 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -260,8 +260,8 @@ void GRAPH_OT_view_all(wmOperatorType *ot) /* api callbacks */ ot->exec = graphkeys_viewall_exec; - ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... - + ot->poll = ED_operator_graphedit_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */ + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -279,7 +279,7 @@ void GRAPH_OT_view_selected(wmOperatorType *ot) /* api callbacks */ ot->exec = graphkeys_view_selected_exec; - ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... + ot->poll = ED_operator_graphedit_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */ /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1641,7 +1641,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) int f; /* sanity check: ensure that there are enough F-Curves to work on in this group */ - // TODO: also enforce assumption that there be a full set of keyframes at each position by ensuring that totvert counts are same? + /* TODO: also enforce assumption that there be a full set of keyframes at each position by ensuring that totvert counts are same? */ if (ELEM3(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) { /* report which components are missing */ BKE_reportf(op->reports, RPT_WARNING, @@ -1655,9 +1655,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) failed++; continue; } - + /* simple method: just treat any difference between keys of greater than 180 degrees as being a flip */ - // FIXME: there are more complicated methods that will be needed to fix more cases than just some + /* FIXME: there are more complicated methods that will be needed to fix more cases than just some */ for (f = 0; f < 3; f++) { FCurve *fcu = euf->fcurves[f]; BezTriple *bezt, *prev = NULL; @@ -2217,10 +2217,10 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op) /* if this exists, call the copy F-Modifiers API function */ if (ale && ale->data) { FCurve *fcu = (FCurve *)ale->data; - - // TODO: when 'active' vs 'all' boolean is added, change last param! + + /* TODO: when 'active' vs 'all' boolean is added, change last param! */ ok = ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0); - + /* free temp data now */ MEM_freeN(ale); } @@ -2272,11 +2272,11 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) /* paste modifiers */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - - // TODO: do we want to replace existing modifiers? add user pref for that! + + /* TODO: do we want to replace existing modifiers? add user pref for that! */ ok += ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, 0); } - + /* clean up */ BLI_freelistN(&anim_data); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 33e32363cf5..52a7f9b115c 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -961,9 +961,9 @@ static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fc } } else if (fpt) { - // TODO... + /* TODO... */ } -} +} /* helper for find_nearest_fcurve_vert() - build the list of nearest matches */ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], ListBase *matches) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 92c339d7672..99969405f9c 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -276,7 +276,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block) /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ - BLI_init_rctf(&dispf, 15.0f, (block->maxx - block->minx) - 15.0f, 15.0f, (block->maxy - block->miny) - 15.0f); + BLI_rctf_init(&dispf, 15.0f, (block->maxx - block->minx) - 15.0f, 15.0f, (block->maxy - block->miny) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); /* correction for gla draw */ @@ -372,7 +372,7 @@ static char *slot_menu(void) static char *layer_menu(RenderResult *rr, short *UNUSED(curlay)) { RenderLayer *rl; - int len = 64 + 32 * BLI_countlist(&rr->layers); + int len = 64 + RE_MAXNAME * BLI_countlist(&rr->layers); short a, nr = 0; char *str = MEM_callocN(len, "menu layers"); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ac71eb972f6..88eb280ea6b 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -728,11 +728,21 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) /* retrieve the image and information about it */ ima = ED_space_image(sima); ED_space_image_zoom(sima, ar, &zoomx, &zoomy); - ibuf = ED_space_image_acquire_buffer(sima, &lock); show_viewer = (ima && ima->source == IMA_SRC_VIEWER); show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT); + if (show_viewer) { + /* use locked draw for drawing viewer image buffer since the conpositor + * is running in separated thread and compositor could free this buffers. + * other images are not modifying in such a way so they does not require + * lock (sergey) + */ + BLI_lock_thread(LOCK_DRAW_IMAGE); + } + + ibuf = ED_space_image_acquire_buffer(sima, &lock); + /* draw the image or grid */ if (ibuf == NULL) ED_region_grid_draw(ar, zoomx, zoomy); @@ -770,5 +780,8 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) /* render info */ if (ima && show_render) draw_render_info(scene, ima, ar); -} + if (show_viewer) { + BLI_unlock_thread(LOCK_DRAW_IMAGE); + } +} diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 3dc1fbd738f..ca16558f3a6 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1652,7 +1652,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) Image *ima = CTX_data_edit_image(C); ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); - // flags indicate if this channel should be inverted + /* flags indicate if this channel should be inverted */ const short r = RNA_boolean_get(op->ptr, "invert_r"); const short g = RNA_boolean_get(op->ptr, "invert_g"); const short b = RNA_boolean_get(op->ptr, "invert_b"); @@ -1660,7 +1660,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) int i; - if (ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup + if (ibuf == NULL) /* TODO: this should actually never happen, but does for render-results -> cleanup */ return OPERATOR_CANCELLED; /* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */ diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 11a39693168..b92fe315d1c 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -140,9 +140,9 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor } else { Base *b; - + /* deselect all */ - // TODO: should this deselect all other types of channels too? + /* TODO: should this deselect all other types of channels too? */ for (b = sce->base.first; b; b = b->next) { b->flag &= ~SELECT; b->object->flag = b->flag; @@ -269,8 +269,8 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { if (nlaedit_is_tweakmode_on(ac) == 0) { /* 'push-down' action - only usable when not in TweakMode */ - // TODO: make this use the operator instead of calling the function directly - // however, calling the operator requires that we supply the args, and that works with proper buttons only + /* TODO: make this use the operator instead of calling the function directly + * however, calling the operator requires that we supply the args, and that works with proper buttons only */ BKE_nla_action_pushdown(adt); } else { diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index 8c3397b9ddd..9c48ce4034d 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -31,6 +31,7 @@ set(INC ../../nodes ../../render/extern/include ../../windowmanager + ../../compositor ../../../../intern/guardedalloc ../../../../intern/opennl/extern ) diff --git a/source/blender/editors/space_node/SConscript b/source/blender/editors/space_node/SConscript index 2dee750f8c0..4c6e94484e4 100644 --- a/source/blender/editors/space_node/SConscript +++ b/source/blender/editors/space_node/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('*.c') incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna ../../makesrna ../../imbuf' -incs += ' ../../nodes ../../render/extern/include ../../blenloader ../../gpu' +incs += ' ../../nodes ../../render/extern/include ../../blenloader ../../gpu ../../compositor' incs += ' ../../windowmanager #intern/guardedalloc #extern/glew/include' defs = [] cf = [] diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 218d11f3035..c4b9d5989e1 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -52,6 +52,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" +#include "BKE_tracking.h" #include "BLF_api.h" #include "BLF_translation.h" @@ -82,7 +83,7 @@ #include "node_intern.h" -// XXX interface.h +/* XXX interface.h */ extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select); /* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */ @@ -140,7 +141,8 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); - layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), FALSE); + layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, + args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), FALSE); uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE); @@ -216,13 +218,17 @@ static void node_draw_output_default(const bContext *C, uiBlock *block, int ofs = 0; const char *ui_name = IFACE_(name); UI_ThemeColor(TH_TEXT); - slen = snode->aspect * UI_GetStringWidth(ui_name); + slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt; while (slen > node->width) { ofs++; - slen = snode->aspect * UI_GetStringWidth(ui_name + ofs); + slen = (UI_GetStringWidth(ui_name + ofs) + NODE_MARGIN_X) * snode->aspect_sqrt; } - uiDefBut(block, LABEL, 0, ui_name + ofs, (short)(sock->locx - 15.0f - slen), (short)(sock->locy - 9.0f), - (short)(node->width - NODE_DY), NODE_DY, NULL, 0, 0, 0, 0, ""); + 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, ""); + + (void)snode; } /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */ @@ -298,14 +304,17 @@ static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiLayout *row; + uiLayout *row, *col; bNodeTree *ntree = (bNodeTree *)ptr->id.data; - row = uiLayoutRow(layout, TRUE); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, TRUE); uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE); if (ntree->type == NTREE_COMPOSIT) uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA); + + uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE); } static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -340,7 +349,7 @@ static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0); } -static float _sample_col[4]; // bad bad, 2.5 will do better? +static float _sample_col[4]; /* bad bad, 2.5 will do better?... no it won't... */ #define SAMPLE_FLT_ISNONE FLT_MAX void ED_node_sample_set(const float col[4]) { @@ -387,12 +396,12 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA * uiBut *bt; bt = uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "", - (short)butr->xmin, (short)butr->xmin, - butr->xmax - butr->xmin, butr->xmax - butr->xmin, + (int)butr->xmin, (int)butr->xmin, + (short)(butr->xmax - butr->xmin), (short)(butr->xmax - butr->xmin), nor, 0.0f, 1.0f, 0, 0, ""); uiButSetFunc(bt, node_normal_cb, ntree, node); } -#if 0 // not used in 2.5x yet +#if 0 /* not used in 2.5x yet */ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) { Main *bmain = CTX_data_main(C); @@ -447,6 +456,7 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); + uiItemR(layout, ptr, "use_clamp", 0, NULL, ICON_NONE); } static int node_resize_area_default(bNode *node, int x, int y) @@ -645,7 +655,8 @@ static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), v ntreeUpdateTree(ngroup); } -static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock, int in_out, float xoffset, float yoffset) +static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock, + int in_out, float xoffset, float yoffset) { bNodeTree *ngroup = (bNodeTree *)gnode->id; uiBut *bt; @@ -667,7 +678,8 @@ 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) +static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode, + bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out) { bNodeTree *ngroup = (bNodeTree *)gnode->id; bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type); @@ -717,12 +729,14 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt if (gsock) { draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0); if (stype->buttonfunc) - stype->buttonfunc(C, gnode->block, ngroup, NULL, gsock, "", gsock->locx + offset, gsock->locy - NODE_DY, colw); + 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); if (stype->buttonfunc) - stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "", sock->locx + offset, sock->locy - NODE_DY, colw); + stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "", + sock->locx + offset, sock->locy - NODE_DY, colw); } } else { @@ -776,8 +790,9 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiLayout *layout; PointerRNA ptr; rctf rect = gnode->totr; - float node_group_frame = U.dpi * NODE_GROUP_FRAME / 72; - float group_header = 26 * U.dpi / 72; + const float dpi_fac = U.dpi / 72.0f; + float node_group_frame = NODE_GROUP_FRAME * dpi_fac; + float group_header = 26 * dpi_fac; int index; @@ -785,7 +800,9 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN glEnable(GL_BLEND); uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); - uiDrawBox(GL_POLYGON, rect.xmin - node_group_frame, rect.ymax, rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD); + uiDrawBox(GL_POLYGON, + rect.xmin - node_group_frame, rect.ymax, + rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD); /* backdrop body */ UI_ThemeColorShadeAlpha(TH_BACK, -8, -70); @@ -820,14 +837,17 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiSetRoundBox(UI_CNR_ALL); glColor4ub(200, 200, 200, 140); glEnable(GL_LINE_SMOOTH); - uiDrawBox(GL_LINE_LOOP, rect.xmin - node_group_frame, rect.ymin, rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD); + uiDrawBox(GL_LINE_LOOP, + rect.xmin - node_group_frame, rect.ymin, + rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); /* backdrop title */ UI_ThemeColor(TH_TEXT_HI); - layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin + 15), (short)(rect.ymax + group_header), + 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))), MIN2((int)(rect.xmax - rect.xmin - 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); @@ -946,20 +966,22 @@ static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode node->totr = rect; } -static void node_draw_frame_label(bNode *node) +static void node_draw_frame_label(bNode *node, const float aspect) { /* XXX font id is crap design */ - const int fontid = blf_mono_font; + const int fontid = UI_GetStyle()->widgetlabel.uifont_id; NodeFrame *data = (NodeFrame *)node->storage; rctf *rct = &node->totr; int color_id = node_get_colorid(node); - char label[128]; + const char *label = nodeLabel(node); /* XXX a bit hacky, should use separate align values for x and y */ float width, ascender; float x, y; - - BLI_strncpy(label, nodeLabel(node), sizeof(label)); - BLF_size(fontid, data->label_size, U.dpi); + const int font_size = data->label_size / aspect; + + BLF_enable(fontid, BLF_ASPECT); + BLF_aspect(fontid, aspect, aspect, 1.0f); + BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */ /* title color */ UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10); @@ -967,11 +989,14 @@ static void node_draw_frame_label(bNode *node) width = BLF_width(fontid, label); ascender = BLF_ascender(fontid); + /* 'x' doesn't need aspect correction */ x = 0.5f * (rct->xmin + rct->xmax) - 0.5f * width; - y = rct->ymax - NODE_DYS - ascender; - + y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect)); + BLF_position(fontid, x, y, 0); BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX); + + BLF_disable(fontid, BLF_ASPECT); } static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *UNUSED(ntree), bNode *node) @@ -981,9 +1006,6 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN unsigned char color[4]; float alpha; - UI_GetThemeColor4ubv(TH_NODE_FRAME, color); - alpha = (float)(color[3])/255.0f; - /* skip if out of view */ if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax || node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) { @@ -992,6 +1014,9 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN node->block = NULL; return; } + + UI_GetThemeColor4ubv(TH_NODE_FRAME, color); + alpha = (float)(color[3]) / 255.0f; /* shadow */ node_draw_shadow(snode, node, BASIS_RAD, alpha); @@ -1016,14 +1041,16 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN else UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); uiSetRoundBox(UI_CNR_ALL); - uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); + uiDrawBox(GL_LINE_LOOP, + rct->xmin, rct->ymin, + rct->xmax, rct->ymax, BASIS_RAD); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } /* label */ - node_draw_frame_label(node); + node_draw_frame_label(node, snode->aspect); UI_ThemeClearColor(color_id); @@ -1062,7 +1089,7 @@ static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), Point } -#define NODE_REROUTE_SIZE 8.0f +#define NODE_REROUTE_SIZE 8.0f static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node) { @@ -1074,36 +1101,36 @@ static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntr nodeToView(node, 0.0f, 0.0f, &locx, &locy); /* reroute node has exactly one input and one output, both in the same place */ - nsock= node->outputs.first; - nsock->locx= locx; - nsock->locy= locy; + nsock = node->outputs.first; + nsock->locx = locx; + nsock->locy = locy; - nsock= node->inputs.first; - nsock->locx= locx; - nsock->locy= locy; - - node->width = size*2; - node->totr.xmin= locx - size; - node->totr.xmax= locx + size; - node->totr.ymax= locy + size; - node->totr.ymin= locy - size; + nsock = node->inputs.first; + nsock->locx = locx; + nsock->locy = locy; + + node->width = size * 2; + node->totr.xmin = locx - size; + node->totr.xmax = locx + size; + node->totr.ymax = locy + size; + node->totr.ymin = locy - size; } static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(snode), bNodeTree *ntree, bNode *node) { bNodeSocket *sock; - #if 0 /* UNUSED */ - rctf *rct= &node->totr; +#if 0 /* UNUSED */ + rctf *rct = &node->totr; float size = NODE_REROUTE_SIZE; - #endif - float socket_size= NODE_SOCKSIZE; +#endif + float socket_size = NODE_SOCKSIZE; /* skip if out of view */ if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax || - node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) { + node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) { uiEndBlock(C, node->block); - node->block= NULL; + node->block = NULL; return; } @@ -1122,12 +1149,12 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - /* using different shades of TH_TEXT_HI for the empasis, like triangle */ - if (node->flag & NODE_ACTIVE) - UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); - else - UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); - uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); + /* using different shades of TH_TEXT_HI for the empasis, like triangle */ + if (node->flag & NODE_ACTIVE) + UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); + else + UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); + uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); @@ -1137,13 +1164,13 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* only draw input socket. as they all are placed on the same position. * highlight also if node itself is selected, since we don't display the node body separately! */ - for (sock= node->inputs.first; sock; sock= sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { node_socket_circle_draw(ntree, sock, socket_size, (sock->flag & SELECT) || (node->flag & SELECT)); } uiEndBlock(C, node->block); uiDrawBlock(C, node->block); - node->block= NULL; + node->block = NULL; } /* Special tweak area for reroute node. @@ -1152,12 +1179,12 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( static int node_tweak_area_reroute(bNode *node, int x, int y) { /* square of tweak radius */ - static const float tweak_radius_sq = 576; /* 24*24 */ + static const float tweak_radius_sq = 576; /* 24 * 24 */ bNodeSocket *sock = node->inputs.first; float dx = sock->locx - x; float dy = sock->locy - y; - return (dx*dx + dy*dy <= tweak_radius_sq); + return (dx * dx + dy * dy <= tweak_radius_sq); } static void node_common_set_butfunc(bNodeType *ntype) @@ -1185,16 +1212,17 @@ static void node_common_set_butfunc(bNodeType *ntype) ntype->resize_area_func = node_resize_area_frame; break; case NODE_REROUTE: - ntype->drawfunc= node_draw_reroute; - ntype->drawupdatefunc= node_update_reroute; - ntype->tweak_area_func= node_tweak_area_reroute; + ntype->drawfunc = node_draw_reroute; + ntype->drawupdatefunc = node_update_reroute; + ntype->tweak_area_func = node_tweak_area_reroute; break; } } /* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */ -static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, PointerRNA *imaptr, PointerRNA *iuserptr) +static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, + PointerRNA *imaptr, PointerRNA *iuserptr) { uiLayout *col; int source; @@ -1938,7 +1966,8 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, imfptr = RNA_pointer_get(&inputptr, "format"); imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); - RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); + RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, + RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); uiBlockSetEmboss(block, UI_EMBOSSP); uiItemL(row, imtype_name, 0); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1976,19 +2005,23 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C /* using different collection properties if multilayer format is enabled */ if (multilayer) { uiTemplateList(layout, C, ptr, "layer_slots", ptr, "active_input_index", NULL, 0, 0, 0); - RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"), active_index, &active_input_ptr); + RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"), + active_index, &active_input_ptr); } else { uiTemplateList(layout, C, ptr, "file_slots", ptr, "active_input_index", NULL, 0, 0, 0); - RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"), active_index, &active_input_ptr); + RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"), + active_index, &active_input_ptr); } /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */ active_input_ptr.id.data = ptr->id.data; row = uiLayoutRow(layout, TRUE); - op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); + op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", + ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&op_ptr, "direction", 1); - op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); + op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", + ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&op_ptr, "direction", 2); if (active_input_ptr.data) { @@ -1999,7 +2032,8 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C uiItemL(col, IFACE_("Layer:"), 0); row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "name", 0, "", 0); - uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); + uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", + ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); } else { uiLayout *row, *col; @@ -2008,7 +2042,8 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C uiItemL(col, IFACE_("File Path:"), 0); row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "path", 0, "", 0); - uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); + uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", + ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); /* format details for individual files */ imfptr = RNA_pointer_get(&active_input_ptr, "format"); @@ -2456,7 +2491,7 @@ static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *p static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr) { - bNode *node= ptr->data; + bNode *node = ptr->data; uiTemplateID(layout, C, ptr, "clip", NULL, NULL, NULL); @@ -2479,6 +2514,7 @@ static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), Poi uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "despill_factor", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "despill_balance", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "edge_kernel_radius", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "edge_kernel_tolerance", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE); @@ -2489,6 +2525,41 @@ static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), Poi uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE); } +static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + bNode *node= ptr->data; + + uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL); + + if (node->id) { + MovieClip *clip = (MovieClip *) node->id; + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *object; + uiLayout *col; + PointerRNA tracking_ptr; + NodeTrackPosData *data = node->storage; + + RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr); + + col = uiLayoutColumn(layout, 0); + uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA); + + object = BKE_tracking_object_get_named(tracking, data->tracking_object); + if (object) { + PointerRNA object_ptr; + + RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr); + + uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA); + } + else { + uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA); + } + + uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE); + } +} + /* only once called */ static void node_composit_set_butfunc(bNodeType *ntype) { @@ -2679,7 +2750,7 @@ static void node_composit_set_butfunc(bNodeType *ntype) ntype->uibackdropfunc = node_composit_backdrop_viewer; break; case CMP_NODE_MASK: - ntype->uifunc= node_composit_buts_mask; + ntype->uifunc = node_composit_buts_mask; break; case CMP_NODE_KEYINGSCREEN: ntype->uifunc = node_composit_buts_keyingscreen; @@ -2687,6 +2758,9 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_KEYING: ntype->uifunc = node_composit_buts_keying; break; + case CMP_NODE_TRACKPOS: + ntype->uifunc = node_composit_buts_trackpos; + break; default: ntype->uifunc = NULL; } @@ -2755,7 +2829,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); row = uiLayoutRow(col, FALSE); - uiLayoutSetActive(row, !(RNA_enum_get(&tex_ptr, "wood_type") == TEX_BAND || RNA_enum_get(&tex_ptr, "wood_type") == TEX_RING)); + uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING))); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; @@ -2967,7 +3041,8 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) glPixelZoom(snode->zoom, snode->zoom); /* 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); + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, + ((unsigned char *)ibuf->rect) + ofs); glPixelZoom(1.0f, 1.0f); } @@ -3003,7 +3078,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) } } - /// @note draw selected info on backdrop + /** @note draw selected info on backdrop */ if (snode->edittree) { bNode *node = snode->edittree->nodes.first; while (node) { @@ -3111,37 +3186,46 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa deltay = vec[3][1] - vec[0][1]; /* check direction later, for top sockets */ if (fromreroute) { - if (ABS(deltax)>ABS(deltay)) { - vec[1][1]= vec[0][1]; - vec[1][0]= vec[0][0]+(deltax>0?dist:-dist); - } else { - vec[1][0]= vec[0][0]; - vec[1][1]= vec[0][1]+(deltay>0?dist:-dist); + if (ABS(deltax) > ABS(deltay)) { + vec[1][1] = vec[0][1]; + vec[1][0] = vec[0][0] + (deltax > 0 ? dist : -dist); + } + else { + vec[1][0] = vec[0][0]; + vec[1][1] = vec[0][1] + (deltay > 0 ? dist : -dist); } - } else { + } + else { vec[1][0] = vec[0][0] + dist; vec[1][1] = vec[0][1]; } if (toreroute) { - if (ABS(deltax)>ABS(deltay)) { - vec[2][1]= vec[3][1]; - vec[2][0]= vec[3][0]+ (deltax>0?-dist:dist); - } else { - vec[2][0]= vec[3][0]; - vec[2][1]= vec[3][1]+(deltay>0?-dist:dist); + if (ABS(deltax) > ABS(deltay)) { + vec[2][1] = vec[3][1]; + vec[2][0] = vec[3][0] + (deltax > 0 ? -dist : dist); + } + else { + vec[2][0] = vec[3][0]; + vec[2][1] = vec[3][1] + (deltay > 0 ? -dist : dist); } - } else { + } + else { vec[2][0] = vec[3][0] - dist; vec[2][1] = vec[3][1]; } - if (v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) ; /* clipped */ - else if (v2d && MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) ; /* clipped */ + if (v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) { + /* clipped */ + } + else if (v2d && MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) { + /* clipped */ + } else { - /* always do all three, to prevent data hanging around */ - BKE_curve_forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0], resol, sizeof(float) * 2); - BKE_curve_forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0] + 1, resol, sizeof(float) * 2); + BKE_curve_forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], + coord_array[0] + 0, resol, sizeof(float) * 2); + BKE_curve_forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], + coord_array[0] + 1, resol, sizeof(float) * 2); return 1; } @@ -3149,9 +3233,10 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa } #define LINK_RESOL 24 -#define LINK_ARROW 12 /* position of arrow on the link, LINK_RESOL/2 */ +#define LINK_ARROW 12 /* position of arrow on the link, LINK_RESOL/2 */ #define ARROW_SIZE 7 -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) +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) { float coord_array[LINK_RESOL + 1][2]; @@ -3169,19 +3254,20 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t glEnable(GL_LINE_SMOOTH); - drawarrow = (link->tonode && (link->tonode->type == NODE_REROUTE)) && (link->fromnode && (link->fromnode->type == NODE_REROUTE)); + drawarrow = ((link->tonode && (link->tonode->type == NODE_REROUTE)) && + (link->fromnode && (link->fromnode->type == NODE_REROUTE))); + if (drawarrow) { - // draw arrow in line segment LINK_ARROW - float dx, dy, len; - dx = coord_array[LINK_ARROW][0]-coord_array[LINK_ARROW-1][0]; - dy = coord_array[LINK_ARROW][1]-coord_array[LINK_ARROW-1][1]; - len = sqrtf(dx*dx+dy*dy); - dx = dx /len*ARROW_SIZE; - dy = dy /len*ARROW_SIZE; - arrow1[0] = coord_array[LINK_ARROW][0]-dx+dy; - arrow1[1] = coord_array[LINK_ARROW][1]-dy-dx; - arrow2[0] = coord_array[LINK_ARROW][0]-dx-dy; - arrow2[1] = coord_array[LINK_ARROW][1]-dy+dx; + /* draw arrow in line segment LINK_ARROW */ + float d_xy[2], len; + + sub_v2_v2v2(d_xy, coord_array[LINK_ARROW], coord_array[LINK_ARROW - 1]); + len = len_v2(d_xy); + mul_v2_fl(d_xy, 1.0f / (len * ARROW_SIZE)); + arrow1[0] = coord_array[LINK_ARROW][0] - d_xy[0] + d_xy[1]; + arrow1[1] = coord_array[LINK_ARROW][1] - d_xy[1] - d_xy[0]; + arrow2[0] = coord_array[LINK_ARROW][0] - d_xy[0] - d_xy[1]; + arrow2[1] = coord_array[LINK_ARROW][1] - d_xy[1] + d_xy[0]; arrow[0] = coord_array[LINK_ARROW][0]; arrow[1] = coord_array[LINK_ARROW][1]; } @@ -3247,6 +3333,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t } } +#if 0 /* not used in 2.5x yet */ static void node_link_straight_points(View2D *UNUSED(v2d), SpaceNode *snode, bNodeLink *link, float coord_array[][2]) { if (link->fromsock) { @@ -3269,7 +3356,8 @@ static void node_link_straight_points(View2D *UNUSED(v2d), SpaceNode *snode, bNo } } -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 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) { float coord_array[2][2]; float linew; @@ -3304,11 +3392,13 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int for (i = 0; i < LINK_RESOL - 1; ++i) { float t = (float)i / (float)(LINK_RESOL - 1); UI_ThemeColorBlend(th_col1, th_col2, t); - glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]); + glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], + (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]); t = (float)(i + 1) / (float)(LINK_RESOL - 1); UI_ThemeColorBlend(th_col1, th_col2, t); - glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]); + glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], + (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]); } glEnd(); } @@ -3316,7 +3406,8 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int glBegin(GL_LINE_STRIP); for (i = 0; i < LINK_RESOL; ++i) { float t = (float)i / (float)(LINK_RESOL - 1); - glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]); + glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], + (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]); } glEnd(); } @@ -3326,6 +3417,7 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int /* restore previuos linewidth */ glLineWidth(linew); } +#endif /* note; this is used for fake links in groups too */ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 65646c855b7..adf52313307 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -80,10 +80,11 @@ #include "intern/node_util.h" #include "node_intern.h" +#include "COM_compositor.h" /* width of socket columns in group display */ -#define NODE_GROUP_FRAME 120 -// XXX interface.h +#define NODE_GROUP_FRAME 120 +/* XXX interface.h */ extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select); /* XXX update functions for node editor are a mess, needs a clear concept */ @@ -91,8 +92,8 @@ void ED_node_tree_update(SpaceNode *snode, Scene *scene) { snode_set_context(snode, scene); - if (snode->nodetree && snode->nodetree->id.us==0) - snode->nodetree->id.us= 1; + if (snode->nodetree && snode->nodetree->id.us == 0) + snode->nodetree->id.us = 1; } void ED_node_changed_update(ID *id, bNode *node) @@ -102,30 +103,30 @@ void ED_node_changed_update(ID *id, bNode *node) node_tree_from_ID(id, &nodetree, &edittree, &treetype); - if (treetype==NTREE_SHADER) { + if (treetype == NTREE_SHADER) { DAG_id_tag_update(id, 0); if (GS(id->name) == ID_MA) - WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, id); + WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, id); else if (GS(id->name) == ID_LA) - WM_main_add_notifier(NC_LAMP|ND_LIGHTING_DRAW, id); + WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, id); else if (GS(id->name) == ID_WO) - WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, id); + WM_main_add_notifier(NC_WORLD | ND_WORLD_DRAW, id); } - else if (treetype==NTREE_COMPOSIT) { + else if (treetype == NTREE_COMPOSIT) { if (node) nodeUpdate(edittree, node); /* don't use NodeTagIDChanged, it gives far too many recomposites for image, scene layers, ... */ - node= node_tree_get_editgroup(nodetree); + node = node_tree_get_editgroup(nodetree); if (node) nodeUpdateID(nodetree, node->id); - WM_main_add_notifier(NC_SCENE|ND_NODES, id); + WM_main_add_notifier(NC_SCENE | ND_NODES, id); } - else if (treetype==NTREE_TEXTURE) { + else if (treetype == NTREE_TEXTURE) { DAG_id_tag_update(id, 0); - WM_main_add_notifier(NC_TEXTURE|ND_NODES, id); + WM_main_add_notifier(NC_TEXTURE | ND_NODES, id); } } @@ -136,9 +137,9 @@ static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) if (ntree == lookup) return 1; - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) if (node->type == NODE_GROUP && node->id) - if (has_nodetree((bNodeTree*)node->id, lookup)) + if (has_nodetree((bNodeTree *)node->id, lookup)) return 1; return 0; @@ -150,14 +151,14 @@ typedef struct NodeUpdateCalldata { } NodeUpdateCalldata; static void node_generic_update_cb(void *calldata, ID *owner_id, bNodeTree *ntree) { - NodeUpdateCalldata *cd= (NodeUpdateCalldata*)calldata; + NodeUpdateCalldata *cd = (NodeUpdateCalldata *)calldata; /* check if nodetree uses the group stored in calldata */ if (has_nodetree(ntree, cd->ntree)) ED_node_changed_update(owner_id, cd->node); } void ED_node_generic_update(Main *bmain, bNodeTree *ntree, bNode *node) { - bNodeTreeType *tti= ntreeGetType(ntree->type); + bNodeTreeType *tti = ntreeGetType(ntree->type); NodeUpdateCalldata cd; cd.ntree = ntree; cd.node = node; @@ -174,14 +175,14 @@ static int compare_nodes(bNode *a, bNode *b) /* These tell if either the node or any of the parent nodes is selected. * A selected parent means an unselected node is also in foreground! */ - int a_select=(a->flag & NODE_SELECT), b_select=(b->flag & NODE_SELECT); - int a_active=(a->flag & NODE_ACTIVE), b_active=(b->flag & NODE_ACTIVE); + int a_select = (a->flag & NODE_SELECT), b_select = (b->flag & NODE_SELECT); + int a_active = (a->flag & NODE_ACTIVE), b_active = (b->flag & NODE_ACTIVE); /* if one is an ancestor of the other */ /* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */ - for (parent = a->parent; parent; parent=parent->parent) { + for (parent = a->parent; parent; parent = parent->parent) { /* if b is an ancestor, it is always behind a */ - if (parent==b) + if (parent == b) return 1; /* any selected ancestor moves the node forward */ if (parent->flag & NODE_ACTIVE) @@ -189,9 +190,9 @@ static int compare_nodes(bNode *a, bNode *b) if (parent->flag & NODE_SELECT) a_select = 1; } - for (parent = b->parent; parent; parent=parent->parent) { + for (parent = b->parent; parent; parent = parent->parent) { /* if a is an ancestor, it is always behind b */ - if (parent==a) + if (parent == a) return 0; /* any selected ancestor moves the node forward */ if (parent->flag & NODE_ACTIVE) @@ -222,7 +223,7 @@ void ED_node_sort(bNodeTree *ntree) { /* merge sort is the algorithm of choice here */ bNode *first_a, *first_b, *node_a, *node_b, *tmp; - int totnodes= BLI_countlist(&ntree->nodes); + int totnodes = BLI_countlist(&ntree->nodes); int k, a, b; k = 1; @@ -231,11 +232,11 @@ void ED_node_sort(bNodeTree *ntree) do { /* setup first_b pointer */ - for (b=0; b < k && first_b; ++b) { + for (b = 0; b < k && first_b; ++b) { first_b = first_b->next; } /* all batches merged? */ - if (first_b==NULL) + if (first_b == NULL) break; /* merge batches */ @@ -243,7 +244,7 @@ void ED_node_sort(bNodeTree *ntree) node_b = first_b; a = b = 0; while (a < k && b < k && node_b) { - if (compare_nodes(node_a, node_b)==0) { + if (compare_nodes(node_a, node_b) == 0) { node_a = node_a->next; ++a; } @@ -260,7 +261,7 @@ void ED_node_sort(bNodeTree *ntree) first_b = node_b; for (; b < k; ++b) { /* all nodes sorted? */ - if (first_b==NULL) + if (first_b == NULL) break; first_b = first_b->next; } @@ -274,8 +275,8 @@ void ED_node_sort(bNodeTree *ntree) static void do_node_internal_buttons(bContext *C, void *node_v, int event) { - if (event==B_NODE_EXEC) { - SpaceNode *snode= CTX_wm_space_node(C); + if (event == B_NODE_EXEC) { + SpaceNode *snode = CTX_wm_space_node(C); if (snode && snode->id) ED_node_changed_update(snode->id, node_v); } @@ -288,10 +289,10 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { /* ui block */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node); - node->block= uiBeginBlock(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS); + node->block = uiBeginBlock(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS); uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); /* this cancels events for background nodes */ @@ -311,85 +312,81 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) /* get "global" coords */ nodeToView(node, 0.0f, 0.0f, &locx, &locy); - dy= locy; + dy = locy; /* header */ - dy-= NODE_DY; + dy -= NODE_DY; /* little bit space in top */ if (node->outputs.first) - dy-= NODE_DYS/2; + dy -= NODE_DYS / 2; /* output sockets */ - for (nsock= node->outputs.first; nsock; nsock= nsock->next) { + for (nsock = node->outputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { - nsock->locx= locx + node->width; - nsock->locy= dy - NODE_DYS; - dy-= NODE_DY; + nsock->locx = locx + node->width; + nsock->locy = dy - NODE_DYS; + dy -= NODE_DY; } } node->prvr.xmin = locx + NODE_DYS; - node->prvr.xmax = locx + node->width- NODE_DYS; + node->prvr.xmax = locx + node->width - NODE_DYS; /* preview rect? */ if (node->flag & NODE_PREVIEW) { - /* only recalculate size when there's a preview actually, otherwise we use stored result */ - BLI_lock_thread(LOCK_PREVIEW); - if (node->preview && node->preview->rect) { - float aspect= 1.0f; + float aspect = 1.0f; if (node->preview && node->preview->xsize && node->preview->ysize) - aspect= (float)node->preview->ysize/(float)node->preview->xsize; + aspect = (float)node->preview->ysize / (float)node->preview->xsize; - dy-= NODE_DYS/2; + dy -= NODE_DYS / 2; node->prvr.ymax = dy; if (aspect <= 1.0f) - node->prvr.ymin = dy - aspect*(node->width-NODE_DY); + node->prvr.ymin = dy - aspect * (node->width - NODE_DY); else { - float dx= (node->width - NODE_DYS) - (node->width- NODE_DYS)/aspect; /* width correction of image */ + /* width correction of image */ + float dx = (node->width - NODE_DYS) - (node->width - NODE_DYS) / aspect; - node->prvr.ymin = dy - (node->width-NODE_DY); + node->prvr.ymin = dy - (node->width - NODE_DY); - node->prvr.xmin+= 0.5f*dx; - node->prvr.xmax-= 0.5f*dx; + node->prvr.xmin += 0.5f * dx; + node->prvr.xmax -= 0.5f * dx; } - dy= node->prvr.ymin - NODE_DYS/2; + dy = node->prvr.ymin - NODE_DYS / 2; /* make sure that maximums are bigger or equal to minimums */ if (node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin); if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin); } else { - float oldh= node->prvr.ymax - node->prvr.ymin; - if (oldh==0.0f) - oldh= 0.6f*node->width-NODE_DY; - dy-= NODE_DYS/2; + float oldh = node->prvr.ymax - node->prvr.ymin; + if (oldh == 0.0f) + oldh = 0.6f * node->width - NODE_DY; + dy -= NODE_DYS / 2; node->prvr.ymax = dy; node->prvr.ymin = dy - oldh; - dy= node->prvr.ymin - NODE_DYS/2; + dy = node->prvr.ymin - NODE_DYS / 2; } - - BLI_unlock_thread(LOCK_PREVIEW); } /* buttons rect? */ if ((node->flag & NODE_OPTIONS) && node->typeinfo->uifunc) { - dy-= NODE_DYS/2; + dy -= NODE_DYS / 2; /* set this for uifunc() that don't use layout engine yet */ node->butr.xmin = 0; - node->butr.xmax = node->width - 2*NODE_DYS; + node->butr.xmax = node->width - 2 * NODE_DYS; node->butr.ymin = 0; node->butr.ymax = 0; RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); - layout= uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, - locx+NODE_DYS, dy, node->butr.xmax, NODE_DY, UI_GetStyle()); + layout = uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, + locx + NODE_DYS, dy, node->butr.xmax, NODE_DY, UI_GetStyle()); uiLayoutSetContextPointer(layout, "node", &ptr); node->typeinfo->uifunc(layout, (bContext *)C, &ptr); @@ -397,35 +394,35 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) uiBlockEndAlign(node->block); uiBlockLayoutResolve(node->block, NULL, &buty); - dy= buty - NODE_DYS/2; + dy = buty - NODE_DYS / 2; } /* input sockets */ - for (nsock= node->inputs.first; nsock; nsock= nsock->next) { + for (nsock = node->inputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { - nsock->locx= locx; - nsock->locy= dy - NODE_DYS; - dy-= NODE_DY; + nsock->locx = locx; + nsock->locy = dy - NODE_DYS; + dy -= NODE_DY; } } /* little bit space in end */ - if (node->inputs.first || (node->flag & (NODE_OPTIONS|NODE_PREVIEW))==0 ) - dy-= NODE_DYS/2; + if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) + dy -= NODE_DYS / 2; node->totr.xmin = locx; node->totr.xmax = locx + node->width; node->totr.ymax = locy; - node->totr.ymin = MIN2(dy, locy-2*NODE_DY); + node->totr.ymin = MIN2(dy, locy - 2 * NODE_DY); /* Set the block bounds to clip mouse events from underlying nodes. * Add a margin for sockets on each side. */ uiExplicitBoundsBlock(node->block, - node->totr.xmin - NODE_SOCKSIZE, - node->totr.ymin, - node->totr.xmax + NODE_SOCKSIZE, - node->totr.ymax); + node->totr.xmin - NODE_SOCKSIZE, + node->totr.ymin, + node->totr.xmax + NODE_SOCKSIZE, + node->totr.ymax); } /* based on settings in node, sets drawing rect info. each redraw! */ @@ -433,49 +430,49 @@ static void node_update_hidden(bNode *node) { bNodeSocket *nsock; float locx, locy; - float rad, drad, hiddenrad= HIDDEN_RAD; - int totin=0, totout=0, tot; + float rad, drad, hiddenrad = HIDDEN_RAD; + int totin = 0, totout = 0, tot; /* get "global" coords */ nodeToView(node, 0.0f, 0.0f, &locx, &locy); /* calculate minimal radius */ - for (nsock= node->inputs.first; nsock; nsock= nsock->next) + for (nsock = node->inputs.first; nsock; nsock = nsock->next) if (!nodeSocketIsHidden(nsock)) totin++; - for (nsock= node->outputs.first; nsock; nsock= nsock->next) + for (nsock = node->outputs.first; nsock; nsock = nsock->next) if (!nodeSocketIsHidden(nsock)) totout++; - tot= MAX2(totin, totout); - if (tot>4) { - hiddenrad += 5.0f*(float)(tot-4); + tot = MAX2(totin, totout); + if (tot > 4) { + hiddenrad += 5.0f * (float)(tot - 4); } node->totr.xmin = locx; - node->totr.xmax = locx + 3*hiddenrad + node->miniwidth; - node->totr.ymax = locy + (hiddenrad - 0.5f*NODE_DY); - node->totr.ymin = node->totr.ymax - 2*hiddenrad; + node->totr.xmax = locx + 3 * hiddenrad + node->miniwidth; + node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY); + node->totr.ymin = node->totr.ymax - 2 * hiddenrad; /* output sockets */ - rad=drad= (float)M_PI/(1.0f + (float)totout); + rad = drad = (float)M_PI / (1.0f + (float)totout); - for (nsock= node->outputs.first; nsock; nsock= nsock->next) { + for (nsock = node->outputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { - nsock->locx= node->totr.xmax - hiddenrad + (float)sin(rad)*hiddenrad; - nsock->locy= node->totr.ymin + hiddenrad + (float)cos(rad)*hiddenrad; - rad+= drad; + nsock->locx = node->totr.xmax - hiddenrad + (float)sin(rad) * hiddenrad; + nsock->locy = node->totr.ymin + hiddenrad + (float)cos(rad) * hiddenrad; + rad += drad; } } /* input sockets */ - rad=drad= - (float)M_PI/(1.0f + (float)totin); + rad = drad = -(float)M_PI / (1.0f + (float)totin); - for (nsock= node->inputs.first; nsock; nsock= nsock->next) { + for (nsock = node->inputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { - nsock->locx= node->totr.xmin + hiddenrad + (float)sin(rad)*hiddenrad; - nsock->locy= node->totr.ymin + hiddenrad + (float)cos(rad)*hiddenrad; - rad+= drad; + nsock->locx = node->totr.xmin + hiddenrad + (float)sin(rad) * hiddenrad; + nsock->locy = node->totr.ymin + hiddenrad + (float)cos(rad) * hiddenrad; + rad += drad; } } @@ -483,10 +480,10 @@ static void node_update_hidden(bNode *node) * Add a margin for sockets on each side. */ uiExplicitBoundsBlock(node->block, - node->totr.xmin - NODE_SOCKSIZE, - node->totr.ymin, - node->totr.xmax + NODE_SOCKSIZE, - node->totr.ymax); + node->totr.xmin - NODE_SOCKSIZE, + node->totr.ymin, + node->totr.xmax + NODE_SOCKSIZE, + node->totr.ymax); } void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node) @@ -509,19 +506,19 @@ int node_tweak_area_default(bNode *node, int x, int y) int node_get_colorid(bNode *node) { - if (node->typeinfo->nclass==NODE_CLASS_INPUT) + if (node->typeinfo->nclass == NODE_CLASS_INPUT) return TH_NODE_IN_OUT; - if (node->typeinfo->nclass==NODE_CLASS_OUTPUT) { + if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { if (node->flag & NODE_DO_OUTPUT) return TH_NODE_IN_OUT; else return TH_NODE; } - if (node->typeinfo->nclass==NODE_CLASS_CONVERTOR) + if (node->typeinfo->nclass == NODE_CLASS_CONVERTOR) return TH_NODE_CONVERTOR; if (ELEM3(node->typeinfo->nclass, NODE_CLASS_OP_COLOR, NODE_CLASS_OP_VECTOR, NODE_CLASS_OP_FILTER)) return TH_NODE_OPERATOR; - if (node->typeinfo->nclass==NODE_CLASS_GROUP) + if (node->typeinfo->nclass == NODE_CLASS_GROUP) return TH_NODE_GROUP; return TH_NODE; } @@ -563,7 +560,7 @@ static void node_circle_draw(float x, float y, float size, char *col, int highli -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f }; /* 16 values of cos function */ - static float co[16] ={ + static float co[16] = { 1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f, -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f, -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f, @@ -574,8 +571,8 @@ static void node_circle_draw(float x, float y, float size, char *col, int highli glColor3ub(col[0], col[1], col[2]); glBegin(GL_POLYGON); - for (a=0; a<16; a++) - glVertex2f(x+size*si[a], y+size*co[a]); + for (a = 0; a < 16; a++) + glVertex2f(x + size * si[a], y + size * co[a]); glEnd(); if (highlight) { @@ -588,8 +585,8 @@ static void node_circle_draw(float x, float y, float size, char *col, int highli glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glBegin(GL_LINE_LOOP); - for (a=0; a<16; a++) - glVertex2f(x+size*si[a], y+size*co[a]); + for (a = 0; a < 16; a++) + glVertex2f(x + size * si[a], y + size * co[a]); glEnd(); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); @@ -607,9 +604,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= (prv->xmax-prv->xmin)/((float)preview->xsize); - float yscale= (prv->ymax-prv->ymin)/((float)preview->ysize); - float tile= (prv->xmax - prv->xmin) / 10.0f; + float xscale = (prv->xmax - prv->xmin) / ((float)preview->xsize); + float yscale = (prv->ymax - prv->ymin) / ((float)preview->ysize); + float tile = (prv->xmax - prv->xmin) / 10.0f; float x, y; /* draw checkerboard backdrop to show alpha */ @@ -617,26 +614,26 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) glRectf(prv->xmin, prv->ymin, prv->xmax, prv->ymax); glColor3ub(160, 160, 160); - for (y=prv->ymin; y<prv->ymax; y+=tile*2) { - for (x=prv->xmin; x<prv->xmax; x+=tile*2) { - float tilex= tile, tiley= tile; + for (y = prv->ymin; y < prv->ymax; y += tile * 2) { + for (x = prv->xmin; x < prv->xmax; x += tile * 2) { + float tilex = tile, tiley = tile; - if (x+tile > prv->xmax) - tilex= prv->xmax-x; - if (y+tile > prv->ymax) - tiley= prv->ymax-y; + if (x + tile > prv->xmax) + tilex = prv->xmax - x; + if (y + tile > prv->ymax) + tiley = prv->ymax - y; glRectf(x, y, x + tilex, y + tiley); } } - for (y=prv->ymin+tile; y<prv->ymax; y+=tile*2) { - for (x=prv->xmin+tile; x<prv->xmax; x+=tile*2) { - float tilex= tile, tiley= tile; + for (y = prv->ymin + tile; y < prv->ymax; y += tile * 2) { + for (x = prv->xmin + tile; x < prv->xmax; x += tile * 2) { + float tilex = tile, tiley = tile; - if (x+tile > prv->xmax) - tilex= prv->xmax-x; - if (y+tile > prv->ymax) - tiley= prv->ymax-y; + if (x + tile > prv->xmax) + tilex = prv->xmax - x; + if (y + tile > prv->ymax) + tiley = prv->ymax - y; glRectf(x, y, x + tilex, y + tiley); } @@ -661,7 +658,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) /* common handle function for operator buttons that need to select the node first */ static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_argv) { - bNode *node = (bNode*)node_argv; + bNode *node = (bNode *)node_argv; const char *opname = (const char *)op_argv; /* select & activate only the button's node */ @@ -675,15 +672,15 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) rctf *rct = &node->totr; uiSetRoundBox(UI_CNR_ALL); - if (node->parent==NULL) + if (node->parent == NULL) ui_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); else { const float margin = 3.0f; glColor4f(0.0f, 0.0f, 0.0f, 0.33f); glEnable(GL_BLEND); - uiRoundBox(rct->xmin-margin, rct->ymin-margin, - rct->xmax+margin, rct->ymax+margin, radius+margin); + uiRoundBox(rct->xmin - margin, rct->ymin - margin, + rct->xmax + margin, rct->ymax + margin, radius + margin); glDisable(GL_BLEND); } } @@ -691,24 +688,24 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { bNodeSocket *sock; - rctf *rct= &node->totr; + rctf *rct = &node->totr; float iconofs; /* float socket_size= NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */ - float iconbutw= 0.8f*UI_UNIT_X; - int color_id= node_get_colorid(node); + float iconbutw = 0.8f * UI_UNIT_X; + int color_id = node_get_colorid(node); char showname[128]; /* 128 used below */ View2D *v2d = &ar->v2d; /* hurmf... another candidate for callback, have to see how this works first */ - if (node->id && node->block && snode->treetype==NTREE_SHADER) + if (node->id && node->block && snode->treetype == NTREE_SHADER) nodeShaderSynchronizeID(node, 0); /* skip if out of view */ if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax || - node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) { - + node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) + { uiEndBlock(C, node->block); - node->block= NULL; + node->block = NULL; return; } @@ -716,7 +713,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN node_draw_shadow(snode, node, BASIS_RAD, 1.0f); /* header */ - if (color_id==TH_NODE) + if (color_id == TH_NODE) UI_ThemeColorShade(color_id, -20); else UI_ThemeColor(color_id); @@ -724,26 +721,25 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); - if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) { - if (node->highlight) { + if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) { + if (COM_isHighlightedbNode(node)) { UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); - node->highlight = 0; } } uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); - uiRoundBox(rct->xmin, rct->ymax-NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); + uiRoundBox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); /* show/hide icons */ - iconofs= rct->xmax - 7.0f; + iconofs = rct->xmax - 7.0f; /* preview */ if (node->typeinfo->flag & NODE_PREVIEW) { uiBut *but; - iconofs-=iconbutw; + iconofs -= iconbutw; uiBlockSetEmboss(node->block, UI_EMBOSSN); but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_MATERIAL, - iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_preview_toggle"); + iconofs, rct->ymax - NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_preview_toggle"); /* XXX this does not work when node is activated and the operator called right afterwards, * since active ID is not updated yet (needs to process the notifier). * This can only work as visual indicator! @@ -755,11 +751,11 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* group edit */ if (node->type == NODE_GROUP) { uiBut *but; - iconofs-=iconbutw; + iconofs -= iconbutw; uiBlockSetEmboss(node->block, UI_EMBOSSN); but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_NODETREE, - iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_group_edit"); + iconofs, rct->ymax - NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_group_edit"); uiBlockSetEmboss(node->block, UI_EMBOSS); } @@ -772,16 +768,17 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* open/close entirely? */ { uiBut *but; - int but_size = UI_UNIT_X *0.6f; + int but_size = UI_UNIT_X * 0.6f; /* XXX button uses a custom triangle draw below, so make it invisible without icon */ uiBlockSetEmboss(node->block, UI_EMBOSSN); but = uiDefBut(node->block, TOGBUT, B_REDR, "", - rct->xmin+10.0f-but_size/2, rct->ymax-NODE_DY/2.0f-but_size/2, but_size, but_size, NULL, 0, 0, 0, 0, ""); - uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_hide_toggle"); + rct->xmin + 10.0f - but_size / 2, rct->ymax - NODE_DY / 2.0f - but_size / 2, + but_size, but_size, NULL, 0, 0, 0, 0, ""); + uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); uiBlockSetEmboss(node->block, UI_EMBOSS); /* custom draw function for this button */ - UI_DrawTriIcon(rct->xmin+10.0f, rct->ymax-NODE_DY/2.0f, 'v'); + UI_DrawTriIcon(rct->xmin + 10.0f, rct->ymax - NODE_DY / 2.0f, 'v'); } /* this isn't doing anything for the label, so commenting out */ @@ -795,10 +792,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); //if (node->flag & NODE_MUTED) - // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - don't print into self! + // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ - uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(rct->ymax-NODE_DY), - (int)(iconofs - rct->xmin-18.0f), NODE_DY, NULL, 0, 0, 0, 0, ""); + uiDefBut(node->block, LABEL, 0, showname, + (int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(rct->ymax - NODE_DY), + (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY, + NULL, 0, 0, 0, 0, ""); /* body */ if (node->flag & NODE_CUSTOM_COLOR) @@ -807,11 +806,11 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN UI_ThemeColor4(TH_NODE); glEnable(GL_BLEND); uiSetRoundBox(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT); - uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax-NODE_DY, BASIS_RAD); + uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD); glDisable(GL_BLEND); /* outline active and selected emphasis */ - if ( node->flag & (NODE_ACTIVE|SELECT)) { + if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -832,51 +831,51 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* socket inputs, buttons */ - for (sock= node->inputs.first; sock; sock= sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT); node->typeinfo->drawinputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name), - sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY); + sock->locx + (NODE_DYS / snode->aspect_sqrt), sock->locy - NODE_DYS, + node->width - NODE_DY); } /* socket outputs */ - for (sock= node->outputs.first; sock; sock= sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT); node->typeinfo->drawoutputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name), - sock->locx-node->width+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY); + sock->locx - node->width + (NODE_DYS / snode->aspect_sqrt), sock->locy - NODE_DYS, + node->width - NODE_DY); } /* preview */ if (node->flag & NODE_PREVIEW) { - BLI_lock_thread(LOCK_PREVIEW); if (node->preview && node->preview->rect && !BLI_rctf_is_empty(&node->prvr)) node_draw_preview(node->preview, &node->prvr); - BLI_unlock_thread(LOCK_PREVIEW); } UI_ThemeClearColor(color_id); uiEndBlock(C, node->block); uiDrawBlock(C, node->block); - node->block= NULL; + node->block = NULL; } static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { bNodeSocket *sock; - rctf *rct= &node->totr; - float dx, centy= 0.5f*(rct->ymax+rct->ymin); - float hiddenrad= 0.5f*(rct->ymax-rct->ymin); - float socket_size= NODE_SOCKSIZE*U.dpi/72; - int color_id= node_get_colorid(node); - char showname[128]; /* 128 is used below */ + rctf *rct = &node->totr; + float dx, centy = 0.5f * (rct->ymax + rct->ymin); + float hiddenrad = 0.5f * (rct->ymax - rct->ymin); + float socket_size = NODE_SOCKSIZE * U.dpi / 72; + int color_id = node_get_colorid(node); + char showname[128]; /* 128 is used below */ /* shadow */ node_draw_shadow(snode, node, hiddenrad, 1.0f); @@ -886,17 +885,16 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); - if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) { - if (node->highlight) { + if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) { + if (COM_isHighlightedbNode(node)) { UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); - node->highlight = 0; } } uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); /* outline active and selected emphasis */ - if ( node->flag & (NODE_ACTIVE|SELECT)) { + if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -919,16 +917,17 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b /* open entirely icon */ { uiBut *but; - int but_size = UI_UNIT_X *0.6f; + int but_size = UI_UNIT_X * 0.6f; /* XXX button uses a custom triangle draw below, so make it invisible without icon */ uiBlockSetEmboss(node->block, UI_EMBOSSN); but = uiDefBut(node->block, TOGBUT, B_REDR, "", - rct->xmin+10.0f-but_size/2, centy-but_size/2, but_size, but_size, NULL, 0, 0, 0, 0, ""); - uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_hide_toggle"); + rct->xmin + 10.0f - but_size / 2, centy - but_size / 2, + but_size, but_size, NULL, 0, 0, 0, 0, ""); + uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); uiBlockSetEmboss(node->block, UI_EMBOSS); /* custom draw function for this button */ - UI_DrawTriIcon(rct->xmin+10.0f, centy, 'h'); + UI_DrawTriIcon(rct->xmin + 10.0f, centy, 'h'); } /* disable lines */ @@ -940,50 +939,52 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b else UI_ThemeColor(TH_TEXT); - if (node->miniwidth>0.0f) { + if (node->miniwidth > 0.0f) { BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); //if (node->flag & NODE_MUTED) - // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - don't print into self! + // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ - uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(centy-10), - (int)(rct->xmax - rct->xmin-18.0f -12.0f), NODE_DY, NULL, 0, 0, 0, 0, ""); + uiDefBut(node->block, LABEL, 0, showname, + (int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10), + (short)(rct->xmax - rct->xmin - 18.0f - 12.0f), (short)NODE_DY, + NULL, 0, 0, 0, 0, ""); } /* scale widget thing */ - UI_ThemeColorShade(color_id, -10); - dx= 10.0f; - fdrawline(rct->xmax-dx, centy-4.0f, rct->xmax-dx, centy+4.0f); - fdrawline(rct->xmax-dx-3.0f*snode->aspect, centy-4.0f, rct->xmax-dx-3.0f*snode->aspect, centy+4.0f); + UI_ThemeColorShade(color_id, -10); + dx = 10.0f; + fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f); + fdrawline(rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f); UI_ThemeColorShade(color_id, +30); - dx-= snode->aspect; - fdrawline(rct->xmax-dx, centy-4.0f, rct->xmax-dx, centy+4.0f); - fdrawline(rct->xmax-dx-3.0f*snode->aspect, centy-4.0f, rct->xmax-dx-3.0f*snode->aspect, centy+4.0f); + dx -= snode->aspect; + fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f); + fdrawline(rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f); /* sockets */ - for (sock= node->inputs.first; sock; sock= sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) node_socket_circle_draw(snode->nodetree, sock, socket_size, sock->flag & SELECT); } - for (sock= node->outputs.first; sock; sock= sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) node_socket_circle_draw(snode->nodetree, sock, socket_size, sock->flag & SELECT); } uiEndBlock(C, node->block); uiDrawBlock(C, node->block); - node->block= NULL; + node->block = NULL; } int node_get_resize_cursor(int directions) { - if (directions==0) + if (directions == 0) return CURSOR_STD; - else if ((directions & ~(NODE_RESIZE_TOP|NODE_RESIZE_BOTTOM))==0) + else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) return CURSOR_Y_MOVE; - else if ((directions & ~(NODE_RESIZE_RIGHT|NODE_RESIZE_LEFT))==0) + else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) return CURSOR_X_MOVE; else return CURSOR_EDIT; @@ -997,14 +998,14 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode) int cursor = CURSOR_STD; if (ntree) { - if (node_find_indicated_socket(snode, &node, &sock, SOCK_IN|SOCK_OUT)) { + if (node_find_indicated_socket(snode, &node, &sock, SOCK_IN | SOCK_OUT)) { /* pass */ } else { /* check nodes front to back */ - for (node=ntree->nodes.last; node; node=node->prev) { + for (node = ntree->nodes.last; node; node = node->prev) { if (BLI_in_rctf(&node->totr, snode->mx, snode->my)) - break; /* first hit on node stops */ + break; /* first hit on node stops */ } if (node) { int dir = node->typeinfo->resize_area_func(node, snode->mx, snode->my); @@ -1035,7 +1036,7 @@ void node_update_nodetree(const bContext *C, bNodeTree *ntree, float offsetx, fl bNode *node; /* update nodes front to back, so children sizes get updated before parents */ - for (node= ntree->nodes.last; node; node= node->prev) { + for (node = ntree->nodes.last; node; node = node->prev) { /* XXX little hack */ node->locx += offsetx; node->locy += offsety; @@ -1059,29 +1060,29 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT bNodeLink *link; int a; - if (ntree==NULL) return; /* groups... */ + if (ntree == NULL) return; /* groups... */ /* draw background nodes, last nodes in front */ - for (a=0, node= ntree->nodes.first; node; node=node->next, a++) { + for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { if (!(node->flag & NODE_BACKGROUND)) continue; - node->nr= a; /* index of node in list, used for exec event code */ + node->nr = a; /* index of node in list, used for exec event code */ node_draw(C, ar, snode, ntree, node); } /* node lines */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - for (link= ntree->links.first; link; link= link->next) + for (link = ntree->links.first; link; link = link->next) node_draw_link(&ar->v2d, snode, link); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); /* draw foreground nodes, last nodes in front */ - for (a=0, node= ntree->nodes.first; node; node=node->next, a++) { + for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { if (node->flag & NODE_BACKGROUND) continue; - node->nr= a; /* index of node in list, used for exec event code */ + node->nr = a; /* index of node in list, used for exec event code */ node_draw(C, ar, snode, ntree, node); } } @@ -1089,8 +1090,8 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) { View2DScrollers *scrollers; - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); + 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; @@ -1109,7 +1110,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) glEnable(GL_MAP1_VERTEX_3); /* aspect+font, set each time */ - snode->aspect= (v2d->cur.xmax - v2d->cur.xmin)/((float)ar->winx); + snode->aspect = (v2d->cur.xmax - v2d->cur.xmin) / ((float)ar->winx); + snode->aspect_sqrt = sqrtf(snode->aspect); // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); /* grid */ @@ -1123,23 +1125,27 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) if (snode->nodetree) { bNode *node; + /* void** highlights = 0; */ /* UNUSED */ node_uiblocks_init(C, snode->nodetree); /* uiBlocks must be initialized in drawing order for correct event clipping. * Node group internal blocks added after the main group block. */ - for (node= snode->nodetree->nodes.first; node; node= node->next) { + for (node = snode->nodetree->nodes.first; node; node = node->next) { if (node->flag & NODE_GROUP_EDIT) node_uiblocks_init(C, (bNodeTree *)node->id); } node_update_nodetree(C, snode->nodetree, 0.0f, 0.0f); + if (snode->nodetree->type == NTREE_COMPOSIT) { + COM_startReadHighlights(); + } node_draw_nodetree(C, ar, snode, snode->nodetree); #if 0 /* active group */ - for (node= snode->nodetree->nodes.first; node; node= node->next) { + for (node = snode->nodetree->nodes.first; node; node = node->next) { if (node->flag & NODE_GROUP_EDIT) node_draw_group(C, ar, snode, snode->nodetree, node); } @@ -1149,9 +1155,10 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) /* temporary links */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - for (nldrag= snode->linkdrag.first; nldrag; nldrag= nldrag->next) { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) + for (nldrag = snode->linkdrag.first; nldrag; nldrag = nldrag->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { node_draw_link(&ar->v2d, snode, (bNodeLink *)linkdata->data); + } } glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); @@ -1170,7 +1177,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) draw_gpencil_view2d(C, 0); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 9a6906c43bc..c4e72fa4a51 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1157,6 +1157,9 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) BLI_remlink(&wgroup->nodes, node); BLI_addtail(&ntree->nodes, node); + /* ensure unique node name in the nodee tree */ + nodeUniqueName(ntree, node); + node->locx += gnode->locx; node->locy += gnode->locy; @@ -1197,7 +1200,8 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) nodeRemLink(wgroup, link); } /* restore links from internal nodes */ - for (link = wgroup->links.first; link; link = link->next) { + for (link = wgroup->links.first; link; link = linkn) { + linkn = link->next; /* indicates link to group input */ if (!link->fromnode) { /* NB: can't use find_group_node_input here, @@ -1370,6 +1374,9 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make BLI_remlink(&ngroup->nodes, newnode); BLI_addtail(&ntree->nodes, newnode); + /* ensure unique node name in the node tree */ + nodeUniqueName(ntree, newnode); + newnode->locx += gnode->locx; newnode->locy += gnode->locy; } @@ -3710,11 +3717,14 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) BLI_remlink(&ntree->nodes, node); BLI_addtail(&ngroup->nodes, node); + /* ensure unique node name in the ngroup */ + nodeUniqueName(ngroup, node); + node->locx -= 0.5f * (min[0] + max[0]); node->locy -= 0.5f * (min[1] + max[1]); } } - + /* move animation data over */ if (ntree->adt) { LinkData *ld, *ldn = NULL; diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index d9dbd646fa5..9cd62342e19 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -118,7 +118,7 @@ void NODE_OT_view_all(struct wmOperatorType *ot); 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 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); /* node_edit.c */ @@ -196,6 +196,7 @@ extern const char *node_context_dir[]; #define BASIS_RAD 8.0f #define NODE_DYS (U.widget_unit/2) #define NODE_DY U.widget_unit +#define NODE_MARGIN_X 15 #define NODE_SOCKSIZE 5 // XXX button events (butspace) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 349259ad71b..ce187c46625 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -192,10 +192,6 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) break; } break; - case NC_WM: - if (wmn->data == ND_FILEREAD) - ED_area_tag_refresh(sa); - break; /* future: add ID checks? */ case NC_MATERIAL: diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index f0275fb6584..1eba2deed96 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2928,8 +2928,11 @@ static int text_insert_invoke(bContext *C, wmOperator *op, wmEvent *event) // if (!RNA_struct_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */ if (!RNA_string_length(op->ptr, "text")) { - /* if alt/ctrl/super are pressed pass through */ - if (event->ctrl || event->oskey) { + /* if alt/ctrl/super are pressed pass through except for utf8 character event + * (when input method are used for utf8 inputs, the user may assign key event + * including alt/ctrl/super like ctrl+m to commit utf8 string. in such case, + * the modifiers in the utf8 character event make no sense.) */ + if ((event->ctrl || event->oskey) && !event->utf8_buf[0]) { return OPERATOR_PASS_THROUGH; } else { diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index f8d942b4fd1..5f312ff7fca 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -43,7 +43,6 @@ #include "DNA_view3d_types.h" #include "DNA_object_types.h" -#include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dlrbTree.h" @@ -63,9 +62,9 @@ /* ************************************ Motion Paths ************************************* */ -// TODO: -// - options to draw paths with lines -// - include support for editing the path verts +/* TODO: + * - options to draw paths with lines + * - include support for editing the path verts */ /* Set up drawing environment for drawing motion paths */ void draw_motion_paths_init(View3D *v3d, ARegion *ar) @@ -80,7 +79,7 @@ void draw_motion_paths_init(View3D *v3d, ARegion *ar) /* Draw the given motion path for an Object or a Bone * - assumes that the viewport has already been initialized properly - * i.e. draw_motion_paths_init() has been called + * i.e. draw_motion_paths_init() has been called */ void draw_motion_path_instance(Scene *scene, Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath) @@ -135,10 +134,10 @@ void draw_motion_path_instance(Scene *scene, /* draw curve-line of path */ glShadeModel(GL_SMOOTH); - glBegin(GL_LINE_STRIP); + glBegin(GL_LINE_STRIP); for (i = 0, mpv = mpv_start; i < len; i++, mpv++) { short sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT); - float intensity; /* how faint */ + float intensity; /* how faint */ /* set color * - more intense for active/selected bones, less intense for unselected bones @@ -223,7 +222,7 @@ void draw_motion_path_instance(Scene *scene, UI_ThemeColor(TH_TEXT_HI); } - // XXX, this isn't up to date but probably should be kept so. + /* XXX, this isn't up to date but probably should be kept so. */ invert_m4_m4(ob->imat, ob->obmat); /* Draw frame numbers at each framestep value */ diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index cdaf7d5690f..48b3672c144 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -686,13 +686,13 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel tailvec = headvec; tail = head; zero_v3(dirvec); - dirvec[0] = 0.00001; // XXX. weak but ok + dirvec[0] = 0.00001; /* XXX. weak but ok */ } else if (tail - view_dist > head) { headvec = tailvec; head = tail; zero_v3(dirvec); - dirvec[0] = 0.00001; // XXX. weak but ok + dirvec[0] = 0.00001; /* XXX. weak but ok */ } } @@ -1019,7 +1019,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned /* Draw root point if we are not connected */ if ((boneflag & BONE_CONNECTED) == 0) { - if (G.f & G_PICKSEL) { // no bitmap in selection mode, crashes 3d cards... + if (G.f & G_PICKSEL) { /* no bitmap in selection mode, crashes 3d cards... */ glLoadName(id | BONESEL_ROOT); glBegin(GL_POINTS); glVertex3f(0.0f, 0.0f, 0.0f); @@ -1151,7 +1151,7 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl glScalef(length, length, length); draw_bone_points(dt, armflag, boneflag, id); glPopMatrix(); - length *= 0.95f; // make vertices visible + length *= 0.95f; /* make vertices visible */ } /* colors for modes */ @@ -1225,7 +1225,7 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, dlen, 0.0f); - glEnd(); // GL_LINES + glEnd(); /* GL_LINES */ glPopMatrix(); } @@ -1266,7 +1266,7 @@ static void draw_wire_bone(const short dt, int armflag, int boneflag, short cons glScalef(length, length, length); draw_bone_points(dt, armflag, boneflag, id); glPopMatrix(); - length *= 0.95f; // make vertices visible + length *= 0.95f; /* make vertices visible */ } /* this chunk not in object mode */ @@ -1416,7 +1416,9 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) /* Find the chain's root */ while (parchan->parent) { segcount++; - if (segcount == data->rootbone || segcount > 255) break; // 255 is weak + if (segcount == data->rootbone || segcount > 255) { + break; /* 255 is weak */ + } parchan = parchan->parent; } if (parchan) @@ -1440,13 +1442,13 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) /* Find the chain's root */ while (parchan->parent) { segcount++; - // FIXME: revise the breaking conditions - if (segcount == data->chainlen || segcount > 255) break; // 255 is weak + /* FIXME: revise the breaking conditions */ + if (segcount == data->chainlen || segcount > 255) break; /* 255 is weak */ parchan = parchan->parent; } - if (parchan) // XXX revise the breaking conditions to only stop at the tail? + if (parchan) /* XXX revise the breaking conditions to only stop at the tail? */ glVertex3fv(parchan->pose_head); - + glEnd(); setlinestyle(0); } @@ -1594,7 +1596,7 @@ static void draw_pose_dofs(Object *ob) theta = RAD2DEGF(0.5f * (pchan->limitmin[2] + pchan->limitmax[2])); glRotatef(theta, 0.0f, 0.0f, 1.0f); - glColor3ub(50, 50, 255); // blue, Z axis limit + glColor3ub(50, 50, 255); /* blue, Z axis limit */ glBegin(GL_LINE_STRIP); for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ @@ -1611,14 +1613,14 @@ static void draw_pose_dofs(Object *ob) glEnd(); glRotatef(-theta, 0.0f, 0.0f, 1.0f); - } + } if (pchan->ikflag & BONE_IK_XLIMIT) { /* OpenGL requires rotations in degrees; so we're taking the average angle here */ theta = RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0])); glRotatef(theta, 1.0f, 0.0f, 0.0f); - glColor3ub(255, 50, 50); // Red, X axis limit + glColor3ub(255, 50, 50); /* Red, X axis limit */ glBegin(GL_LINE_STRIP); for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ @@ -1792,7 +1794,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } if (index != -1) - index += 0x10000; // pose bones count in higher 2 bytes only + index += 0x10000; /* pose bones count in higher 2 bytes only */ } /* very very confusing... but in object mode, solid draw, we cannot do glLoadName yet, @@ -1861,7 +1863,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } if (index != -1) - index += 0x10000; // pose bones count in higher 2 bytes only + index += 0x10000; /* pose bones count in higher 2 bytes only */ } /* stick or wire bones have not been drawn yet so don't clear object selection in this case */ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && draw_wire) { @@ -1900,11 +1902,11 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, const short constflag = pchan->constflag; if ((do_dashed & 1) && (pchan->parent)) { /* Draw a line from our root to the parent's tip - * - only if V3D_HIDE_HELPLINES is enabled... + * - only if V3D_HIDE_HELPLINES is enabled... */ if ( (do_dashed & 2) && ((bone->flag & BONE_CONNECTED) == 0) ) { if (arm->flag & ARM_POSEMODE) { - glLoadName(index & 0xFFFF); // object tag, for bordersel optim + glLoadName(index & 0xFFFF); /* object tag, for bordersel optim */ UI_ThemeColor(TH_WIRE); } setlinestyle(3); @@ -1922,15 +1924,15 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (constflag & PCHAN_HAS_IK) { if (bone->flag & BONE_SELECTED) { if (constflag & PCHAN_HAS_TARGET) glColor3ub(200, 120, 0); - else glColor3ub(200, 200, 50); // add theme! - + else glColor3ub(200, 200, 50); /* add theme! */ + glLoadName(index & 0xFFFF); pchan_draw_IK_root_lines(pchan, !(do_dashed & 2)); } } else if (constflag & PCHAN_HAS_SPLINEIK) { if (bone->flag & BONE_SELECTED) { - glColor3ub(150, 200, 50); // add theme! + glColor3ub(150, 200, 50); /* add theme! */ glLoadName(index & 0xFFFF); pchan_draw_IK_root_lines(pchan, !(do_dashed & 2)); @@ -2205,7 +2207,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) /* offset to parent */ if (eBone->parent) { UI_ThemeColor(TH_WIRE); - glLoadName(-1); // -1 here is OK! + glLoadName(-1); /* -1 here is OK! */ setlinestyle(3); glBegin(GL_LINES); @@ -2227,7 +2229,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) /* finally names and axes */ if (arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) { - // patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing + /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */ if ((G.f & G_PICKSEL) == 0) { float vec[3]; unsigned char col[4]; @@ -2574,7 +2576,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); // only for lighting... + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); /* only for lighting... */ } /* arm->flag is being used to detect mode... */ diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 19696b2b0e0..112f41278b7 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -71,7 +71,7 @@ #include "ED_mesh.h" #include "ED_uvedit.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* user data structures for derived mesh callbacks */ typedef struct drawMeshFaceSelect_userData { @@ -214,7 +214,7 @@ void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data); setlinestyle(0); - bglPolygonOffset(rv3d->dist, 0.0); // resets correctly now, even after calling accumulated offsets + bglPolygonOffset(rv3d->dist, 0.0); /* resets correctly now, even after calling accumulated offsets */ BLI_edgehash_free(data.eh, NULL); } @@ -223,7 +223,7 @@ void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) static Material *give_current_material_or_def(Object *ob, int matnr) { - extern Material defmaterial; // render module abuse... + extern Material defmaterial; /* render module abuse... */ Material *ma = give_current_material(ob, matnr); return ma ? ma : &defmaterial; @@ -248,7 +248,7 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m static int c_lit; static int c_has_texface; - Object *litob = NULL; //to get mode to turn off mipmap in painting mode + Object *litob = NULL; /* to get mode to turn off mipmap in painting mode */ int backculled = GEMAT_BACKCULL; int alphablend = 0; int textured = 0; @@ -317,7 +317,7 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m if (lit != c_lit || ma != c_ma) { if (lit) { float spec[4]; - if (!ma) ma = give_current_material_or_def(NULL, 0); //default material + if (!ma) ma = give_current_material_or_def(NULL, 0); /* default material */ spec[0] = ma->spec * ma->specr; spec[1] = ma->spec * ma->specg; @@ -345,7 +345,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O unsigned char obcol[4]; int is_tex, solidtex; - // XXX scene->obedit warning + /* XXX scene->obedit warning */ /* texture draw is abused for mask selection mode, do this so wire draw * with face selection in weight paint is not lit. */ @@ -466,7 +466,8 @@ static DMDrawOption draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr) return DM_DRAW_OPTION_NORMAL; /* Set color from mcol */ } } -static void add_tface_color_layer(DerivedMesh *dm) + +static void update_tface_color_layer(DerivedMesh *dm) { MTFace *tface = DM_get_tessface_data_layer(dm, CD_MTFACE); MFace *mface = dm->getTessFaceArray(dm); @@ -476,7 +477,15 @@ static void add_tface_color_layer(DerivedMesh *dm) if (!mcol) mcol = dm->getTessFaceDataArray(dm, CD_MCOL); - finalCol = MEM_mallocN(sizeof(MCol) * 4 * dm->getNumTessFaces(dm), "add_tface_color_layer"); + if (CustomData_has_layer(&dm->faceData, CD_TEXTURE_MCOL)) { + finalCol = CustomData_get_layer(&dm->faceData, CD_TEXTURE_MCOL); + } + else { + finalCol = MEM_mallocN(sizeof(MCol) * 4 * dm->getNumTessFaces(dm), "add_tface_color_layer"); + + CustomData_add_layer(&dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData); + } + for (i = 0; i < dm->getNumTessFaces(dm); i++) { Material *ma = give_current_material(Gtexdraw.ob, mface[i].mat_nr + 1); @@ -542,7 +551,6 @@ static void add_tface_color_layer(DerivedMesh *dm) } } } - CustomData_add_layer(&dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData); } static DMDrawOption draw_tface_mapped__set_draw(void *userData, int index) @@ -640,7 +648,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) short matnr = mp->mat_nr; int mf_smooth = mp->flag & ME_SMOOTH; Material *mat = me->mat[matnr]; - int mode = mat->game.flag; + int mode = mat ? mat->game.flag : GEMAT_INVISIBLE; if (!(mode & GEMAT_INVISIBLE) && (mode & GEMAT_TEXT) && mp->totloop >= 3) { /* get the polygon as a tri/quad */ @@ -705,8 +713,8 @@ 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 + /* The BM_FONT handling is in the gpu module, shared with the + * game engine, was duplicated previously */ set_property_valstr(prop, string); characters = strlen(string); @@ -797,8 +805,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec else { drawTFace_userData userData; - if (!CustomData_has_layer(&dm->faceData, CD_TEXTURE_MCOL)) - add_tface_color_layer(dm); + update_tface_color_layer(dm); userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE); userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE); @@ -1062,7 +1069,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *d * rather than the shading, this is also forced in wire view */ bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ glEnable(GL_BLEND); glColor4ub(255, 255, 255, 96); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 7210944d3e7..919772bbf46 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -35,7 +35,7 @@ #include "DNA_camera_types.h" #include "DNA_curve_types.h" -#include "DNA_constraint_types.h" // for drawing constraint +#include "DNA_constraint_types.h" /* for drawing constraint */ #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" @@ -56,10 +56,10 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" -#include "BKE_anim.h" //for the where_on_path function +#include "BKE_anim.h" /* for the where_on_path function */ #include "BKE_armature.h" #include "BKE_camera.h" -#include "BKE_constraint.h" // for the get_constraint_target function +#include "BKE_constraint.h" /* for the get_constraint_target function */ #include "BKE_curve.h" #include "BKE_DerivedMesh.h" #include "BKE_deform.h" @@ -108,7 +108,7 @@ #include "wm_subwindow.h" #include "BLF_api.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ typedef enum eWireDrawMode { OBDRAW_WIRE_OFF = 0, @@ -2118,7 +2118,7 @@ static void drawSelectedVertices__mapFunc(void *userData, int index, const float if (!(mv->flag & ME_HIDE)) { const char sel = mv->flag & SELECT; - // TODO define selected color + /* TODO define selected color */ if (sel) { glColor3f(1.0f, 1.0f, 0.0f); } @@ -2797,7 +2797,7 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, ToolSettings *ts = scene->toolsettings; int sel; - if (v3d->zbuf) glDepthMask(0); // disable write in zbuffer, zbuf select + if (v3d->zbuf) glDepthMask(0); /* disable write in zbuffer, zbuf select */ for (sel = 0; sel < 2; sel++) { unsigned char col[4], fcol[4]; @@ -3218,8 +3218,8 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); } - // Setup for drawing wire over, disable zbuffer - // write to show selected edge wires better + /* Setup for drawing wire over, disable zbuffer + * write to show selected edge wires better */ UI_ThemeColor(TH_WIRE); bglPolygonOffset(rv3d->dist, 1.0); @@ -3239,21 +3239,21 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, UI_GetThemeColor4ubv(TH_FACE_SELECT, col2); UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col3); UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4); - + glEnable(GL_BLEND); - glDepthMask(0); // disable write in zbuffer, needed for nice transp - + glDepthMask(0); /* disable write in zbuffer, needed for nice transp */ + /* don't draw unselected faces, only selected, this is MUCH nicer when texturing */ if (check_object_draw_texture(scene, v3d, dt)) col1[3] = 0; - + if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE)) col3[3] = 0; draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act); glDisable(GL_BLEND); - glDepthMask(1); // restore write in zbuffer + glDepthMask(1); /* restore write in zbuffer */ } else if (efa_act) { /* even if draw faces is off it would be nice to draw the stipple face @@ -3262,15 +3262,15 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, unsigned char col1[4], col2[4], col3[4], col4[4]; col1[3] = col2[3] = col3[3] = 0; /* don't draw */ UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4); - + glEnable(GL_BLEND); - glDepthMask(0); // disable write in zbuffer, needed for nice transp - + glDepthMask(0); /* disable write in zbuffer, needed for nice transp */ + draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act); glDisable(GL_BLEND); - glDepthMask(1); // restore write in zbuffer - + glDepthMask(1); /* restore write in zbuffer */ + } /* here starts all fancy draw-extra over */ @@ -3613,7 +3613,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D */ if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ } if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0) @@ -3848,7 +3848,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW); else glFrontFace(GL_CCW); - if (ob->type == OB_MBALL) { // mball always smooth shaded + if (ob->type == OB_MBALL) { /* mball always smooth shaded */ glShadeModel(GL_SMOOTH); } @@ -5669,8 +5669,8 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, while (nr-- > 0) { /* accounts for empty bevel lists */ const float fac = bevp->radius * ts->normalsize; - float vec_a[3]; // Offset perpendicular to the curve - float vec_b[3]; // Delta along the curve + float vec_a[3]; /* Offset perpendicular to the curve */ + float vec_b[3]; /* Delta along the curve */ vec_a[0] = fac; vec_a[1] = 0.0f; @@ -5766,7 +5766,7 @@ static void draw_empty_cone(float size) } /* draw points on curve speed handles */ -#if 0 // XXX old animation system stuff +#if 0 /* XXX old animation system stuff */ static void curve_draw_speed(Scene *scene, Object *ob) { Curve *cu = ob->data; @@ -5795,7 +5795,7 @@ static void curve_draw_speed(Scene *scene, Object *ob) glPointSize(1.0); bglEnd(); } -#endif // XXX old animation system stuff +#endif /* XXX old animation system stuff */ static void draw_textcurs(float textcurs[4][2]) @@ -6039,7 +6039,7 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) /* calculus here, is reused in PFIELD_FORCE */ invert_m4_m4(imat, rv3d->viewmatob); -// normalize_v3(imat[0]); // we don't do this because field doesnt scale either... apart from wind! +// normalize_v3(imat[0]); /* we don't do this because field doesnt scale either... apart from wind! */ // normalize_v3(imat[1]); if (pd->forcefield == PFIELD_WIND) { @@ -6413,8 +6413,8 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) } bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better - + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ + if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { Curve *cu = ob->data; if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { @@ -7020,7 +7020,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short #endif } - // only draw domains + /* only draw domains */ if (smd->domain && smd->domain->fluid) { if (CFRA < smd->domain->point_cache[0]->startframe) { /* don't show smoke before simulation starts, this could be made an option in the future */ @@ -7438,7 +7438,7 @@ static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index) } } -// must have called WM_set_framebuffer_index_color beforehand +/* must have called WM_set_framebuffer_index_color beforehand */ static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index) { Mesh *me = userData; @@ -7492,11 +7492,11 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec bglPolygonOffset(rv3d->dist, 1.0); - // we draw edges always, for loop (select) tools + /* we draw edges always, for loop (select) tools */ bbs_mesh_wire(em, dm, bm_solidoffs); bm_wireoffs = bm_solidoffs + em->bm->totedge; - // we draw verts if vert select mode or if in transform (for snap). + /* we draw verts if vert select mode or if in transform (for snap). */ if ((ts->selectmode & SCE_SELECT_VERTEX) || (G.moving & G_TRANSFORM_EDIT)) { bbs_mesh_verts(em, dm, bm_wireoffs); bm_vertoffs = bm_wireoffs + em->bm->totvert; diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 60b3b911b1b..2c2d4039225 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -45,7 +45,7 @@ #include "BLI_rand.h" #include "BKE_curve.h" -#include "BKE_constraint.h" // for the get_constraint_target function +#include "BKE_constraint.h" /* for the get_constraint_target function */ #include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_effect.h" @@ -148,7 +148,7 @@ static int intersect_edges(float *points, float a, float b, float c, float d, fl static int convex(const float p0[3], const float up[3], const float a[3], const float b[3]) { - // Vec3 va = a-p0, vb = b-p0; + /* Vec3 va = a-p0, vb = b-p0; */ float va[3], vb[3], tmp[3]; sub_v3_v3v3(va, a, p0); sub_v3_v3v3(vb, b, p0); @@ -175,7 +175,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r {1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}, {1.0f, -1.0f, -1.0f} }; - // edges have the form edges[n][0][xyz] + t*edges[n][1][xyz] + /* edges have the form edges[n][0][xyz] + t*edges[n][1][xyz] */ float edges[12][2][3] = { {{1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 2.0f}}, {{-1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 2.0f}}, @@ -226,54 +226,54 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r sub_v3_v3v3(size, max, min); - // maxx, maxy, maxz + /* maxx, maxy, maxz */ cv[0][0] = max[0]; cv[0][1] = max[1]; cv[0][2] = max[2]; - // minx, maxy, maxz + /* minx, maxy, maxz */ cv[1][0] = min[0]; cv[1][1] = max[1]; cv[1][2] = max[2]; - // minx, miny, maxz + /* minx, miny, maxz */ cv[2][0] = min[0]; cv[2][1] = min[1]; cv[2][2] = max[2]; - // maxx, miny, maxz + /* maxx, miny, maxz */ cv[3][0] = max[0]; cv[3][1] = min[1]; cv[3][2] = max[2]; - // maxx, maxy, minz + /* maxx, maxy, minz */ cv[4][0] = max[0]; cv[4][1] = max[1]; cv[4][2] = min[2]; - // minx, maxy, minz + /* minx, maxy, minz */ cv[5][0] = min[0]; cv[5][1] = max[1]; cv[5][2] = min[2]; - // minx, miny, minz + /* minx, miny, minz */ cv[6][0] = min[0]; cv[6][1] = min[1]; cv[6][2] = min[2]; - // maxx, miny, minz + /* maxx, miny, minz */ cv[7][0] = max[0]; cv[7][1] = min[1]; cv[7][2] = min[2]; - copy_v3_v3(edges[0][0], cv[4]); // maxx, maxy, minz - copy_v3_v3(edges[1][0], cv[5]); // minx, maxy, minz - copy_v3_v3(edges[2][0], cv[6]); // minx, miny, minz - copy_v3_v3(edges[3][0], cv[7]); // maxx, miny, minz + copy_v3_v3(edges[0][0], cv[4]); /* maxx, maxy, minz */ + copy_v3_v3(edges[1][0], cv[5]); /* minx, maxy, minz */ + copy_v3_v3(edges[2][0], cv[6]); /* minx, miny, minz */ + copy_v3_v3(edges[3][0], cv[7]); /* maxx, miny, minz */ - copy_v3_v3(edges[4][0], cv[3]); // maxx, miny, maxz - copy_v3_v3(edges[5][0], cv[2]); // minx, miny, maxz - copy_v3_v3(edges[6][0], cv[6]); // minx, miny, minz - copy_v3_v3(edges[7][0], cv[7]); // maxx, miny, minz + copy_v3_v3(edges[4][0], cv[3]); /* maxx, miny, maxz */ + copy_v3_v3(edges[5][0], cv[2]); /* minx, miny, maxz */ + copy_v3_v3(edges[6][0], cv[6]); /* minx, miny, minz */ + copy_v3_v3(edges[7][0], cv[7]); /* maxx, miny, minz */ - copy_v3_v3(edges[8][0], cv[1]); // minx, maxy, maxz - copy_v3_v3(edges[9][0], cv[2]); // minx, miny, maxz - copy_v3_v3(edges[10][0], cv[6]); // minx, miny, minz - copy_v3_v3(edges[11][0], cv[5]); // minx, maxy, minz + copy_v3_v3(edges[8][0], cv[1]); /* minx, maxy, maxz */ + copy_v3_v3(edges[9][0], cv[2]); /* minx, miny, maxz */ + copy_v3_v3(edges[10][0], cv[6]); /* minx, miny, minz */ + copy_v3_v3(edges[11][0], cv[5]); /* minx, maxy, minz */ // printf("size x: %f, y: %f, z: %f\n", size[0], size[1], size[2]); // printf("min[2]: %f, max[2]: %f\n", min[2], max[2]); @@ -311,11 +311,11 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r printf("%f, %f, %f\n", rv3d->viewinv[2][0], rv3d->viewinv[2][1], rv3d->viewinv[2][2]); #endif - // get view vector + /* get view vector */ copy_v3_v3(viewnormal, rv3d->viewinv[2]); normalize_v3(viewnormal); - // find cube vertex that is closest to the viewer + /* find cube vertex that is closest to the viewer */ for (i = 0; i < 8; i++) { float x, y, z; @@ -346,9 +346,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog); glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(text), text); - // cell spacing + /* cell spacing */ glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, dx, dx, dx, 1.0); - // custom parameter for smoke style (higher = thicker) + /* custom parameter for smoke style (higher = thicker) */ glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 7.0, 7.0, 7.0, 1.0); } else @@ -366,10 +366,10 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r cor[2] = (float)res[2] / (float)power_of_2_max_i(res[2]); } - // our slices are defined by the plane equation a*x + b*y +c*z + d = 0 - // (a,b,c), the plane normal, are given by viewdir - // d is the parameter along the view direction. the first d is given by - // inserting previously found vertex into the plane equation + /* our slices are defined by the plane equation a*x + b*y +c*z + d = 0 + * (a,b,c), the plane normal, are given by viewdir + * d is the parameter along the view direction. the first d is given by + * inserting previously found vertex into the plane equation */ /* d0 = (viewnormal[0]*cv[i][0] + viewnormal[1]*cv[i][1] + viewnormal[2]*cv[i][2]); */ /* UNUSED */ ds = (ABS(viewnormal[0]) * size[0] + ABS(viewnormal[1]) * size[1] + ABS(viewnormal[2]) * size[2]); @@ -395,8 +395,8 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r // printf("my d: %f\n", d); - // intersect_edges returns the intersection points of all cube edges with - // the given plane that lie within the cube + /* intersect_edges returns the intersection points of all cube edges with + * the given plane that lie within the cube */ numpoints = intersect_edges(points, viewnormal[0], viewnormal[1], viewnormal[2], -d, edges); // printf("points: %d\n", numpoints); @@ -404,7 +404,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r if (numpoints > 2) { copy_v3_v3(p0, points); - // sort points to get a convex polygon + /* sort points to get a convex polygon */ for (i = 1; i < numpoints - 1; i++) { for (j = i + 1; j < numpoints; j++) { if (!convex(p0, viewnormal, &points[j * 3], &points[i * 3])) { @@ -454,4 +454,3 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r glDepthMask(GL_TRUE); } } - diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index a6948222d93..88d08d937be 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -62,7 +62,7 @@ #include "UI_resources.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* ******************** manage regions ********************* */ @@ -1016,7 +1016,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) break; } - // removed since BKE_image_user_frame_calc is now called in view3d_draw_bgpic because screen_ops doesnt call the notifier. + /* removed since BKE_image_user_frame_calc is now called in view3d_draw_bgpic because screen_ops doesnt call the notifier. */ #if 0 if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) { View3D *v3d = area->spacedata.first; @@ -1172,7 +1172,7 @@ void ED_spacetype_view3d(void) /* regions: listview/buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d buttons region"); art->regionid = RGN_TYPE_UI; - art->prefsizex = 180; // XXX + art->prefsizex = 180; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = view3d_buttons_area_listener; art->init = view3d_buttons_area_init; @@ -1184,8 +1184,8 @@ void ED_spacetype_view3d(void) /* regions: tool(bar) */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; - art->prefsizex = 160; // XXX - art->prefsizey = 50; // XXX + art->prefsizex = 160; /* XXX */ + art->prefsizey = 50; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = view3d_buttons_area_listener; art->init = view3d_tools_area_init; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3079719efe0..1ace4688991 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -28,7 +28,6 @@ * \ingroup spview3d */ - #include <string.h> #include <stdio.h> #include <math.h> @@ -65,7 +64,7 @@ #include "BKE_movieclip.h" #include "RE_engine.h" -#include "RE_pipeline.h" // make_stars +#include "RE_pipeline.h" /* make_stars */ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -92,8 +91,7 @@ #include "GPU_material.h" #include "GPU_extensions.h" -#include "view3d_intern.h" // own include - +#include "view3d_intern.h" /* own include */ static void star_stuff_init_func(void) @@ -299,7 +297,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** dx = fabs(x - (wx) * fx / fw); if (dx == 0) dx = fabs(y - (wy) * fy / fw); - glDepthMask(0); // disable write in zbuffer + glDepthMask(0); /* disable write in zbuffer */ /* check zoom out */ UI_ThemeColor(TH_GRID); @@ -361,7 +359,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** drawgrid_draw(ar, wx, wy, x, y, dx); } } - else { // start blending out + else { /* start blending out */ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); @@ -369,7 +367,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** drawgrid_draw(ar, wx, wy, x, y, sublines * dx); } } - else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) + else { /* start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) */ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); @@ -378,10 +376,10 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } } else { - if (dx > (GRID_MIN_PX_D * 10.0)) { // start blending in + if (dx > (GRID_MIN_PX_D * 10.0)) { /* start blending in */ rv3d->gridview /= sublines; dx /= sublines; - if (dx > (GRID_MIN_PX_D * 10.0)) { // start blending in + if (dx > (GRID_MIN_PX_D * 10.0)) { /* start blending in */ rv3d->gridview /= sublines; dx /= sublines; if (dx > (GRID_MIN_PX_D * 10.0)) { @@ -435,7 +433,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** fdrawline(x, 0.0, x, (float)ar->winy); - glDepthMask(1); // enable write in zbuffer + glDepthMask(1); /* enable write in zbuffer */ } #undef GRID_MIN_PX @@ -473,7 +471,8 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit); grid = gridlines * grid_scale; - if (v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select + if (v3d->zbuf && scene->obedit) + glDepthMask(0); /* for zbuffer-select */ UI_GetThemeColor3ubv(TH_GRID, col_grid); @@ -665,10 +664,10 @@ static void draw_view_axis(RegionView3D *rv3d) /* draw center and axis of rotation for ongoing 3D mouse navigation */ static void draw_rotation_guide(RegionView3D *rv3d) { - float o[3]; // center of rotation - float end[3]; // endpoints for drawing + float o[3]; /* center of rotation */ + float end[3]; /* endpoints for drawing */ - float color[4] = {0.0f, 0.4235f, 1.0f, 1.0f}; // bright blue so it matches device LEDs + float color[4] = {0.0f, 0.4235f, 1.0f, 1.0f}; /* bright blue so it matches device LEDs */ negate_v3_v3(o, rv3d->ofs); @@ -677,25 +676,25 @@ static void draw_rotation_guide(RegionView3D *rv3d) glShadeModel(GL_SMOOTH); glPointSize(5); glEnable(GL_POINT_SMOOTH); - glDepthMask(0); // don't overwrite zbuf + glDepthMask(0); /* don't overwrite zbuf */ if (rv3d->rot_angle != 0.f) { - // -- draw rotation axis -- + /* -- draw rotation axis -- */ float scaled_axis[3]; const float scale = rv3d->dist; mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale); glBegin(GL_LINE_STRIP); - color[3] = 0.f; // more transparent toward the ends + color[3] = 0.f; /* more transparent toward the ends */ glColor4fv(color); add_v3_v3v3(end, o, scaled_axis); glVertex3fv(end); - // color[3] = 0.2f + fabsf(rv3d->rot_angle); // modulate opacity with angle + // color[3] = 0.2f + fabsf(rv3d->rot_angle); /* modulate opacity with angle */ // ^^ neat idea, but angle is frame-rate dependent, so it's usually close to 0.2 - color[3] = 0.5f; // more opaque toward the center + color[3] = 0.5f; /* more opaque toward the center */ glColor4fv(color); glVertex3fv(o); @@ -705,7 +704,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) glVertex3fv(end); glEnd(); - // -- draw ring around rotation center -- + /* -- draw ring around rotation center -- */ { #define ROT_AXIS_DETAIL 13 @@ -714,7 +713,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) float angle; int i; - float q[4]; // rotate ring so it's perpendicular to axis + float q[4]; /* rotate ring so it's perpendicular to axis */ const int upright = fabsf(rv3d->rot_axis[2]) >= 0.95f; if (!upright) { const float up[3] = {0.f, 0.f, 1.f}; @@ -725,7 +724,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) axis_angle_to_quat(q, vis_axis, vis_angle); } - color[3] = 0.25f; // somewhat faint + color[3] = 0.25f; /* somewhat faint */ glColor4fv(color); glBegin(GL_LINE_LOOP); for (i = 0, angle = 0.f; i < ROT_AXIS_DETAIL; ++i, angle += step) { @@ -743,21 +742,23 @@ static void draw_rotation_guide(RegionView3D *rv3d) #undef ROT_AXIS_DETAIL } - color[3] = 1.f; // solid dot + color[3] = 1.0f; /* solid dot */ } else - color[3] = 0.5f; // see-through dot + color[3] = 0.5f; /* see-through dot */ - // -- draw rotation center -- + /* -- draw rotation center -- */ glColor4fv(color); glBegin(GL_POINTS); glVertex3fv(o); glEnd(); - // find screen coordinates for rotation center, then draw pretty icon - // mul_m4_v3(rv3d->persinv, rot_center); - // UI_icon_draw(rot_center[0], rot_center[1], ICON_NDOF_TURN); - // ^^ just playing around, does not work + /* find screen coordinates for rotation center, then draw pretty icon */ +#if 0 + mul_m4_v3(rv3d->persinv, rot_center); + UI_icon_draw(rot_center[0], rot_center[1], ICON_NDOF_TURN); +#endif + /* ^^ just playing around, does not work */ glDisable(GL_BLEND); glDisable(GL_POINT_SMOOTH); @@ -1319,12 +1320,14 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) if (!(v3d->flag & V3D_INVALID_BACKBUF) ) return; -// if (test) { -// if (qtest()) { -// addafterqueue(ar->win, BACKBUFDRAW, 1); -// return; -// } -// } +#if 0 + if (test) { + if (qtest()) { + addafterqueue(ar->win, BACKBUFDRAW, 1); + return; + } + } +#endif if (v3d->drawtype > OB_WIRE) v3d->zbuf = TRUE; @@ -1370,7 +1373,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) ED_view3d_clipping_disable(); /* it is important to end a view in a transform compatible with buttons */ -// persp(PERSP_WIN); // set ortho +// persp(PERSP_WIN); /* set ortho */ } @@ -1493,20 +1496,20 @@ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int for (a = 0; a < 2; a++) { for (b = 0; b < nr; b++, distance++) { - if (*tbuf && *tbuf >= min && *tbuf < max) { //we got a hit + if (*tbuf && *tbuf >= min && *tbuf < max) { /* we got a hit */ if (strict) { indexok = indextest(handle, *tbuf - min + 1); if (indexok) { *dist = (short) sqrt( (float)distance); index = *tbuf - min + 1; goto exit; - } + } } else { - *dist = (short) sqrt( (float)distance); // XXX, this distance is wrong - - index = *tbuf - min + 1; // messy yah, but indices start at 1 + *dist = (short) sqrt( (float)distance); /* XXX, this distance is wrong - */ + index = *tbuf - min + 1; /* messy yah, but indices start at 1 */ goto exit; - } + } } tbuf += (dirvec[rc][0] + dirvec[rc][1]); @@ -1912,7 +1915,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas tbase.flag = OB_FROMDUPLI | base->flag; lb = object_duplilist(scene, base->object); - // BLI_sortlist(lb, dupli_ob_sort); // might be nice to have if we have a dupli list with mixed objects. + // BLI_sortlist(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */ dob = dupli_step(lb->first); if (dob) dob_next = dupli_step(dob->next); @@ -2174,7 +2177,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *)) glClear(GL_DEPTH_BUFFER_BIT); glLoadMatrixf(rv3d->viewmat); -// persp(PERSP_STORE); // store correct view for persp(PERSP_VIEW) calls +// persp(PERSP_STORE); /* store correct view for persp(PERSP_VIEW) calls */ if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_set(rv3d); @@ -2640,7 +2643,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, glPopMatrix(); - // XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell + /* XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell */ glColor4ub(255, 255, 255, 255); G.f &= ~G_RENDER_OGL; @@ -2686,9 +2689,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, GPU_offscreen_read_pixels(ofs, GL_FLOAT, ibuf->rect_float); else if (ibuf->rect) GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, ibuf->rect); - - //if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) - // BKE_stamp_buf(scene, NULL, rr->rectf, rr->rectx, rr->recty, 4); /* unbind */ GPU_offscreen_unbind(ofs); @@ -2951,7 +2951,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const glEnable(GL_MULTISAMPLE_ARB); #endif - // needs to be done always, gridview is adjusted in drawgrid() now + /* needs to be done always, gridview is adjusted in drawgrid() now */ rv3d->gridview = v3d->grid; if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { @@ -3049,7 +3049,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const /* Transp and X-ray afterdraw stuff */ if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); - if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! + if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); /* clears zbuffer if it is used! */ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); @@ -3078,7 +3078,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const } if ((U.ndof_flag & NDOF_SHOW_GUIDE) && (rv3d->viewlock != RV3D_LOCKED) && (rv3d->persp != RV3D_CAMOB)) - // TODO: draw something else (but not this) during fly mode + /* TODO: draw something else (but not this) during fly mode */ draw_rotation_guide(rv3d); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 218aa71d621..97123767211 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -81,7 +81,7 @@ #include "PIL_time.h" /* smoothview */ -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* ********************** view3d_edit: view manipulations ********************* */ @@ -444,7 +444,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) float my_pivot[3]; /* view */ float dvec[3]; - // locals for dist correction + /* locals for dist correction */ float mat[3][3]; float upvec[3]; @@ -1517,13 +1517,13 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, fac = -fac; } - // oldstyle zoom + /* oldstyle zoom */ zfac = 1.0f + ((fac / 20.0f) * time_step); vod->timer_lastdraw = time; } else if (viewzoom == USER_ZOOM_SCALE) { int ctr[2], len1, len2; - // method which zooms based on how far you move the mouse + /* method which zooms based on how far you move the mouse */ ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin) / 2; ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin) / 2; @@ -2100,7 +2100,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in new_ofs[1] = -(min[1] + max[1]) / 2.0f; new_ofs[2] = -(min[2] + max[2]) / 2.0f; - // correction for window aspect ratio + /* correction for window aspect ratio */ if (ar->winy > 2 && ar->winx > 2) { size = (float)ar->winx / (float)ar->winy; if (size < 1.0f) size = 1.0f / size; @@ -3402,7 +3402,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve if (mval[0] != IS_CLIPPED) { short depth_used = 0; - if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */ + if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */ view3d_operator_needs_opengl(C); if (ED_view3d_autodist(scene, ar, v3d, event->mval, fp)) depth_used = 1; @@ -3596,7 +3596,7 @@ int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2] return 1; } -int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, float *autodist ) +int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) { /* Get Z Depths, needed for perspective, nice for ortho */ switch (mode) { @@ -3611,9 +3611,9 @@ int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) // return 1; } -// no 4x4 sampling, run view_autodist_init first +/* no 4x4 sampling, run view_autodist_init first */ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], - int margin, float *force_depth) //, float *autodist ) + int margin, float *force_depth) { bglMats mats; /* ZBuffer depth vars, could cache? */ float depth; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 95cc37d9f87..40837d00409 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -513,7 +513,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) } break; case P_FINISHING: - // stop keeping track of 3D mouse position + /* stop keeping track of 3D mouse position */ #ifdef NDOF_FLY_DEBUG puts("stop keeping track of 3D mouse position"); #endif diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index eb202497260..465279ee6ed 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -115,8 +115,8 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event); #define B_REDR 122 #define B_NOP 123 -// XXX quickly ported across -static void handle_view3d_lock(bContext *C) +/* XXX quickly ported across */ +static void handle_view3d_lock(bContext *C) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f9ebd4e39c1..39ec7514a88 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -92,9 +92,9 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ -// TODO: should return whether there is valid context to continue +/* TODO: should return whether there is valid context to continue */ void view3d_set_viewcontext(bContext *C, ViewContext *vc) { memset(vc, 0, sizeof(ViewContext)); @@ -758,7 +758,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) bNode *node; rcti rect; - short node_cent[2]; + int node_cent[2]; float node_centf[2]; BLI_lasso_boundbox(&rect, mcords, moves); @@ -770,7 +770,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) node_centf[1] = (node->totr.ymin + node->totr.ymax) / 2; ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); - if (BLI_in_rcti(&rect, node_cent[0], node_cent[1]) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { + if (BLI_in_rcti_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { if (select) { node->flag |= SELECT; } @@ -1130,19 +1130,19 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff short a, hits15, hits9 = 0, hits5 = 0; short has_bones15 = 0, has_bones9 = 0, has_bones5 = 0; - BLI_init_rcti(&rect, mval[0] - 14, mval[0] + 14, mval[1] - 14, mval[1] + 14); + BLI_rcti_init(&rect, mval[0] - 14, mval[0] + 14, mval[1] - 14, mval[1] + 14); hits15 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); if (hits15 > 0) { for (a = 0; a < hits15; a++) if (buffer[4 * a + 3] & 0xFFFF0000) has_bones15 = 1; offs = 4 * hits15; - BLI_init_rcti(&rect, mval[0] - 9, mval[0] + 9, mval[1] - 9, mval[1] + 9); + BLI_rcti_init(&rect, mval[0] - 9, mval[0] + 9, mval[1] - 9, mval[1] + 9); hits9 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect); if (hits9 > 0) { for (a = 0; a < hits9; a++) if (buffer[offs + 4 * a + 3] & 0xFFFF0000) has_bones9 = 1; offs += 4 * hits9; - BLI_init_rcti(&rect, mval[0] - 5, mval[0] + 5, mval[1] - 5, mval[1] + 5); + BLI_rcti_init(&rect, mval[0] - 5, mval[0] + 5, mval[1] - 5, mval[1] + 5); hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect); if (hits5 > 0) { for (a = 0; a < hits5; a++) if (buffer[offs + 4 * a + 3] & 0xFFFF0000) has_bones5 = 1; @@ -1825,7 +1825,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i unsigned int *col; /* color in buffer */ int bone_only; int bone_selected = 0; - int totobj = MAXPICKBUF; // XXX solve later + int totobj = MAXPICKBUF; /* XXX solve later */ short hits; if ((ob) && (ob->mode & OB_MODE_POSE)) @@ -2370,7 +2370,7 @@ static void lattice_circle_select(ViewContext *vc, int select, const int mval[2] } -// NOTE: pose-bone case is copied from editbone case... +/* NOTE: pose-bone case is copied from editbone case... */ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y) { CircleSelectUserData *data = userData; @@ -2403,7 +2403,7 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */ /* check each PoseChannel... */ - // TODO: could be optimized at some point + /* TODO: could be optimized at some point */ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { short sco1[2], sco2[2], didpoint = 0; float vec[3]; @@ -2475,7 +2475,7 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ /* check each EditBone... */ - // TODO: could be optimized at some point + /* TODO: could be optimized at some point */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { short sco1[2], sco2[2], didpoint = 0; float vec[3]; @@ -2497,7 +2497,7 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 didpoint = 1; /* only if the endpoints didn't get selected, deal with the middle of the bone too */ - // XXX should we just do this always? + /* XXX should we just do this always? */ if ( (didpoint == 0) && edge_inside_circle(mval[0], mval[1], rad, sco1[0], sco1[1], sco2[0], sco2[1]) ) { if (select) ebone->flag |= BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 1991d4bce4f..fc97b9bbb36 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -102,7 +102,7 @@ static void special_transvert_update(Object *obedit) if (obedit->type == OB_MESH) { Mesh *me = obedit->data; - BM_mesh_normals_update(me->edit_btmesh->bm, TRUE); // does face centers too + BM_mesh_normals_update(me->edit_btmesh->bm, TRUE); /* does face centers too */ } else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { Curve *cu = obedit->data; @@ -223,8 +223,8 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod float total, center[3], centroid[3]; int a; - tottrans = 0; // global! - + tottrans = 0; /* global! */ + INIT_MINMAX(min, max); zero_v3(centroid); @@ -239,7 +239,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod /* abuses vertex index all over, set, just set dirty here, * perhaps this could use its own array instead? - campbell */ - // transform now requires awareness for select mode, so we tag the f1 flags in verts + /* transform now requires awareness for select mode, so we tag the f1 flags in verts */ tottrans = 0; if (em->selectmode & SCE_SELECT_VERTEX) { BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { @@ -304,7 +304,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod copy_v3_v3(tv->oldloc, eve->co); tv->loc = eve->co; if (eve->no[0] != 0.0f || eve->no[1] != 0.0f || eve->no[2] != 0.0f) - tv->nor = eve->no; // note this is a hackish signal (ton) + tv->nor = eve->no; /* note this is a hackish signal (ton) */ tv->flag = BM_elem_index_get(eve) & SELECT; tv++; a++; @@ -794,8 +794,8 @@ static int snap_curs_to_grid(bContext *C, wmOperator *UNUSED(op)) curs[1] = gridf * floorf(0.5f + curs[1] / gridf); curs[2] = gridf * floorf(0.5f + curs[2] / gridf); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); // hrm - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); /* hrm */ + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index b4350847552..bc41ecd1dc5 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -71,7 +71,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* use this call when executing an operator, * event system doesn't set for each event the @@ -184,7 +184,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec /* original values */ if (oldcamera) { - sms.orig_dist = rv3d->dist; // below function does weird stuff with it... + sms.orig_dist = rv3d->dist; /* below function does weird stuff with it... */ ED_view3d_from_object(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { @@ -1100,14 +1100,14 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->dist = 0.0; ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX - + smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */ + rv3d->persp = RV3D_CAMOB; /* just to be polite, not needed */ } else { mat3_to_quat(new_quat, tmat); - smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */ } } else { @@ -1211,7 +1211,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b /* case not a border select */ if (input->xmin == input->xmax) { - rect.xmin = input->xmin - 12; // seems to be default value for bones only now + rect.xmin = input->xmin - 12; /* seems to be default value for bones only now */ rect.xmax = input->xmin + 12; rect.ymin = input->ymin - 12; rect.ymax = input->ymin + 12; @@ -1252,7 +1252,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b else { Base *base; - v3d->xray = TRUE; // otherwise it postpones drawing + v3d->xray = TRUE; /* otherwise it postpones drawing */ for (base = scene->base.first; base; base = base->next) { if (base->lay & v3d->lay) { @@ -1294,7 +1294,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b } } } - v3d->xray = FALSE; // restore + v3d->xray = FALSE; /* restore */ } glPopName(); /* see above (pushname) */ @@ -1313,8 +1313,8 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b if (vc->rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_disable(); - if (hits < 0) printf("Too many objects in select buffer\n"); // XXX make error message - + if (hits < 0) printf("Too many objects in select buffer\n"); /* XXX make error message */ + return hits; } @@ -1392,29 +1392,31 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active) return lay; } -static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) +static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportList *reports) { View3D *v3d = sa->spacedata.first; Base *base; float size = 0.0, min[3], max[3], box[3]; unsigned int locallay; - int ok = 0; + int ok = FALSE; - if (v3d->localvd) return; + if (v3d->localvd) { + return ok; + } INIT_MINMAX(min, max); locallay = free_localbit(bmain); if (locallay == 0) { - printf("Sorry, no more than 8 localviews\n"); // XXX error - ok = 0; + BKE_reportf(reports, RPT_ERROR, "No more than 8 localviews"); + ok = FALSE; } else { if (scene->obedit) { BKE_object_minmax(scene->obedit, min, max); - ok = 1; + ok = TRUE; BASACT->lay |= locallay; scene->obedit->lay = BASACT->lay; @@ -1425,7 +1427,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) BKE_object_minmax(base->object, min, max); base->lay |= locallay; base->object->lay = base->lay; - ok = 1; + ok = TRUE; } } } @@ -1437,7 +1439,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) if (size <= 0.01f) size = 0.01f; } - if (ok) { + if (ok == TRUE) { ARegion *ar; v3d->localvd = MEM_mallocN(sizeof(View3D), "localview"); @@ -1460,7 +1462,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) if (rv3d->persp == RV3D_ORTHO) rv3d->dist *= 0.7f; - // correction for window aspect ratio + /* correction for window aspect ratio */ if (ar->winy > 2 && ar->winx > 2) { float asp = (float)ar->winx / (float)ar->winy; if (asp < 1.0f) asp = 1.0f / asp; @@ -1486,9 +1488,10 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) if (base->object != scene->obedit) base->flag |= SELECT; base->object->lay = base->lay; } - } + } } + return ok; } static void restore_localviewdata(ScrArea *sa, int free) @@ -1531,7 +1534,7 @@ static void restore_localviewdata(ScrArea *sa, int free) } } -static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) +static int view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa) { View3D *v3d = sa->spacedata.first; struct Base *base; @@ -1541,7 +1544,7 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) locallay = v3d->lay & 0xFF000000; - restore_localviewdata(sa, 1); // 1 = free + restore_localviewdata(sa, 1); /* 1 = free */ /* for when in other window the layers have changed */ if (v3d->scenelock) v3d->lay = scene->lay; @@ -1559,23 +1562,38 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) } DAG_on_visible_update(bmain, FALSE); + + return TRUE; } + else { + return FALSE; + } } -static int localview_exec(bContext *C, wmOperator *UNUSED(unused)) +static int localview_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); View3D *v3d = CTX_wm_view3d(C); + int change; - if (v3d->localvd) - endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); - else - initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); + if (v3d->localvd) { + change = view3d_localview_exit(bmain, scene, sa); + } + else { + change = view3d_localview_init(bmain, scene, sa, op->reports); + } - DAG_id_type_tag(bmain, ID_OB); - ED_area_tag_redraw(CTX_wm_area(C)); - - return OPERATOR_FINISHED; + if (change) { + DAG_id_type_tag(bmain, ID_OB); + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } } void VIEW3D_OT_localview(wmOperatorType *ot) @@ -1681,7 +1699,7 @@ static void game_set_commmandline_options(GameData *gm) } } -#endif // WITH_GAMEENGINE +#endif /* WITH_GAMEENGINE */ static int game_engine_poll(bContext *C) { @@ -1722,7 +1740,7 @@ int ED_view3d_context_activate(bContext *C) if (!ar) return 0; - // bad context switch .. + /* bad context switch .. */ CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); @@ -1741,7 +1759,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) (void)op; /* unused */ - // bad context switch .. + /* bad context switch .. */ if (!ED_view3d_context_activate(C)) return OPERATOR_CANCELLED; @@ -1854,11 +1872,11 @@ static void UNUSED_FUNCTION(view3d_align_axis_to_vector)(View3D *v3d, RegionView rv3d->persp = RV3D_PERSP; rv3d->dist = 0.0; ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */ } else { if (rv3d->persp == RV3D_CAMOB) rv3d->persp = RV3D_PERSP; /* switch out of camera mode */ - smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */ } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f20fa035d32..956c3a16277 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -263,6 +263,9 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1); } + else if (t->spacetype == SPACE_NODE) { + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], adr, adr + 1); + } } void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) @@ -1670,19 +1673,25 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int /* Stupid code to have Ctrl-Click on manipulator work ok */ if (event) { - wmKeyMap *keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); - wmKeyMapItem *kmi; - - for (kmi = keymap->items.first; kmi; kmi = kmi->next) { - if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS) { - if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) || - (ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) || - (ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) || - ((kmi->type == OSKEY) && event->oskey) ) - { - t->modifiers |= MOD_SNAP_INVERT; + /* do this only for translation/rotation/resize due to only this + * moded are available from manipulator and doing such check could + * lead to keymap conflicts for other modes (see #31584) + */ + if (ELEM3(mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) { + wmKeyMap *keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); + wmKeyMapItem *kmi; + + for (kmi = keymap->items.first; kmi; kmi = kmi->next) { + if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS) { + if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) || + (ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) || + (ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) || + ((kmi->type == OSKEY) && event->oskey) ) + { + t->modifiers |= MOD_SNAP_INVERT; + } + break; } - break; } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d7241555cc7..949266a0cc2 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4880,7 +4880,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o for (fcu = act->curves.first; fcu; fcu = fcu->next) { /* only insert keyframes for this F-Curve if it affects the current bone */ if (strstr(fcu->rna_path, "bones")) { - char *pchanName = BLI_getQuotedStr(fcu->rna_path, "bones["); + char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones["); /* only if bone name matches too... * NOTE: this will do constraints too, but those are ok to do here too? diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 216ac61b628..7ef205b69f0 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -196,7 +196,15 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im } else { /* old shading system, assign image to selected faces */ - + float prev_aspect[2], fprev_aspect; + float aspect[2], faspect; + + ED_image_uv_aspect(previma, prev_aspect, prev_aspect + 1); + ED_image_uv_aspect(ima, aspect, aspect + 1); + + fprev_aspect = prev_aspect[0]/prev_aspect[1]; + faspect = aspect[0]/aspect[1]; + /* ensure we have a uv map */ if (!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) { BM_data_layer_add(em->bm, &em->bm->pdata, CD_MTEXPOLY); @@ -214,6 +222,19 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im if (ima->id.us == 0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); + + /* we also need to correct the aspect of uvs */ + if(tf->unwrap & TF_CORRECT_ASPECT) { + BMIter liter; + BMLoop *l; + + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); + + luv->uv[0] *= fprev_aspect; + luv->uv[0] /= faspect; + } + } } else { tf->tpage = NULL; @@ -2458,7 +2479,7 @@ static int border_select_exec(bContext *C, wmOperator *op) tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); if (uvedit_face_visible_test(scene, ima, efa, tf)) { uv_poly_center(em, efa, cent); - if (BLI_in_rctf(&rectf, cent[0], cent[1])) { + if (BLI_in_rctf_v(&rectf, cent)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); change = 1; } @@ -2483,15 +2504,13 @@ static int border_select_exec(bContext *C, wmOperator *op) if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) { /* UV_SYNC_SELECTION - can't do pinned selection */ - if (BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) { + if (BLI_in_rctf_v(&rectf, luv->uv)) { if (select) uvedit_uv_select_enable(em, scene, l, FALSE); else uvedit_uv_select_disable(em, scene, l); } } else if (pinned) { - if ((luv->flag & MLOOPUV_PINNED) && - BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) - { + if ((luv->flag & MLOOPUV_PINNED) && BLI_in_rctf_v(&rectf, luv->uv)) { if (select) uvedit_uv_select_enable(em, scene, l, FALSE); else uvedit_uv_select_disable(em, scene, l); } @@ -2664,7 +2683,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh float cent[2]; uv_poly_center(em, efa, cent); UI_view2d_view_to_region(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]); - if (BLI_in_rcti(&rect, screen_uv[0], screen_uv[1]) && + if (BLI_in_rcti_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { uvedit_face_select_enable(scene, em, efa, FALSE); @@ -2681,7 +2700,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh if ((select) != (uvedit_uv_select_test(em, scene, l))) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); UI_view2d_view_to_region(&ar->v2d, luv->uv[0], luv->uv[1], &screen_uv[0], &screen_uv[1]); - if (BLI_in_rcti(&rect, screen_uv[0], screen_uv[1]) && + if (BLI_in_rcti_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { if (select) { diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 87ff36ebf27..a2e276c09e3 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -145,6 +145,7 @@ typedef struct PFace { struct PEdge *edge; unsigned char flag; + short *unwrap_flag; } PFace; @@ -232,8 +233,11 @@ typedef struct PHandle { RNG *rng; float blend; + char do_aspect; } PHandle; +/* duplicate, to avoid including DNA_mesh_types.h */ +#define TF_CORRECT_ASPECT 256 /* PHash * - special purpose hash that keeps all its elements in a single linked list. @@ -646,6 +650,7 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v) static void p_flush_uvs(PHandle *handle, PChart *chart) { PEdge *e; + PFace *f; for (e = chart->edges; e; e = e->nextlink) { if (e->orig_uv) { @@ -653,6 +658,16 @@ static void p_flush_uvs(PHandle *handle, PChart *chart) e->orig_uv[1] = e->vert->uv[1] / handle->aspy; } } + + for (f = chart->faces; f; f = f->nextlink) { + if(f->unwrap_flag) { + if (handle->do_aspect) { + *f->unwrap_flag |= TF_CORRECT_ASPECT; + } else { + *f->unwrap_flag &= ~TF_CORRECT_ASPECT; + } + } + } } static void p_flush_uvs_blend(PHandle *handle, PChart *chart, float blend) @@ -1042,6 +1057,7 @@ static PFace *p_face_add(PHandle *handle) /* allocate */ f = (PFace *)BLI_memarena_alloc(handle->arena, sizeof *f); f->flag = 0; // init ! + f->unwrap_flag = NULL; e1 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e1); e2 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e2); @@ -1068,7 +1084,7 @@ static PFace *p_face_add(PHandle *handle) static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkeys, float *co[3], float *uv[3], int i1, int i2, int i3, - ParamBool *pin, ParamBool *select) + ParamBool *pin, ParamBool *select, short *unwrap_flag) { PFace *f = p_face_add(handle); PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; @@ -1095,6 +1111,7 @@ static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkey /* insert into hash */ f->u.key = key; + f->unwrap_flag = unwrap_flag; phash_insert(handle->hash_faces, (PHashLink *)f); e1->u.key = PHASH_edge(vkeys[i1], vkeys[i2]); @@ -4087,6 +4104,7 @@ ParamHandle *param_construct_begin(void) handle->arena = BLI_memarena_new((1 << 16), "param construct arena"); handle->aspx = 1.0f; handle->aspy = 1.0f; + handle->do_aspect = FALSE; handle->hash_verts = phash_new((PHashLink **)&handle->construction_chart->verts, 1); handle->hash_edges = phash_new((PHashLink **)&handle->construction_chart->edges, 1); @@ -4101,6 +4119,7 @@ void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy) phandle->aspx = aspx; phandle->aspy = aspy; + phandle->do_aspect = TRUE; } void param_delete(ParamHandle *handle) @@ -4131,7 +4150,7 @@ void param_delete(ParamHandle *handle) void param_face_add(ParamHandle *handle, ParamKey key, int nverts, ParamKey *vkeys, float **co, float **uv, - ParamBool *pin, ParamBool *select) + ParamBool *pin, ParamBool *select, short *unwrap_flag) { PHandle *phandle = (PHandle *)handle; @@ -4141,16 +4160,16 @@ void param_face_add(ParamHandle *handle, ParamKey key, int nverts, if (nverts == 4) { if (p_quad_split_direction(phandle, co, vkeys)) { - p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select); - p_face_add_construct(phandle, key, vkeys, co, uv, 0, 2, 3, pin, select); + p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select, unwrap_flag); + p_face_add_construct(phandle, key, vkeys, co, uv, 0, 2, 3, pin, select, unwrap_flag); } else { - p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 3, pin, select); - p_face_add_construct(phandle, key, vkeys, co, uv, 1, 2, 3, pin, select); + p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 3, pin, select, unwrap_flag); + p_face_add_construct(phandle, key, vkeys, co, uv, 1, 2, 3, pin, select, unwrap_flag); } } else if (!p_face_exists(phandle, vkeys, 0, 1, 2)) { - p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select); + p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select, unwrap_flag); } } diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h index 3c886367191..9a2fea0d7f9 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.h +++ b/source/blender/editors/uvedit/uvedit_parametrizer.h @@ -62,7 +62,7 @@ void param_face_add(ParamHandle *handle, float **co, float **uv, ParamBool *pin, - ParamBool *select); + ParamBool *select, short *unwrap_flag); void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 0930edbe46d..1def5caad87 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -202,6 +202,8 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, if (aspx != aspy) param_aspect_ratio(handle, aspx, aspy); + else + param_aspect_ratio(handle, 1.0, 1.0); } } @@ -211,6 +213,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, BLI_srand(0); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + MTexPoly *tf; ScanFillVert *sf_vert, *sf_vert_last, *sf_vert_first; ScanFillFace *sf_tri; ParamKey key, vkeys[4]; @@ -237,6 +240,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); if (efa->len == 3 || efa->len == 4) { /* for quads let parametrize split, it can make better decisions @@ -253,7 +257,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, i++; } - param_face_add(handle, key, i, vkeys, co, uv, pin, select); + param_face_add(handle, key, i, vkeys, co, uv, pin, select, &tf->unwrap); } else { /* ngon - scanfill time! */ @@ -298,7 +302,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, select[i] = uvedit_uv_select_test(em, scene, ls[i]) != 0; } - param_face_add(handle, key, 3, vkeys, co, uv, pin, select); + param_face_add(handle, key, 3, vkeys, co, uv, pin, select, &tf->unwrap); } BLI_scanfill_end(&sf_ctx); @@ -388,6 +392,8 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e if (aspx != aspy) param_aspect_ratio(handle, aspx, aspy); + else + param_aspect_ratio(handle, 1.0, 1.0); } } @@ -440,7 +446,8 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e float *co[4]; float *uv[4]; BMFace *origFace = faceMap[i]; - + MTexPoly *tf; + face = subsurfedFaces + i; if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { @@ -452,6 +459,8 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e continue; } + tf = CustomData_bmesh_get(&em->bm->pdata, origFace->head.data, CD_MTEXPOLY); + /* We will not check for v4 here. Subsurfed mfaces always have 4 vertices. */ key = (ParamKey)face; vkeys[0] = (ParamKey)face->v1; @@ -471,7 +480,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e texface_from_original_index(origFace, origVertIndices[face->v3], &uv[2], &pin[2], &select[2], scene, em); texface_from_original_index(origFace, origVertIndices[face->v4], &uv[3], &pin[3], &select[3], scene, em); - param_face_add(handle, key, 4, vkeys, co, uv, pin, select); + param_face_add(handle, key, 4, vkeys, co, uv, pin, select, &tf->unwrap); } /* these are calculated from original mesh too */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 8a31a454633..f4e1e0c1147 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -638,8 +638,9 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float * frect, int int tpy = recth; /* scale if not a power of two. this is not strictly necessary for newer - * GPUs (OpenGL version >= 2.0) since they support non-power-of-two-textures */ - if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) { + * GPUs (OpenGL version >= 2.0) since they support non-power-of-two-textures + * Then don't bother scaling for hardware that supports NPOT textures! */ + if (!GLEW_ARB_texture_non_power_of_two && (!is_pow2_limit(rectw) || !is_pow2_limit(recth))) { rectw= smaller_pow2_limit(rectw); recth= smaller_pow2_limit(recth); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 78b5219206d..0fad5e47445 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1032,7 +1032,9 @@ static void do_material_tex(GPUShadeInput *shi) if (tex->imaflag & TEX_USEALPHA) talpha= 1; } - else continue; + else { + continue; + } /* texture output */ if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index d544e6501fc..21d50e4a71d 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -139,7 +139,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t size = MIN2(segcount, tree->totchannel); a = t = 0; while (a < size && t < tree->totchannel) { - // locate first matching channel + /* locate first matching channel */ for (; t < tree->totchannel && tree->pchan[t] != chanlist[segcount - a - 1]; t++) ; if (t >= tree->totchannel) break; @@ -535,7 +535,7 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose for (a = 0; a < tree->totchannel; a++) { if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag BKE_pose_where_is_bone(scene, ob, tree->pchan[a], ctime, 1); - // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() + /* tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() */ tree->pchan[a]->flag |= POSE_CHAIN; } /* 5. execute the IK solver */ diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index a0d7bfbaaf6..652b16a7c65 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -1618,7 +1618,7 @@ static void execute_scene(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, fl timestep = sts / 1000.0; } } - // don't cache if we are reiterating because we don't want to distroy the cache unnecessarily + // don't cache if we are reiterating because we don't want to destroy the cache unnecessarily ikscene->scene->update(timestamp, timestep, numstep, false, !reiterate, simulation); if (reiterate) { // how many times do we reiterate? diff --git a/source/blender/imbuf/IMB_moviecache.h b/source/blender/imbuf/IMB_moviecache.h index f6927d4f31d..d1d34a01433 100644 --- a/source/blender/imbuf/IMB_moviecache.h +++ b/source/blender/imbuf/IMB_moviecache.h @@ -44,10 +44,19 @@ struct MovieCache; typedef void (*MovieCacheGetKeyDataFP) (void *userkey, int *framenr, int *proxy, int *render_flags); +typedef void *(*MovieCacheGetPriorityDataFP) (void *userkey); +typedef int (*MovieCacheGetItemPriorityFP) (void *last_userkey, void *priority_data); +typedef void (*MovieCachePriorityDeleterFP) (void *priority_data); + void IMB_moviecache_init(void); void IMB_moviecache_destruct(void); -struct MovieCache *IMB_moviecache_create(int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp, MovieCacheGetKeyDataFP getdatafp); +struct MovieCache *IMB_moviecache_create(const char *name, int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp); +void IMB_moviecache_set_getdata_callback(struct MovieCache *cache, MovieCacheGetKeyDataFP getdatafp); +void IMB_moviecache_set_priority_callback(struct MovieCache *cache, MovieCacheGetPriorityDataFP getprioritydatafp, + MovieCacheGetItemPriorityFP getitempriorityfp, + MovieCachePriorityDeleterFP prioritydeleterfp); + void IMB_moviecache_put(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf); struct ImBuf* IMB_moviecache_get(struct MovieCache *cache, void *userkey); void IMB_moviecache_free(struct MovieCache *cache); diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 7f4abd29890..571c54b9cb3 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -129,9 +129,9 @@ struct anim { float frs_sec_base; int x, y; - /* voor op nummer */ + /* for number */ char name[1024]; - /* voor sequence */ + /* for sequence */ char first[1024]; /* movie */ diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 68a094c26d0..c717d8eee5a 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -424,7 +424,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) /* silly trick to copy the entire contents of ibuf1 struct over to ibuf */ tbuf = *ibuf1; - // fix pointers + /* fix pointers */ tbuf.rect = ibuf2->rect; tbuf.rect_float = ibuf2->rect_float; tbuf.encodedbuffer = ibuf2->encodedbuffer; @@ -433,12 +433,12 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) for (a = 0; a < IB_MIPMAP_LEVELS; a++) tbuf.mipmap[a] = NULL; - // set malloc flag + /* set malloc flag */ tbuf.mall = ibuf2->mall; tbuf.c_handle = NULL; tbuf.refcounter = 0; - // for now don't duplicate metadata + /* for now don't duplicate metadata */ tbuf.metadata = NULL; *ibuf2 = tbuf; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index f0c2d754333..a27aae815da 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -42,8 +42,8 @@ #include <vfw.h> #endif -#undef AVIIF_KEYFRAME // redefined in AVI_avi.h -#undef AVIIF_LIST // redefined in AVI_avi.h +#undef AVIIF_KEYFRAME /* redefined in AVI_avi.h */ +#undef AVIIF_LIST /* redefined in AVI_avi.h */ #define FIXCC(fcc) \ { \ @@ -324,10 +324,10 @@ static int startavi(struct anim *anim) if (anim->pgf) { firstvideo = i; - // get stream length + /* get stream length */ anim->avi->header->TotalFrames = AVIStreamLength(anim->pavi[i]); - - // get information about images inside the stream + + /* get information about images inside the stream */ l = sizeof(abFormat); AVIStreamReadFormat(anim->pavi[i], 0, &abFormat, &l); lpbi = (LPBITMAPINFOHEADER)abFormat; @@ -344,12 +344,12 @@ static int startavi(struct anim *anim) } } - // register number of opened avistreams + /* register number of opened avistreams */ anim->avistreams = i; - // - // Couldn't get any video streams out of this file - // + /* + * Couldn't get any video streams out of this file + */ if ((anim->avistreams == 0) || (firstvideo == -1)) { avierror = AVI_ERROR_FORMAT; } diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 40f6f36e06b..5114fcb3ae0 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -258,11 +258,11 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float * y1 = (int)floor(v); y2 = (int)ceil(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) return; if (outF) { - // sample including outside of edges of image + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1 = empty; else row1 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x1; @@ -285,7 +285,7 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float * outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; } if (outI) { - // sample including outside of edges of image + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1I = emptyI; else row1I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1; @@ -332,18 +332,18 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl y1 = (int)floor(v); y2 = (int)ceil(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) return; - + /* wrap interpolation pixels - main difference from bilinear_interpolation_color */ if (x1 < 0) x1 = in->x + x1; if (y1 < 0) y1 = in->y + y1; - + if (x2 >= in->x) x2 = x2 - in->x; if (y2 >= in->y) y2 = y2 - in->y; if (outF) { - // sample including outside of edges of image + /* sample including outside of edges of image */ row1 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x1; row2 = (float *)in->rect_float + in->x * y2 * 4 + 4 * x1; row3 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x2; @@ -359,7 +359,7 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; } if (outI) { - // sample including outside of edges of image + /* sample including outside of edges of image */ row1I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1; row2I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x1; row3I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x2; @@ -404,10 +404,10 @@ void neareast_interpolation_color(struct ImBuf *in, unsigned char *outI, float * x1 = (int)(u); y1 = (int)(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x1 < 0 || x1 > in->x - 1 || y1 < 0 || y1 > in->y - 1) return; - - // sample including outside of edges of image + + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) { if (outI) { outI[0] = 0; diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 8b2e27ae1f3..9cf06b08ba4 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -181,12 +181,12 @@ struct anim_index *IMB_indexer_open(const char *name) fseek(fp, 0, SEEK_END); idx->num_entries = (ftell(fp) - 12) / - (sizeof(int) + // framepos - sizeof(unsigned long long) + // seek_pos - sizeof(unsigned long long) + // seek_pos_dts - sizeof(unsigned long long) // pts + (sizeof(int) + /* framepos */ + sizeof(unsigned long long) + /* seek_pos */ + sizeof(unsigned long long) + /* seek_pos_dts */ + sizeof(unsigned long long) /* pts */ ); - + fseek(fp, 12, SEEK_SET); idx->entries = MEM_callocN(sizeof(struct anim_index_entry) * @@ -472,7 +472,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( char fname[FILE_MAX]; int ffmpeg_quality; - // JPEG requires this + /* JPEG requires this */ width = round_up(width, 8); height = round_up(height, 8); diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c index 0090577062f..4c6b750aa41 100644 --- a/source/blender/imbuf/intern/indexer_dv.c +++ b/source/blender/imbuf/intern/indexer_dv.c @@ -129,7 +129,7 @@ static void parse_packet(indexer_dv_context *This, unsigned char *p) b = bitstream_new(p + 1); switch (type) { - case 0x62: // Record date + case 0x62: /* Record date */ parse_num(&b, 8); This->rec_curr_day = parse_bcd(&b, 6); parse_num(&b, 2); @@ -144,7 +144,7 @@ static void parse_packet(indexer_dv_context *This, unsigned char *p) } This->got_record_date = 1; break; - case 0x63: // Record time + case 0x63: /* Record time */ This->rec_curr_frame = parse_bcd(&b, 6); parse_num(&b, 2); This->rec_curr_second = parse_bcd(&b, 7); @@ -322,7 +322,7 @@ static void proc_frame(indexer_dv_context *This, } } else if (This->ref_time_read_new == This->ref_time_read) { - // do nothing + /* do nothing */ } else { This->gap_start = This->ref_time_read; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 3008c233718..6477d40d695 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -880,7 +880,7 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags) parameters.tcp_rates[0] = ((100 - quality) / 90.0f * 99.0f) + 1; - parameters.tcp_numlayers = 1; // only one resolution + parameters.tcp_numlayers = 1; /* only one resolution */ parameters.cp_disto_alloc = 1; image = ibuftoimage(ibuf, ¶meters); diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 47555302a59..03c949bc3d1 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -86,9 +86,9 @@ int imb_is_a_jpeg(unsigned char *mem) return 0; } -//---------------------------------------------------------- -// JPG ERROR HANDLING -//---------------------------------------------------------- +/*---------------------------------------------------------- + * JPG ERROR HANDLING + *---------------------------------------------------------- */ typedef struct my_error_mgr { struct jpeg_error_mgr pub; /* "public" fields */ @@ -112,9 +112,9 @@ static void jpeg_error(j_common_ptr cinfo) longjmp(err->setjmp_buffer, 1); } -//---------------------------------------------------------- -// INPUT HANDLER FROM MEMORY -//---------------------------------------------------------- +/*---------------------------------------------------------- + * INPUT HANDLER FROM MEMORY + *---------------------------------------------------------- */ typedef struct { unsigned char *buffer; @@ -159,7 +159,7 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) my_src_ptr src = (my_src_ptr) cinfo->src; if (num_bytes > 0) { - // prevent skipping over file end + /* prevent skipping over file end */ size_t skip_size = (size_t)num_bytes <= src->pub.bytes_in_buffer ? num_bytes : src->pub.bytes_in_buffer; src->pub.next_input_byte = src->pub.next_input_byte + skip_size; diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 2992e4a0aa7..671c79a0659 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -29,12 +29,15 @@ * \ingroup bke */ +#undef DEBUG_MESSAGES + #include <stdlib.h> /* for qsort */ #include <memory.h> #include "MEM_guardedalloc.h" #include "MEM_CacheLimiterC-Api.h" +#include "BLI_string.h" #include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_mempool.h" @@ -44,20 +47,37 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#ifdef DEBUG_MESSAGES +# if defined __GNUC__ || defined __sun +# define PRINT(format, args ...) printf(format, ##args) +# else +# define PRINT(format, ...) printf(__VA_ARGS__) +# endif +#else +# define PRINT(format, ...) +#endif + static MEM_CacheLimiterC *limitor = NULL; typedef struct MovieCache { + char name[64]; + GHash *hash; GHashHashFP hashfp; GHashCmpFP cmpfp; MovieCacheGetKeyDataFP getdatafp; + MovieCacheGetPriorityDataFP getprioritydatafp; + MovieCacheGetItemPriorityFP getitempriorityfp; + MovieCachePriorityDeleterFP prioritydeleterfp; + struct BLI_mempool *keys_pool; struct BLI_mempool *items_pool; struct BLI_mempool *userkeys_pool; int keysize; - unsigned long curtime; + + void *last_userkey; int totseg, *points, proxy, render_flags; /* for visual statistics optimization */ int pad; @@ -72,7 +92,7 @@ typedef struct MovieCacheItem { MovieCache *cache_owner; ImBuf *ibuf; MEM_CacheLimiterHandleC *c_handle; - unsigned long last_access; + void *priority_data; } MovieCacheItem; static unsigned int moviecache_hashhash(const void *keyv) @@ -94,18 +114,27 @@ static void moviecache_keyfree(void *val) { MovieCacheKey *key = (MovieCacheKey *)val; + BLI_mempool_free(key->cache_owner->userkeys_pool, key->userkey); + BLI_mempool_free(key->cache_owner->keys_pool, key); } static void moviecache_valfree(void *val) { MovieCacheItem *item = (MovieCacheItem *)val; + MovieCache *cache = item->cache_owner; + + PRINT("%s: cache '%s' free item %p buffer %p\n", __func__, cache->name, item, item->ibuf); if (item->ibuf) { MEM_CacheLimiter_unmanage(item->c_handle); IMB_freeImBuf(item->ibuf); } + if (item->priority_data && cache->prioritydeleterfp) { + cache->prioritydeleterfp(item->priority_data); + } + BLI_mempool_free(item->cache_owner->items_pool, item); } @@ -117,10 +146,17 @@ static void check_unused_keys(MovieCache *cache) while (!BLI_ghashIterator_isDone(iter)) { MovieCacheKey *key = BLI_ghashIterator_getKey(iter); MovieCacheItem *item = BLI_ghashIterator_getValue(iter); + int remove = 0; BLI_ghashIterator_step(iter); - if (!item->ibuf) + remove = !item->ibuf; + + if (remove) { + PRINT("%s: cache '%s' remove item %p without buffer\n", __func__, cache->name, item); + } + + if (remove) BLI_ghash_remove(cache->hash, key, moviecache_keyfree, moviecache_valfree); } @@ -137,12 +173,21 @@ static int compare_int(const void *av, const void *bv) static void IMB_moviecache_destructor(void *p) { MovieCacheItem *item = (MovieCacheItem *) p; + MovieCache *cache = item->cache_owner; + + PRINT("%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->name, item, item->ibuf); if (item && item->ibuf) { IMB_freeImBuf(item->ibuf); item->ibuf = NULL; item->c_handle = NULL; + + /* force cached segments to be updated */ + if (cache->points) { + MEM_freeN(cache->points); + cache->points = NULL; + } } } @@ -187,9 +232,30 @@ static size_t get_item_size(void *p) return size; } +static int get_item_priority(void *item_v, int default_priority) +{ + MovieCacheItem *item = (MovieCacheItem *) item_v; + MovieCache *cache = item->cache_owner; + int priority; + + if (!cache->getitempriorityfp) { + PRINT("%s: cache '%s' item %p use default priority %d\n", __func__, cache-> name, item, default_priority); + + return default_priority; + } + + priority = cache->getitempriorityfp(cache->last_userkey, item->priority_data); + + PRINT("%s: cache '%s' item %p priority %d\n", __func__, cache-> name, item, priority); + + return priority; +} + void IMB_moviecache_init(void) { limitor = new_MEM_CacheLimiter(IMB_moviecache_destructor, get_item_size); + + MEM_CacheLimiter_ItemPriority_Func_set(limitor, get_item_priority); } void IMB_moviecache_destruct(void) @@ -198,12 +264,16 @@ void IMB_moviecache_destruct(void) delete_MEM_CacheLimiter(limitor); } -MovieCache *IMB_moviecache_create(int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp, - MovieCacheGetKeyDataFP getdatafp) +MovieCache *IMB_moviecache_create(const char *name, int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp) { MovieCache *cache; + PRINT("%s: cache '%s' create\n", __func__, name); + cache = MEM_callocN(sizeof(MovieCache), "MovieCache"); + + BLI_strncpy(cache->name, name, sizeof(cache->name)); + cache->keys_pool = BLI_mempool_create(sizeof(MovieCacheKey), 64, 64, 0); cache->items_pool = BLI_mempool_create(sizeof(MovieCacheItem), 64, 64, 0); cache->userkeys_pool = BLI_mempool_create(keysize, 64, 64, 0); @@ -212,12 +282,27 @@ MovieCache *IMB_moviecache_create(int keysize, GHashHashFP hashfp, GHashCmpFP cm cache->keysize = keysize; cache->hashfp = hashfp; cache->cmpfp = cmpfp; - cache->getdatafp = getdatafp; cache->proxy = -1; return cache; } +void IMB_moviecache_set_getdata_callback(MovieCache *cache, MovieCacheGetKeyDataFP getdatafp) +{ + cache->getdatafp = getdatafp; +} + +void IMB_moviecache_set_priority_callback(struct MovieCache *cache, MovieCacheGetPriorityDataFP getprioritydatafp, + MovieCacheGetItemPriorityFP getitempriorityfp, + MovieCachePriorityDeleterFP prioritydeleterfp) +{ + cache->last_userkey = MEM_mallocN(cache->keysize, "movie cache last user key"); + + cache->getprioritydatafp = getprioritydatafp; + cache->getitempriorityfp = getitempriorityfp; + cache->prioritydeleterfp = prioritydeleterfp; +} + void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf) { MovieCacheKey *key; @@ -234,16 +319,27 @@ void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf) memcpy(key->userkey, userkey, cache->keysize); item = BLI_mempool_alloc(cache->items_pool); + + PRINT("%s: cache '%s' put %p, item %p\n", __func__, cache-> name, ibuf, item); + item->ibuf = ibuf; item->cache_owner = cache; - item->last_access = cache->curtime++; item->c_handle = NULL; + item->priority_data = NULL; + + if (cache->getprioritydatafp) { + item->priority_data = cache->getprioritydatafp(userkey); + } BLI_ghash_remove(cache->hash, key, moviecache_keyfree, moviecache_valfree); BLI_ghash_insert(cache->hash, key, item); item->c_handle = MEM_CacheLimiter_insert(limitor, item); + if (cache->last_userkey) { + memcpy(cache->last_userkey, userkey, cache->keysize); + } + MEM_CacheLimiter_ref(item->c_handle); MEM_CacheLimiter_enforce_limits(limitor); MEM_CacheLimiter_unref(item->c_handle); @@ -267,8 +363,6 @@ ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey) item = (MovieCacheItem *)BLI_ghash_lookup(cache->hash, &key); if (item) { - item->last_access = cache->curtime++; - if (item->ibuf) { MEM_CacheLimiter_touch(item->c_handle); IMB_refImBuf(item->ibuf); @@ -282,6 +376,8 @@ ImBuf *IMB_moviecache_get(MovieCache *cache, void *userkey) void IMB_moviecache_free(MovieCache *cache) { + PRINT("%s: create '%s' free\n", __func__, cache->name); + BLI_ghash_free(cache->hash, moviecache_keyfree, moviecache_valfree); BLI_mempool_destroy(cache->keys_pool); @@ -291,6 +387,9 @@ void IMB_moviecache_free(MovieCache *cache) if (cache->points) MEM_freeN(cache->points); + if (cache->last_userkey) + MEM_freeN(cache->last_userkey); + MEM_freeN(cache); } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 18957cb8260..f5479bce570 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -665,9 +665,9 @@ void IMB_exr_read_channels(void *handle) } void IMB_exr_multilayer_convert(void *handle, void *base, - void * (*addlayer)(void *base, char *str), - void (*addpass)(void *base, void *lay, char *str, - float *rect, int totchan, char *chan_id)) + void * (*addlayer)(void *base, const char *str), + void (*addpass)(void *base, void *lay, const char *str, + float *rect, int totchan, const char *chan_id)) { ExrHandle *data = (ExrHandle *)handle; ExrLayer *lay; @@ -908,14 +908,6 @@ static ExrHandle *imb_exr_begin_read_mem(InputFile *file, int width, int height) /* ********************************************************* */ -typedef struct RGBA { - float r; - float g; - float b; - float a; -} RGBA; - - /* debug only */ static void exr_print_filecontents(InputFile *file) { diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h index 523dc8120c4..78071975c72 100644 --- a/source/blender/imbuf/intern/openexr/openexr_multi.h +++ b/source/blender/imbuf/intern/openexr/openexr_multi.h @@ -37,9 +37,9 @@ /* Note: as for now openexr only supports 32 chars in channel names. * This api also supports max 8 channels per pass now. easy to fix! */ -#define EXR_LAY_MAXNAME 19 +#define EXR_LAY_MAXNAME 51 #define EXR_PASS_MAXNAME 11 -#define EXR_TOT_MAXNAME 32 +#define EXR_TOT_MAXNAME 64 #define EXR_PASS_MAXCHAN 8 @@ -62,8 +62,8 @@ void IMB_exrtile_write_channels(void *handle, int partx, int party, int level void IMB_exrtile_clear_channels(void *handle); void IMB_exr_multilayer_convert(void *handle, void *base, - void * (*addlayer)(void *base, char *str), - void (*addpass)(void *base, void *lay, char *str, float *rect, int totchan, char *chan_id)); + void * (*addlayer)(void *base, const char *str), + void (*addpass)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id)); void IMB_exr_close(void *handle); diff --git a/source/blender/imbuf/intern/openexr/openexr_stub.cpp b/source/blender/imbuf/intern/openexr/openexr_stub.cpp index e896fc58cf3..7262656d4e8 100644 --- a/source/blender/imbuf/intern/openexr/openexr_stub.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_stub.cpp @@ -48,8 +48,8 @@ void IMB_exrtile_write_channels (void *handle, int partx, int party, int level) void IMB_exrtile_clear_channels (void *handle) { (void)handle; } void IMB_exr_multilayer_convert (void *handle, void *base, - void * (*addlayer)(void *base, char *str), - void (*addpass)(void *base, void *lay, char *str, float *rect, int totchan, char *chan_id)) + void * (*addlayer)(void *base, const char *str), + void (*addpass)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id)) { (void)handle; (void)base; (void)addlayer; (void)addpass; } diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 2aed1485700..928eb219ea5 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -73,7 +73,7 @@ static void WriteData(png_structp png_ptr, png_bytep data, png_size_t length) { ImBuf *ibuf = (ImBuf *) png_get_io_ptr(png_ptr); - // if buffer is to small increase it. + /* if buffer is to small increase it. */ while (ibuf->encodedsize + length > ibuf->encodedbuffersize) { imb_enlargeencodedbufferImBuf(ibuf); } @@ -144,7 +144,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return 0; } - // copy image data + /* copy image data */ pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels"); if (pixels == NULL) { @@ -186,7 +186,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) } if (flags & IB_mem) { - // create image in memory + /* create image in memory */ imb_addencodedbufferImBuf(ibuf); ibuf->encodedsize = 0; @@ -218,7 +218,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) png_set_compression_level(png_ptr, compression); - // png image settings + /* png image settings */ png_set_IHDR(png_ptr, info_ptr, ibuf->x, @@ -261,10 +261,10 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) png_set_pHYs(png_ptr, info_ptr, (unsigned int)(ibuf->ppm[0] + 0.5), (unsigned int)(ibuf->ppm[1] + 0.5), PNG_RESOLUTION_METER); } - // write the file header information + /* write the file header information */ png_write_info(png_ptr, info_ptr); - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); if (row_pointers == NULL) { printf("imb_savepng: Cannot allocate row-pointers array for file '%s'\n", name); @@ -276,19 +276,19 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return 0; } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); } - // write out the entire image data in one call + /* write out the entire image data in one call */ png_write_image(png_ptr, row_pointers); - // write the additional chunks to the PNG file (not really needed) + /* write the additional chunks to the PNG file (not really needed) */ png_write_end(png_ptr, info_ptr); - // clean up + /* clean up */ MEM_freeN(pixels); MEM_freeN(row_pointers); png_destroy_write_struct(&png_ptr, &info_ptr); @@ -419,14 +419,14 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) longjmp(png_jmpbuf(png_ptr), 1); } - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_uint_16p), "row_pointers"); if (row_pointers == NULL) { printf("Cannot allocate row-pointers array\n"); longjmp(png_jmpbuf(png_ptr), 1); } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((png_uint_16 *)pixels16 + (i * ibuf->x) * bytesperpixel); @@ -434,7 +434,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_image(png_ptr, row_pointers); - // copy image data + /* copy image data */ to_float = ibuf->rect_float; from16 = pixels16; @@ -487,14 +487,14 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) longjmp(png_jmpbuf(png_ptr), 1); } - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); if (row_pointers == NULL) { printf("Cannot allocate row-pointers array\n"); longjmp(png_jmpbuf(png_ptr), 1); } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); @@ -502,7 +502,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_image(png_ptr, row_pointers); - // copy image data + /* copy image data */ to = (unsigned char *) ibuf->rect; from = pixels; @@ -555,7 +555,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_end(png_ptr, info_ptr); } - // clean up + /* clean up */ if (pixels) MEM_freeN(pixels); if (pixels16) diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 29c2e63637d..2ba1ebf90b5 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -163,8 +163,8 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe) int imb_is_a_hdr(unsigned char *buf) { - // For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead - // update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part + /* For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead */ + /* update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part */ //if (strstr((char*)buf, "#?RADIANCE")) return 1; if (strstr((char *)buf, "#?")) return 1; // if (strstr((char*)buf, "32-bit_rle_rgbe")) return 1; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 615b420429a..cc57ffff812 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -466,7 +466,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) 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) + /* Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) */ if (bitspersample < 16) if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(tmpibuf); diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index fb6ae8e3833..58964a16aee 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -108,7 +108,7 @@ typedef struct ID { void *next, *prev; struct ID *newid; struct Library *lib; - char name[66]; + char name[66]; /* MAX_ID_NAME */ short pad, us; /** * LIB_... flags report on status of the datablock this ID belongs diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index d28a14a9fd6..c4258c0870e 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -362,13 +362,14 @@ typedef struct MVertSkin { /* mtface->unwrap */ -#define TF_DEPRECATED1 1 -#define TF_DEPRECATED2 2 -#define TF_DEPRECATED3 4 -#define TF_DEPRECATED4 8 -#define TF_PIN1 16 -#define TF_PIN2 32 -#define TF_PIN3 64 -#define TF_PIN4 128 +#define TF_DEPRECATED1 1 +#define TF_DEPRECATED2 2 +#define TF_DEPRECATED3 4 +#define TF_DEPRECATED4 8 +#define TF_PIN1 16 +#define TF_PIN2 32 +#define TF_PIN3 64 +#define TF_PIN4 128 +#define TF_CORRECT_ASPECT 256 #endif diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index e4b5a264ba3..1e2f6eabce6 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -178,9 +178,7 @@ typedef struct bNode { char label[64]; /* custom user-defined label, MAX_NAME */ short custom1, custom2; /* to be abused for buttons */ float custom3, custom4; - int highlight; /* 0 = not highlighted, 1-N = highlighted*/ - int pad; - + short need_exec, exec; /* need_exec is set as UI execution event, exec is flag during exec */ void *threaddata; /* optional extra storage for use in thread (read only then!) */ rctf totr; /* entire boundbox */ @@ -654,6 +652,7 @@ typedef struct NodeKeyingScreenData { typedef struct NodeKeyingData { float screen_balance; float despill_factor; + float despill_balance; int edge_kernel_radius; float edge_kernel_tolerance; float clip_black, clip_white; @@ -663,6 +662,11 @@ typedef struct NodeKeyingData { int blur_pre, blur_post; } NodeKeyingData; +typedef struct NodeTrackPosData { + char tracking_object[64]; + char track_name[64]; +} NodeTrackPosData; + /* frame node flags */ #define NODE_FRAME_SHRINK 1 /* keep the bounding box minimal */ #define NODE_FRAME_RESIZEABLE 2 /* test flag, if frame can be resized by user */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index b3f0950fa75..7e1094ef93b 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -518,7 +518,7 @@ typedef enum eSpaceSeq_Proxy_RenderSize { /* Config and Input for File Selector */ typedef struct FileSelectParams { - char title[32]; /* title, also used for the text of the execute button */ + char title[96]; /* title, also used for the text of the execute button */ char dir[1056]; /* directory, FILE_MAX_LIBEXTRA, 1024 + 32, this is for extreme case when 1023 length path * needs to be linked in, where foo.blend/Armature need adding */ char file[256]; /* file */ @@ -856,10 +856,10 @@ typedef struct SpaceNode { struct ID *id, *from; /* context, no need to save in file? well... pinning... */ short flag, pad1; /* menunr: browse id block in header */ - float aspect; + float aspect, aspect_sqrt; float xof, yof; /* offset for drawing the backdrop */ - float zoom, padf; /* zoom for backdrop */ + float zoom; /* zoom for backdrop */ float mx, my; /* mousepos for drawing socketless link */ struct bNodeTree *nodetree, *edittree; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 8690d0a26e4..fc0ce20e0c9 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -348,6 +348,7 @@ typedef struct UserDef { char textudir[768]; char pythondir[768]; char sounddir[768]; + char i18ndir[768]; char image_editor[1024]; /* 1024 = FILE_MAX */ char anim_player[1024]; /* 1024 = FILE_MAX */ int anim_player_preset; diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index f8c0f6a5910..ab320322f83 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -64,8 +64,8 @@ /* headers around with more freedom. */ static const char *includefiles[] = { - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_listBase.h", "DNA_vec_types.h", @@ -80,8 +80,8 @@ static const char *includefiles[] = { "DNA_lamp_types.h", "DNA_material_types.h", "DNA_vfont_types.h", - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_meta_types.h", "DNA_curve_types.h", "DNA_mesh_types.h", @@ -122,8 +122,8 @@ static const char *includefiles[] = { "DNA_particle_types.h", "DNA_cloth_types.h", "DNA_gpencil_types.h", - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_windowmanager_types.h", "DNA_anim_types.h", "DNA_boid_types.h", @@ -136,7 +136,7 @@ static const char *includefiles[] = { "DNA_freestyle_types.h", "DNA_linestyle_types.h", - // empty string to indicate end of includefiles + /* empty string to indicate end of includefiles */ "" }; @@ -452,7 +452,7 @@ static int preprocess_include(char *maindata, int len) memcpy(temp, maindata, len); - // remove all c++ comments + /* remove all c++ comments */ /* replace all enters/tabs/etc with spaces */ cp = temp; a = len; @@ -831,8 +831,8 @@ static int calculate_structlens(int firststruct) else { typelens[structtype] = len; alphalens[structtype] = alphalen; - // two ways to detect if a struct contains a pointer: - // has_pointer is set or alphalen != len + /* two ways to detect if a struct contains a pointer: + * has_pointer is set or alphalen != len */ if (has_pointer || alphalen != len) { if (alphalen % 8) { printf("Sizeerror 8 in struct: %s (add %d bytes)\n", types[structtype], alphalen % 8); @@ -974,7 +974,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) add_type("uint64_t", 8); /* SDNA_TYPE_UINT64 */ add_type("void", 0); /* SDNA_TYPE_VOID */ - // the defines above shouldn't be output in the padding file... + /* the defines above shouldn't be output in the padding file... */ firststruct = nr_types; /* add all include files defined in the global array */ @@ -992,7 +992,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) if (debugSDNA) printf("\tFinished scanning %d headers.\n", i); if (calculate_structlens(firststruct)) { - // error + /* error */ return(1); } @@ -1093,7 +1093,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) if (fp == NULL) ; else { - // add all include files defined in the global array + /* add all include files defined in the global array */ for (i = 0; strlen(includefiles[i]); i++) { fprintf(fp, "#include \"%s%s\"\n", baseDirectory, includefiles[i]); } @@ -1170,7 +1170,7 @@ int main(int argc, char **argv) fprintf(file, "unsigned char DNAstr[]= {\n"); if (make_structDNA(baseDirectory, file)) { - // error + /* error */ fclose(file); make_bad_file(argv[1], __LINE__); return_status = 1; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index d237fb5abd1..ac1dd3e74b4 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -679,6 +679,7 @@ StructRNA *RNA_struct_find(const char *identifier); const char *RNA_struct_identifier(StructRNA *type); const char *RNA_struct_ui_name(StructRNA *type); const char *RNA_struct_ui_description(StructRNA *type); +const char *RNA_struct_translation_context(StructRNA *type); int RNA_struct_ui_icon(StructRNA *type); PropertyRNA *RNA_struct_name_property(StructRNA *type); @@ -744,6 +745,7 @@ int RNA_property_string_maxlength(PropertyRNA *prop); const char *RNA_property_ui_name(PropertyRNA *prop); const char *RNA_property_ui_description(PropertyRNA *prop); +const char *RNA_property_translation_context(PropertyRNA *prop); int RNA_property_ui_icon(PropertyRNA *prop); /* Dynamic Property Information */ diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 6f024cde1d0..c722e6fa5ab 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -127,6 +127,8 @@ extern EnumPropertyItem ramp_blend_items[]; extern EnumPropertyItem prop_dynamicpaint_type_items[]; +extern EnumPropertyItem clip_editor_mode_items[]; + extern EnumPropertyItem linestyle_color_modifier_type_items[]; extern EnumPropertyItem linestyle_alpha_modifier_type_items[]; extern EnumPropertyItem linestyle_thickness_modifier_type_items[]; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c8ca0be8ab7..8e9c0dbc4c4 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -527,6 +527,11 @@ const char *RNA_struct_ui_description(StructRNA *type) return TIP_(type->description); } +const char *RNA_struct_translation_context(StructRNA *type) +{ + return type->translation_context ? type->translation_context : BLF_I18NCONTEXT_DEFAULT; +} + PropertyRNA *RNA_struct_name_property(StructRNA *type) { return type->nameproperty; @@ -1363,6 +1368,12 @@ const char *RNA_property_ui_description(PropertyRNA *prop) return rna_ensure_property_description(prop); } +const char *RNA_property_translation_context(PropertyRNA *_prop) +{ + PropertyRNA *prop = rna_ensure_property(_prop); + return prop->translation_context ? prop->translation_context : BLF_I18NCONTEXT_DEFAULT; +} + int RNA_property_ui_icon(PropertyRNA *prop) { return rna_ensure_property(prop)->icon; diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index ec03d452b57..fe18e6254d0 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -36,6 +36,8 @@ #include "BLO_sys_types.h" +#include "BLI_utildefines.h" + #include "BKE_mesh.h" #include "ED_mesh.h" diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a39c168c594..a72059063fd 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1191,6 +1191,11 @@ static void def_math(StructRNA *srna) RNA_def_property_enum_items(prop, node_math_items); RNA_def_property_ui_text(prop, "Operation", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); + RNA_def_property_ui_text(prop, "Clamp", "Clamp result of the node to 0..1 range"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_vector_math(StructRNA *srna) @@ -1272,6 +1277,11 @@ static void def_mix_rgb(StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); RNA_def_property_ui_text(prop, "Alpha", "Include alpha of second input in this operation"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom2", 2); + RNA_def_property_ui_text(prop, "Clamp", "Clamp result of the node to 0..1 range"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_texture(StructRNA *srna) @@ -3580,7 +3590,13 @@ static void def_cmp_keying(StructRNA *srna) prop = RNA_def_property(srna, "despill_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "despill_factor"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Despill", "Factor of despilling screen color from image"); + RNA_def_property_ui_text(prop, "Despill Factor", "Factor of despilling screen color from image"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "despill_balance", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "despill_balance"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Despill Balance", "Balance between non-key colors used to detect amount of key color to be removed"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "clip_black", PROP_FLOAT, PROP_FACTOR); @@ -3638,6 +3654,35 @@ static void def_cmp_keying(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_cmp_trackpos(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "MovieClip"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Movie Clip", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1); + RNA_def_property_ui_text(prop, "Relative", "Return relative position to first track's marker"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "NodeTrackPosData", "storage"); + + prop = RNA_def_property(srna, "tracking_object", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "tracking_object"); + RNA_def_property_ui_text(prop, "Tracking Object", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "track_name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "track_name"); + RNA_def_property_ui_text(prop, "Track", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); +} + /* -- Texture Nodes --------------------------------------------------------- */ static void def_tex_output(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 5ebaddda043..a4837a88b17 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -170,6 +170,7 @@ DefNode( CompositorNode, CMP_NODE_COLORCORRECTION,def_cmp_colorcorrection,"COLOR DefNode( CompositorNode, CMP_NODE_MASK, def_cmp_mask, "MASK", Mask, "Mask", "" ) DefNode( CompositorNode, CMP_NODE_KEYINGSCREEN, def_cmp_keyingscreen, "KEYINGSCREEN", KeyingScreen, "KeyingScreen", "" ) DefNode( CompositorNode, CMP_NODE_KEYING, def_cmp_keying, "KEYING", Keying, "Keying", "" ) +DefNode( CompositorNode, CMP_NODE_TRACKPOS, def_cmp_trackpos, "TRACKPOS", TrackPos, "Track Position", "" ) DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d5bac7a8c26..4473a9ef0f6 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -118,6 +118,15 @@ EnumPropertyItem viewport_shade_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem clip_editor_mode_items[] = { + {SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"}, + {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction", + "Show tracking/reconstruction tools"}, + {SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"}, + {SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -3011,15 +3020,6 @@ static void rna_def_space_clip(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem mode_items[] = { - {SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"}, - {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction", - "Show tracking/reconstruction tools"}, - {SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"}, - {SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem view_items[] = { {SC_VIEW_CLIP, "CLIP", ICON_SEQUENCE, "Clip", "Show editing clip preview"}, {SC_VIEW_GRAPH, "GRAPH", ICON_IPO, "Graph", "Show graph view for active element"}, @@ -3086,7 +3086,7 @@ static void rna_def_space_clip(BlenderRNA *brna) /* mode */ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_items(prop, clip_editor_mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_clip_mode_update"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index b4703c06eb7..0948438abc8 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2986,6 +2986,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) static EnumPropertyItem language_items[] = { { 0, "", 0, N_("Nearly done"), ""}, { 0, "DEFAULT", 0, "Default (Default)", ""}, + {21, "ARABIC", 0, "Arabic (ﺔﻴﺑﺮﻌﻟﺍ)", "ar_EG"}, { 1, "ENGLISH", 0, "English (English)", "en_US"}, { 8, "FRENCH", 0, "French (Français)", "fr_FR"}, { 4, "ITALIAN", 0, "Italian (Italiano)", "it_IT"}, @@ -2997,7 +2998,6 @@ static void rna_def_userdef_system(BlenderRNA *brna) {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, { 0, "", 0, N_("In progress"), ""}, /* using the utf8 flipped form of Arabic (العربية) */ - {21, "ARABIC", 0, "Arabic (ﺔﻴﺑﺮﻌﻟﺍ)", "ar_EG"}, {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"}, {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"}, {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"}, @@ -3520,6 +3520,12 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) "startup, addons & modules (requires restart)"); /* TODO, editing should reset sys.path! */ + prop = RNA_def_property(srna, "i18n_branches_directory", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_sdna(prop, NULL, "i18ndir"); + RNA_def_property_ui_text(prop, "Translation Branches Directory", + "The path to the '/branches' directory of your local svn-translation copy, " + "to allow translating from the UI"); + prop = RNA_def_property(srna, "sound_directory", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "sounddir"); RNA_def_property_ui_text(prop, "Sounds Directory", "The default directory to search for sounds"); diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 1b4d9444fd9..9ff35c227de 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -73,7 +73,7 @@ typedef struct { static void VertexIt_Destruct(CSG_VertexIteratorDescriptor *iterator) { if (iterator->it) { - // deallocate memory for iterator + /* deallocate memory for iterator */ MEM_freeN(iterator->it); iterator->it = 0; } @@ -128,18 +128,18 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh VertexIt *it; if (output == 0) return; - // allocate some memory for blender iterator + /* allocate some memory for blender iterator */ it = (VertexIt *)(MEM_mallocN(sizeof(VertexIt), "Boolean_VIt")); if (it == 0) { return; } - // assign blender specific variables + /* assign blender specific variables */ it->dm = dm; - it->ob = ob; // needed for obmat transformations - + it->ob = ob; /* needed for obmat transformations */ + it->pos = 0; - // assign iterator function pointers. + /* assign iterator function pointers. */ output->Step = VertexIt_Step; output->Fill = VertexIt_Fill; output->Done = VertexIt_Done; @@ -171,14 +171,14 @@ static void FaceIt_Destruct(CSG_FaceIteratorDescriptor *iterator) static int FaceIt_Done(CSG_IteratorPtr it) { - // assume CSG_IteratorPtr is of the correct type. + /* assume CSG_IteratorPtr is of the correct type. */ FaceIt *iterator = (FaceIt *)it; return(iterator->pos >= iterator->dm->getNumTessFaces(iterator->dm)); } static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) { - // assume CSG_IteratorPtr is of the correct type. + /* assume CSG_IteratorPtr is of the correct type. */ FaceIt *face_it = (FaceIt *)it; MFace *mfaces = face_it->dm->getTessFaceArray(face_it->dm); MFace *mface = &mfaces[face_it->pos]; @@ -222,12 +222,12 @@ static void FaceIt_Construct( FaceIt *it; if (output == 0) return; - // allocate some memory for blender iterator + /* allocate some memory for blender iterator */ it = (FaceIt *)(MEM_mallocN(sizeof(FaceIt), "Boolean_FIt")); if (it == 0) { return; } - // assign blender specific variables + /* assign blender specific variables */ it->dm = dm; it->offset = offset; it->pos = 0; @@ -256,7 +256,7 @@ static void FaceIt_Construct( } } - // assign iterator function pointers. + /* assign iterator function pointers. */ output->Step = FaceIt_Step; output->Fill = FaceIt_Fill; output->Done = FaceIt_Done; @@ -267,37 +267,37 @@ static void FaceIt_Construct( static Object *AddNewBlenderMesh(Scene *scene, Base *base) { - // This little function adds a new mesh object to the blender object list - // It uses ob to duplicate data as this seems to be easier than creating - // a new one. This new oject contains no faces nor vertices. + /* This little function adds a new mesh object to the blender object list + * It uses ob to duplicate data as this seems to be easier than creating + * a new one. This new oject contains no faces nor vertices. */ Mesh *old_me; Base *basen; Object *ob_new; - // now create a new blender object. - // duplicating all the settings from the previous object - // to the new one. + /* now create a new blender object. + * duplicating all the settings from the previous object + * to the new one. */ ob_new = BKE_object_copy(base->object); - // Ok we don't want to use the actual data from the - // last object, the above function incremented the - // number of users, so decrement it here. + /* Ok we don't want to use the actual data from the + * last object, the above function incremented the + * number of users, so decrement it here. */ old_me = ob_new->data; old_me->id.us--; - // Now create a new base to add into the linked list of - // vase objects. - + /* Now create a new base to add into the linked list of + * vase objects. */ + basen = MEM_mallocN(sizeof(Base), "duplibase"); *basen = *base; BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ basen->object = ob_new; basen->flag &= ~SELECT; - // Initialize the mesh data associated with this object. + /* Initialize the mesh data associated with this object. */ ob_new->data = BKE_mesh_add("Mesh"); - // Finally assign the object type. + /* Finally assign the object type. */ ob_new->type = OB_MESH; return ob_new; @@ -314,20 +314,20 @@ static void InterpCSGFace( mface = CDDM_get_tessface(dm, index); orig_mface = orig_dm->getTessFaceArray(orig_dm) + orig_index; - // get the vertex coordinates from the original mesh + /* get the vertex coordinates from the original mesh */ orig_co[0] = (orig_dm->getVertArray(orig_dm) + orig_mface->v1)->co; orig_co[1] = (orig_dm->getVertArray(orig_dm) + orig_mface->v2)->co; orig_co[2] = (orig_dm->getVertArray(orig_dm) + orig_mface->v3)->co; orig_co[3] = (orig_mface->v4) ? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co : NULL; - // get the vertex coordinates from the new derivedmesh + /* get the vertex coordinates from the new derivedmesh */ co[0] = CDDM_get_vert(dm, mface->v1)->co; co[1] = CDDM_get_vert(dm, mface->v2)->co; co[2] = CDDM_get_vert(dm, mface->v3)->co; co[3] = (nr == 4) ? CDDM_get_vert(dm, mface->v4)->co : NULL; for (j = 0; j < nr; j++) { - // get coordinate into the space of the original mesh + /* get coordinate into the space of the original mesh */ if (mapmat) mul_v3_m4v3(obco, mapmat, co[j]); else @@ -359,28 +359,28 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( Mesh *me2 = (Mesh *)ob2->data; int i, *origindex_layer; - // create a new DerivedMesh + /* create a new DerivedMesh */ result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements, 0, 0); CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), CD_DEFAULT, face_it->num_elements); CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), CD_DEFAULT, face_it->num_elements); - // step through the vertex iterators: + /* step through the vertex iterators: */ for (i = 0; !vertex_it->Done(vertex_it->it); i++) { CSG_IVertex csgvert; MVert *mvert = CDDM_get_vert(result, i); - // retrieve a csg vertex from the boolean module + /* retrieve a csg vertex from the boolean module */ vertex_it->Fill(vertex_it->it, &csgvert); vertex_it->Step(vertex_it->it); - // we have to map the vertex coordinates back in the coordinate frame - // of the resulting object, since it was computed in world space + /* we have to map the vertex coordinates back in the coordinate frame + * of the resulting object, since it was computed in world space */ mul_v3_m4v3(mvert->co, parinv, csgvert.position); } - // a hash table to remap materials to indices + /* a hash table to remap materials to indices */ material_hash = BLI_ghash_ptr_new("CSG_mat gh"); if (mat) @@ -388,7 +388,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( origindex_layer = result->getTessFaceDataArray(result, CD_ORIGINDEX); - // step through the face iterators + /* step through the face iterators */ for (i = 0; !face_it->Done(face_it->it); i++) { Mesh *orig_me; Object *orig_ob; @@ -397,27 +397,27 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( MFace *mface; int orig_index, mat_nr; - // retrieve a csg face from the boolean module + /* retrieve a csg face from the boolean module */ face_it->Fill(face_it->it, &csgface); face_it->Step(face_it->it); - // find the original mesh and data + /* find the original mesh and data */ orig_ob = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? ob1 : ob2; orig_dm = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? dm1 : dm2; orig_me = (orig_ob == ob1) ? me1 : me2; orig_index = (orig_ob == ob1) ? csgface.orig_face : csgface.orig_face - dm1->getNumTessFaces(dm1); - // copy all face layers, including mface + /* copy all face layers, including mface */ CustomData_copy_data(&orig_dm->faceData, &result->faceData, orig_index, i, 1); - // set mface + /* set mface */ mface = CDDM_get_tessface(result, i); mface->v1 = csgface.vertex_index[0]; mface->v2 = csgface.vertex_index[1]; mface->v3 = csgface.vertex_index[2]; mface->v4 = (csgface.vertex_number == 4) ? csgface.vertex_index[3] : 0; - // set material, based on lookup in hash table + /* set material, based on lookup in hash table */ orig_mat = give_current_material(orig_ob, mface->mat_nr + 1); if (mat && orig_mat) { @@ -431,11 +431,11 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( } else if (orig_mat) { if (orig_ob == ob1) { - // No need to change materian index for faces from left operand + /* No need to change materian index for faces from left operand */ } else { - // for faces from right operand checn if there's needed material in left operand and if it is, - // use index of that material, otherwise fallback to first material (material with index=0) + /* for faces from right operand checn if there's needed material in left operand and if it is, + * use index of that material, otherwise fallback to first material (material with index=0) */ if (!BLI_ghash_haskey(material_hash, orig_mat)) { int a; @@ -521,27 +521,27 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( if (dm == NULL || dm_select == NULL) return 0; if (!dm->getNumTessFaces(dm) || !dm_select->getNumTessFaces(dm_select)) return 0; - // we map the final object back into ob's local coordinate space. For this - // we need to compute the inverse transform from global to ob (inv_mat), - // and the transform from ob to ob_select for use in interpolation (map_mat) + /* we map the final object back into ob's local coordinate space. For this + * we need to compute the inverse transform from global to ob (inv_mat), + * and the transform from ob to ob_select for use in interpolation (map_mat) */ invert_m4_m4(inv_mat, ob->obmat); mult_m4_m4m4(map_mat, inv_mat, ob_select->obmat); invert_m4_m4(inv_mat, ob_select->obmat); { - // interface with the boolean module: - // - // the idea is, we pass the boolean module verts and faces using the - // provided descriptors. once the boolean operation is performed, we - // get back output descriptors, from which we then build a DerivedMesh + /* interface with the boolean module: + * + * the idea is, we pass the boolean module verts and faces using the + * provided descriptors. once the boolean operation is performed, we + * get back output descriptors, from which we then build a DerivedMesh */ CSG_VertexIteratorDescriptor vd_1, vd_2; CSG_FaceIteratorDescriptor fd_1, fd_2; CSG_OperationType op_type; CSG_BooleanOperation *bool_op; - // work out the operation they chose and pick the appropriate - // enum from the csg module. + /* work out the operation they chose and pick the appropriate + * enum from the csg module. */ switch (int_op_type) { case 1: op_type = e_csg_intersection; break; case 2: op_type = e_csg_union; break; @@ -549,13 +549,13 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( case 4: op_type = e_csg_classify; break; default: op_type = e_csg_intersection; } - + BuildMeshDescriptors(dm_select, ob_select, 0, &fd_1, &vd_1); BuildMeshDescriptors(dm, ob, dm_select->getNumTessFaces(dm_select), &fd_2, &vd_2); bool_op = CSG_NewBooleanFunction(); - // perform the operation + /* perform the operation */ if (CSG_PerformBooleanOperation(bool_op, op_type, fd_1, vd_1, fd_2, vd_2)) { CSG_VertexIteratorDescriptor vd_o; CSG_FaceIteratorDescriptor fd_o; @@ -563,12 +563,12 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( CSG_OutputFaceDescriptor(bool_op, &fd_o); CSG_OutputVertexDescriptor(bool_op, &vd_o); - // iterate through results of operation and insert - // into new object + /* iterate through results of operation and insert + * into new object */ result = ConvertCSGDescriptorsToDerivedMesh( &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); - // free up the memory + /* free up the memory */ CSG_FreeVertexDescriptor(&vd_o); CSG_FreeFaceDescriptor(&fd_o); } diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 609d70b6e98..45296e322b5 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -140,15 +140,15 @@ static void deformVerts(ModifierData *md, Object *ob, if ((current_time > collmd->time_xnew) || (BKE_ptcache_get_continue_physics())) { unsigned int i; - // check if mesh has changed + /* check if mesh has changed */ if (collmd->x && (numverts != collmd->numverts)) freeData((ModifierData *)collmd); - + if (collmd->time_xnew == -1000) { /* first time */ - collmd->x = dm->dupVertArray(dm); // frame start position - + collmd->x = dm->dupVertArray(dm); /* frame start position */ + for (i = 0; i < numverts; i++) { - // we save global positions + /* we save global positions */ mul_m4_v3(ob->obmat, collmd->x[i].co); } @@ -164,22 +164,22 @@ static void deformVerts(ModifierData *md, Object *ob, collmd->mfaces = dm->dupTessFaceArray(dm); collmd->numfaces = dm->getNumTessFaces(dm); - // create bounding box hierarchy + /* create bounding box hierarchy */ collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sboft); - + collmd->time_x = collmd->time_xnew = current_time; } else if (numverts == collmd->numverts) { - // put positions to old positions + /* put positions to old positions */ tempVert = collmd->x; collmd->x = collmd->xnew; collmd->xnew = tempVert; collmd->time_x = collmd->time_xnew; - + memcpy(collmd->xnew, dm->getVertArray(dm), numverts * sizeof(MVert)); - + for (i = 0; i < numverts; i++) { - // we save global positions + /* we save global positions */ mul_m4_v3(ob->obmat, collmd->xnew[i].co); } @@ -200,7 +200,7 @@ static void deformVerts(ModifierData *md, Object *ob, collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sboft); } else { - // recalc static bounding boxes + /* recalc static bounding boxes */ bvhtree_update_from_mvert(collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1); } diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index a33d80bcd35..1c98880c3db 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -96,20 +96,20 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->animRate = 1.0; fss->gstar = 0.005; // used as normgstar fss->maxRefine = -1; - // maxRefine is set according to resolutionxyz during bake + /* maxRefine is set according to resolutionxyz during bake */ - // fluid/inflow settings - // fss->iniVel --> automatically set to 0 + /* fluid/inflow settings + * fss->iniVel --> automatically set to 0 */ modifier_path_init(fss->surfdataPath, sizeof(fss->surfdataPath), "cache_fluid"); - // first init of bounding box - // no bounding box needed - - // todo - reuse default init from elbeem! + /* first init of bounding box */ + /* no bounding box needed */ + + /* todo - reuse default init from elbeem! */ fss->typeFlags = OB_FSBND_PARTSLIP | OB_FSSG_NOOBS; fss->domainNovecgen = 0; - fss->volumeInitType = 1; // volume + fss->volumeInitType = 1; /* volume */ fss->partSlipValue = 0.2; fss->generateTracers = 0; @@ -118,8 +118,8 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->surfaceSubdivs = 0.0; fss->particleInfSize = 0.0; fss->particleInfAlpha = 0.0; - - // init fluid control settings + + /* init fluid control settings */ fss->attractforceStrength = 0.2; fss->attractforceRadius = 0.75; fss->velocityforceStrength = 0.2; @@ -179,27 +179,27 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam const short mp_mat_nr = mp_example->mat_nr; const char mp_flag = mp_example->flag; - // ------------------------------------------------ - // get numverts + numfaces first - // ------------------------------------------------ + /* ------------------------------------------------ + * get numverts + numfaces first + * ------------------------------------------------ */ gzf = BLI_gzopen(filename, "rb"); if (!gzf) { return NULL; } - // read numverts + /* read numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); numverts = wri; - // skip verts + /* skip verts */ gotBytes = gzseek(gzf, numverts * 3 * sizeof(float), SEEK_CUR) != -1; - // read number of normals + /* read number of normals */ if (gotBytes) gotBytes = gzread(gzf, &wri, sizeof(wri)); - // skip normals + /* skip normals */ gotBytes = gzseek(gzf, numverts * 3 * sizeof(float), SEEK_CUR) != -1; /* get no. of triangles */ @@ -208,7 +208,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam numfaces = wri; gzclose(gzf); - // ------------------------------------------------ + /* ------------------------------------------------ */ if (!numfaces || !numverts || !gotBytes) return NULL; @@ -225,16 +225,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read numverts + /* read numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); - // read vertex position from file + /* read vertex position from file */ mv = CDDM_get_verts(dm); for (i = 0; i < numverts; i++, mv++) gotBytes = gzread(gzf, mv->co, sizeof(float) * 3); - // should be the same as numverts + /* should be the same as numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); if (wri != numverts) { if (dm) @@ -251,7 +251,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read normals from file (but don't save them yet) + /* read normals from file (but don't save them yet) */ for (i = numverts, no_s = normals; i > 0; i--, no_s += 3) { gotBytes = gzread(gzf, no, sizeof(float) * 3); normal_float_to_short_v3(no_s, no); @@ -269,7 +269,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read triangles from file + /* read triangles from file */ mp = CDDM_get_polys(dm); ml = CDDM_get_loops(dm); for (i = 0; i < numfaces; i++, mp++, ml += 3) { @@ -333,7 +333,7 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], if (vec[2] > bbez) { bbez = vec[2]; } } - // return values... + /* return values... */ if (start) { start[0] = bbsx; start[1] = bbsy; @@ -377,7 +377,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * int totvert = dm->getNumVerts(dm); FluidVertexVelocity *velarray = NULL; - // mesh and vverts have to be valid from loading... + /* mesh and vverts have to be valid from loading... */ if (fss->meshVelocities) MEM_freeN(fss->meshVelocities); @@ -393,8 +393,8 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * velarray = fss->meshVelocities; - // .bobj.gz, correct filename - // 87654321 + /* .bobj.gz, correct filename + * 87654321 */ filename[len - 6] = 'v'; filename[len - 5] = 'e'; filename[len - 4] = 'l'; @@ -461,8 +461,8 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, BLI_path_abs(targetFile, modifier_path_relbase(ob)); BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no - // assign material + flags to new dm - // if there's no faces in original dm, keep materials and flags unchanged + /* assign material + flags to new dm + * if there's no faces in original dm, keep materials and flags unchanged */ mpoly = orgdm->getPolyArray(orgdm); if (mpoly) { mp_example = *mpoly; @@ -472,7 +472,7 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, dm = fluidsim_read_obj(targetFile, &mp_example); if (!dm) { - // switch, abort background rendering when fluidsim mesh is missing + /* switch, abort background rendering when fluidsim mesh is missing */ const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp if (G.background == 1) { @@ -486,13 +486,13 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, } } - // display org. object upon failure which is in dm + /* display org. object upon failure which is in dm */ return NULL; } - // load vertex velocities, if they exist... - // TODO? use generate flag as loading flag as well? - // warning, needs original .bobj.gz mesh loading filename + /* load vertex velocities, if they exist... + * TODO? use generate flag as loading flag as well? + * warning, needs original .bobj.gz mesh loading filename */ if (displaymode == 3) { fluidsim_read_vel_cache(fluidmd, dm, targetFile); } @@ -519,20 +519,20 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, framenr = (int)scene->r.cfra; - // only handle fluidsim domains + /* only handle fluidsim domains */ if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN)) return dm; - - // sanity check + + /* sanity check */ if (!fluidmd || (fluidmd && !fluidmd->fss)) return dm; - + fss = fluidmd->fss; - - // timescale not supported yet - // clmd->sim_parms->timescale= timescale; - // support reversing of baked fluid frames here + /* timescale not supported yet + * clmd->sim_parms->timescale= timescale; */ + + /* support reversing of baked fluid frames here */ if ((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0)) { framenr = fss->lastgoodframe - framenr + 1; CLAMP(framenr, 1, fss->lastgoodframe); diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 472836e3716..afc85a8144e 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -38,6 +38,8 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "BLI_utildefines.h" + #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_multires.h" diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 46987f30205..f24898ccee2 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -91,6 +91,7 @@ typedef enum { CAP_START = 1, CAP_END = 2, SEAM_FRAME = 4, + ROOT = 8 } SkinNodeFlag; typedef struct Frame { @@ -502,6 +503,9 @@ static void end_node_frames(int v, SkinNode *skin_nodes, const MVert *mvert, /* End frame */ create_frame(&skin_nodes[v].frames[0], mvert[v].co, rad, mat, 0); } + + if (nodes[v].flag & MVERT_SKIN_ROOT) + skin_nodes[v].flag |= ROOT; } /* Returns 1 for seam, 0 otherwise */ @@ -1493,18 +1497,27 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, } if (sn->flag & CAP_START) { - add_poly(so, - sn->frames[0].verts[3], - sn->frames[0].verts[2], - sn->frames[0].verts[1], - sn->frames[0].verts[0]); + if (sn->flag & ROOT) { + add_poly(so, + sn->frames[0].verts[0], + sn->frames[0].verts[1], + sn->frames[0].verts[2], + sn->frames[0].verts[3]); + } + else { + add_poly(so, + sn->frames[0].verts[3], + sn->frames[0].verts[2], + sn->frames[0].verts[1], + sn->frames[0].verts[0]); + } } if (sn->flag & CAP_END) { add_poly(so, - sn->frames[1].verts[3], - sn->frames[1].verts[2], + sn->frames[1].verts[0], sn->frames[1].verts[1], - sn->frames[1].verts[0]); + sn->frames[1].verts[2], + sn->frames[1].verts[3]); } } } diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 7092ef04d0f..b9b3b89e06d 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -117,7 +117,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, if (go->ob) { SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - // check for initialized smoke object + /* check for initialized smoke object */ if (smd2 && (smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { DagNode *curNode = dag_get_node(forest, go->ob); dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow"); @@ -130,7 +130,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, if (go->ob) { SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - // check for initialized smoke object + /* check for initialized smoke object */ if (smd2 && (smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) { DagNode *curNode = dag_get_node(forest, go->ob); dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Coll"); diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index ce5ce1d87c1..e8dd4acb63b 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -103,6 +103,7 @@ set(SRC composite/nodes/node_composite_stabilize2d.c composite/nodes/node_composite_texture.c composite/nodes/node_composite_tonemap.c + composite/nodes/node_composite_trackpos.c composite/nodes/node_composite_transform.c composite/nodes/node_composite_translate.c composite/nodes/node_composite_valToRgb.c diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h index 33d6327ece1..3b4fa49ea05 100644 --- a/source/blender/nodes/NOD_composite.h +++ b/source/blender/nodes/NOD_composite.h @@ -132,4 +132,6 @@ void register_node_type_cmp_bokehimage(struct bNodeTreeType *ttype); void register_node_type_cmp_bokehblur(struct bNodeTreeType *ttype); void register_node_type_cmp_switch(struct bNodeTreeType *ttype); +void register_node_type_cmp_trackpos(struct bNodeTreeType *ttype); + #endif diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index b9acf821efe..43edc06194d 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -61,7 +61,7 @@ #include "node_composite_util.h" #ifdef WITH_COMPOSITOR -# include "COM_compositor.h" + #include "COM_compositor.h" #endif static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 98ded3ea3b3..1b9ff610e4c 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -647,7 +647,7 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) if (stackbuf_use!=stackbuf) free_compbuf(stackbuf_use); - BLI_lock_thread(LOCK_PREVIEW); + // BLI_lock_thread(LOCK_PREVIEW); if (preview->rect) MEM_freeN(preview->rect); @@ -655,7 +655,7 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) preview->ysize= ysize; preview->rect= rect; - BLI_unlock_thread(LOCK_PREVIEW); + // BLI_unlock_thread(LOCK_PREVIEW); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_keying.c b/source/blender/nodes/composite/nodes/node_composite_keying.c index f37c3686e2b..f3074bc8ed3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keying.c +++ b/source/blender/nodes/composite/nodes/node_composite_keying.c @@ -71,6 +71,7 @@ static void node_composit_init_keying(bNodeTree *UNUSED(ntree), bNode* node, bNo data = MEM_callocN(sizeof(NodeKeyingData), "node keying data"); data->screen_balance = 0.5f; + data->despill_balance = 0.5f; data->despill_factor = 1.0f; data->edge_kernel_radius = 3; data->edge_kernel_tolerance = 0.1f; diff --git a/source/blender/nodes/composite/nodes/node_composite_trackpos.c b/source/blender/nodes/composite/nodes/node_composite_trackpos.c new file mode 100644 index 00000000000..09eb42b4d93 --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_trackpos.c @@ -0,0 +1,65 @@ +/* + * ***** 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) 2011 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_movieclip.c + * \ingroup cmpnodes + */ + + +#include "node_composite_util.h" + +static bNodeSocketTemplate cmp_node_trackpos_out[] = { + { SOCK_FLOAT, 1, N_("X")}, + { SOCK_FLOAT, 1, N_("Y")}, + { -1, 0, "" } +}; + +static void node_composit_exec_trackpos(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out)) +{ +} + +static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) +{ + NodeTrackPosData *data = MEM_callocN(sizeof(NodeTrackPosData), "node track position data"); + + node->storage = data; +} + +void register_node_type_cmp_trackpos(bNodeTreeType *ttype) +{ + static bNodeType ntype; + + node_type_base(ttype, &ntype, CMP_NODE_TRACKPOS, "Track Position", NODE_CLASS_INPUT, NODE_OPTIONS); + node_type_socket_templates(&ntype, NULL, cmp_node_trackpos_out); + node_type_size(&ntype, 120, 80, 300); + node_type_init(&ntype, init); + node_type_storage(&ntype, "NodeTrackPosData", node_free_standard_storage, node_copy_standard_storage); + node_type_exec(&ntype, node_composit_exec_trackpos); + + nodeRegisterType(ttype, &ntype); +} diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index f7a7d379ba4..65bff1db7f6 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -2438,21 +2438,21 @@ static int bpy_bmelem_ass_subscript(BPy_BMElem *self, BPy_BMLayerItem *key, PyOb } static PySequenceMethods bpy_bmelemseq_as_sequence = { - (lenfunc)bpy_bmelemseq_length, /* sq_length */ + (lenfunc)bpy_bmelemseq_length, /* sq_length */ NULL, /* sq_concat */ NULL, /* sq_repeat */ - (ssizeargfunc)bpy_bmelemseq_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */ + (ssizeargfunc)bpy_bmelemseq_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */ NULL, /* sq_slice */ (ssizeobjargproc)NULL, /* sq_ass_item */ NULL, /* *was* sq_ass_slice */ - (objobjproc)bpy_bmelemseq_contains, /* sq_contains */ + (objobjproc)bpy_bmelemseq_contains, /* sq_contains */ (binaryfunc) NULL, /* sq_inplace_concat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; static PyMappingMethods bpy_bmelemseq_as_mapping = { - (lenfunc)bpy_bmelemseq_length, /* mp_length */ - (binaryfunc)bpy_bmelemseq_subscript, /* mp_subscript */ + (lenfunc)bpy_bmelemseq_length, /* mp_length */ + (binaryfunc)bpy_bmelemseq_subscript, /* mp_subscript */ (objobjargproc)NULL, /* mp_ass_subscript */ }; @@ -2859,7 +2859,7 @@ static struct PyModuleDef BPy_BM_types_module_def = { PyModuleDef_HEAD_INIT, "bmesh.types", /* m_name */ NULL, /* m_doc */ - 0, /* m_size */ + 0, /* m_size */ NULL, /* m_methods */ NULL, /* m_reload */ NULL, /* m_traverse */ diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index aa78dc64f6b..b2cc0d73481 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -432,7 +432,7 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key, /* dvert[group_index] = 0.5 */ if (i < 0) { PyErr_SetString(PyExc_KeyError, "BMDeformVert[key] = x: " - "weight keys can't be negative"); + "weight keys can't be negative"); return -1; } else { @@ -440,8 +440,8 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key, const float f = PyFloat_AsDouble(value); if (f == -1 && PyErr_Occurred()) { // parsed key not a number PyErr_SetString(PyExc_TypeError, - "BMDeformVert[key] = x: " - "argument not a number"); + "BMDeformVert[key] = x: " + "argument not a number"); return -1; } @@ -496,7 +496,7 @@ static PySequenceMethods bpy_bmdeformvert_as_sequence = { NULL, /* sq_slice */ NULL, /* sq_ass_item */ NULL, /* *was* sq_ass_slice */ - (objobjproc)bpy_bmdeformvert_contains, /* sq_contains */ + (objobjproc)bpy_bmdeformvert_contains, /* sq_contains */ (binaryfunc) NULL, /* sq_inplace_concat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index ac9ff4c8ef5..93f49fd72c9 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -303,7 +303,7 @@ void BPY_python_end(void) PyGILState_Ensure(); /* finalizing, no need to grab the state */ - // free other python data. + /* free other python data. */ pyrna_free_types(); /* clear all python data from structs */ @@ -317,7 +317,7 @@ void BPY_python_end(void) Py_Finalize(); #ifdef TIME_PY_RUN - // measure time since py started + /* measure time since py started */ bpy_timer = PIL_check_seconds_timer() - bpy_timer; printf("*bpy stats* - "); diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index d34bdfe9448..40ec8136eb7 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -39,6 +39,12 @@ #include "BLO_readfile.h" +#include "BLI_utildefines.h" +#include "BLI_string.h" +#include "BLI_linklist.h" +#include "BLI_path_util.h" +#include "BLI_listbase.h" + #include "BKE_global.h" #include "BKE_main.h" #include "BKE_library.h" @@ -46,12 +52,6 @@ #include "BKE_report.h" #include "BKE_context.h" -#include "BLI_utildefines.h" -#include "BLI_string.h" -#include "BLI_linklist.h" -#include "BLI_path_util.h" -#include "BLI_listbase.h" - #include "DNA_space_types.h" /* FILE_LINK, FILE_RELPATH */ #include "bpy_util.h" diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4bba7ba6838..e85adf21477 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4267,7 +4267,7 @@ static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args, return -1; } - *tot = PySequence_Size(*seq); // TODO - buffer may not be a sequence! array.array() is tho. + *tot = PySequence_Size(*seq); /* TODO - buffer may not be a sequence! array.array() is tho. */ if (*tot > 0) { foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed); diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index e5f45ca7736..7e2da5b1818 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -83,7 +83,7 @@ PyInit_gpu(void) if (m == NULL) return NULL; - // device constants + /* device constants */ PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWMAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_MAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWIMAT); @@ -187,13 +187,13 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj return NULL; } - // we can call our internal function at last: + /* we can call our internal function at last: */ shader = GPU_shader_export(scene, material); if (!shader) { PyErr_SetString(PyExc_RuntimeError, "cannot export shader"); return NULL; } - // build a dictionary + /* build a dictionary */ result = PyDict_New(); if (shader->fragment) { PY_DICT_ADD_STRING(result, shader, fragment); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 5f372abcc69..895352ccf93 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -2282,7 +2282,7 @@ static struct PyMethodDef Matrix_methods[] = { {"invert", (PyCFunction) Matrix_invert, METH_NOARGS, Matrix_invert_doc}, {"inverted", (PyCFunction) Matrix_inverted, METH_NOARGS, Matrix_inverted_doc}, {"to_3x3", (PyCFunction) Matrix_to_3x3, METH_NOARGS, Matrix_to_3x3_doc}, - // TODO. {"resize_3x3", (PyCFunction) Matrix_resize3x3, METH_NOARGS, Matrix_resize3x3_doc}, + /* TODO. {"resize_3x3", (PyCFunction) Matrix_resize3x3, METH_NOARGS, Matrix_resize3x3_doc}, */ {"to_4x4", (PyCFunction) Matrix_to_4x4, METH_NOARGS, Matrix_to_4x4_doc}, {"resize_4x4", (PyCFunction) Matrix_resize_4x4, METH_NOARGS, Matrix_resize_4x4_doc}, {"rotate", (PyCFunction) Matrix_rotate, METH_O, Matrix_rotate_doc}, diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c index ab1192bfdfc..659fd997c1f 100644 --- a/source/blender/quicktime/apple/quicktime_export.c +++ b/source/blender/quicktime/apple/quicktime_export.c @@ -202,7 +202,7 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports) QuicktimeCodecData *qcd = rd->qtcodecdata; - // check if current scene already has qtcodec settings, and clear them + /* check if current scene already has qtcodec settings, and clear them */ if (qcd) { free_qtcodecdata(qcd); } @@ -210,26 +210,26 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports) qcd = rd->qtcodecdata = MEM_callocN(sizeof(QuicktimeCodecData), "QuicktimeCodecData"); } - // obtain all current codec settings + /* obtain all current codec settings */ SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - // retreive codecdata from quicktime in a atomcontainer + /* retreive codecdata from quicktime in a atomcontainer */ myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer); if (myErr != noErr) { - BKE_reportf(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed\n"); + BKE_reportf(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed\n"); goto bail; } - // get the size of the atomcontainer + /* get the size of the atomcontainer */ mySize = GetHandleSize((Handle)myContainer); - // lock and convert the atomcontainer to a *valid* pointer + /* lock and convert the atomcontainer to a *valid* pointer */ QTLockContainer(myContainer); myPtr = *(Handle)myContainer; - // copy the Quicktime data into the blender qtcodecdata struct + /* copy the Quicktime data into the blender qtcodecdata struct */ if (myPtr) { qcd->cdParms = MEM_mallocN(mySize, "qt.cdParms"); memcpy(qcd->cdParms, myPtr, mySize); @@ -258,21 +258,21 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports) QuicktimeCodecData *qcd = rd->qtcodecdata; - // if there is codecdata in the blendfile, convert it to a Quicktime handle + /* if there is codecdata in the blendfile, convert it to a Quicktime handle */ if (qcd) { myHandle = NewHandle(qcd->cdSize); PtrToHand(qcd->cdParms, &myHandle, qcd->cdSize); } - // restore codecsettings to the quicktime component + /* restore codecsettings to the quicktime component */ if (qcd->cdParms && qcd->cdSize) { myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle); if (myErr != noErr) { - BKE_reportf(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed\n"); + BKE_reportf(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed\n"); goto bail; } - // update runtime codecsettings for use with the codec dialog + /* update runtime codecsettings for use with the codec dialog */ SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -312,22 +312,22 @@ static OSErr QT_AddUserDataTextToMovie(Movie theMovie, char *theText, OSType the long myLength = strlen(theText); OSErr myErr = noErr; - // get the movie's user data list + /* get the movie's user data list */ myUserData = GetMovieUserData(theMovie); if (myUserData == NULL) return(paramErr); - - // copy the specified text into a new handle + + /* copy the specified text into a new handle */ myHandle = NewHandleClear(myLength); if (myHandle == NULL) return(MemError()); BlockMoveData(theText, *myHandle, myLength); - // add the data to the movie's user data + /* add the data to the movie's user data */ myErr = AddUserDataText(myUserData, myHandle, theType, 1, (short)GetScriptManagerVariable(smRegionCode)); - // clean up + /* clean up */ DisposeHandle(myHandle); return(myErr); } @@ -408,9 +408,9 @@ static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, in SCDefaultPixMapSettings(qtdata->theComponent, qtexport->thePixMap, true); - // workaround for crash with H.264, which requires an upgrade to - // the new callback based api for proper encoding, but that's not - // really compatible with rendering out frames sequentially + /* workaround for crash with H.264, which requires an upgrade to + * the new callback based api for proper encoding, but that's not + * really compatible with rendering out frames sequentially */ gTemporalSettings = qtdata->gTemporalSettings; if (qtdata->gSpatialSettings.codecType == kH264CodecType) { if (gTemporalSettings.temporalQuality != codecMinQuality) { @@ -662,7 +662,7 @@ void free_qtcomponentdata(void) static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) { - // to keep float framerates consistent between the codec dialog and frs/sec button. + /* to keep float framerates consistent between the codec dialog and frs/sec button. */ OSErr err; err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -722,17 +722,17 @@ void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf) int get_qtcodec_settings(RenderData *rd, ReportList *reports) { OSErr err = noErr; - // erase any existing codecsetting + /* erase any existing codecsetting */ if (qtdata) { if (qtdata->theComponent) CloseComponent(qtdata->theComponent); free_qtcomponentdata(); } - // allocate new + /* allocate new */ qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData"); qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - // get previous selected codecsetting, from qtatom or detailed settings + /* get previous selected codecsetting, from qtatom or detailed settings */ if (rd->qtcodecdata && rd->qtcodecdata->cdParms) { QT_GetCodecSettingsFromScene(rd, reports); } @@ -774,17 +774,17 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); RenderData *rd = &scene->r; - // erase any existing codecsetting + /* erase any existing codecsetting */ if (qtdata) { if (qtdata->theComponent) CloseComponent(qtdata->theComponent); free_qtcomponentdata(); } - - // allocate new + + /* allocate new */ qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData"); qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - - // get previous selected codecsetting, from qtatom or detailed settings + + /* get previous selected codecsetting, from qtatom or detailed settings */ if (rd->qtcodecdata && rd->qtcodecdata->cdParms) { QT_GetCodecSettingsFromScene(rd, op->reports); } @@ -813,14 +813,14 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); CheckError(err, "SCSetInfo3 error", op->reports); } - // put up the dialog box - it needs to be called from the main thread + /* put up the dialog box - it needs to be called from the main thread */ err = SCRequestSequenceSettings(qtdata->theComponent); - + if (err == scUserCancelled) { return OPERATOR_FINISHED; } - // update runtime codecsettings for use with the codec dialog + /* update runtime codecsettings for use with the codec dialog */ SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -843,7 +843,7 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) QT_SaveCodecSettingsToScene(rd, op->reports); - // framerate jugglin' + /* framerate jugglin' */ if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps qtdata->kVideoTimeScale = 24000; qtdata->duration = 1001; diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 9c7511c0c60..d6bd49f5621 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -51,8 +51,8 @@ struct EnvMap; /* this include is what is exposed of render to outside world */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#define RE_MAXNAME 32 +/* length of the scene name + passname */ +#define RE_MAXNAME ((MAX_ID_NAME - 2) + 10) /* only used as handle */ typedef struct Render Render; @@ -81,7 +81,7 @@ typedef struct RenderLayer { struct RenderLayer *next, *prev; /* copy of RenderData */ - char name[RE_MAXNAME]; + char name[RE_MAXNAME]; unsigned int lay, lay_zmask, lay_exclude; int layflag, passflag, pass_xor; @@ -144,8 +144,7 @@ typedef struct RenderStats { short curfield, curblur, curpart, partsdone, convertdone, curfsa; double starttime, lastframetime; const char *infostr, *statstr; - char scenename[32]; - + char scene_name[MAX_ID_NAME - 2]; } RenderStats; /* *********************** API ******************** */ diff --git a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp index 2e37782d047..16d70297a34 100644 --- a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp @@ -151,7 +151,7 @@ RayObject *RE_rayobject_qbvh_create(int size) #else -RayObject *RE_rayobject_qbvh_create(int size) +RayObject *RE_rayobject_qbvh_create(int UNUSED(size)) { puts("WARNING: SSE disabled at compile time\n"); return NULL; diff --git a/source/blender/render/intern/raytrace/rayobject_svbvh.cpp b/source/blender/render/intern/raytrace/rayobject_svbvh.cpp index 697ba9ad6e2..c1bdfa6c72c 100644 --- a/source/blender/render/intern/raytrace/rayobject_svbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_svbvh.cpp @@ -183,7 +183,7 @@ RayObject *RE_rayobject_svbvh_create(int size) #else -RayObject *RE_rayobject_svbvh_create(int size) +RayObject *RE_rayobject_svbvh_create(int UNUSED(size)) { puts("WARNING: SSE disabled at compile time\n"); return NULL; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 19a474df342..2dcd0f7c70a 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -526,7 +526,7 @@ typedef struct { } SRenderMeshToTangent; -// interface +/* interface */ #include "mikktspace.h" static int GetNumFaces(const SMikkTSpaceContext * pContext) @@ -1030,7 +1030,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par static int second=0; sub_v3_v3v3(nor, vec, vec1); - normalize_v3(nor); // nor needed as tangent + normalize_v3(nor); /* nor needed as tangent */ cross_v3_v3v3(cross, vec, nor); /* turn cross in pixelsize */ @@ -1090,7 +1090,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v1->co, cross); copy_v3_v3(vlr->v1->n, nor); vlr->v1->orco= sd->orco; - vlr->v1->accum= -1.0f; // accum abuse for strand texco + vlr->v1->accum = -1.0f; /* accum abuse for strand texco */ copy_v3_v3(vlr->v2->co, vec); sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross); @@ -1102,8 +1102,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v4->co, cross); copy_v3_v3(vlr->v4->n, nor); vlr->v4->orco= sd->orco; - vlr->v4->accum= 1.0f; // accum abuse for strand texco - + vlr->v4->accum = 1.0f; /* accum abuse for strand texco */ + copy_v3_v3(vlr->v3->co, vec1); sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); copy_v3_v3(vlr->v3->n, nor); @@ -1164,7 +1164,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(v1->co, cross); copy_v3_v3(v1->n, nor); v1->orco= sd->orco; - v1->accum= -1.0f; // accum abuse for strand texco + v1->accum = -1.0f; /* accum abuse for strand texco */ copy_v3_v3(v2->co, vec); sub_v3_v3v3(v2->co, v2->co, cross); @@ -1181,11 +1181,11 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->v2= v2; vlr->v3= RE_findOrAddVert(obr, obr->totvert++); vlr->v4= RE_findOrAddVert(obr, obr->totvert++); - - v1= vlr->v4; // cycle - v2= vlr->v3; // cycle - + v1= vlr->v4; /* cycle */ + v2= vlr->v3; /* cycle */ + + if (sd->adapt) { second=0; copy_v3_v3(anor, nor); @@ -1210,9 +1210,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->v2= v2; vlr->v3= RE_findOrAddVert(obr, obr->totvert++); vlr->v4= RE_findOrAddVert(obr, obr->totvert++); - - v1= vlr->v4; // cycle - v2= vlr->v3; // cycle + + v1= vlr->v4; /* cycle */ + v2= vlr->v3; /* cycle */ copy_v3_v3(anor, nor); copy_v3_v3(avec, vec); @@ -1226,8 +1226,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v4->co, cross); copy_v3_v3(vlr->v4->n, nor); vlr->v4->orco= sd->orco; - vlr->v4->accum= -1.0f + 2.0f*sd->time; // accum abuse for strand texco - + vlr->v4->accum= -1.0f + 2.0f * sd->time; /* accum abuse for strand texco */ + copy_v3_v3(vlr->v3->co, vec); sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); copy_v3_v3(vlr->v3->n, nor); @@ -1310,7 +1310,7 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3 vlr->v3= vlr->v2; vlr->v4= NULL; - v1= vlr->v2; // cycle + v1= vlr->v2; /* cycle */ copy_v3_v3(v1->co, vec); sub_v3_v3v3(vlr->n, vec, vec1); @@ -1631,12 +1631,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* 2.1 setup material stff */ ma= give_render_material(re, ob, part->omat); -#if 0 // XXX old animation system +#if 0 /* XXX old animation system */ if (ma->ipo) { calc_ipo(ma->ipo, cfra); execute_ipo((ID *)ma, ma->ipo); } -#endif // XXX old animation system +#endif /* XXX old animation system */ hasize = ma->hasize; seed = ma->seed1; @@ -2088,10 +2088,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem strandbuf->surface= cache_strand_surface(re, obr, psmd->dm, mat, timeoffset); /* 4. clean up */ -#if 0 // XXX old animation system +#if 0 /* XXX old animation system */ if (ma) do_mat_ipo(re->scene, ma); -#endif // XXX old animation system - +#endif /* XXX old animation system */ + if (orco1) MEM_freeN(sd.orco); @@ -3286,7 +3286,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) int a, a1, ok, vertofs; int end, do_autosmooth = FALSE, totvert = 0; int use_original_normals = FALSE; - int recalc_normals = 0; // false by default + int recalc_normals = 0; /* false by default */ int negative_scale; me= ob->data; @@ -3511,7 +3511,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) int t; mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1); mtface= (MTFace*)layer->data; - *mtf= mtface[a]; // copy face info + *mtf = mtface[a]; /* copy face info */ for (vindex=0; vindex<nr_verts; vindex++) for (t=0; t<2; t++) mtf->uv[vindex][t]=mtface[a].uv[rev_tab[vindex]][t]; @@ -3776,7 +3776,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->shdwb= la->shdwb; lar->k= la->k; - // area + /* area */ lar->ray_samp= la->ray_samp; lar->ray_sampy= la->ray_sampy; lar->ray_sampz= la->ray_sampz; @@ -3827,7 +3827,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) } area_lamp_vectors(lar); - init_jitter_plane(lar); // subsamples + init_jitter_plane(lar); /* subsamples */ } else if (lar->type==LA_SUN) { lar->ray_totsamp= lar->ray_samp*lar->ray_samp; @@ -3862,7 +3862,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *)); - lar->lay= ob->lay & 0xFFFFFF; // higher 8 bits are localview layers + lar->lay = ob->lay & 0xFFFFFF; /* higher 8 bits are localview layers */ lar->falloff_type = la->falloff_type; lar->ld1= la->att1; @@ -3947,7 +3947,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) /* Per lamp, one shadow buffer is made. */ lar->bufflag= la->bufflag; copy_m4_m4(mat, ob->obmat); - initshadowbuf(re, lar, mat); // mat is altered + initshadowbuf(re, lar, mat); /* mat is altered */ } @@ -4290,8 +4290,8 @@ static void check_non_flat_quads(ObjectRen *obr) xn = dot_v3v3(nor, vlr->n); - if (ABS(xn) < 0.999995f ) { // checked on noisy fractal grid - + if (ABS(xn) < 0.999995f ) { /* checked on noisy fractal grid */ + float d1, d2; vlr1= RE_vlakren_copy(obr, vlr); @@ -5098,7 +5098,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l /* per second, per object, stats print this */ re->i.infostr= "Preparing Scene data"; re->i.cfra= scene->r.cfra; - BLI_strncpy(re->i.scenename, scene->id.name+2, sizeof(re->i.scenename)); + BLI_strncpy(re->i.scene_name, scene->id.name + 2, sizeof(re->i.scene_name)); /* XXX add test if dbase was filled already? */ @@ -5538,7 +5538,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * else ver++; - // get fluid velocity + /* get fluid velocity */ fsvec[3] = 0.0f; //fsvec[0] = fsvec[1] = fsvec[2] = fsvec[3] = 0.0; fsvec[2] = 2.0f; // NT fixed test for (j=0;j<3;j++) fsvec[j] = velarray[a].vel[j]; @@ -5550,31 +5550,31 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * fsvec[2] = avgvel[2]; } - // transform (=rotate) to cam space + /* transform (=rotate) to cam space */ camco[0] = dot_v3v3(imat[0], fsvec); camco[1] = dot_v3v3(imat[1], fsvec); camco[2] = dot_v3v3(imat[2], fsvec); - // get homogenous coordinates + /* get homogenous coordinates */ projectvert(camco, winmat, hoco); projectvert(ver->co, winmat, ho); /* now map hocos to screenspace, uses very primitive clip still */ - // use ho[3] of original vertex, xy component of vel. direction + /* use ho[3] of original vertex, xy component of vel. direction */ if (ho[3]<0.1f) div= 10.0f; else div= 1.0f/ho[3]; zco[0]= zmulx*hoco[0]*div; zco[1]= zmuly*hoco[1]*div; - // maximize speed as usual + /* maximize speed as usual */ len= zco[0]*zco[0] + zco[1]*zco[1]; if (len > winsq) { len= winroot/sqrtf(len); zco[0]*= len; zco[1]*= len; } - + speed= RE_vertren_get_winspeed(obi, ver, 1); - // set both to the same value + /* set both to the same value */ speed[0]= speed[2]= zco[0]; speed[1]= speed[3]= zco[1]; //if (a < 20) fprintf(stderr,"speed %d %f,%f | camco %f,%f,%f | hoco %f,%f,%f,%f\n", a, speed[0], speed[1], camco[0],camco[1], camco[2], hoco[0],hoco[1], hoco[2],hoco[3]); // NT DEBUG @@ -5711,7 +5711,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned continue; } - // NT check for fluidsim special treatment + /* NT check for fluidsim special treatment */ fluidmd = (FluidsimModifierData *)modifiers_findByType(obi->ob, eModifierType_Fluidsim); if (fluidmd && fluidmd->fss && (fluidmd->fss->type & OB_FLUIDSIM_DOMAIN)) { /* use preloaded per vertex simulation data, only does calculation for step=1 */ @@ -5724,7 +5724,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned calculate_speedvectors(re, obi, oldobi->vectors, step); else printf("Warning: object %s has different amount of vertices or strands on other frame\n", obi->ob->id.name+2); - } // not fluidsim + } /* not fluidsim */ oldobi= oldobi->next; } diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 61de4d39585..5879a9bd66d 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -49,7 +49,7 @@ #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_image.h" // BKE_imbuf_write +#include "BKE_image.h" /* BKE_imbuf_write */ #include "BKE_texture.h" @@ -579,7 +579,7 @@ void make_envmaps(Render *re) re->display_clear(re->dch, re->result); // re->flag |= R_REDRAW_PRV; } - // restore + /* restore */ re->r.mode |= trace; } diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index e3eab0c3b34..1180e74d391 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -192,7 +192,7 @@ void RE_engine_update_result(RenderEngine *engine, RenderResult *result) Render *re = engine->re; if (result) { - result->renlay = result->layers.first; // weak, draws first layer always + result->renlay = result->layers.first; /* weak, draws first layer always */ re->display_draw(re->ddh, result, NULL); } } @@ -210,7 +210,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result) /* draw */ if (!re->test_break(re->tbh)) { - result->renlay = result->layers.first; // weak, draws first layer always + result->renlay = result->layers.first; /* weak, draws first layer always */ re->display_draw(re->ddh, result, NULL); } @@ -305,7 +305,7 @@ int RE_engine_render(Render *re, int do_all) /* set render info */ re->i.cfra = re->scene->r.cfra; - BLI_strncpy(re->i.scenename, re->scene->id.name + 2, sizeof(re->i.scenename)); + BLI_strncpy(re->i.scene_name, re->scene->id.name + 2, sizeof(re->i.scene_name)); re->i.totface = re->i.totvert = re->i.totstrand = re->i.totlamp = re->i.tothalo = 0; /* render */ diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index dcc09c92bb0..a0ba2a82ead 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -231,13 +231,13 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul if (texres->nor) { if (tex->imaflag & TEX_NORMALMAP) { - // qdn: normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* qdn: normal from color + * The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); @@ -619,36 +619,36 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max } } -//----------------------------------------------------------------------------------------------------------------- -// from here, some functions only used for the new filtering +/*----------------------------------------------------------------------------------------------------------------- + * from here, some functions only used for the new filtering */ -// anisotropic filters, data struct used instead of long line of (possibly unused) func args +/* anisotropic filters, data struct used instead of long line of (possibly unused) func args */ typedef struct afdata_t { float dxt[2], dyt[2]; int intpol, extflag; - // feline only + /* feline only */ float majrad, minrad, theta; int iProbes; float dusc, dvsc; } afdata_t; -// this only used here to make it easier to pass extend flags as single int -enum {TXC_XMIR=1, TXC_YMIR, TXC_REPT, TXC_EXTD}; +/* this only used here to make it easier to pass extend flags as single int */ +enum {TXC_XMIR = 1, TXC_YMIR, TXC_REPT, TXC_EXTD}; -// similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags -// returns true if out of range in clipmode +/* similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags + * returns true if out of range in clipmode */ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag) { int clip = 0; switch (extflag) { - case TXC_XMIR: // y rep + case TXC_XMIR: /* y rep */ x %= 2*ibuf->x; x += x < 0 ? 2*ibuf->x : 0; x = x >= ibuf->x ? 2*ibuf->x - x - 1 : x; y %= ibuf->y; y += y < 0 ? ibuf->y : 0; break; - case TXC_YMIR: // x rep + case TXC_YMIR: /* x rep */ x %= ibuf->x; x += x < 0 ? ibuf->x : 0; y %= 2*ibuf->y; @@ -665,11 +665,12 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf y %= ibuf->y; y += (y < 0) ? ibuf->y : 0; break; - default: { // as extend, if clipped, set alpha to 0.0 - if (x < 0) { x = 0; } // TXF alpha: clip = 1; } - if (x >= ibuf->x) { x = ibuf->x - 1; } // TXF alpha: clip = 1; } - if (y < 0) { y = 0; } // TXF alpha: clip = 1; } - if (y >= ibuf->y) { y = ibuf->y - 1; } // TXF alpha: clip = 1; } + default: + { /* as extend, if clipped, set alpha to 0.0 */ + if (x < 0) { x = 0; } /* TXF alpha: clip = 1; } */ + if (x >= ibuf->x) { x = ibuf->x - 1; } /* TXF alpha: clip = 1; } */ + if (y < 0) { y = 0; } /* TXF alpha: clip = 1; } */ + if (y >= ibuf->y) { y = ibuf->y - 1; } /* TXF alpha: clip = 1; } */ } } @@ -694,7 +695,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf return clip; } -// as above + bilerp +/* as above + bilerp */ static int ibuf_get_color_clip_bilerp(float col[4], ImBuf *ibuf, float u, float v, int intpol, int extflag) { if (intpol) { @@ -749,12 +750,12 @@ static void area_sample(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata texr->tr *= xsd; texr->tg *= xsd; texr->tb *= xsd; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ texr->ta = texr->talpha ? texr->ta*xsd : (clip ? cw*xsd : 1.f); } -// table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2 -// used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible +/* table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2 + * used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible */ #define EWA_MAXIDX 255 static float EWA_WTS[EWA_MAXIDX + 1] = { 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f, @@ -791,9 +792,9 @@ static float EWA_WTS[EWA_MAXIDX + 1] = 0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f }; -// test if a float value is 'nan' -// there is a C99 function for this: isnan(), but blender seems to use C90 (according to gcc warns), -// and may not be supported by other compilers either +/* test if a float value is 'nan' + * there is a C99 function for this: isnan(), but blender seems to use C90 (according to gcc warns), + * and may not be supported by other compilers either */ #ifndef ISNAN #define ISNAN(x) ((x) != (x)) #endif @@ -802,7 +803,7 @@ static float EWA_WTS[EWA_MAXIDX + 1] = static void radangle2imp(float a2, float b2, float th, float* A, float* B, float* C, float* F) { float ct2 = cosf(th); - const float st2 = 1.f - ct2*ct2; // <- sin(th)^2 + const float st2 = 1.0f - ct2 * ct2; /* <- sin(th)^2 */ ct2 *= ct2; *A = a2*st2 + b2*ct2; *B = (b2 - a2)*sinf(2.f*th); @@ -810,10 +811,10 @@ static void radangle2imp(float a2, float b2, float th, float* A, float* B, float *F = a2*b2; } -// all tests here are done to make sure possible overflows are hopefully minimized +/* all tests here are done to make sure possible overflows are hopefully minimized */ static void imp2radangle(float A, float B, float C, float F, float* a, float* b, float* th, float* ecc) { - if (F <= 1e-5f) { // use arbitrary major radius, zero minor, infinite eccentricity + if (F <= 1e-5f) { /* use arbitrary major radius, zero minor, infinite eccentricity */ *a = sqrtf(A > C ? A : C); *b = 0.f; *ecc = 1e10f; @@ -833,31 +834,31 @@ static void imp2radangle(float A, float B, float C, float F, float* a, float* b, *b = sqrtf(F2 / d); *ecc = *a / *b; } - // incr theta by 0.5*pi (angle of major axis) + /* incr theta by 0.5*pi (angle of major axis) */ *th = 0.5f*(atan2f(B, AmC) + (float)M_PI); } } static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) { - // scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values, - // scaling by aspect ratio alone does the opposite, so try something in between instead... + /* scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values, + * scaling by aspect ratio alone does the opposite, so try something in between instead... */ const float ff2 = ibuf->x, ff = sqrtf(ff2), q = ibuf->y / ff; const float Ux = AFD->dxt[0]*ff, Vx = AFD->dxt[1]*q, Uy = AFD->dyt[0]*ff, Vy = AFD->dyt[1]*q; float A = Vx*Vx + Vy*Vy; float B = -2.f*(Ux*Vx + Uy*Vy); float C = Ux*Ux + Uy*Uy; float F = A*C - B*B*0.25f; - float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d; // TXF alpha: cw = 0.f; - int u, v, u1, u2, v1, v2; // TXF alpha: clip = 0; - - // The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C, - // so the ellipse always covers at least some texels. But since the filter is now always larger, - // it also means that everywhere else it's also more blurry then ideally should be the case. - // So instead here the ellipse radii are modified instead whenever either is too low. - // Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off, - // and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on - // (minimum values: const float rmin = intpol ? 1.f : 0.5f;) + float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d; /* TXF alpha: cw = 0.f; */ + int u, v, u1, u2, v1, v2; /* TXF alpha: clip = 0; */ + + /* The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C, + * so the ellipse always covers at least some texels. But since the filter is now always larger, + * it also means that everywhere else it's also more blurry then ideally should be the case. + * So instead here the ellipse radii are modified instead whenever either is too low. + * Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off, + * and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on + * (minimum values: const float rmin = intpol ? 1.f : 0.5f;) */ const float rmin = (AFD->intpol ? 1.5625f : 0.765625f)/ff2; imp2radangle(A, B, C, F, &a, &b, &th, &ecc); if ((b2 = b*b) < rmin) { @@ -903,8 +904,8 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* float tc[4]; const float wt = EWA_WTS[(Q < 0.f) ? 0 : (unsigned int)Q]; /*const int out =*/ ibuf_get_color_clip(tc, ibuf, u, v, AFD->extflag); - // TXF alpha: clip |= out; - // TXF alpha: cw += out ? 0.f : wt; + /* TXF alpha: clip |= out; + * TXF alpha: cw += out ? 0.f : wt; */ texr->tr += tc[0]*wt; texr->tg += tc[1]*wt; texr->tb += tc[2]*wt; @@ -916,13 +917,13 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* } } - // d should hopefully never be zero anymore + /* d should hopefully never be zero anymore */ d = 1.f/d; texr->tr *= d; texr->tg *= d; texr->tb *= d; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge - texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha (clip ? cw*d : 1.f); + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ + texr->ta = texr->talpha ? texr->ta*d : 1.f; /* TXF alpha (clip ? cw*d : 1.f); */ } static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) @@ -931,11 +932,11 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata const float ll = ((AFD->majrad == AFD->minrad) ? 2.f*AFD->majrad : 2.f*(AFD->majrad - AFD->minrad)) / (maxn ? (float)maxn : 1.f); float du = maxn ? cosf(AFD->theta)*ll : 0.f; float dv = maxn ? sinf(AFD->theta)*ll : 0.f; - //const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); + /* const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); */ const float D = (EWA_MAXIDX + 1)*0.25f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); - float d; // TXF alpha: cw = 0.f; - int n; // TXF alpha: clip = 0; - // have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) + float d; /* TXF alpha: cw = 0.f; */ + int n; /* TXF alpha: clip = 0; */ + /* have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) */ du *= AFD->dusc; dv *= AFD->dvsc; d = texr->tr = texr->tb = texr->tg = texr->ta = 0.f; @@ -943,12 +944,12 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata float tc[4]; const float hn = n*0.5f; const float u = fx + hn*du, v = fy + hn*dv; - //const float wt = expf(n*n*D); - // can use ewa table here too + /*const float wt = expf(n*n*D); + * can use ewa table here too */ const float wt = EWA_WTS[(int)(n*n*D)]; /*const int out =*/ ibuf_get_color_clip_bilerp(tc, ibuf, ibuf->x*u, ibuf->y*v, AFD->intpol, AFD->extflag); - // TXF alpha: clip |= out; - // TXF alpha: cw += out ? 0.f : wt; + /* TXF alpha: clip |= out; + * TXF alpha: cw += out ? 0.f : wt; */ texr->tr += tc[0]*wt; texr->tg += tc[1]*wt; texr->tb += tc[2]*wt; @@ -960,7 +961,7 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata texr->tr *= d; texr->tg *= d; texr->tb *= d; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha: (clip ? cw*d : 1.f); } #undef EWA_MAXIDX @@ -970,8 +971,8 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl float alphaclip; rctf rf; - // TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting - // if this is actually correct for the all the filtering algorithms .. + /* TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting + * if this is actually correct for the all the filtering algorithms .. */ if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) { rf.xmin = minx*(ibuf->x); @@ -1040,13 +1041,13 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.f; - // we need to set retval OK, otherwise texture code generates normals itself... + /* we need to set retval OK, otherwise texture code generates normals itself... */ retval = texres->nor ? 3 : 1; - // quick tests + /* quick tests */ if (ibuf==NULL && ima==NULL) return retval; - if (ima) { // hack for icon render + if (ima) { /* hack for icon render */ if ((ima->ibufs.first == NULL) && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval; ibuf = BKE_image_get_ibuf(ima, &tex->iuser); } @@ -1079,18 +1080,18 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex } } - // pixel coordinates + /* pixel coordinates */ minx = MIN3(dxt[0], dyt[0], dxt[0] + dyt[0]); maxx = MAX3(dxt[0], dyt[0], dxt[0] + dyt[0]); miny = MIN3(dxt[1], dyt[1], dxt[1] + dyt[1]); maxy = MAX3(dxt[1], dyt[1], dxt[1] + dyt[1]); - // tex_sharper has been removed + /* tex_sharper has been removed */ minx = (maxx - minx)*0.5f; miny = (maxy - miny)*0.5f; if (tex->imaflag & TEX_FILTER_MIN) { - // make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) + /* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */ const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y); if (addval > minx) minx = addval; if (addval > miny) miny = addval; @@ -1107,9 +1108,9 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (tex->imaflag & TEX_IMAROT) { float t; SWAP(float, minx, miny); - // must rotate dxt/dyt 90 deg - // yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar, - // but it doesn't, it only swaps coords, so filter area will be incorrect in those cases. + /* must rotate dxt/dyt 90 deg + * yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar, + * but it doesn't, it only swaps coords, so filter area will be incorrect in those cases. */ t = dxt[0]; dxt[0] = dxt[1]; dxt[1] = -t; @@ -1118,11 +1119,11 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex dyt[1] = -t; } - // side faces of unit-cube + /* side faces of unit-cube */ minx = (minx > 0.25f) ? 0.25f : ((minx < 1e-5f) ? 1e-5f : minx); miny = (miny > 0.25f) ? 0.25f : ((miny < 1e-5f) ? 1e-5f : miny); - // repeat and clip + /* repeat and clip */ if (tex->extend == TEX_REPEAT) { if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) @@ -1139,7 +1140,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (tex->extend == TEX_CHECKER) { int xs = (int)floorf(fx), ys = (int)floorf(fy); - // both checkers available, no boundary exceptions, checkerdist will eat aliasing + /* both checkers available, no boundary exceptions, checkerdist will eat aliasing */ if ((tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN)) { fx -= xs; fy -= ys; @@ -1166,7 +1167,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex fy -= ys; } } - // scale around center, (0.5, 0.5) + /* scale around center, (0.5, 0.5) */ if (tex->checkerdist < 1.f) { const float omcd = 1.f / (1.f - tex->checkerdist); fx = (fx - 0.5f)*omcd + 0.5f; @@ -1195,34 +1196,34 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex intpol = tex->imaflag & TEX_INTERPOL; - // warning no return! + /* warning no return! */ if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields)) ibuf->rect += ibuf->x*ibuf->y; - // struct common data + /* struct common data */ copy_v2_v2(AFD.dxt, dxt); copy_v2_v2(AFD.dyt, dyt); AFD.intpol = intpol; AFD.extflag = extflag; - // brecht: added stupid clamping here, large dx/dy can give very large - // filter sizes which take ages to render, it may be better to do this - // more intelligently later in the code .. probably it's not noticeable + /* brecht: added stupid clamping here, large dx/dy can give very large + * filter sizes which take ages to render, it may be better to do this + * more intelligently later in the code .. probably it's not noticeable */ if (AFD.dxt[0]*AFD.dxt[0] + AFD.dxt[1]*AFD.dxt[1] > 2.0f*2.0f) mul_v2_fl(AFD.dxt, 2.0f/len_v2(AFD.dxt)); if (AFD.dyt[0]*AFD.dyt[0] + AFD.dyt[1]*AFD.dyt[1] > 2.0f*2.0f) mul_v2_fl(AFD.dyt, 2.0f/len_v2(AFD.dyt)); - // choice: + /* choice: */ if (tex->imaflag & TEX_MIPMAP) { ImBuf *previbuf, *curibuf; float levf; int maxlev; ImBuf* mipmaps[IB_MIPMAP_LEVELS + 1]; - // modify ellipse minor axis if too eccentric, use for area sampling as well - // scaling dxt/dyt as done in pbrt is not the same - // (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) + /* modify ellipse minor axis if too eccentric, use for area sampling as well + * scaling dxt/dyt as done in pbrt is not the same + * (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) */ const float ff = sqrtf(ibuf->x), q = ibuf->y/ff; const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q; const float A = Vx*Vx + Vy*Vy; @@ -1248,7 +1249,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex AFD.dusc = 1.f/ff; AFD.dvsc = ff / (float)ibuf->y; } - else { // EWA & area + else { /* EWA & area */ if (ecc > (float)tex->afmax) b = a / (float)tex->afmax; b *= ff; } @@ -1264,8 +1265,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex curmap++; } - // mipmap level - if (levf < 0.f) { // original image only + /* mipmap level */ + if (levf < 0.f) { /* original image only */ previbuf = curibuf = mipmaps[0]; levf = 0.f; } @@ -1281,39 +1282,39 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex levf -= floorf(levf); } - // filter functions take care of interpolation themselves, no need to modify dxt/dyt here + /* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */ if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { - // color & normal + /* color & normal */ filterfunc(texres, curibuf, fx, fy, &AFD); val1 = texres->tr + texres->tg + texres->tb; filterfunc(&texr, curibuf, fx + dxt[0], fy + dxt[1], &AFD); val2 = texr.tr + texr.tg + texr.tb; filterfunc(&texr, curibuf, fx + dyt[0], fy + dyt[1], &AFD); val3 = texr.tr + texr.tg + texr.tb; - // don't switch x or y! + /* don't switch x or y! */ texres->nor[0] = val1 - val2; texres->nor[1] = val1 - val3; - if (previbuf != curibuf) { // interpolate + if (previbuf != curibuf) { /* interpolate */ filterfunc(&texr, previbuf, fx, fy, &AFD); - // rgb + /* rgb */ texres->tr += levf*(texr.tr - texres->tr); texres->tg += levf*(texr.tg - texres->tg); texres->tb += levf*(texr.tb - texres->tb); texres->ta += levf*(texr.ta - texres->ta); - // normal + /* normal */ val1 += levf*((texr.tr + texr.tg + texr.tb) - val1); filterfunc(&texr, previbuf, fx + dxt[0], fy + dxt[1], &AFD); val2 += levf*((texr.tr + texr.tg + texr.tb) - val2); filterfunc(&texr, previbuf, fx + dyt[0], fy + dyt[1], &AFD); val3 += levf*((texr.tr + texr.tg + texr.tb) - val3); - texres->nor[0] = val1 - val2; // vals have been interpolated above! + texres->nor[0] = val1 - val2; /* vals have been interpolated above! */ texres->nor[1] = val1 - val3; } } - else { // color + else { /* color */ filterfunc(texres, curibuf, fx, fy, &AFD); - if (previbuf != curibuf) { // interpolate + if (previbuf != curibuf) { /* interpolate */ filterfunc(&texr, previbuf, fx, fy, &AFD); texres->tr += levf*(texr.tr - texres->tr); texres->tg += levf*(texr.tg - texres->tg); @@ -1324,8 +1325,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex alpha_clip_aniso(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, extflag, texres); } } - else { // no mipmap - // filter functions take care of interpolation themselves, no need to modify dxt/dyt here + else { /* no mipmap */ + /* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */ if (tex->texfilter == TXF_FELINE) { const float ff = sqrtf(ibuf->x), q = ibuf->y/ff; const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q; @@ -1340,7 +1341,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex a = MAX2(a, 1.f); b = MAX2(b, 1.f); fProbes = 2.f*(a / b) - 1.f; - // no limit to number of Probes here + /* no limit to number of Probes here */ AFD.iProbes = (int)floorf(fProbes + 0.5f); if (AFD.iProbes < fProbes) b = 2.f*a / (float)(AFD.iProbes + 1); AFD.majrad = a/ff; @@ -1350,14 +1351,14 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex AFD.dvsc = ff / (float)ibuf->y; } if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { - // color & normal + /* color & normal */ filterfunc(texres, ibuf, fx, fy, &AFD); val1 = texres->tr + texres->tg + texres->tb; filterfunc(&texr, ibuf, fx + dxt[0], fy + dxt[1], &AFD); val2 = texr.tr + texr.tg + texr.tb; filterfunc(&texr, ibuf, fx + dyt[0], fy + dyt[1], &AFD); val3 = texr.tr + texr.tg + texr.tb; - // don't switch x or y! + /* don't switch x or y! */ texres->nor[0] = val1 - val2; texres->nor[1] = val1 - val3; } @@ -1376,23 +1377,23 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields)) ibuf->rect -= ibuf->x*ibuf->y; - if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { // normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */ + /* The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); } - - // de-premul, this is being premulled in shade_input_do_shade() - // TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out - // also disabled in imagewraposa() to be able to compare results with blender's default texture filtering - // brecht: tried to fix this, see "TXF alpha" comments + /* de-premul, this is being premulled in shade_input_do_shade() + * TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out + * also disabled in imagewraposa() to be able to compare results with blender's default texture filtering */ + + /* brecht: tried to fix this, see "TXF alpha" comments */ if (texres->ta != 1.f && (texres->ta > 1e-4f)) { fx = 1.f/texres->ta; @@ -1414,12 +1415,12 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const float maxd, pixsize, val1, val2, val3; int curmap, retval, imaprepeat, imapextend; - // TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call, - // make a local copy here so that original vecs remain untouched + /* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call, + * make a local copy here so that original vecs remain untouched */ copy_v3_v3(dxt, DXT); copy_v3_v3(dyt, DYT); - // anisotropic filtering + /* anisotropic filtering */ if (tex->texfilter != TXF_BOX) return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres); @@ -1530,7 +1531,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const xs= (int)floor(fx); ys= (int)floor(fy); - // both checkers available, no boundary exceptions, checkerdist will eat aliasing + /* both checkers available, no boundary exceptions, checkerdist will eat aliasing */ if ( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) { fx-= xs; fy-= ys; @@ -1765,18 +1766,18 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const } if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { - // qdn: normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* qdn: normal from color + * The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); } - + /* de-premul, this is being premulled in shade_input_do_shade() */ if (texres->ta!=1.0f && texres->ta>1e-4f) { fx= 1.0f/texres->ta; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index b3eb8c0fd5c..485dd005be7 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -96,11 +96,11 @@ typedef struct OccNode { typedef struct OcclusionTree { MemArena *arena; - float (*co)[3]; /* temporary during build */ + float (*co)[3]; /* temporary during build */ - OccFace *face; /* instance and face indices */ - float *occlusion; /* occlusion for faces */ - float (*rad)[3]; /* radiance for faces */ + OccFace *face; /* instance and face indices */ + float *occlusion; /* occlusion for faces */ + float (*rad)[3]; /* radiance for faces */ OccNode *root; @@ -137,35 +137,35 @@ typedef struct OcclusionBuildThread { /* ------------------------- Shading --------------------------- */ -extern Render R; // meh +extern Render R; /* meh */ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, float *rad) { - ShadeInput *shi= ssamp->shi; - ShadeResult *shr= ssamp->shr; + ShadeInput *shi = ssamp->shi; + ShadeResult *shr = ssamp->shr; float l, u, v, *v1, *v2, *v3; /* init */ if (vlr->v4) { - shi->u= u= 0.5f; - shi->v= v= 0.5f; + shi->u = u = 0.5f; + shi->v = v = 0.5f; } else { - shi->u= u= 1.0f/3.0f; - shi->v= v= 1.0f/3.0f; + shi->u = u = 1.0f / 3.0f; + shi->v = v = 1.0f / 3.0f; } /* setup render coordinates */ - v1= vlr->v1->co; - v2= vlr->v2->co; - v3= vlr->v3->co; + v1 = vlr->v1->co; + v2 = vlr->v2->co; + v3 = vlr->v3->co; /* renderco */ - l= 1.0f-u-v; + l = 1.0f - u - v; - shi->co[0]= l*v3[0]+u*v1[0]+v*v2[0]; - shi->co[1]= l*v3[1]+u*v1[1]+v*v2[1]; - shi->co[2]= l*v3[2]+u*v1[2]+v*v2[2]; + shi->co[0] = l * v3[0] + u * v1[0] + v * v2[0]; + shi->co[1] = l * v3[1] + u * v1[1] + v * v2[1]; + shi->co[2] = l * v3[2] + u * v1[2] + v * v2[2]; shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2); @@ -175,9 +175,9 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, /* cache for shadow */ shi->samplenr++; - - shi->xs= 0; // TODO - shi->ys= 0; + + shi->xs = 0; /* TODO */ + shi->ys = 0; shade_input_set_normals(shi); @@ -195,9 +195,9 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, } /* init material vars */ - // note, keep this synced with render_types.h - memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); - shi->har= shi->mat->har; + /* note, keep this synced with render_types.h */ + memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float)); + shi->har = shi->mat->har; /* render */ shade_input_set_shade_texco(shi); @@ -213,18 +213,18 @@ static void occ_build_shade(Render *re, OcclusionTree *tree) VlakRen *vlr; int a; - R= *re; + R = *re; /* setup shade sample with correct passes */ memset(&ssamp, 0, sizeof(ShadeSample)); - ssamp.shi[0].lay= re->lay; - ssamp.shi[0].passflag= SCE_PASS_DIFFUSE|SCE_PASS_RGBA; - ssamp.shi[0].combinedflag= ~(SCE_PASS_SPEC); - ssamp.tot= 1; + ssamp.shi[0].lay = re->lay; + ssamp.shi[0].passflag = SCE_PASS_DIFFUSE | SCE_PASS_RGBA; + ssamp.shi[0].combinedflag = ~(SCE_PASS_SPEC); + ssamp.tot = 1; - for (a=0; a<tree->totface; a++) { - obi= &R.objectinstance[tree->face[a].obi]; - vlr= RE_findOrAddVlak(obi->obr, tree->face[a].facenr); + for (a = 0; a < tree->totface; a++) { + obi = &R.objectinstance[tree->face[a].obi]; + vlr = RE_findOrAddVlak(obi->obr, tree->face[a].facenr); occ_shade(&ssamp, obi, vlr, tree->rad[a]); } @@ -233,20 +233,20 @@ static void occ_build_shade(Render *re, OcclusionTree *tree) /* ------------------------- Spherical Harmonics --------------------------- */ /* Use 2nd order SH => 9 coefficients, stored in this order: - * 0 = (0,0), - * 1 = (1,-1), 2 = (1,0), 3 = (1,1), - * 4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */ +* 0 = (0,0), +* 1 = (1,-1), 2 = (1,0), 3 = (1,1), +* 4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */ static void sh_copy(float *shresult, float *sh) { - memcpy(shresult, sh, sizeof(float)*9); + memcpy(shresult, sh, sizeof(float) * 9); } static void sh_mul(float *sh, float f) { int i; - for (i=0; i<9; i++) + for (i = 0; i < 9; i++) sh[i] *= f; } @@ -254,8 +254,8 @@ static void sh_add(float *shresult, float *sh1, float *sh2) { int i; - for (i=0; i<9; i++) - shresult[i]= sh1[i] + sh2[i]; + for (i = 0; i < 9; i++) + shresult[i] = sh1[i] + sh2[i]; } static void sh_from_disc(float *n, float area, float *shresult) @@ -264,21 +264,21 @@ static void sh_from_disc(float *n, float area, float *shresult) * "An Efficient Representation for Irradiance Environment Maps" */ float sh[9], x, y, z; - x= n[0]; - y= n[1]; - z= n[2]; + x = n[0]; + y = n[1]; + z = n[2]; - sh[0]= 0.282095f; + sh[0] = 0.282095f; - sh[1]= 0.488603f*y; - sh[2]= 0.488603f*z; - sh[3]= 0.488603f*x; - - sh[4]= 1.092548f*x*y; - sh[5]= 1.092548f*y*z; - sh[6]= 0.315392f*(3.0f*z*z - 1.0f); - sh[7]= 1.092548f*x*z; - sh[8]= 0.546274f*(x*x - y*y); + sh[1] = 0.488603f * y; + sh[2] = 0.488603f * z; + sh[3] = 0.488603f * x; + + sh[4] = 1.092548f * x * y; + sh[5] = 1.092548f * y * z; + sh[6] = 0.315392f * (3.0f * z * z - 1.0f); + sh[7] = 1.092548f * x * z; + sh[8] = 0.546274f * (x * x - y * y); sh_mul(sh, area); sh_copy(shresult, sh); @@ -292,16 +292,16 @@ static float sh_eval(float *sh, float *v) static const float c4 = 0.886227f, c5 = 0.247708f; float x, y, z, sum; - x= v[0]; - y= v[1]; - z= v[2]; + x = v[0]; + y = v[1]; + z = v[2]; - sum= c1*sh[8]*(x*x - y*y); - sum += c3*sh[6]*z*z; - sum += c4*sh[0]; - sum += -c5*sh[6]; - sum += 2.0f*c1*(sh[4]*x*y + sh[7]*x*z + sh[5]*y*z); - sum += 2.0f*c2*(sh[3]*x + sh[1]*y + sh[2]*z); + sum = c1 * sh[8] * (x * x - y * y); + sum += c3 * sh[6] * z * z; + sum += c4 * sh[0]; + sum += -c5 * sh[6]; + sum += 2.0f * c1 * (sh[4] * x * y + sh[7] * x * z + sh[5] * y * z); + sum += 2.0f * c2 * (sh[3] * x + sh[1] * y + sh[2] * z); return sum; } @@ -314,8 +314,8 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a VlakRen *vlr; float v1[3], v2[3], v3[3], v4[3]; - obi= &R.objectinstance[face->obi]; - vlr= RE_findOrAddVlak(obi->obr, face->facenr); + obi = &R.objectinstance[face->obi]; + vlr = RE_findOrAddVlak(obi->obr, face->facenr); if (co) { if (vlr->v4) @@ -328,9 +328,9 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a } if (normal) { - normal[0]= -vlr->n[0]; - normal[1]= -vlr->n[1]; - normal[2]= -vlr->n[2]; + normal[0] = -vlr->n[0]; + normal[1] = -vlr->n[1]; + normal[2] = -vlr->n[2]; if (obi->flag & R_TRANSFORMED) mul_m3_v3(obi->nmat, normal); @@ -351,9 +351,9 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a /* todo: correct area for instances */ if (vlr->v4) - *area= area_quad_v3(v1, v2, v3, v4); + *area = area_quad_v3(v1, v2, v3, v4); else - *area= area_tri_v3(v1, v2, v3); + *area = area_tri_v3(v1, v2, v3); } } @@ -361,25 +361,25 @@ static void occ_sum_occlusion(OcclusionTree *tree, OccNode *node) { OccNode *child; float occ, area, totarea, rad[3]; - int a, b, indirect= tree->doindirect; + int a, b, indirect = tree->doindirect; - occ= 0.0f; - totarea= 0.0f; + occ = 0.0f; + totarea = 0.0f; if (indirect) zero_v3(rad); - for (b=0; b<TOTCHILD; b++) { - if (node->childflag & (1<<b)) { - a= node->child[b].face; + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + a = node->child[b].face; occ_face(&tree->face[a], 0, 0, &area); - occ += area*tree->occlusion[a]; + occ += area * tree->occlusion[a]; if (indirect) madd_v3_v3fl(rad, tree->rad[a], area); totarea += area; } else if (node->child[b].node) { - child= node->child[b].node; + child = node->child[b].node; occ_sum_occlusion(tree, child); - occ += child->area*child->occlusion; + occ += child->area * child->occlusion; if (indirect) madd_v3_v3fl(rad, child->rad, child->area); totarea += child->area; } @@ -387,16 +387,16 @@ static void occ_sum_occlusion(OcclusionTree *tree, OccNode *node) if (totarea != 0.0f) { occ /= totarea; - if (indirect) mul_v3_fl(rad, 1.0f/totarea); + if (indirect) mul_v3_fl(rad, 1.0f / totarea); } - node->occlusion= occ; + node->occlusion = occ; if (indirect) copy_v3_v3(node->rad, rad); } static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *min, float *max) { - float len, maxlen= -1.0f; + float len, maxlen = -1.0f; int a, axis = 0; INIT_MINMAX(min, max); @@ -405,12 +405,12 @@ static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *mi minmax_v3v3_v3(min, max, tree->co[a]); } - for (a=0; a<3; a++) { - len= max[a] - min[a]; + for (a = 0; a < 3; a++) { + len = max[a] - min[a]; if (len > maxlen) { - maxlen= len; - axis= a; + maxlen = len; + axis = a; } } @@ -422,21 +422,21 @@ static void occ_node_from_face(OccFace *face, OccNode *node) float n[3]; occ_face(face, node->co, n, &node->area); - node->dco= 0.0f; + node->dco = 0.0f; sh_from_disc(n, node->area, node->sh); } static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], float *dco) { int b; - for (b=0; b<TOTCHILD; b++) { + for (b = 0; b < TOTCHILD; b++) { float dist, d[3], nco[3]; - if (node->childflag & (1<<b)) { - occ_face(tree->face+node->child[b].face, nco, NULL, NULL); + if (node->childflag & (1 << b)) { + occ_face(tree->face + node->child[b].face, nco, NULL, NULL); } else if (node->child[b].node) { - OccNode *child= node->child[b].node; + OccNode *child = node->child[b].node; occ_build_dco(tree, child, co, dco); copy_v3_v3(nco, child->co); } @@ -445,9 +445,9 @@ static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], } sub_v3_v3v3(d, nco, co); - dist= dot_v3v3(d, d); + dist = dot_v3v3(d, d); if (dist > *dco) - *dco= dist; + *dco = dist; } } @@ -459,12 +459,12 @@ static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split) /* split in middle of boundbox. this seems faster than median split * on complex scenes, possibly since it avoids two distant faces to * be in the same node better? */ - axis= occ_find_bbox_axis(tree, begin, end, min, max); - mid= 0.5f*(min[axis]+max[axis]); + axis = occ_find_bbox_axis(tree, begin, end, min, max); + mid = 0.5f * (min[axis] + max[axis]); - a= begin; - enda= end; - while (a<enda) { + a = begin; + enda = end; + while (a < enda) { if (tree->co[a][axis] > mid) { enda--; SWAP(OccFace, tree->face[a], tree->face[enda]); @@ -476,7 +476,7 @@ static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split) a++; } - *split= enda; + *split = enda; } static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offset, int *count) @@ -488,7 +488,7 @@ static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offs /* force split if none found, to deal with degenerate geometry */ if (splitx == begin || splitx == end) - splitx= (begin+end)/2; + splitx = (begin + end) / 2; occ_build_split(tree, begin, splitx, &splity[0]); occ_build_split(tree, splitx, end, &splity[1]); @@ -498,25 +498,25 @@ static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offs occ_build_split(tree, splitx, splity[1], &splitz[2]); occ_build_split(tree, splity[1], end, &splitz[3]); - offset[0]= begin; - offset[1]= splitz[0]; - offset[2]= splity[0]; - offset[3]= splitz[1]; - offset[4]= splitx; - offset[5]= splitz[2]; - offset[6]= splity[1]; - offset[7]= splitz[3]; - - for (b=0; b<7; b++) - count[b]= offset[b+1] - offset[b]; - count[7]= end - offset[7]; + offset[0] = begin; + offset[1] = splitz[0]; + offset[2] = splity[0]; + offset[3] = splitz[1]; + offset[4] = splitx; + offset[5] = splitz[2]; + offset[6] = splity[1]; + offset[7] = splitz[3]; + + for (b = 0; b < 7; b++) + count[b] = offset[b + 1] - offset[b]; + count[7] = end - offset[7]; } static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, int end, int depth); static void *exec_occ_build(void *data) { - OcclusionBuildThread *othread= (OcclusionBuildThread*)data; + OcclusionBuildThread *othread = (OcclusionBuildThread *)data; occ_build_recursive(othread->tree, othread->node, othread->begin, othread->end, othread->depth); @@ -529,17 +529,17 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i OcclusionBuildThread othreads[BLENDER_MAX_THREADS]; OccNode *child, tmpnode; /* OccFace *face; */ - int a, b, totthread=0, offset[TOTCHILD], count[TOTCHILD]; + int a, b, totthread = 0, offset[TOTCHILD], count[TOTCHILD]; /* add a new node */ - node->occlusion= 1.0f; + node->occlusion = 1.0f; /* leaf node with only children */ if (end - begin <= TOTCHILD) { - for (a=begin, b=0; a<end; a++, b++) { + for (a = begin, b = 0; a < end; a++, b++) { /* face= &tree->face[a]; */ - node->child[b].face= a; - node->childflag |= (1<<b); + node->child[b].face = a; + node->childflag |= (1 << b); } } else { @@ -549,40 +549,40 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i if (depth == 1 && tree->dothreadedbuild) BLI_init_threads(&threads, exec_occ_build, tree->totbuildthread); - for (b=0; b<TOTCHILD; b++) { + for (b = 0; b < TOTCHILD; b++) { if (count[b] == 0) { - node->child[b].node= NULL; + node->child[b].node = NULL; } else if (count[b] == 1) { /* face= &tree->face[offset[b]]; */ - node->child[b].face= offset[b]; - node->childflag |= (1<<b); + node->child[b].face = offset[b]; + node->childflag |= (1 << b); } else { if (tree->dothreadedbuild) BLI_lock_thread(LOCK_CUSTOM1); - child= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); - node->child[b].node= child; + child = BLI_memarena_alloc(tree->arena, sizeof(OccNode)); + node->child[b].node = child; /* keep track of maximum depth for stack */ - if (depth+1 > tree->maxdepth) - tree->maxdepth= depth+1; + if (depth + 1 > tree->maxdepth) + tree->maxdepth = depth + 1; if (tree->dothreadedbuild) BLI_unlock_thread(LOCK_CUSTOM1); if (depth == 1 && tree->dothreadedbuild) { - othreads[totthread].tree= tree; - othreads[totthread].node= child; - othreads[totthread].begin= offset[b]; - othreads[totthread].end= offset[b]+count[b]; - othreads[totthread].depth= depth+1; + othreads[totthread].tree = tree; + othreads[totthread].node = child; + othreads[totthread].begin = offset[b]; + othreads[totthread].end = offset[b] + count[b]; + othreads[totthread].depth = depth + 1; BLI_insert_thread(&threads, &othreads[totthread]); totthread++; } else - occ_build_recursive(tree, child, offset[b], offset[b]+count[b], depth+1); + occ_build_recursive(tree, child, offset[b], offset[b] + count[b], depth + 1); } } @@ -591,13 +591,13 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } /* combine area, position and sh */ - for (b=0; b<TOTCHILD; b++) { - if (node->childflag & (1<<b)) { - child= &tmpnode; - occ_node_from_face(tree->face+node->child[b].face, &tmpnode); + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + child = &tmpnode; + occ_node_from_face(tree->face + node->child[b].face, &tmpnode); } else { - child= node->child[b].node; + child = node->child[b].node; } if (child) { @@ -608,10 +608,10 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } if (node->area != 0.0f) - mul_v3_fl(node->co, 1.0f/node->area); + mul_v3_fl(node->co, 1.0f / node->area); /* compute maximum distance from center */ - node->dco= 0.0f; + node->dco = 0.0f; if (node->area > 0.0f) occ_build_dco(tree, node, node->co, &node->dco); } @@ -623,10 +623,10 @@ static void occ_build_sh_normalize(OccNode *node) int b; if (node->area != 0.0f) - sh_mul(node->sh, 1.0f/node->area); + sh_mul(node->sh, 1.0f / node->area); - for (b=0; b<TOTCHILD; b++) { - if (node->childflag & (1<<b)); + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) ; else if (node->child[b].node) occ_build_sh_normalize(node->child[b].node); } @@ -638,18 +638,18 @@ static OcclusionTree *occ_tree_build(Render *re) ObjectInstanceRen *obi; ObjectRen *obr; Material *ma; - VlakRen *vlr= NULL; + VlakRen *vlr = NULL; int a, b, c, totface; /* count */ - totface= 0; - for (obi=re->instancetable.first; obi; obi=obi->next) { - obr= obi->obr; - for (a=0; a<obr->totvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + totface = 0; + for (obi = re->instancetable.first; obi; obi = obi->next) { + obr = obi->obr; + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; - ma= vlr->mat; + ma = vlr->mat; if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) totface++; @@ -659,41 +659,41 @@ static OcclusionTree *occ_tree_build(Render *re) if (totface == 0) return NULL; - tree= MEM_callocN(sizeof(OcclusionTree), "OcclusionTree"); - tree->totface= totface; + tree = MEM_callocN(sizeof(OcclusionTree), "OcclusionTree"); + tree->totface = totface; /* parameters */ - tree->error= get_render_aosss_error(&re->r, re->wrld.ao_approx_error); - tree->distfac= (re->wrld.aomode & WO_AODIST)? re->wrld.aodistfac: 0.0f; - tree->doindirect= (re->wrld.ao_indirect_energy > 0.0f && re->wrld.ao_indirect_bounces > 0); + tree->error = get_render_aosss_error(&re->r, re->wrld.ao_approx_error); + tree->distfac = (re->wrld.aomode & WO_AODIST) ? re->wrld.aodistfac : 0.0f; + tree->doindirect = (re->wrld.ao_indirect_energy > 0.0f && re->wrld.ao_indirect_bounces > 0); /* allocation */ - tree->arena= BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena"); + tree->arena = BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena"); BLI_memarena_use_calloc(tree->arena); if (re->wrld.aomode & WO_AOCACHE) - tree->cache= MEM_callocN(sizeof(OcclusionCache)*BLENDER_MAX_THREADS, "OcclusionCache"); + tree->cache = MEM_callocN(sizeof(OcclusionCache) * BLENDER_MAX_THREADS, "OcclusionCache"); - tree->face= MEM_callocN(sizeof(OccFace)*totface, "OcclusionFace"); - tree->co= MEM_callocN(sizeof(float)*3*totface, "OcclusionCo"); - tree->occlusion= MEM_callocN(sizeof(float)*totface, "OcclusionOcclusion"); + tree->face = MEM_callocN(sizeof(OccFace) * totface, "OcclusionFace"); + tree->co = MEM_callocN(sizeof(float) * 3 * totface, "OcclusionCo"); + tree->occlusion = MEM_callocN(sizeof(float) * totface, "OcclusionOcclusion"); if (tree->doindirect) - tree->rad= MEM_callocN(sizeof(float)*3*totface, "OcclusionRad"); + tree->rad = MEM_callocN(sizeof(float) * 3 * totface, "OcclusionRad"); /* make array of face pointers */ - for (b=0, c=0, obi=re->instancetable.first; obi; obi=obi->next, c++) { - obr= obi->obr; - for (a=0; a<obr->totvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (b = 0, c = 0, obi = re->instancetable.first; obi; obi = obi->next, c++) { + obr = obi->obr; + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; - ma= vlr->mat; + ma = vlr->mat; if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) { - tree->face[b].obi= c; - tree->face[b].facenr= a; - tree->occlusion[b]= 1.0f; + tree->face[b].obi = c; + tree->face[b].facenr = a; + tree->occlusion[b] = 1.0f; occ_face(&tree->face[b], tree->co[b], NULL, NULL); b++; } @@ -701,12 +701,12 @@ static OcclusionTree *occ_tree_build(Render *re) } /* threads */ - tree->totbuildthread= (re->r.threads > 1 && totface > 10000)? 8: 1; - tree->dothreadedbuild= (tree->totbuildthread > 1); + tree->totbuildthread = (re->r.threads > 1 && totface > 10000) ? 8 : 1; + tree->dothreadedbuild = (tree->totbuildthread > 1); /* recurse */ - tree->root= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); - tree->maxdepth= 1; + tree->root = BLI_memarena_alloc(tree->arena, sizeof(OccNode)); + tree->maxdepth = 1; occ_build_recursive(tree, tree->root, 0, totface, 1); if (tree->doindirect) { @@ -715,12 +715,12 @@ static OcclusionTree *occ_tree_build(Render *re) } MEM_freeN(tree->co); - tree->co= NULL; + tree->co = NULL; occ_build_sh_normalize(tree->root); - for (a=0; a<BLENDER_MAX_THREADS; a++) - tree->stack[a]= MEM_callocN(sizeof(OccNode)*TOTCHILD*(tree->maxdepth+1), "OccStack"); + for (a = 0; a < BLENDER_MAX_THREADS; a++) + tree->stack[a] = MEM_callocN(sizeof(OccNode) * TOTCHILD * (tree->maxdepth + 1), "OccStack"); return tree; } @@ -731,7 +731,7 @@ static void occ_free_tree(OcclusionTree *tree) if (tree) { if (tree->arena) BLI_memarena_free(tree->arena); - for (a=0; a<BLENDER_MAX_THREADS; a++) + for (a = 0; a < BLENDER_MAX_THREADS; a++) if (tree->stack[a]) MEM_freeN(tree->stack[a]); if (tree->occlusion) MEM_freeN(tree->occlusion); @@ -749,36 +749,40 @@ static float occ_solid_angle(OccNode *node, const float v[3], float d2, float in float dotreceive, dotemit; float ev[3]; - ev[0]= -v[0]*invd2; - ev[1]= -v[1]*invd2; - ev[2]= -v[2]*invd2; - dotemit= sh_eval(node->sh, ev); - dotreceive= dot_v3v3(receivenormal, v)*invd2; + ev[0] = -v[0] * invd2; + ev[1] = -v[1] * invd2; + ev[2] = -v[2] * invd2; + dotemit = sh_eval(node->sh, ev); + dotreceive = dot_v3v3(receivenormal, v) * invd2; CLAMP(dotemit, 0.0f, 1.0f); CLAMP(dotreceive, 0.0f, 1.0f); - return ((node->area*dotemit*dotreceive)/(d2 + node->area*INVPI))*INVPI; + return ((node->area * dotemit * dotreceive) / (d2 + node->area * INVPI)) * INVPI; } -static void VecAddDir(float result[3], const float v1[3], const float v2[3], const float fac) +static void vec_add_dir(float r[3], const float v1[3], const float v2[3], const float fac) { - result[0]= v1[0] + fac*(v2[0] - v1[0]); - result[1]= v1[1] + fac*(v2[1] - v1[1]); - result[2]= v1[2] + fac*(v2[2] - v1[2]); + r[0] = v1[0] + fac * (v2[0] - v1[0]); + r[1] = v1[1] + fac * (v2[1] - v1[1]); + r[2] = v1[2] + fac * (v2[2] - v1[2]); } -static int occ_visible_quad(float *p, const float n[3], const float v0[3], const float *v1, const float *v2, float q0[3], float q1[3], float q2[3], float q3[3]) +/* TODO: exact duplicate of ff_visible_quad() in math_geom.c + * why not de-duplicate? (also above helper func) */ +static int occ_visible_quad(const float p[3], const float n[3], + const float v0[3], const float v1[3], const float v2[3], + float q0[3], float q1[3], float q2[3], float q3[3]) { static const float epsilon = 1e-6f; float c, sd[3]; - c= dot_v3v3(n, p); + c = dot_v3v3(n, p); /* signed distances from the vertices to the plane. */ - sd[0]= dot_v3v3(n, v0) - c; - sd[1]= dot_v3v3(n, v1) - c; - sd[2]= dot_v3v3(n, v2) - c; + sd[0] = dot_v3v3(n, v0) - c; + sd[1] = dot_v3v3(n, v1) - c; + sd[2] = dot_v3v3(n, v2) - c; if (fabsf(sd[0]) < epsilon) sd[0] = 0.0f; if (fabsf(sd[1]) < epsilon) sd[1] = 0.0f; @@ -787,21 +791,21 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const if (sd[0] > 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // +++ + /* +++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // ++- + /* ++- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); - VecAddDir(q3, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); + vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else { - // ++0 + /* ++0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -810,44 +814,44 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // +-+ + /* +-+ */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, v2); } else if (sd[2] < 0) { - // +-- + /* +-- */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); - VecAddDir(q2, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); + vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +-0 + /* +-0 */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } } else { if (sd[2] > 0) { - // +0+ + /* +0+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // +0- + /* +0- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +00 + /* +00 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -858,22 +862,22 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const else if (sd[0] < 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // -++ - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -++ */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); - VecAddDir(q3, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else if (sd[2] < 0) { - // -+- - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -+- */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // -+0 - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -+0 */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); @@ -881,35 +885,35 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // --+ - VecAddDir(q0, v0, v2, (sd[0]/(sd[0]-sd[2]))); - VecAddDir(q1, v1, v2, (sd[1]/(sd[1]-sd[2]))); + /* --+ */ + vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); + vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // --- + /* --- */ return 0; } else { - // --0 + /* --0 */ return 0; } } else { if (sd[2] > 0) { - // -0+ - VecAddDir(q0, v0, v2, (sd[0]/(sd[0]-sd[2]))); + /* -0+ */ + vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // -0- + /* -0- */ return 0; } else { - // -00 + /* -00 */ return 0; } } @@ -917,21 +921,21 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const else { if (sd[1] > 0) { if (sd[2] > 0) { - // 0++ + /* 0++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0+- + /* 0+- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // 0+0 + /* 0+0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -940,35 +944,35 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // 0-+ + /* 0-+ */ copy_v3_v3(q0, v0); - VecAddDir(q1, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0-- + /* 0-- */ return 0; } else { - // 0-0 + /* 0-0 */ return 0; } } else { if (sd[2] > 0) { - // 00+ + /* 00+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 00- + /* 00- */ return 0; } else { - // 000 + /* 000 */ return 0; } } @@ -995,49 +999,49 @@ static vFloat vec_splat_float(float val) static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3) { vFloat vcos, rlen, vrx, vry, vrz, vsrx, vsry, vsrz, gx, gy, gz, vangle; - vUInt8 rotate = (vUInt8) {4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3}; + vUInt8 rotate = (vUInt8) {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3}; vFloatResult vresult; float result; /* compute r* */ - vrx = (vFloat) {q0[0], q1[0], q2[0], q3[0]} - vec_splat_float(p[0]); - vry = (vFloat) {q0[1], q1[1], q2[1], q3[1]} - vec_splat_float(p[1]); - vrz = (vFloat) {q0[2], q1[2], q2[2], q3[2]} - vec_splat_float(p[2]); + vrx = (vFloat) {q0[0], q1[0], q2[0], q3[0]} -vec_splat_float(p[0]); + vry = (vFloat) {q0[1], q1[1], q2[1], q3[1]} -vec_splat_float(p[1]); + vrz = (vFloat) {q0[2], q1[2], q2[2], q3[2]} -vec_splat_float(p[2]); /* normalize r* */ - rlen = vec_rsqrte(vrx*vrx + vry*vry + vrz*vrz + vec_splat_float(1e-16f)); - vrx = vrx*rlen; - vry = vry*rlen; - vrz = vrz*rlen; + rlen = vec_rsqrte(vrx * vrx + vry * vry + vrz * vrz + vec_splat_float(1e-16f)); + vrx = vrx * rlen; + vry = vry * rlen; + vrz = vrz * rlen; /* rotate r* for cross and dot */ - vsrx= vec_perm(vrx, vrx, rotate); - vsry= vec_perm(vry, vry, rotate); - vsrz= vec_perm(vrz, vrz, rotate); + vsrx = vec_perm(vrx, vrx, rotate); + vsry = vec_perm(vry, vry, rotate); + vsrz = vec_perm(vrz, vrz, rotate); /* cross product */ - gx = vsry*vrz - vsrz*vry; - gy = vsrz*vrx - vsrx*vrz; - gz = vsrx*vry - vsry*vrx; + gx = vsry * vrz - vsrz * vry; + gy = vsrz * vrx - vsrx * vrz; + gz = vsrx * vry - vsry * vrx; /* normalize */ - rlen = vec_rsqrte(gx*gx + gy*gy + gz*gz + vec_splat_float(1e-16f)); - gx = gx*rlen; - gy = gy*rlen; - gz = gz*rlen; + rlen = vec_rsqrte(gx * gx + gy * gy + gz * gz + vec_splat_float(1e-16f)); + gx = gx * rlen; + gy = gy * rlen; + gz = gz * rlen; /* angle */ - vcos = vrx*vsrx + vry*vsry + vrz*vsrz; - vcos= vec_max(vec_min(vcos, vec_splat_float(1.0f)), vec_splat_float(-1.0f)); - vangle= vacosf(vcos); + vcos = vrx * vsrx + vry * vsry + vrz * vsrz; + vcos = vec_max(vec_min(vcos, vec_splat_float(1.0f)), vec_splat_float(-1.0f)); + vangle = vacosf(vcos); /* dot */ - vresult.v = (vec_splat_float(n[0])*gx + - vec_splat_float(n[1])*gy + - vec_splat_float(n[2])*gz)*vangle; + vresult.v = (vec_splat_float(n[0]) * gx + + vec_splat_float(n[1]) * gy + + vec_splat_float(n[2]) * gz) * vangle; - result= (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3])*(0.5f/(float)M_PI); - result= MAX2(result, 0.0f); + result = (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3]) * (0.5f / (float)M_PI); + result = MAX2(result, 0.0f); return result; } @@ -1053,8 +1057,8 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa static __m128 sse_approx_acos(__m128 x) { /* needs a better approximation than taylor expansion of acos, since that - * gives big erros for near 1.0 values, sqrt(2*x)*acos(1-x) should work - * better, see http://www.tom.womack.net/projects/sse-fast-arctrig.html */ + * gives big erros for near 1.0 values, sqrt(2*x)*acos(1-x) should work + * better, see http://www.tom.womack.net/projects/sse-fast-arctrig.html */ return _mm_set_ps1(1.0f); } @@ -1076,36 +1080,36 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa rz = qz - _mm_set_ps1(p[2]); /* normalize r */ - rlen = _mm_rsqrt_ps(rx*rx + ry*ry + rz*rz + _mm_set_ps1(1e-16f)); - rx = rx*rlen; - ry = ry*rlen; - rz = rz*rlen; + rlen = _mm_rsqrt_ps(rx * rx + ry * ry + rz * rz + _mm_set_ps1(1e-16f)); + rx = rx * rlen; + ry = ry * rlen; + rz = rz * rlen; /* cross product */ - srx = _mm_shuffle_ps(rx, rx, _MM_SHUFFLE(0,3,2,1)); - sry = _mm_shuffle_ps(ry, ry, _MM_SHUFFLE(0,3,2,1)); - srz = _mm_shuffle_ps(rz, rz, _MM_SHUFFLE(0,3,2,1)); + srx = _mm_shuffle_ps(rx, rx, _MM_SHUFFLE(0, 3, 2, 1)); + sry = _mm_shuffle_ps(ry, ry, _MM_SHUFFLE(0, 3, 2, 1)); + srz = _mm_shuffle_ps(rz, rz, _MM_SHUFFLE(0, 3, 2, 1)); - gx = sry*rz - srz*ry; - gy = srz*rx - srx*rz; - gz = srx*ry - sry*rx; + gx = sry * rz - srz * ry; + gy = srz * rx - srx * rz; + gz = srx * ry - sry * rx; /* normalize g */ - glen = _mm_rsqrt_ps(gx*gx + gy*gy + gz*gz + _mm_set_ps1(1e-16f)); - gx = gx*glen; - gy = gy*glen; - gz = gz*glen; + glen = _mm_rsqrt_ps(gx * gx + gy * gy + gz * gz + _mm_set_ps1(1e-16f)); + gx = gx * glen; + gy = gy * glen; + gz = gz * glen; /* compute angle */ - rcos = rx*srx + ry*sry + rz*srz; - rcos= _mm_max_ps(_mm_min_ps(rcos, _mm_set_ps1(1.0f)), _mm_set_ps1(-1.0f)); + rcos = rx * srx + ry * sry + rz * srz; + rcos = _mm_max_ps(_mm_min_ps(rcos, _mm_set_ps1(1.0f)), _mm_set_ps1(-1.0f)); angle = sse_approx_cos(rcos); - aresult = (_mm_set_ps1(n[0])*gx + _mm_set_ps1(n[1])*gy + _mm_set_ps1(n[2])*gz)*angle; + aresult = (_mm_set_ps1(n[0]) * gx + _mm_set_ps1(n[1]) * gy + _mm_set_ps1(n[2]) * gz) * angle; /* sum together */ - result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI); - result= MAX2(result, 0.0f); + result = (fresult[0] + fresult[1] + fresult[2] + fresult[3]) * (0.5f / (float)M_PI); + result = MAX2(result, 0.0f); return result; } @@ -1116,10 +1120,10 @@ static void normalizef(float *n) { float d; - d= dot_v3v3(n, n); + d = dot_v3v3(n, n); if (d > 1.0e-35F) { - d= 1.0f/sqrtf(d); + d = 1.0f / sqrtf(d); n[0] *= d; n[1] *= d; @@ -1127,6 +1131,8 @@ static void normalizef(float *n) } } +/* TODO: exact duplicate of ff_quad_form_factor() in math_geom.c + * why not de-duplicate? (also above helper func) */ static float occ_quad_form_factor(const float p[3], const float n[3], const float q0[3], const float q1[3], const float q2[3], const float q3[3]) { float r0[3], r1[3], r2[3], r3[3], g0[3], g1[3], g2[3], g3[3]; @@ -1147,18 +1153,18 @@ static float occ_quad_form_factor(const float p[3], const float n[3], const floa cross_v3_v3v3(g2, r3, r2); normalizef(g2); cross_v3_v3v3(g3, r0, r3); normalizef(g3); - a1= saacosf(dot_v3v3(r0, r1)); - a2= saacosf(dot_v3v3(r1, r2)); - a3= saacosf(dot_v3v3(r2, r3)); - a4= saacosf(dot_v3v3(r3, r0)); + a1 = saacosf(dot_v3v3(r0, r1)); + a2 = saacosf(dot_v3v3(r1, r2)); + a3 = saacosf(dot_v3v3(r2, r3)); + a4 = saacosf(dot_v3v3(r3, r0)); - dot1= dot_v3v3(n, g0); - dot2= dot_v3v3(n, g1); - dot3= dot_v3v3(n, g2); - dot4= dot_v3v3(n, g3); + dot1 = dot_v3v3(n, g0); + dot2 = dot_v3v3(n, g1); + dot3 = dot_v3v3(n, g2); + dot4 = dot_v3v3(n, g3); - result= (a1*dot1 + a2*dot2 + a3*dot3 + a4*dot4)*0.5f/(float)M_PI; - result= MAX2(result, 0.0f); + result = (a1 * dot1 + a2 * dot2 + a3 * dot3 + a4 * dot4) * 0.5f / (float)M_PI; + result = MAX2(result, 0.0f); return result; } @@ -1167,10 +1173,10 @@ static float occ_form_factor(OccFace *face, float *p, float *n) { ObjectInstanceRen *obi; VlakRen *vlr; - float v1[3], v2[3], v3[3], v4[3], q0[3], q1[3], q2[3], q3[3], contrib= 0.0f; + float v1[3], v2[3], v3[3], v4[3], q0[3], q1[3], q2[3], q3[3], contrib = 0.0f; - obi= &R.objectinstance[face->obi]; - vlr= RE_findOrAddVlak(obi->obr, face->facenr); + obi = &R.objectinstance[face->obi]; + vlr = RE_findOrAddVlak(obi->obr, face->facenr); copy_v3_v3(v1, vlr->v1->co); copy_v3_v3(v2, vlr->v2->co); @@ -1214,103 +1220,103 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, if (bentn) copy_v3_v3(bentn, n); - error= tree->error; - distfac= tree->distfac; + error = tree->error; + distfac = tree->distfac; - resultocc= 0.0f; + resultocc = 0.0f; zero_v3(resultrad); /* init stack */ - stack= tree->stack[thread]; - stack[0]= tree->root; - totstack= 1; + stack = tree->stack[thread]; + stack[0] = tree->root; + totstack = 1; while (totstack) { /* pop point off the stack */ - node= stack[--totstack]; + node = stack[--totstack]; sub_v3_v3v3(v, node->co, p); - d2= dot_v3v3(v, v) + 1e-16f; - emitarea= MAX2(node->area, node->dco); + d2 = dot_v3v3(v, v) + 1e-16f; + emitarea = MAX2(node->area, node->dco); - if (d2*error > emitarea) { + if (d2 * error > emitarea) { if (distfac != 0.0f) { - fac= 1.0f/(1.0f + distfac*d2); + fac = 1.0f / (1.0f + distfac * d2); if (fac < 0.01f) continue; } else - fac= 1.0f; + fac = 1.0f; /* accumulate occlusion from spherical harmonics */ - invd2 = 1.0f/sqrtf(d2); - weight= occ_solid_angle(node, v, d2, invd2, n); + invd2 = 1.0f / sqrtf(d2); + weight = occ_solid_angle(node, v, d2, invd2, n); if (rad) - madd_v3_v3fl(resultrad, node->rad, weight*fac); + madd_v3_v3fl(resultrad, node->rad, weight * fac); weight *= node->occlusion; if (bentn) { - bentn[0] -= weight*invd2*v[0]; - bentn[1] -= weight*invd2*v[1]; - bentn[2] -= weight*invd2*v[2]; + bentn[0] -= weight * invd2 * v[0]; + bentn[1] -= weight * invd2 * v[1]; + bentn[2] -= weight * invd2 * v[2]; } - resultocc += weight*fac; + resultocc += weight * fac; } else { /* traverse into children */ - for (b=0; b<TOTCHILD; b++) { - if (node->childflag & (1<<b)) { - f= node->child[b].face; - face= &tree->face[f]; + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + f = node->child[b].face; + face = &tree->face[f]; /* accumulate occlusion with face form factor */ if (!exclude || !(face->obi == exclude->obi && face->facenr == exclude->facenr)) { if (bentn || distfac != 0.0f) { occ_face(face, co, NULL, NULL); sub_v3_v3v3(v, co, p); - d2= dot_v3v3(v, v) + 1e-16f; + d2 = dot_v3v3(v, v) + 1e-16f; - fac= (distfac == 0.0f)? 1.0f: 1.0f/(1.0f + distfac*d2); + fac = (distfac == 0.0f) ? 1.0f : 1.0f / (1.0f + distfac * d2); if (fac < 0.01f) continue; } else - fac= 1.0f; + fac = 1.0f; - weight= occ_form_factor(face, p, n); + weight = occ_form_factor(face, p, n); if (rad) - madd_v3_v3fl(resultrad, tree->rad[f], weight*fac); + madd_v3_v3fl(resultrad, tree->rad[f], weight * fac); weight *= tree->occlusion[f]; if (bentn) { - invd2= 1.0f/sqrtf(d2); - bentn[0] -= weight*invd2*v[0]; - bentn[1] -= weight*invd2*v[1]; - bentn[2] -= weight*invd2*v[2]; + invd2 = 1.0f / sqrtf(d2); + bentn[0] -= weight * invd2 * v[0]; + bentn[1] -= weight * invd2 * v[1]; + bentn[2] -= weight * invd2 * v[2]; } - resultocc += weight*fac; + resultocc += weight * fac; } } else if (node->child[b].node) { /* push child on the stack */ - stack[totstack++]= node->child[b].node; + stack[totstack++] = node->child[b].node; } } } } - if (occ) *occ= resultocc; + if (occ) *occ = resultocc; if (rad) copy_v3_v3(rad, resultrad); #if 0 if (rad && exclude) { int a; - for (a=0; a<tree->totface; a++) + for (a = 0; a < tree->totface; a++) if ((tree->face[a].obi == exclude->obi && tree->face[a].facenr == exclude->facenr)) copy_v3_v3(rad, tree->rad[a]); } @@ -1323,18 +1329,18 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) float (*rad)[3], (*sum)[3], (*tmp)[3], co[3], n[3], occ; int bounce, i; - rad= MEM_callocN(sizeof(float)*3*tree->totface, "OcclusionBounceRad"); - sum= MEM_dupallocN(tree->rad); + rad = MEM_callocN(sizeof(float) * 3 * tree->totface, "OcclusionBounceRad"); + sum = MEM_dupallocN(tree->rad); - for (bounce=1; bounce<totbounce; bounce++) { - for (i=0; i<tree->totface; i++) { + for (bounce = 1; bounce < totbounce; bounce++) { + for (i = 0; i < tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); madd_v3_v3fl(co, n, 1e-8f); occ_lookup(tree, 0, &tree->face[i], co, n, &occ, rad[i], NULL); - rad[i][0]= MAX2(rad[i][0], 0.0f); - rad[i][1]= MAX2(rad[i][1], 0.0f); - rad[i][2]= MAX2(rad[i][2], 0.0f); + rad[i][0] = MAX2(rad[i][0], 0.0f); + rad[i][1] = MAX2(rad[i][1], 0.0f); + rad[i][2] = MAX2(rad[i][2], 0.0f); add_v3_v3(sum[i], rad[i]); if (re->test_break(re->tbh)) @@ -1344,16 +1350,16 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) if (re->test_break(re->tbh)) break; - tmp= tree->rad; - tree->rad= rad; - rad= tmp; + tmp = tree->rad; + tree->rad = rad; + rad = tmp; occ_sum_occlusion(tree, tree->root); } MEM_freeN(rad); MEM_freeN(tree->rad); - tree->rad= sum; + tree->rad = sum; if (!re->test_break(re->tbh)) occ_sum_occlusion(tree, tree->root); @@ -1364,10 +1370,10 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) float *occ, co[3], n[3]; int pass, i; - occ= MEM_callocN(sizeof(float)*tree->totface, "OcclusionPassOcc"); + occ = MEM_callocN(sizeof(float) * tree->totface, "OcclusionPassOcc"); - for (pass=0; pass<totpass; pass++) { - for (i=0; i<tree->totface; i++) { + for (pass = 0; pass < totpass; pass++) { + for (i = 0; i < tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); negate_v3(n); madd_v3_v3fl(co, n, 1e-8f); @@ -1380,10 +1386,10 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) if (re->test_break(re->tbh)) break; - for (i=0; i<tree->totface; i++) { + for (i = 0; i < tree->totface; i++) { tree->occlusion[i] -= occ[i]; //MAX2(1.0f-occ[i], 0.0f); if (tree->occlusion[i] < 0.0f) - tree->occlusion[i]= 0.0f; + tree->occlusion[i] = 0.0f; } occ_sum_occlusion(tree, tree->root); @@ -1399,25 +1405,25 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, float nn[3], bn[3], fac, occ, occlusion, correction, rad[3]; int envcolor; - envcolor= re->wrld.aocolor; + envcolor = re->wrld.aocolor; if (onlyshadow) - envcolor= WO_AOPLAIN; + envcolor = WO_AOPLAIN; negate_v3_v3(nn, n); - occ_lookup(tree, thread, exclude, co, nn, &occ, (tree->doindirect)? rad: NULL, (env && envcolor)? bn: NULL); + occ_lookup(tree, thread, exclude, co, nn, &occ, (tree->doindirect) ? rad : NULL, (env && envcolor) ? bn : NULL); - correction= re->wrld.ao_approx_correction; + correction = re->wrld.ao_approx_correction; - occlusion= (1.0f-correction)*(1.0f-occ); + occlusion = (1.0f - correction) * (1.0f - occ); CLAMP(occlusion, 0.0f, 1.0f); if (correction != 0.0f) - occlusion += correction*expf(-occ); + occlusion += correction * expf(-occ); if (env) { /* sky shading using bent normal */ if (ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { - fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); + fac = 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); env[0] = (1.0f - fac) * re->wrld.horr + fac * re->wrld.zenr; env[1] = (1.0f - fac) * re->wrld.horg + fac * re->wrld.zeng; env[2] = (1.0f - fac) * re->wrld.horb + fac * re->wrld.zenb; @@ -1425,28 +1431,28 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, mul_v3_fl(env, occlusion); } else { - env[0]= occlusion; - env[1]= occlusion; - env[2]= occlusion; + env[0] = occlusion; + env[1] = occlusion; + env[2] = occlusion; } #if 0 - else { /* WO_AOSKYTEX */ + else { /* WO_AOSKYTEX */ float dxyview[3]; - bn[0]= -bn[0]; - bn[1]= -bn[1]; - bn[2]= -bn[2]; - dxyview[0]= 1.0f; - dxyview[1]= 1.0f; - dxyview[2]= 0.0f; + bn[0] = -bn[0]; + bn[1] = -bn[1]; + bn[2] = -bn[2]; + dxyview[0] = 1.0f; + dxyview[1] = 1.0f; + dxyview[2] = 0.0f; shadeSkyView(ao, co, bn, dxyview); } #endif } if (ao) { - ao[0]= occlusion; - ao[1]= occlusion; - ao[2]= occlusion; + ao[0] = occlusion; + ao[1] = occlusion; + ao[2] = occlusion; } if (tree->doindirect) copy_v3_v3(indirect, rad); @@ -1468,7 +1474,7 @@ static OcclusionCacheSample *find_occ_sample(OcclusionCache *cache, int x, int y if (x < 0 || x >= cache->w || y < 0 || y >= cache->h) return NULL; else - return &cache->sample[y*cache->w + x]; + return &cache->sample[y * cache->w + x]; } static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int y, int thread, float *ao, float *env, float *indirect) @@ -1483,14 +1489,14 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int return 0; /* first try to find a sample in the same pixel */ - cache= &tree->cache[thread]; + cache = &tree->cache[thread]; if (cache->sample && cache->step) { - sample= &cache->sample[(y-cache->y)*cache->w + (x-cache->x)]; + sample = &cache->sample[(y - cache->y) * cache->w + (x - cache->x)]; if (sample->filled) { sub_v3_v3v3(d, sample->co, co); - dist2= dot_v3v3(d, d); - if (dist2 < 0.5f*sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) { + dist2 = dot_v3v3(d, d); + if (dist2 < 0.5f * sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) { copy_v3_v3(ao, sample->ao); copy_v3_v3(env, sample->env); copy_v3_v3(indirect, sample->indirect); @@ -1502,18 +1508,18 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int return 0; /* try to interpolate between 4 neighboring pixels */ - samples[0]= find_occ_sample(cache, x, y); - samples[1]= find_occ_sample(cache, x+cache->step, y); - samples[2]= find_occ_sample(cache, x, y+cache->step); - samples[3]= find_occ_sample(cache, x+cache->step, y+cache->step); + samples[0] = find_occ_sample(cache, x, y); + samples[1] = find_occ_sample(cache, x + cache->step, y); + samples[2] = find_occ_sample(cache, x, y + cache->step); + samples[3] = find_occ_sample(cache, x + cache->step, y + cache->step); - for (i=0; i<4; i++) + for (i = 0; i < 4; i++) if (!samples[i] || !samples[i]->filled) return 0; /* require intensities not being too different */ - mino= MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); - maxo= MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); + mino = MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); + maxo = MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); if (maxo - mino > 0.05f) return 0; @@ -1522,29 +1528,29 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int zero_v3(ao); zero_v3(env); zero_v3(indirect); - totw= 0.0f; + totw = 0.0f; - x1= samples[0]->x; - y1= samples[0]->y; - x2= samples[3]->x; - y2= samples[3]->y; + x1 = samples[0]->x; + y1 = samples[0]->y; + x2 = samples[3]->x; + y2 = samples[3]->y; - tx= (float)(x2 - x)/(float)(x2 - x1); - ty= (float)(y2 - y)/(float)(y2 - y1); + tx = (float)(x2 - x) / (float)(x2 - x1); + ty = (float)(y2 - y) / (float)(y2 - y1); - wb[3]= (1.0f-tx)*(1.0f-ty); - wb[2]= (tx)*(1.0f-ty); - wb[1]= (1.0f-tx)*(ty); - wb[0]= tx*ty; + wb[3] = (1.0f - tx) * (1.0f - ty); + wb[2] = (tx) * (1.0f - ty); + wb[1] = (1.0f - tx) * (ty); + wb[0] = tx * ty; - for (i=0; i<4; i++) { + for (i = 0; i < 4; i++) { sub_v3_v3v3(d, samples[i]->co, co); //dist2= dot_v3v3(d, d); - wz[i]= 1.0f; //(samples[i]->dist2/(1e-4f + dist2)); - wn[i]= pow(dot_v3v3(samples[i]->n, n), 32.0f); + wz[i] = 1.0f; //(samples[i]->dist2/(1e-4f + dist2)); + wn[i] = pow(dot_v3v3(samples[i]->n, n), 32.0f); - w= wb[i]*wn[i]*wz[i]; + w = wb[i] * wn[i] * wz[i]; totw += w; madd_v3_v3fl(ao, samples[i]->ao, w); @@ -1553,7 +1559,7 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int } if (totw >= 0.9f) { - totw= 1.0f/totw; + totw = 1.0f / totw; mul_v3_fl(ao, totw); mul_v3_fl(env, totw); mul_v3_fl(indirect, totw); @@ -1565,18 +1571,18 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int static void sample_occ_surface(ShadeInput *shi) { - StrandRen *strand= shi->strand; - StrandSurface *mesh= strand->buffer->surface; + StrandRen *strand = shi->strand; + StrandSurface *mesh = strand->buffer->surface; int *face, *index = RE_strandren_get_face(shi->obr, strand, 0); float w[4], *co1, *co2, *co3, *co4; if (mesh && mesh->face && mesh->co && mesh->ao && index) { - face= mesh->face[*index]; + face = mesh->face[*index]; - co1= mesh->co[face[0]]; - co2= mesh->co[face[1]]; - co3= mesh->co[face[2]]; - co4= (face[3])? mesh->co[face[3]]: NULL; + co1 = mesh->co[face[0]]; + co2 = mesh->co[face[1]]; + co3 = mesh->co[face[2]]; + co4 = (face[3]) ? mesh->co[face[3]] : NULL; interp_weights_face_v3(w, co1, co2, co3, co4, strand->vert->co); @@ -1600,9 +1606,9 @@ static void sample_occ_surface(ShadeInput *shi) } } else { - shi->ao[0]= 1.0f; - shi->ao[1]= 1.0f; - shi->ao[2]= 1.0f; + shi->ao[0] = 1.0f; + shi->ao[1] = 1.0f; + shi->ao[2] = 1.0f; zero_v3(shi->env); zero_v3(shi->indirect); } @@ -1612,20 +1618,20 @@ static void sample_occ_surface(ShadeInput *shi) static void *exec_strandsurface_sample(void *data) { - OcclusionThread *othread= (OcclusionThread*)data; - Render *re= othread->re; - StrandSurface *mesh= othread->mesh; + OcclusionThread *othread = (OcclusionThread *)data; + Render *re = othread->re; + StrandSurface *mesh = othread->mesh; float ao[3], env[3], indirect[3], co[3], n[3], *co1, *co2, *co3, *co4; int a, *face; - for (a=othread->begin; a<othread->end; a++) { - face= mesh->face[a]; - co1= mesh->co[face[0]]; - co2= mesh->co[face[1]]; - co3= mesh->co[face[2]]; + for (a = othread->begin; a < othread->end; a++) { + face = mesh->face[a]; + co1 = mesh->co[face[0]]; + co2 = mesh->co[face[1]]; + co3 = mesh->co[face[2]]; if (face[3]) { - co4= mesh->co[face[3]]; + co4 = mesh->co[face[3]]; mid_v3_v3v3(co, co1, co3); normal_quad_v3(n, co1, co2, co3, co4); @@ -1655,12 +1661,12 @@ void make_occ_tree(Render *re) int a, totface, totthread, *face, *count; /* ugly, needed for occ_face */ - R= *re; + R = *re; - re->i.infostr= "Occlusion preprocessing"; + re->i.infostr = "Occlusion preprocessing"; re->stats_draw(re->sdh, &re->i); - re->occlusiontree= tree= occ_tree_build(re); + re->occlusiontree = tree = occ_tree_build(re); if (tree) { if (re->wrld.ao_approx_passes > 0) @@ -1668,26 +1674,26 @@ void make_occ_tree(Render *re) if (tree->doindirect && (re->wrld.mode & WO_INDIRECT_LIGHT)) occ_compute_bounces(re, tree, re->wrld.ao_indirect_bounces); - for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) { + for (mesh = re->strandsurface.first; mesh; mesh = mesh->next) { if (!mesh->face || !mesh->co || !mesh->ao) continue; - count= MEM_callocN(sizeof(int)*mesh->totvert, "OcclusionCount"); - faceao= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceAO"); - faceenv= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceEnv"); - faceindirect= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceIndirect"); - - totthread= (mesh->totface > 10000)? re->r.threads: 1; - totface= mesh->totface/totthread; - for (a=0; a<totthread; a++) { - othreads[a].re= re; - othreads[a].faceao= faceao; - othreads[a].faceenv= faceenv; - othreads[a].faceindirect= faceindirect; - othreads[a].thread= a; - othreads[a].mesh= mesh; - othreads[a].begin= a*totface; - othreads[a].end= (a == totthread-1)? mesh->totface: (a+1)*totface; + count = MEM_callocN(sizeof(int) * mesh->totvert, "OcclusionCount"); + faceao = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceAO"); + faceenv = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceEnv"); + faceindirect = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceIndirect"); + + totthread = (mesh->totface > 10000) ? re->r.threads : 1; + totface = mesh->totface / totthread; + for (a = 0; a < totthread; a++) { + othreads[a].re = re; + othreads[a].faceao = faceao; + othreads[a].faceenv = faceenv; + othreads[a].faceindirect = faceindirect; + othreads[a].thread = a; + othreads[a].mesh = mesh; + othreads[a].begin = a * totface; + othreads[a].end = (a == totthread - 1) ? mesh->totface : (a + 1) * totface; } if (totthread == 1) { @@ -1696,14 +1702,14 @@ void make_occ_tree(Render *re) else { BLI_init_threads(&threads, exec_strandsurface_sample, totthread); - for (a=0; a<totthread; a++) + for (a = 0; a < totthread; a++) BLI_insert_thread(&threads, &othreads[a]); BLI_end_threads(&threads); } - for (a=0; a<mesh->totface; a++) { - face= mesh->face[a]; + for (a = 0; a < mesh->totface; a++) { + face = mesh->face[a]; copy_v3_v3(ao, faceao[a]); copy_v3_v3(env, faceenv[a]); @@ -1730,11 +1736,11 @@ void make_occ_tree(Render *re) } } - for (a=0; a<mesh->totvert; a++) { + for (a = 0; a < mesh->totvert; a++) { if (count[a]) { - mul_v3_fl(mesh->ao[a], 1.0f/count[a]); - mul_v3_fl(mesh->env[a], 1.0f/count[a]); - mul_v3_fl(mesh->indirect[a], 1.0f/count[a]); + mul_v3_fl(mesh->ao[a], 1.0f / count[a]); + mul_v3_fl(mesh->env[a], 1.0f / count[a]); + mul_v3_fl(mesh->indirect[a], 1.0f / count[a]); } } @@ -1756,7 +1762,7 @@ void free_occ(Render *re) void sample_occ(Render *re, ShadeInput *shi) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; OcclusionCache *cache; OcclusionCacheSample *sample; OccFace exclude; @@ -1767,91 +1773,91 @@ void sample_occ(Render *re, ShadeInput *shi) sample_occ_surface(shi); } /* try to get result from the cache if possible */ - else if (shi->depth!=0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) { + else if (shi->depth != 0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) { /* no luck, let's sample the occlusion */ - exclude.obi= shi->obi - re->objectinstance; - exclude.facenr= shi->vlr->index; - onlyshadow= (shi->mat->mode & MA_ONLYSHADOW); + exclude.obi = shi->obi - re->objectinstance; + exclude.facenr = shi->vlr->index; + onlyshadow = (shi->mat->mode & MA_ONLYSHADOW); sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect); /* fill result into sample, each time */ if (tree->cache) { - cache= &tree->cache[shi->thread]; + cache = &tree->cache[shi->thread]; if (cache->sample && cache->step) { - sample= &cache->sample[(shi->ys-cache->y)*cache->w + (shi->xs-cache->x)]; + sample = &cache->sample[(shi->ys - cache->y) * cache->w + (shi->xs - cache->x)]; copy_v3_v3(sample->co, shi->co); copy_v3_v3(sample->n, shi->vno); copy_v3_v3(sample->ao, shi->ao); copy_v3_v3(sample->env, shi->env); copy_v3_v3(sample->indirect, shi->indirect); - sample->intensity= MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); - sample->intensity= MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); - sample->intensity= MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); - sample->dist2= dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); - sample->filled= 1; + sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); + sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); + sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); + sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); + sample->filled = 1; } } } } else { - shi->ao[0]= 1.0f; - shi->ao[1]= 1.0f; - shi->ao[2]= 1.0f; + shi->ao[0] = 1.0f; + shi->ao[1] = 1.0f; + shi->ao[2] = 1.0f; - shi->env[0]= 0.0f; - shi->env[1]= 0.0f; - shi->env[2]= 0.0f; + shi->env[0] = 0.0f; + shi->env[1] = 0.0f; + shi->env[2] = 0.0f; - shi->indirect[0]= 0.0f; - shi->indirect[1]= 0.0f; - shi->indirect[2]= 0.0f; + shi->indirect[0] = 0.0f; + shi->indirect[1] = 0.0f; + shi->indirect[2] = 0.0f; } } void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; PixStr ps; OcclusionCache *cache; OcclusionCacheSample *sample; OccFace exclude; ShadeInput *shi; - intptr_t *rd=NULL; - int *ro=NULL, *rp=NULL, *rz=NULL, onlyshadow; + intptr_t *rd = NULL; + int *ro = NULL, *rp = NULL, *rz = NULL, onlyshadow; int x, y, step = CACHE_STEP; if (!tree->cache) return; - cache= &tree->cache[pa->thread]; - cache->w= pa->rectx; - cache->h= pa->recty; - cache->x= pa->disprect.xmin; - cache->y= pa->disprect.ymin; - cache->step= step; - cache->sample= MEM_callocN(sizeof(OcclusionCacheSample)*cache->w*cache->h, "OcclusionCacheSample"); - sample= cache->sample; + cache = &tree->cache[pa->thread]; + cache->w = pa->rectx; + cache->h = pa->recty; + cache->x = pa->disprect.xmin; + cache->y = pa->disprect.ymin; + cache->step = step; + cache->sample = MEM_callocN(sizeof(OcclusionCacheSample) * cache->w * cache->h, "OcclusionCacheSample"); + sample = cache->sample; if (re->osa) { - rd= pa->rectdaps; + rd = pa->rectdaps; } else { /* fake pixel struct for non-osa */ - ps.next= NULL; - ps.mask= 0xFFFF; + ps.next = NULL; + ps.mask = 0xFFFF; - ro= pa->recto; - rp= pa->rectp; - rz= pa->rectz; + ro = pa->recto; + rp = pa->rectp; + rz = pa->rectz; } /* compute a sample at every step pixels */ - for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { - for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) { - if (!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax-1)) + for (y = pa->disprect.ymin; y < pa->disprect.ymax; y++) { + for (x = pa->disprect.xmin; x < pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) { + if (!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax - 1)) continue; - if (!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax-1)) + if (!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax - 1)) continue; if (re->osa) { @@ -1862,17 +1868,17 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) else { if (!*rp) continue; - ps.obi= *ro; - ps.facenr= *rp; - ps.z= *rz; + ps.obi = *ro; + ps.facenr = *rp; + ps.z = *rz; shade_samples_fill_with_ps(ssamp, &ps, x, y); } - shi= ssamp->shi; + shi = ssamp->shi; if (shi->vlr) { - onlyshadow= (shi->mat->mode & MA_ONLYSHADOW); - exclude.obi= shi->obi - re->objectinstance; - exclude.facenr= shi->vlr->index; + onlyshadow = (shi->mat->mode & MA_ONLYSHADOW); + exclude.obi = shi->obi - re->objectinstance; + exclude.facenr = shi->vlr->index; sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect); copy_v3_v3(sample->co, shi->co); @@ -1880,13 +1886,13 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) copy_v3_v3(sample->ao, shi->ao); copy_v3_v3(sample->env, shi->env); copy_v3_v3(sample->indirect, shi->indirect); - sample->intensity= MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); - sample->intensity= MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); - sample->intensity= MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); - sample->dist2= dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); - sample->x= shi->xs; - sample->y= shi->ys; - sample->filled= 1; + sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); + sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); + sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); + sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); + sample->x = shi->xs; + sample->y = shi->ys; + sample->filled = 1; } if (re->test_break(re->tbh)) @@ -1897,18 +1903,18 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) void free_occ_samples(Render *re, RenderPart *pa) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; OcclusionCache *cache; if (tree->cache) { - cache= &tree->cache[pa->thread]; + cache = &tree->cache[pa->thread]; if (cache->sample) MEM_freeN(cache->sample); - cache->w= 0; - cache->h= 0; - cache->step= 0; + cache->w = 0; + cache->h = 0; + cache->step = 0; } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index e3ecfc49a4b..701d21fbbd0 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -169,9 +169,9 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) } else { if (rs->tothalo) - fprintf(stdout, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); + fprintf(stdout, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", rs->scene_name, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); else - fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp); + fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scene_name, rs->totvert, rs->totface, rs->totlamp); } BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index f11e5d22574..8a936545903 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -99,7 +99,7 @@ static RayObject* RE_rayobject_create(Render *re, int type, int size) RayObject * res = NULL; if (type == R_RAYSTRUCTURE_AUTO) { - //TODO + /* TODO */ //if (detect_simd()) #ifdef __SSE__ type = BLI_cpu_support_sse2()? R_RAYSTRUCTURE_SIMD_SVBVH: R_RAYSTRUCTURE_VBVH; @@ -216,12 +216,12 @@ static int is_raytraceable(Render *re, ObjectInstanceRen *obi) RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi) { - //TODO - // out-of-memory safeproof - // break render - // update render stats + /*TODO + * out-of-memory safeproof + * break render + * update render stats */ ObjectRen *obr = obi->obr; - + if (obr->raytree == NULL) { RayObject *raytree; RayFace *face = NULL; @@ -421,8 +421,8 @@ void makeraytree(Render *re) re->stats_draw(re->sdh, &re->i); } else { - //Calculate raytree max_size - //This is ONLY needed to kept a bogus behavior of SUN and HEMI lights + /* Calculate raytree max_size + * This is ONLY needed to kept a bogus behavior of SUN and HEMI lights */ INIT_MINMAX(min, max); RE_rayobject_merge_bb(re->raytree, min, max); for (i=0; i<3; i++) { @@ -739,8 +739,8 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con tracol[0]= shi.r; tracol[1]= shi.g; tracol[2]= shi.b; - tracol[3]= col[3]; // we pass on and accumulate alpha - + tracol[3]= col[3]; /* we pass on and accumulate alpha */ + if ((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) { /* don't overwrite traflag, it's value is used in mirror reflection */ int new_traflag = traflag; @@ -883,12 +883,12 @@ static void DP_energy(float *table, float vec[2], int tot, float xsize, float ys } vec[0] += 0.1f*min*result[0]/(float)tot; vec[1] += 0.1f*min*result[1]/(float)tot; - // cyclic clamping + /* cyclic clamping */ vec[0]= vec[0] - xsize*floorf(vec[0]/xsize + 0.5f); vec[1]= vec[1] - ysize*floorf(vec[1]/ysize + 0.5f); } -// random offset of 1 in 2 +/* random offset of 1 in 2 */ static void jitter_plane_offset(float *jitter1, float *jitter2, int tot, float sizex, float sizey, float ofsx, float ofsy) { float dsizex= sizex*ofsx; @@ -974,10 +974,10 @@ static float *give_jitter_plane(LampRen *lar, int thread, int xs, int ys) static void halton_sample(double *ht_invprimes, double *ht_nums, double *v) { - // incremental halton sequence generator, from: - // "Instant Radiosity", Keller A. + /* incremental halton sequence generator, from: + * "Instant Radiosity", Keller A. */ unsigned int i; - + for (i = 0; i < 2; i++) { double r = fabs((1.0 - ht_nums[i]) - 1e-10); @@ -1812,7 +1812,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in float *sphere; int a; - // always returns table + /* always returns table */ sphere= threadsafe_table_sphere(0, thread, xs, ys, tot); /* total random sampling. NOT THREADSAFE! (should be removed, is not useful) */ @@ -1827,7 +1827,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in float *sphere; float *vec1; - // returns table if xs and ys were equal to last call, and not resetting + /* returns table if xs and ys were equal to last call, and not resetting */ sphere= (reset)? NULL: threadsafe_table_sphere(1, thread, xs, ys, tot); if (sphere==NULL) { float cosfi, sinfi, cost, sint; @@ -1836,7 +1836,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in sphere= threadsafe_table_sphere(0, thread, xs, ys, tot); - // random rotation + /* random rotation */ ang= BLI_thread_frand(thread); sinfi= sin(ang); cosfi= cos(ang); ang= BLI_thread_frand(thread); @@ -2056,7 +2056,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) * for strand render we always require a new sampler because x/y are not set */ vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys, shi->strand != NULL); - // warning: since we use full sphere now, and dotproduct is below, we do twice as much + /* warning: since we use full sphere now, and dotproduct is below, we do twice as much */ tot= 2*resol*resol; if (envcolor == WO_AOSKYTEX) { @@ -2116,7 +2116,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) skyadded++; } } - // samples + /* samples */ vec+= 3; } @@ -2436,7 +2436,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ shadfac[3] /= div; } else { - // sqrt makes nice umbra effect + /* sqrt makes nice umbra effect */ if (lar->ray_samp_type & LA_SAMP_UMBRA) shadfac[3]= sqrt(1.0f-fac/div); else @@ -2501,8 +2501,8 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]) isec.orig.ob = shi->obi; isec.orig.face = shi->vlr; - shadfac[3]= 1.0f; // 1.0=full light - + shadfac[3]= 1.0f; /* 1.0=full light */ + /* set up isec.dir */ copy_v3_v3(isec.start, shi->co); sub_v3_v3v3(isec.dir, lampco, isec.start); diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 3fd59b5e67c..9eb3f78635f 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -461,7 +461,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf rl->lay_zmask = srl->lay_zmask; rl->lay_exclude = srl->lay_exclude; rl->layflag = srl->layflag; - rl->passflag = srl->passflag; // for debugging: srl->passflag|SCE_PASS_RAYHITS; + rl->passflag = srl->passflag; /* for debugging: srl->passflag | SCE_PASS_RAYHITS; */ rl->pass_xor = srl->pass_xor; rl->light_override = srl->light_override; rl->mat_override = srl->mat_override; @@ -585,7 +585,7 @@ RenderResult *render_result_new_full_sample(Render *re, ListBase *lb, rcti *part } /* callbacks for render_result_new_from_exr */ -static void *ml_addlayer_cb(void *base, char *str) +static void *ml_addlayer_cb(void *base, const char *str) { RenderResult *rr = base; RenderLayer *rl; @@ -597,7 +597,7 @@ static void *ml_addlayer_cb(void *base, char *str) return rl; } -static void ml_addpass_cb(void *UNUSED(base), void *lay, char *str, float *rect, int totchan, char *chan_id) +static void ml_addpass_cb(void *UNUSED(base), void *lay, const char *str, float *rect, int totchan, const char *chan_id) { RenderLayer *rl = lay; RenderPass *rpass = MEM_callocN(sizeof(RenderPass), "loaded pass"); @@ -621,7 +621,7 @@ static void ml_addpass_cb(void *UNUSED(base), void *lay, char *str, float *rect, /* 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 *rr = MEM_callocN(sizeof(RenderResult), "loaded render result"); + RenderResult *rr = MEM_callocN(sizeof(RenderResult), __func__); RenderLayer *rl; RenderPass *rpass; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 39577bf8da8..c8ef3e4a8dd 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -244,7 +244,7 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres) texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); if (texres->nor!=NULL) { - // calculate bumpnormal + /* calculate bumpnormal */ texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + tex->nabla, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + tex->nabla, texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -254,8 +254,8 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres) } if (tex->stype==TEX_COLOR) { - // in this case, int. value should really be computed from color, - // and bumpnormal from that, would be too slow, looks ok as is + /* in this case, int. value should really be computed from color, + * and bumpnormal from that, would be too slow, looks ok as is */ texres->tr = texres->tin; texres->tg = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -538,8 +538,8 @@ static float mg_mFractalOrfBmTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); @@ -568,8 +568,8 @@ static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); @@ -593,8 +593,8 @@ static float mg_HTerrainTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mg_HeteroTerrain(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); @@ -618,8 +618,8 @@ static float mg_distNoiseTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = mg_VLNoise(texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = mg_VLNoise(texvec[0] + offs, texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); texres->nor[1] = mg_VLNoise(texvec[0], texvec[1] + offs, texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); @@ -688,7 +688,7 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres) } if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ /* calculate bumpnormal */ voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm); @@ -745,7 +745,7 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1 int ret; if (n==NULL) { - nor[0]= x; nor[1]= y; nor[2]= z; // use local render coord + nor[0]= x; nor[1]= y; nor[2]= z; /* use local render coord */ } else { copy_v3_v3(nor, n); @@ -1026,7 +1026,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], if (tex->xrepeat>1) { float origf= fx *= tex->xrepeat; - // TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call + /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */ if (tex->texfilter == TXF_BOX) { if (fx>1.0f) fx -= (int)(fx); else if (fx<0.0f) fx+= 1-(int)(fx); @@ -1046,7 +1046,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], if (tex->yrepeat>1) { float origf= fy *= tex->yrepeat; - // TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call + /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */ if (tex->texfilter == TXF_BOX) { if (fy>1.0f) fy -= (int)(fy); else if (fy<0.0f) fy+= 1-(int)(fy); @@ -1512,9 +1512,9 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, float* dx, float* dy, float* texvec, float* dxt, float* dyt) { - // new: first swap coords, then map, then trans/scale + /* new: first swap coords, then map, then trans/scale */ if (tex->type == TEX_IMAGE) { - // placement + /* placement */ texvec[0] = mtex->projx ? co[mtex->projx - 1] : 0.f; texvec[1] = mtex->projy ? co[mtex->projy - 1] : 0.f; texvec[2] = mtex->projz ? co[mtex->projz - 1] : 0.f; @@ -1538,7 +1538,7 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt); - // translate and scale + /* translate and scale */ texvec[0] = mtex->size[0]*(texvec[0] - 0.5f) + mtex->ofs[0] + 0.5f; texvec[1] = mtex->size[1]*(texvec[1] - 0.5f) + mtex->ofs[1] + 0.5f; if (shi->osatex) { @@ -1549,13 +1549,13 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } /* problem: repeat-mirror is not a 'repeat' but 'extend' in imagetexture.c */ - // TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too. - // New texfilters solve mirroring differently so that it also works correctly when - // textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping(). - // (since currently only done in osa mode, results will look incorrect without osa TODO) + /* TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too. + * New texfilters solve mirroring differently so that it also works correctly when + * textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping(). + * (since currently only done in osa mode, results will look incorrect without osa TODO) */ if (tex->extend == TEX_REPEAT && (tex->flag & TEX_REPEAT_XMIR)) { if (tex->texfilter == TXF_BOX) - texvec[0] -= floorf(texvec[0]); // this line equivalent to old code, same below + texvec[0] -= floorf(texvec[0]); /* this line equivalent to old code, same below */ else if (texvec[0] < 0.f || texvec[0] > 1.f) { const float tx = 0.5f*texvec[0]; texvec[0] = 2.f*(tx - floorf(tx)); @@ -1573,8 +1573,8 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } } - else { // procedural - // placement + else { /* procedural */ + /* placement */ texvec[0] = mtex->size[0]*(mtex->projx ? (co[mtex->projx - 1] + mtex->ofs[0]) : mtex->ofs[0]); texvec[1] = mtex->size[1]*(mtex->projy ? (co[mtex->projy - 1] + mtex->ofs[1]) : mtex->ofs[1]); texvec[2] = mtex->size[2]*(mtex->projz ? (co[mtex->projz - 1] + mtex->ofs[2]) : mtex->ofs[2]); @@ -1617,11 +1617,16 @@ static void compatible_bump_init(CompatibleBump *compat_bump) static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, int i) { - // uvmapping only, calculation of normal tangent u/v partial derivatives - // (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct, - // nu/nv in ShadeInput and this calculation should then move to shadeinput.c, shade_input_set_shade_texco() func.) - // NOTE: test for shi->obr->ob here, since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. - // NOTE: shi->v1 is NULL when called from displace_render_vert, assigning verts in this case is not trivial because the shi quad face side is not know. + /* uvmapping only, calculation of normal tangent u/v partial derivatives + * (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct, + * nu/nv in ShadeInput and this calculation should then move to shadeinput.c, + * shade_input_set_shade_texco() func.) */ + + /* NOTE: test for shi->obr->ob here, + * since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. */ + + /* NOTE: shi->v1 is NULL when called from displace_render_vert, + * assigning verts in this case is not trivial because the shi quad face side is not know. */ if ((mtex->texflag & MTEX_COMPAT_BUMP) && shi->obr && shi->obr->ob && shi->v1) { if (mtex->mapto & (MAP_NORM|MAP_WARP) && !((mtex->tex->type==TEX_IMAGE) && (mtex->tex->imaflag & TEX_NORMALMAP))) { MTFace* tf = RE_vlakren_get_tface(shi->obr, shi->vlr, i, NULL, 0); @@ -1629,9 +1634,9 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3); - // compute ortho basis around normal + /* compute ortho basis around normal */ if (!compat_bump->nunvdone) { - // render normal is negated + /* render normal is negated */ compat_bump->nn[0] = -shi->vn[0]; compat_bump->nn[1] = -shi->vn[1]; compat_bump->nn[2] = -shi->vn[2]; @@ -1672,32 +1677,32 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt) { - TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; // temp TexResult + TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */ float tco[3], texv[3], cd, ud, vd, du, dv, idu, idv; const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); const float bf = -0.04f*Tnor*mtex->norfac; int rgbnor; - // disable internal bump eval + /* disable internal bump eval */ float* nvec = texres->nor; texres->nor = NULL; - // du & dv estimates, constant value defaults + /* du & dv estimates, constant value defaults */ du = dv = 0.01f; - // compute ortho basis around normal + /* compute ortho basis around normal */ if (!compat_bump->nunvdone) { - // render normal is negated + /* render normal is negated */ negate_v3_v3(compat_bump->nn, shi->vn); ortho_basis_v3v3_v3(compat_bump->nu, compat_bump->nv, compat_bump->nn); compat_bump->nunvdone = TRUE; } - // two methods, either constant based on main image resolution, - // (which also works without osa, though of course not always good (or even very bad) results), - // or based on tex derivative max values (osa only). Not sure which is best... + /* two methods, either constant based on main image resolution, + * (which also works without osa, though of course not always good (or even very bad) results), + * or based on tex derivative max values (osa only). Not sure which is best... */ if (!shi->osatex && (tex->type == TEX_IMAGE) && tex->ima) { - // in case we have no proper derivatives, fall back to - // computing du/dv it based on image size + /* in case we have no proper derivatives, fall back to + * computing du/dv it based on image size */ ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { du = 1.f/(float)ibuf->x; @@ -1705,14 +1710,14 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, } } else if (shi->osatex) { - // we have derivatives, can compute proper du/dv - if (tex->type == TEX_IMAGE) { // 2d image, use u & v max. of dx/dy 2d vecs + /* we have derivatives, can compute proper du/dv */ + if (tex->type == TEX_IMAGE) { /* 2d image, use u & v max. of dx/dy 2d vecs */ const float adx[2] = {fabsf(dx[0]), fabsf(dx[1])}; const float ady[2] = {fabsf(dy[0]), fabsf(dy[1])}; du = MAX2(adx[0], ady[0]); dv = MAX2(adx[1], ady[1]); } - else { // 3d procedural, estimate from all dx/dy elems + else { /* 3d procedural, estimate from all dx/dy elems */ const float adx[3] = {fabsf(dx[0]), fabsf(dx[1]), fabsf(dx[2])}; const float ady[3] = {fabsf(dy[0]), fabsf(dy[1]), fabsf(dy[2])}; du = MAX3(adx[0], adx[1], adx[2]); @@ -1720,18 +1725,18 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, } } - // center, main return value + /* center, main return value */ texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); cd = fromrgb ? (texres->tr + texres->tg + texres->tb)*0.33333333f : texres->tin; if (mtex->texco == TEXCO_UV) { - // for the uv case, use the same value for both du/dv, - // since individually scaling the normal derivatives makes them useless... + /* for the uv case, use the same value for both du/dv, + * since individually scaling the normal derivatives makes them useless... */ du = MIN2(du, dv); idu = (du < 1e-5f) ? bf : (bf/du); - // +u val + /* +u val */ tco[0] = co[0] + compat_bump->dudnu*du; tco[1] = co[1] + compat_bump->dvdnu*du; tco[2] = 0.f; @@ -1739,7 +1744,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr); ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); - // +v val + /* +v val */ tco[0] = co[0] + compat_bump->dudnv*du; tco[1] = co[1] + compat_bump->dvdnv*du; tco[2] = 0.f; @@ -1773,7 +1778,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, normalize_v3(tv); } - // +u val + /* +u val */ tco[0] = co[0] + tu[0]*du; tco[1] = co[1] + tu[1]*du; tco[2] = co[2] + tu[2]*du; @@ -1781,7 +1786,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr); ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); - // +v val + /* +v val */ tco[0] = co[0] + tv[0]*dv; tco[1] = co[1] + tv[1]*dv; tco[2] = co[2] + tv[2]*dv; @@ -1790,7 +1795,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, vd = idv*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); } - // bumped normal + /* bumped normal */ compat_bump->nu[0] += ud*compat_bump->nn[0]; compat_bump->nu[1] += ud*compat_bump->nn[1]; compat_bump->nu[2] += ud*compat_bump->nn[2]; @@ -1812,13 +1817,13 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, typedef struct NTapBump { int init_done; - int iPrevBumpSpace; // 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace - // bumpmapping - float vNorg[3]; // backup copy of shi->vn - float vNacc[3]; // original surface normal minus the surface gradient of every bump map which is encountered - float vR1[3], vR2[3]; // cross products (sigma_y, original_normal), (original_normal, sigma_x) - float sgn_det; // sign of the determinant of the matrix {sigma_x, sigma_y, original_normal} - float fPrevMagnitude; // copy of previous magnitude, used for multiple bumps in different spaces + int iPrevBumpSpace; /* 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace */ + /* bumpmapping */ + float vNorg[3]; /* backup copy of shi->vn */ + float vNacc[3]; /* original surface normal minus the surface gradient of every bump map which is encountered */ + float vR1[3], vR2[3]; /* cross products (sigma_y, original_normal), (original_normal, sigma_x) */ + float sgn_det; /* sign of the determinant of the matrix {sigma_x, sigma_y, original_normal} */ + float fPrevMagnitude; /* copy of previous magnitude, used for multiple bumps in different spaces */ } NTapBump; static void ntap_bump_init(NTapBump *ntap_bump) @@ -1828,38 +1833,38 @@ static void ntap_bump_init(NTapBump *ntap_bump) static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt) { - TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; // temp TexResult + TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */ const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); - // The negate on Hscale is done because the - // normal in the renderer points inward which corresponds - // to inverting the bump map. The normals are generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* The negate on Hscale is done because the + * normal in the renderer points inward which corresponds + * to inverting the bump map. The normals are generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ float Hscale = -Tnor*mtex->norfac; int dimx=512, dimy=512; - const int imag_tspace_dimension_x = 1024; // only used for texture space variant + const int imag_tspace_dimension_x = 1024; /* only used for texture space variant */ float aspect = 1.0f; - // 2 channels for 2D texture and 3 for 3D textures. + /* 2 channels for 2D texture and 3 for 3D textures. */ const int nr_channels = (mtex->texco == TEXCO_UV)? 2 : 3; int c, rgbnor, iBumpSpace; float dHdx, dHdy; int found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP); - // disable internal bump eval in sampler, save pointer + /* disable internal bump eval in sampler, save pointer */ float *nvec = texres->nor; texres->nor = NULL; if (found_deriv_map==0) { if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) - Hscale *= 13.0f; // appears to be a sensible default value + Hscale *= 13.0f; /* appears to be a sensible default value */ } else - Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code + Hscale *= 0.1f; /* factor 0.1 proved to look like the previous bump code */ } if ( !ntap_bump->init_done ) { @@ -1871,7 +1876,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T ntap_bump->init_done = TRUE; } - // resolve image dimensions + /* resolve image dimensions */ if (found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) { ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { @@ -1883,7 +1888,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if (found_deriv_map) { float dBdu, dBdv, auto_bump = 1.0f; - float s = 1; // negate this if flipped texture coordinate + float s = 1; /* negate this if flipped texture coordinate */ texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); @@ -1895,9 +1900,9 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T float fVirtDim = sqrtf(fabsf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1])); auto_bump /= MAX2(fVirtDim, FLT_EPSILON); } - - // this variant using a derivative map is described here - // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html + + /* this variant using a derivative map is described here + * http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html */ dBdu = auto_bump*Hscale*dimx*(2*texres->tr-1); dBdv = auto_bump*Hscale*dimy*(2*texres->tg-1); @@ -1905,32 +1910,32 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T dHdy = dBdu*dyt[0] + s * dBdv*dyt[1]; } else if (!(mtex->texflag & MTEX_5TAP_BUMP)) { - // compute height derivatives with respect to output image pixel coordinates x and y + /* compute height derivatives with respect to output image pixel coordinates x and y */ float STll[3], STlr[3], STul[3]; float Hll, Hlr, Hul; texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); for (c=0; c<nr_channels; c++) { - // dx contains the derivatives (du/dx, dv/dx) - // dy contains the derivatives (du/dy, dv/dy) + /* dx contains the derivatives (du/dx, dv/dx) + * dy contains the derivatives (du/dy, dv/dy) */ STll[c] = texvec[c]; STlr[c] = texvec[c]+dxt[c]; STul[c] = texvec[c]+dyt[c]; } - // clear unused derivatives + /* clear unused derivatives */ for (c=nr_channels; c<3; c++) { STll[c] = 0.0f; STlr[c] = 0.0f; STul[c] = 0.0f; } - // use texres for the center sample, set rgbnor + /* use texres for the center sample, set rgbnor */ rgbnor = multitex_mtex(shi, mtex, STll, dxt, dyt, texres); Hll = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin; - // use ttexr for the other 2 taps + /* use ttexr for the other 2 taps */ multitex_mtex(shi, mtex, STlr, dxt, dyt, &ttexr); Hlr = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; @@ -1955,7 +1960,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T STu[c] = texvec[c] + 0.5f*dyt[c]; } - // clear unused derivatives + /* clear unused derivatives */ for (c=nr_channels; c<3; c++) { STc[c] = 0.0f; STl[c] = 0.0f; @@ -1964,11 +1969,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T STu[c] = 0.0f; } - // use texres for the center sample, set rgbnor + /* use texres for the center sample, set rgbnor */ rgbnor = multitex_mtex(shi, mtex, STc, dxt, dyt, texres); /* Hc = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin; */ /* UNUSED */ - // use ttexr for the other taps + /* use ttexr for the other taps */ multitex_mtex(shi, mtex, STl, dxt, dyt, &ttexr); Hl = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; multitex_mtex(shi, mtex, STr, dxt, dyt, &ttexr); @@ -1982,7 +1987,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T dHdy = Hscale*(Hu - Hd); } - // restore pointer + /* restore pointer */ texres->nor = nvec; /* replaced newbump with code based on listing 1 and 2 of @@ -1994,32 +1999,32 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) iBumpSpace = 2; else - iBumpSpace = 4; // ViewSpace - + iBumpSpace = 4; /* ViewSpace */ + if ( ntap_bump->iPrevBumpSpace != iBumpSpace ) { - - // initialize normal perturbation vectors + + /* initialize normal perturbation vectors */ int xyz; float fDet, abs_fDet, fMagnitude; - // object2view and inverted matrix + /* object2view and inverted matrix */ float obj2view[3][3], view2obj[3][3], tmp[4][4]; - // local copies of derivatives and normal + /* local copies of derivatives and normal */ float dPdx[3], dPdy[3], vN[3]; copy_v3_v3(dPdx, shi->dxco); copy_v3_v3(dPdy, shi->dyco); copy_v3_v3(vN, ntap_bump->vNorg); if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { - // TODO: these calculations happen for every pixel! - // -> move to shi->obi + /* TODO: these calculations happen for every pixel! + * -> move to shi->obi */ mult_m4_m4m4(tmp, R.viewmat, shi->obr->ob->obmat); - copy_m3_m4(obj2view, tmp); // use only upper left 3x3 matrix + copy_m3_m4(obj2view, tmp); /* use only upper left 3x3 matrix */ invert_m3_m3(view2obj, obj2view); - - // generate the surface derivatives in object space + + /* generate the surface derivatives in object space */ mul_m3_v3(view2obj, dPdx); mul_m3_v3(view2obj, dPdy); - // generate the unit normal in object space + /* generate the unit normal in object space */ mul_transposed_m3_v3(obj2view, vN); normalize_v3(vN); } @@ -2032,7 +2037,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) { - // crazy hack solution that gives results similar to normal mapping - part 1 + /* crazy hack solution that gives results similar to normal mapping - part 1 */ normalize_v3(ntap_bump->vR1); normalize_v3(ntap_bump->vR2); abs_fDet = 1.0f; @@ -2041,7 +2046,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T fMagnitude = abs_fDet; if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { - // pre do transform of texres->nor by the inverse transposed of obj2view + /* pre do transform of texres->nor by the inverse transposed of obj2view */ mul_transposed_m3_v3(view2obj, vN); mul_transposed_m3_v3(view2obj, ntap_bump->vR1); mul_transposed_m3_v3(view2obj, ntap_bump->vR2); @@ -2059,7 +2064,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) { - // crazy hack solution that gives results similar to normal mapping - part 2 + /* crazy hack solution that gives results similar to normal mapping - part 2 */ float vec[2]; const float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x; @@ -2072,11 +2077,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } } - // subtract the surface gradient from vNacc + /* subtract the surface gradient from vNacc */ for (c=0; c<3; c++) { float vSurfGrad_compi = ntap_bump->sgn_det * (dHdx * ntap_bump->vR1[c] + dHdy * ntap_bump->vR2[c]); ntap_bump->vNacc[c] -= vSurfGrad_compi; - texres->nor[c] = ntap_bump->vNacc[c]; // copy + texres->nor[c] = ntap_bump->vNacc[c]; /* copy */ } rgbnor |= TEX_NOR; @@ -2235,7 +2240,9 @@ void do_material_tex(ShadeInput *shi, Render *re) dy[0]= 0.0f; dy[1]= dy[2]= 0.0f; } - else continue; // can happen when texco defines disappear and it renders old files + else { + continue; /* can happen when texco defines disappear and it renders old files */ + } /* the pointer defines if bumping happens */ if (mtex->mapto & (MAP_NORM|MAP_WARP)) { @@ -2319,7 +2326,7 @@ void do_material_tex(ShadeInput *shi, Render *re) texres.nor[2]= f2*co_nor-f1*si; } } - // warping, local space + /* warping, local space */ if (mtex->mapto & MAP_WARP) { float *warpnor= texres.nor, warpnor_[3]; @@ -2335,11 +2342,11 @@ void do_material_tex(ShadeInput *shi, Render *re) } #if 0 if (mtex->texflag & MTEX_VIEWSPACE) { - // rotate to global coords + /* rotate to global coords */ if (mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { if (shi->vlr && shi->obr && shi->obr->ob) { float len= normalize_v3(texres.nor); - // can be optimized... (ton) + /* can be optimized... (ton) */ mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor); mul_mat3_m4_v3(re->viewmat, texres.nor); normalize_v3(texres.nor); @@ -2388,7 +2395,7 @@ void do_material_tex(ShadeInput *shi, Render *re) if (mtex->mapto & MAP_COLMIR) { float mirrfac= mtex->mirrfac*stencilTin; - // exception for envmap only + /* exception for envmap only */ if (tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) { fact= texres.tin*mirrfac; facm= 1.0f- fact; @@ -2565,7 +2572,7 @@ void do_material_tex(ShadeInput *shi, Render *re) else if (shi->alpha>1.0f) shi->alpha= 1.0f; } if (mtex->mapto & MAP_HAR) { - float har; // have to map to 0-1 + float har; /* have to map to 0-1 */ float hardfac= mtex->hardfac*stencilTin; har= ((float)shi->har)/128.0f; @@ -2605,7 +2612,7 @@ void do_material_tex(ShadeInput *shi, Render *re) } if ((use_compat_bump || use_ntap_bump || found_nmapping) && (shi->mat->mode & MA_TANGENT_V) != 0) { const float fnegdot = -dot_v3v3(shi->vn, shi->tang); - // apply Gram-Schmidt projection + /* apply Gram-Schmidt projection */ madd_v3_v3fl(shi->tang, shi->vn, fnegdot); normalize_v3(shi->tang); } @@ -2665,12 +2672,14 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_ copy_v3_v3(co, xyz); mul_m4_v3(re->viewinv, co); } - else continue; // can happen when texco defines disappear and it renders old files + else { + continue; /* can happen when texco defines disappear and it renders old files */ + } texres.nor= NULL; - if (tex->type==TEX_IMAGE) { - continue; /* not supported yet */ + if (tex->type == TEX_IMAGE) { + continue; /* not supported yet */ //do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } else { @@ -3381,7 +3390,7 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, void render_realtime_texture(ShadeInput *shi, Image *ima) { TexResult texr; - static Tex imatex[BLENDER_MAX_THREADS]; // threadsafe + static Tex imatex[BLENDER_MAX_THREADS]; /* threadsafe */ static int firsttime= 1; Tex *tex; float texvec[3], dx[2], dy[2]; @@ -3409,7 +3418,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima) texvec[0]= 0.5f+0.5f*suv->uv[0]; texvec[1]= 0.5f+0.5f*suv->uv[1]; - texvec[2] = 0.0f; // initalize it because imagewrap looks at it. + texvec[2] = 0.0f; /* initalize it because imagewrap looks at it. */ if (shi->osatex) { dx[0]= 0.5f*suv->dxuv[0]; dx[1]= 0.5f*suv->dxuv[1]; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 03bea0122cf..63aa6cdd139 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2098,12 +2098,12 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua normalize_v3(nor); /* in case object has scaling */ - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ shr.combined[0]= (-nor[0])/2.0f + 0.5f; shr.combined[1]= nor[1]/2.0f + 0.5f; shr.combined[2]= nor[2]/2.0f + 0.5f; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 93587734e2b..e13da98ecb4 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1561,9 +1561,9 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch)); /* new sample array */ - left->samples= BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *)); - right->samples= samples; // tmp - + left->samples = BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *)); + right->samples = samples; /* tmp */ + /* split samples */ for (a=BSPMAX_SAMPLE-1; a>=0; a--) { int comp= 0; @@ -1824,7 +1824,7 @@ static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face) if ((samp->facenr!=face->facenr || samp->obi!=face->obi) && samp->shadfac) { if (face->box.zmin < samp->zco[2]) { - if (BLI_in_rctf((rctf *)&face->box, samp->zco[0], samp->zco[1])) { + if (BLI_in_rctf_v((rctf *)&face->box, samp->zco)) { int inshadow= 0; if (face->type) { diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index f9b0de5b87d..bbdcfbb5a73 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -97,8 +97,8 @@ extern struct Render R; void shade_input_init_material(ShadeInput *shi) { /* note, keep this synced with render_types.h */ - memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); - shi->har= shi->mat->har; + memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float)); + shi->har = shi->mat->har; } /* also used as callback for nodes */ @@ -106,16 +106,16 @@ void shade_input_init_material(ShadeInput *shi) void shade_material_loop(ShadeInput *shi, ShadeResult *shr) { - shade_lamp_loop(shi, shr); /* clears shr */ + shade_lamp_loop(shi, shr); /* clears shr */ - if (shi->translucency!=0.0f) { + if (shi->translucency != 0.0f) { ShadeResult shr_t; - float fac= shi->translucency; + float fac = shi->translucency; shade_input_init_material(shi); negate_v3_v3(shi->vn, shi->vno); negate_v3(shi->facenor); - shi->depth++; /* hack to get real shadow now */ + shi->depth++; /* hack to get real shadow now */ shade_lamp_loop(shi, &shr_t); shi->depth--; @@ -133,17 +133,17 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) } /* depth >= 1 when ray-shading */ - if (shi->depth==0 || shi->volume_depth > 0) { + if (shi->depth == 0 || shi->volume_depth > 0) { if (R.r.mode & R_RAYTRACE) { - if (shi->ray_mirror!=0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { + if (shi->ray_mirror != 0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha != 1.0f)) { /* ray trace works on combined, but gives pass info */ ray_trace(shi, shr); } } /* disable adding of sky for raytransp */ if ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP)) - if ((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode==R_ADDSKY)) - shr->alpha= 1.0f; + if ((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode == R_ADDSKY)) + shr->alpha = 1.0f; } if (R.r.mode & R_RAYTRACE) { @@ -181,38 +181,38 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) } /* copy additional passes */ - if (shi->passflag & (SCE_PASS_VECTOR|SCE_PASS_NORMAL)) { + if (shi->passflag & (SCE_PASS_VECTOR | SCE_PASS_NORMAL)) { copy_v4_v4(shr->winspeed, shi->winspeed); copy_v3_v3(shr->nor, shi->vn); } /* MIST */ - if ((shi->passflag & SCE_PASS_MIST) || ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0)) { + if ((shi->passflag & SCE_PASS_MIST) || ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST) == 0)) { if (R.r.mode & R_ORTHO) - shr->mist= mistfactor(-shi->co[2], shi->co); + shr->mist = mistfactor(-shi->co[2], shi->co); else - shr->mist= mistfactor(len_v3(shi->co), shi->co); + shr->mist = mistfactor(len_v3(shi->co), shi->co); } - else shr->mist= 0.0f; + else shr->mist = 0.0f; - if ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0 ) { - alpha= shr->mist; + if ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST) == 0) { + alpha = shr->mist; } - else alpha= 1.0f; + else alpha = 1.0f; /* add mist and premul color */ - if (shr->alpha!=1.0f || alpha!=1.0f) { - float fac= alpha*(shr->alpha); - shr->combined[3]= fac; + if (shr->alpha != 1.0f || alpha != 1.0f) { + float fac = alpha * (shr->alpha); + shr->combined[3] = fac; - if (shi->mat->material_type!= MA_TYPE_VOLUME) + if (shi->mat->material_type != MA_TYPE_VOLUME) mul_v3_fl(shr->combined, fac); } else - shr->combined[3]= 1.0f; + shr->combined[3] = 1.0f; /* add z */ - shr->z= -shi->co[2]; + shr->z = -shi->co[2]; /* RAYHITS */ #if 0 @@ -258,28 +258,28 @@ void vlr_set_uv_indices(VlakRen *vlr, int *i1, int *i2, int *i3) /* indices 0 1 2 3 only */ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen *vlr, short i1, short i2, short i3) { - VertRen **vpp= &vlr->v1; + VertRen **vpp = &vlr->v1; - shi->vlr= vlr; - shi->obi= obi; - shi->obr= obi->obr; + shi->vlr = vlr; + shi->obi = obi; + shi->obr = obi->obr; - shi->v1= vpp[i1]; - shi->v2= vpp[i2]; - shi->v3= vpp[i3]; - - shi->i1= i1; - shi->i2= i2; - shi->i3= i3; + shi->v1 = vpp[i1]; + shi->v2 = vpp[i2]; + shi->v3 = vpp[i3]; + + shi->i1 = i1; + shi->i2 = i2; + shi->i3 = i3; /* note, shi->mat is set in node shaders */ - shi->mat= shi->mat_override?shi->mat_override:vlr->mat; + shi->mat = shi->mat_override ? shi->mat_override : vlr->mat; - shi->osatex= (shi->mat->texco & TEXCO_OSA); - shi->mode= shi->mat->mode_l; /* or-ed result for all nodes */ + shi->osatex = (shi->mat->texco & TEXCO_OSA); + shi->mode = shi->mat->mode_l; /* or-ed result for all nodes */ /* facenormal copy, can get flipped */ - shi->flippednor= 0; + shi->flippednor = 0; RE_vlakren_get_normal(&R, obi, vlr, shi->facenor); /* calculate vertexnormals */ @@ -303,12 +303,12 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen /* copy data from face to ShadeInput, scanline case */ void shade_input_set_triangle(ShadeInput *shi, volatile int obi, volatile int facenr, int UNUSED(normal_flip)) { - if (facenr>0) { - shi->obi= &R.objectinstance[obi]; - shi->obr= shi->obi->obr; - shi->facenr= (facenr-1) & RE_QUAD_MASK; - if ( shi->facenr < shi->obr->totvlak ) { - VlakRen *vlr= RE_findOrAddVlak(shi->obr, shi->facenr); + if (facenr > 0) { + shi->obi = &R.objectinstance[obi]; + shi->obr = shi->obi->obr; + shi->facenr = (facenr - 1) & RE_QUAD_MASK; + if (shi->facenr < shi->obr->totvlak) { + VlakRen *vlr = RE_findOrAddVlak(shi->obr, shi->facenr); if (facenr & RE_QUAD_OFFS) shade_input_set_triangle_i(shi, shi->obi, vlr, 0, 2, 3); @@ -316,10 +316,10 @@ void shade_input_set_triangle(ShadeInput *shi, volatile int obi, volatile int fa shade_input_set_triangle_i(shi, shi->obi, vlr, 0, 1, 2); } else - shi->vlr= NULL; /* general signal we got sky */ + shi->vlr = NULL; /* general signal we got sky */ } else - shi->vlr= NULL; /* general signal we got sky */ + shi->vlr = NULL; /* general signal we got sky */ } /* full osa case: copy static info */ @@ -333,18 +333,18 @@ void shade_input_copy_triangle(ShadeInput *shi, ShadeInput *from) void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spoint) { /* note, shi->mat is set in node shaders */ - shi->mat= shi->mat_override? shi->mat_override: strand->buffer->ma; + shi->mat = shi->mat_override ? shi->mat_override : strand->buffer->ma; - shi->osatex= (shi->mat->texco & TEXCO_OSA); - shi->mode= shi->mat->mode_l; /* or-ed result for all nodes */ + shi->osatex = (shi->mat->texco & TEXCO_OSA); + shi->mode = shi->mat->mode_l; /* or-ed result for all nodes */ /* shade_input_set_viewco equivalent */ copy_v3_v3(shi->co, spoint->co); copy_v3_v3(shi->view, shi->co); normalize_v3(shi->view); - shi->xs= (int)spoint->x; - shi->ys= (int)spoint->y; + shi->xs = (int)spoint->x; + shi->ys = (int)spoint->y; if (shi->osatex || (R.r.mode & R_SHADOW)) { copy_v3_v3(shi->dxco, spoint->dtco); @@ -376,27 +376,27 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert *svert, StrandPoint *spoint) { - StrandBuffer *strandbuf= strand->buffer; - ObjectRen *obr= strandbuf->obr; + StrandBuffer *strandbuf = strand->buffer; + ObjectRen *obr = strandbuf->obr; StrandVert *sv; - int mode= shi->mode; /* or-ed result for all nodes */ - short texco= shi->mat->texco; + int mode = shi->mode; /* or-ed result for all nodes */ + short texco = shi->mat->texco; if ((shi->mat->texco & TEXCO_REFL)) { /* shi->dxview, shi->dyview, not supported */ } - if (shi->osatex && (texco & (TEXCO_NORM|TEXCO_REFL))) { + if (shi->osatex && (texco & (TEXCO_NORM | TEXCO_REFL))) { /* not supported */ } - if (mode & (MA_TANGENT_V|MA_NORMAP_TANG)) { + if (mode & (MA_TANGENT_V | MA_NORMAP_TANG)) { copy_v3_v3(shi->tang, spoint->tan); copy_v3_v3(shi->nmaptang, spoint->tan); } if (mode & MA_STR_SURFDIFF) { - float *surfnor= RE_strandren_get_surfnor(obr, strand, 0); + float *surfnor = RE_strandren_get_surfnor(obr, strand, 0); if (surfnor) copy_v3_v3(shi->surfnor, surfnor); @@ -404,21 +404,21 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert copy_v3_v3(shi->surfnor, shi->vn); if (shi->mat->strand_surfnor > 0.0f) { - shi->surfdist= 0.0f; - for (sv=strand->vert; sv!=svert; sv++) - shi->surfdist+=len_v3v3(sv->co, (sv+1)->co); - shi->surfdist += spoint->t*len_v3v3(sv->co, (sv+1)->co); + shi->surfdist = 0.0f; + for (sv = strand->vert; sv != svert; sv++) + shi->surfdist += len_v3v3(sv->co, (sv + 1)->co); + shi->surfdist += spoint->t * len_v3v3(sv->co, (sv + 1)->co); } } if (R.r.mode & R_SPEED) { float *speed; - speed= RE_strandren_get_winspeed(shi->obi, strand, 0); + speed = RE_strandren_get_winspeed(shi->obi, strand, 0); if (speed) copy_v4_v4(shi->winspeed, speed); else - shi->winspeed[0]= shi->winspeed[1]= shi->winspeed[2]= shi->winspeed[3]= 0.0f; + shi->winspeed[0] = shi->winspeed[1] = shi->winspeed[2] = shi->winspeed[3] = 0.0f; } /* shade_input_set_shade_texco equivalent */ @@ -441,109 +441,109 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } if (texco & TEXCO_STRAND) { - shi->strandco= spoint->strandco; + shi->strandco = spoint->strandco; if (shi->osatex) { - shi->dxstrand= spoint->dtstrandco; - shi->dystrand= 0.0f; + shi->dxstrand = spoint->dtstrandco; + shi->dystrand = 0.0f; } } - if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE))) { + if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE))) { MCol *mcol; float *uv; char *name; int i; - shi->totuv= 0; - shi->totcol= 0; - shi->actuv= obr->actmtface; - shi->actcol= obr->actmcol; + shi->totuv = 0; + shi->totcol = 0; + shi->actuv = obr->actmtface; + shi->actcol = obr->actmcol; - if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) { - for (i=0; (mcol=RE_strandren_get_mcol(obr, strand, i, &name, 0)); i++) { - ShadeInputCol *scol= &shi->col[i]; - char *cp= (char*)mcol; + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) { + for (i = 0; (mcol = RE_strandren_get_mcol(obr, strand, i, &name, 0)); i++) { + ShadeInputCol *scol = &shi->col[i]; + char *cp = (char *)mcol; shi->totcol++; - scol->name= name; + scol->name = name; - scol->col[0]= cp[3]/255.0f; - scol->col[1]= cp[2]/255.0f; - scol->col[2]= cp[1]/255.0f; - scol->col[3]= cp[0]/255.0f; + scol->col[0] = cp[3] / 255.0f; + scol->col[1] = cp[2] / 255.0f; + scol->col[2] = cp[1] / 255.0f; + scol->col[3] = cp[0] / 255.0f; } if (shi->totcol) { - shi->vcol[0]= shi->col[shi->actcol].col[0]; - shi->vcol[1]= shi->col[shi->actcol].col[1]; - shi->vcol[2]= shi->col[shi->actcol].col[2]; - shi->vcol[3]= shi->col[shi->actcol].col[3]; + shi->vcol[0] = shi->col[shi->actcol].col[0]; + shi->vcol[1] = shi->col[shi->actcol].col[1]; + shi->vcol[2] = shi->col[shi->actcol].col[2]; + shi->vcol[3] = shi->col[shi->actcol].col[3]; } else { - shi->vcol[0]= 0.0f; - shi->vcol[1]= 0.0f; - shi->vcol[2]= 0.0f; - shi->vcol[3]= 0.0f; + shi->vcol[0] = 0.0f; + shi->vcol[1] = 0.0f; + shi->vcol[2] = 0.0f; + shi->vcol[3] = 0.0f; } } - for (i=0; (uv=RE_strandren_get_uv(obr, strand, i, &name, 0)); i++) { - ShadeInputUV *suv= &shi->uv[i]; + for (i = 0; (uv = RE_strandren_get_uv(obr, strand, i, &name, 0)); i++) { + ShadeInputUV *suv = &shi->uv[i]; shi->totuv++; - suv->name= name; + suv->name = name; if (strandbuf->overrideuv == i) { - suv->uv[0]= -1.0f; - suv->uv[1]= spoint->strandco; - suv->uv[2]= 0.0f; + suv->uv[0] = -1.0f; + suv->uv[1] = spoint->strandco; + suv->uv[2] = 0.0f; } else { - suv->uv[0]= -1.0f + 2.0f*uv[0]; - suv->uv[1]= -1.0f + 2.0f*uv[1]; - suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ + suv->uv[0] = -1.0f + 2.0f * uv[0]; + suv->uv[1] = -1.0f + 2.0f * uv[1]; + suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ } if (shi->osatex) { - suv->dxuv[0]= 0.0f; - suv->dxuv[1]= 0.0f; - suv->dyuv[0]= 0.0f; - suv->dyuv[1]= 0.0f; + suv->dxuv[0] = 0.0f; + suv->dxuv[1] = 0.0f; + suv->dyuv[0] = 0.0f; + suv->dyuv[1] = 0.0f; } - 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 ((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 (shi->totuv == 0) { - ShadeInputUV *suv= &shi->uv[0]; + ShadeInputUV *suv = &shi->uv[0]; - suv->uv[0]= 0.0f; - suv->uv[1]= spoint->strandco; - suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ + suv->uv[0] = 0.0f; + suv->uv[1] = spoint->strandco; + suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ if (mode & MA_FACETEXTURE) { /* no tface? set at 1.0f */ - shi->vcol[0]= 1.0f; - shi->vcol[1]= 1.0f; - shi->vcol[2]= 1.0f; - shi->vcol[3]= 1.0f; + shi->vcol[0] = 1.0f; + shi->vcol[1] = 1.0f; + shi->vcol[2] = 1.0f; + shi->vcol[3] = 1.0f; } } } if (texco & TEXCO_NORM) { - shi->orn[0]= -shi->vn[0]; - shi->orn[1]= -shi->vn[1]; - shi->orn[2]= -shi->vn[2]; + shi->orn[0] = -shi->vn[0]; + shi->orn[1] = -shi->vn[1]; + shi->orn[2] = -shi->vn[2]; } if (texco & TEXCO_STRESS) { @@ -551,27 +551,27 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } if (texco & TEXCO_TANGENT) { - if ((mode & MA_TANGENT_V)==0) { + if ((mode & MA_TANGENT_V) == 0) { /* just prevent surprises */ - shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; - shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; + shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f; + shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f; } } } /* this only avalailable for scanline renders */ - if (shi->depth==0) { + if (shi->depth == 0) { if (texco & TEXCO_WINDOW) { - shi->winco[0]= -1.0f + 2.0f*spoint->x/(float)R.winx; - shi->winco[1]= -1.0f + 2.0f*spoint->y/(float)R.winy; - shi->winco[2]= 0.0f; + shi->winco[0] = -1.0f + 2.0f * spoint->x / (float)R.winx; + shi->winco[1] = -1.0f + 2.0f * spoint->y / (float)R.winy; + shi->winco[2] = 0.0f; /* not supported */ if (shi->osatex) { - shi->dxwin[0]= 0.0f; - shi->dywin[1]= 0.0f; - shi->dxwin[0]= 0.0f; - shi->dywin[1]= 0.0f; + shi->dxwin[0] = 0.0f; + shi->dywin[1] = 0.0f; + shi->dxwin[0] = 0.0f; + shi->dywin[1] = 0.0f; } } @@ -581,7 +581,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } if (shi->do_manage) { - if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) { srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol); } } @@ -615,37 +615,37 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ if (R.r.mode & R_ORTHO) { /* x and y 3d coordinate can be derived from pixel coord and winmat */ - float fx= 2.0f/(R.winx*R.winmat[0][0]); - float fy= 2.0f/(R.winy*R.winmat[1][1]); + float fx = 2.0f / (R.winx * R.winmat[0][0]); + float fy = 2.0f / (R.winy * R.winmat[1][1]); - co[0]= (x - 0.5f*R.winx)*fx - R.winmat[3][0]/R.winmat[0][0]; - co[1]= (y - 0.5f*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1]; + co[0] = (x - 0.5f * R.winx) * fx - R.winmat[3][0] / R.winmat[0][0]; + co[1] = (y - 0.5f * R.winy) * fy - R.winmat[3][1] / R.winmat[1][1]; /* using a*x + b*y + c*z = d equation, (a b c) is normal */ - if (shi->facenor[2]!=0.0f) - co[2]= (dface - shi->facenor[0]*co[0] - shi->facenor[1]*co[1])/shi->facenor[2]; + if (shi->facenor[2] != 0.0f) + co[2] = (dface - shi->facenor[0] * co[0] - shi->facenor[1] * co[1]) / shi->facenor[2]; else - co[2]= 0.0f; + co[2] = 0.0f; if (dxco && dyco) { - dxco[0]= fx; - dxco[1]= 0.0f; - if (shi->facenor[2]!=0.0f) - dxco[2]= -(shi->facenor[0]*fx)/shi->facenor[2]; + dxco[0] = fx; + dxco[1] = 0.0f; + if (shi->facenor[2] != 0.0f) + dxco[2] = -(shi->facenor[0] * fx) / shi->facenor[2]; else - dxco[2]= 0.0f; + dxco[2] = 0.0f; - dyco[0]= 0.0f; - dyco[1]= fy; - if (shi->facenor[2]!=0.0f) - dyco[2]= -(shi->facenor[1]*fy)/shi->facenor[2]; + dyco[0] = 0.0f; + dyco[1] = fy; + if (shi->facenor[2] != 0.0f) + dyco[2] = -(shi->facenor[1] * fy) / shi->facenor[2]; else - dyco[2]= 0.0f; + dyco[2] = 0.0f; if (dxyview) { - if (co[2]!=0.0f) fac= 1.0f/co[2]; else fac= 0.0f; - dxyview[0]= -R.viewdx*fac; - dxyview[1]= -R.viewdy*fac; + if (co[2] != 0.0f) fac = 1.0f / co[2]; else fac = 0.0f; + dxyview[0] = -R.viewdx * fac; + dxyview[1] = -R.viewdy * fac; } } } @@ -653,30 +653,30 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v float div; div = dot_v3v3(shi->facenor, view); - if (div!=0.0f) fac= dface/div; - else fac= 0.0f; + if (div != 0.0f) fac = dface / div; + else fac = 0.0f; - co[0]= fac*view[0]; - co[1]= fac*view[1]; - co[2]= fac*view[2]; + co[0] = fac * view[0]; + co[1] = fac * view[1]; + co[2] = fac * view[2]; /* pixel dx/dy for render coord */ if (dxco && dyco) { - float u= dface/(div - R.viewdx*shi->facenor[0]); - float v= dface/(div - R.viewdy*shi->facenor[1]); - - dxco[0]= co[0]- (view[0]-R.viewdx)*u; - dxco[1]= co[1]- (view[1])*u; - dxco[2]= co[2]- (view[2])*u; + float u = dface / (div - R.viewdx * shi->facenor[0]); + float v = dface / (div - R.viewdy * shi->facenor[1]); - dyco[0]= co[0]- (view[0])*v; - dyco[1]= co[1]- (view[1]-R.viewdy)*v; - dyco[2]= co[2]- (view[2])*v; + dxco[0] = co[0] - (view[0] - R.viewdx) * u; + dxco[1] = co[1] - (view[1]) * u; + dxco[2] = co[2] - (view[2]) * u; + + dyco[0] = co[0] - (view[0]) * v; + dyco[1] = co[1] - (view[1] - R.viewdy) * v; + dyco[2] = co[2] - (view[2]) * v; if (dxyview) { - if (fac!=0.0f) fac= 1.0f/fac; - dxyview[0]= -R.viewdx*fac; - dxyview[1]= -R.viewdy*fac; + if (fac != 0.0f) fac = 1.0f / fac; + dxyview[0] = -R.viewdx * fac; + dxyview[1] = -R.viewdy * fac; } } } @@ -693,24 +693,24 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v /* from scanline pixel coordinates to 3d coordinates, requires set_triangle */ void shade_input_set_viewco(ShadeInput *shi, float x, float y, float xs, float ys, float z) { - float *dxyview= NULL, *dxco= NULL, *dyco= NULL; + float *dxyview = NULL, *dxco = NULL, *dyco = NULL; /* currently in use for dithering (soft shadow), node preview, irregular shad */ - shi->xs= (int)xs; - shi->ys= (int)ys; + shi->xs = (int)xs; + shi->ys = (int)ys; /* original scanline coordinate without jitter */ - shi->scanco[0]= x; - shi->scanco[1]= y; - shi->scanco[2]= z; + shi->scanco[0] = x; + shi->scanco[1] = y; + shi->scanco[2] = z; /* check if we need derivatives */ if (shi->osatex || (R.r.mode & R_SHADOW)) { - dxco= shi->dxco; - dyco= shi->dyco; + dxco = shi->dxco; + dyco = shi->dyco; if ((shi->mat->texco & TEXCO_REFL)) - dxyview= &shi->dxview; + dxyview = &shi->dxview; } shade_input_calc_viewco(shi, xs, ys, z, shi->view, dxyview, shi->co, dxco, dyco); @@ -719,7 +719,7 @@ void shade_input_set_viewco(ShadeInput *shi, float x, float y, float xs, float y /* calculate U and V, for scanline (silly render face u and v are in range -1 to 0) */ void shade_input_set_uv(ShadeInput *shi) { - VlakRen *vlr= shi->vlr; + VlakRen *vlr = shi->vlr; if ((vlr->flag & R_SMOOTH) || (shi->mat->texco & NEED_UV) || (shi->passflag & SCE_PASS_UV)) { float v1[3], v2[3], v3[3]; @@ -735,25 +735,25 @@ void shade_input_set_uv(ShadeInput *shi) } /* exception case for wire render of edge */ - if (vlr->v2==vlr->v3) { + if (vlr->v2 == vlr->v3) { float lend, lenc; - lend= len_v3v3(v2, v1); - lenc= len_v3v3(shi->co, v1); + lend = len_v3v3(v2, v1); + lenc = len_v3v3(shi->co, v1); - if (lend==0.0f) { - shi->u=shi->v= 0.0f; + if (lend == 0.0f) { + shi->u = shi->v = 0.0f; } else { - shi->u= - (1.0f - lenc/lend); - shi->v= 0.0f; + shi->u = -(1.0f - lenc / lend); + shi->v = 0.0f; } if (shi->osatex) { - shi->dx_u= 0.0f; - shi->dx_v= 0.0f; - shi->dy_u= 0.0f; - shi->dy_v= 0.0f; + shi->dx_u = 0.0f; + shi->dx_v = 0.0f; + shi->dy_u = 0.0f; + shi->dy_v = 0.0f; } } else { @@ -765,21 +765,21 @@ void shade_input_set_uv(ShadeInput *shi) axis_dominant_v3(&axis1, &axis2, shi->facenor); /* compute u,v and derivatives */ - t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2]; - t10= v3[axis1]-v2[axis1]; t11= v3[axis2]-v2[axis2]; + t00 = v3[axis1] - v1[axis1]; t01 = v3[axis2] - v1[axis2]; + t10 = v3[axis1] - v2[axis1]; t11 = v3[axis2] - v2[axis2]; - detsh= (t00*t11-t10*t01); - detsh= (detsh != 0.0f)? 1.0f/detsh: 0.0f; - t00*= detsh; t01*=detsh; - t10*=detsh; t11*=detsh; + detsh = (t00 * t11 - t10 * t01); + detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f; + t00 *= detsh; t01 *= detsh; + t10 *= detsh; t11 *= detsh; - shi->u= (shi->co[axis1]-v3[axis1])*t11-(shi->co[axis2]-v3[axis2])*t10; - shi->v= (shi->co[axis2]-v3[axis2])*t00-(shi->co[axis1]-v3[axis1])*t01; + shi->u = (shi->co[axis1] - v3[axis1]) * t11 - (shi->co[axis2] - v3[axis2]) * t10; + shi->v = (shi->co[axis2] - v3[axis2]) * t00 - (shi->co[axis1] - v3[axis1]) * t01; if (shi->osatex) { - shi->dx_u= shi->dxco[axis1]*t11- shi->dxco[axis2]*t10; - shi->dx_v= shi->dxco[axis2]*t00- shi->dxco[axis1]*t01; - shi->dy_u= shi->dyco[axis1]*t11- shi->dyco[axis2]*t10; - shi->dy_v= shi->dyco[axis2]*t00- shi->dyco[axis1]*t01; + shi->dx_u = shi->dxco[axis1] * t11 - shi->dxco[axis2] * t10; + shi->dx_v = shi->dxco[axis2] * t00 - shi->dxco[axis1] * t01; + shi->dy_u = shi->dyco[axis1] * t11 - shi->dyco[axis2] * t10; + shi->dy_v = shi->dyco[axis2] * t00 - shi->dyco[axis1] * t01; } /* u and v are in range -1 to 0, we allow a little bit extra but not too much, screws up speedvectors */ @@ -791,8 +791,8 @@ void shade_input_set_uv(ShadeInput *shi) void shade_input_set_normals(ShadeInput *shi) { - float u= shi->u, v= shi->v; - float l= 1.0f+u+v; + float u = shi->u, v = shi->v; + float l = 1.0f + u + v; shi->flippednor = 0; @@ -800,13 +800,13 @@ void shade_input_set_normals(ShadeInput *shi) if (!(shi->vlr->flag & R_TANGENT)) { if (dot_v3v3(shi->facenor, shi->view) < 0.0f) { negate_v3(shi->facenor); - shi->flippednor= 1; + shi->flippednor = 1; } } /* calculate vertexnormals */ if (shi->vlr->flag & R_SMOOTH) { - float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; + float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3; if (shi->flippednor) { negate_v3(n1); @@ -814,11 +814,11 @@ void shade_input_set_normals(ShadeInput *shi) negate_v3(n3); } - shi->vn[0]= l*n3[0]-u*n1[0]-v*n2[0]; - shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; - shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; + shi->vn[0] = l * n3[0] - u * n1[0] - v * n2[0]; + shi->vn[1] = l * n3[1] - u * n1[1] - v * n2[1]; + shi->vn[2] = l * n3[2] - u * n1[2] - v * n2[2]; - // use unnormalized normal (closer to games) + /* use unnormalized normal (closer to games) */ copy_v3_v3(shi->nmapnorm, shi->vn); normalize_v3(shi->vn); @@ -840,18 +840,18 @@ void shade_input_set_normals(ShadeInput *shi) /* XXX shi->flippednor messes up otherwise */ void shade_input_set_vertex_normals(ShadeInput *shi) { - float u= shi->u, v= shi->v; - float l= 1.0f+u+v; + float u = shi->u, v = shi->v; + float l = 1.0f + u + v; /* calculate vertexnormals */ if (shi->vlr->flag & R_SMOOTH) { - float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; + const float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3; - shi->vn[0]= l*n3[0]-u*n1[0]-v*n2[0]; - shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; - shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; + shi->vn[0] = l * n3[0] - u * n1[0] - v * n2[0]; + shi->vn[1] = l * n3[1] - u * n1[1] - v * n2[1]; + shi->vn[2] = l * n3[2] - u * n1[2] - v * n2[2]; - // use unnormalized normal (closer to games) + /* use unnormalized normal (closer to games) */ copy_v3_v3(shi->nmapnorm, shi->vn); normalize_v3(shi->vn); @@ -869,73 +869,61 @@ void shade_input_set_vertex_normals(ShadeInput *shi) /* use by raytrace, sss, bake to flip into the right direction */ void shade_input_flip_normals(ShadeInput *shi) { - shi->facenor[0]= -shi->facenor[0]; - shi->facenor[1]= -shi->facenor[1]; - shi->facenor[2]= -shi->facenor[2]; - - shi->vn[0]= -shi->vn[0]; - shi->vn[1]= -shi->vn[1]; - shi->vn[2]= -shi->vn[2]; - - shi->vno[0]= -shi->vno[0]; - shi->vno[1]= -shi->vno[1]; - shi->vno[2]= -shi->vno[2]; - - shi->nmapnorm[0] = -shi->nmapnorm[0]; - shi->nmapnorm[1] = -shi->nmapnorm[1]; - shi->nmapnorm[2] = -shi->nmapnorm[2]; - - shi->flippednor= !shi->flippednor; + negate_v3(shi->facenor); + negate_v3(shi->vn); + negate_v3(shi->vno); + negate_v3(shi->nmapnorm); + shi->flippednor = !shi->flippednor; } void shade_input_set_shade_texco(ShadeInput *shi) { - ObjectInstanceRen *obi= shi->obi; - ObjectRen *obr= shi->obr; - VertRen *v1= shi->v1, *v2= shi->v2, *v3= shi->v3; - float u= shi->u, v= shi->v; - float l= 1.0f+u+v, dl; - int mode= shi->mode; /* or-ed result for all nodes */ - short texco= shi->mat->texco; + ObjectInstanceRen *obi = shi->obi; + ObjectRen *obr = shi->obr; + VertRen *v1 = shi->v1, *v2 = shi->v2, *v3 = shi->v3; + float u = shi->u, v = shi->v; + float l = 1.0f + u + v, dl; + int mode = shi->mode; /* or-ed result for all nodes */ + short texco = shi->mat->texco; /* calculate dxno */ if (shi->vlr->flag & R_SMOOTH) { - if (shi->osatex && (texco & (TEXCO_NORM|TEXCO_REFL)) ) { - float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; + if (shi->osatex && (texco & (TEXCO_NORM | TEXCO_REFL)) ) { + float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3; - dl= shi->dx_u+shi->dx_v; - shi->dxno[0]= dl*n3[0]-shi->dx_u*n1[0]-shi->dx_v*n2[0]; - shi->dxno[1]= dl*n3[1]-shi->dx_u*n1[1]-shi->dx_v*n2[1]; - shi->dxno[2]= dl*n3[2]-shi->dx_u*n1[2]-shi->dx_v*n2[2]; - dl= shi->dy_u+shi->dy_v; - shi->dyno[0]= dl*n3[0]-shi->dy_u*n1[0]-shi->dy_v*n2[0]; - shi->dyno[1]= dl*n3[1]-shi->dy_u*n1[1]-shi->dy_v*n2[1]; - shi->dyno[2]= dl*n3[2]-shi->dy_u*n1[2]-shi->dy_v*n2[2]; + dl = shi->dx_u + shi->dx_v; + shi->dxno[0] = dl * n3[0] - shi->dx_u * n1[0] - shi->dx_v * n2[0]; + shi->dxno[1] = dl * n3[1] - shi->dx_u * n1[1] - shi->dx_v * n2[1]; + shi->dxno[2] = dl * n3[2] - shi->dx_u * n1[2] - shi->dx_v * n2[2]; + dl = shi->dy_u + shi->dy_v; + shi->dyno[0] = dl * n3[0] - shi->dy_u * n1[0] - shi->dy_v * n2[0]; + shi->dyno[1] = dl * n3[1] - shi->dy_u * n1[1] - shi->dy_v * n2[1]; + shi->dyno[2] = dl * n3[2] - shi->dy_u * n1[2] - shi->dy_v * n2[2]; } } /* calc tangents */ - if (mode & (MA_TANGENT_V|MA_NORMAP_TANG) || R.flag & R_NEED_TANGENT) { + if (mode & (MA_TANGENT_V | MA_NORMAP_TANG) || R.flag & R_NEED_TANGENT) { float *tangent, *s1, *s2, *s3; float tl, tu, tv; if (shi->vlr->flag & R_SMOOTH) { - tl= l; - tu= u; - tv= v; + tl = l; + tu = u; + tv = v; } else { /* qdn: flat faces have tangents too, * could pick either one, using average here */ - tl= 1.0f/3.0f; - tu= -1.0f/3.0f; - tv= -1.0f/3.0f; + tl = 1.0f / 3.0f; + tu = -1.0f / 3.0f; + tv = -1.0f / 3.0f; } - shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; - shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; + shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f; + shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f; if (mode & MA_TANGENT_V) { s1 = RE_vertren_get_tangent(obr, v1, 0); @@ -943,9 +931,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) s3 = RE_vertren_get_tangent(obr, v3, 0); if (s1 && s2 && s3) { - shi->tang[0]= (tl*s3[0] - tu*s1[0] - tv*s2[0]); - shi->tang[1]= (tl*s3[1] - tu*s1[1] - tv*s2[1]); - shi->tang[2]= (tl*s3[2] - tu*s1[2] - tv*s2[2]); + shi->tang[0] = (tl * s3[0] - tu * s1[0] - tv * s2[0]); + shi->tang[1] = (tl * s3[1] - tu * s1[1] - tv * s2[1]); + shi->tang[2] = (tl * s3[2] - tu * s1[2] - tv * s2[2]); if (obi->flag & R_TRANSFORMED) mul_m3_v3(obi->nmat, shi->tang); @@ -956,41 +944,41 @@ void shade_input_set_shade_texco(ShadeInput *shi) } if (mode & MA_NORMAP_TANG || R.flag & R_NEED_TANGENT) { - tangent= RE_vlakren_get_nmap_tangent(obr, shi->vlr, 0); + tangent = RE_vlakren_get_nmap_tangent(obr, shi->vlr, 0); if (tangent) { - int j1= shi->i1, j2= shi->i2, j3= shi->i3; + int j1 = shi->i1, j2 = shi->i2, j3 = shi->i3; float c0[3], c1[3], c2[3]; vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3); - copy_v3_v3(c0, &tangent[j1*4]); - copy_v3_v3(c1, &tangent[j2*4]); - copy_v3_v3(c2, &tangent[j3*4]); + copy_v3_v3(c0, &tangent[j1 * 4]); + copy_v3_v3(c1, &tangent[j2 * 4]); + copy_v3_v3(c2, &tangent[j3 * 4]); - // keeping tangents normalized at vertex level - // corresponds better to how it's done in game engines + /* keeping tangents normalized at vertex level + * corresponds better to how it's done in game engines */ if (obi->flag & R_TRANSFORMED) { mul_mat3_m4_v3(obi->mat, c0); normalize_v3(c0); mul_mat3_m4_v3(obi->mat, c1); normalize_v3(c1); mul_mat3_m4_v3(obi->mat, c2); normalize_v3(c2); } - - // we don't normalize the interpolated TBN tangent - // corresponds better to how it's done in game engines - shi->nmaptang[0]= (tl*c2[0] - tu*c0[0] - tv*c1[0]); - shi->nmaptang[1]= (tl*c2[1] - tu*c0[1] - tv*c1[1]); - shi->nmaptang[2]= (tl*c2[2] - tu*c0[2] - tv*c1[2]); - - // the sign is the same for all 3 vertices of any - // non degenerate triangle. - shi->nmaptang[3]= tangent[j1*4+3]; + + /* we don't normalize the interpolated TBN tangent + * corresponds better to how it's done in game engines */ + shi->nmaptang[0] = (tl * c2[0] - tu * c0[0] - tv * c1[0]); + shi->nmaptang[1] = (tl * c2[1] - tu * c0[1] - tv * c1[1]); + shi->nmaptang[2] = (tl * c2[2] - tu * c0[2] - tv * c1[2]); + + /* the sign is the same for all 3 vertices of any + * non degenerate triangle. */ + shi->nmaptang[3] = tangent[j1 * 4 + 3]; } } } if (mode & MA_STR_SURFDIFF) { - float *surfnor= RE_vlakren_get_surfnor(obr, shi->vlr, 0); + float *surfnor = RE_vlakren_get_surfnor(obr, shi->vlr, 0); if (surfnor) { copy_v3_v3(shi->surfnor, surfnor); @@ -1000,29 +988,29 @@ void shade_input_set_shade_texco(ShadeInput *shi) else copy_v3_v3(shi->surfnor, shi->vn); - shi->surfdist= 0.0f; + shi->surfdist = 0.0f; } if (R.r.mode & R_SPEED) { float *s1, *s2, *s3; - s1= RE_vertren_get_winspeed(obi, v1, 0); - s2= RE_vertren_get_winspeed(obi, v2, 0); - s3= RE_vertren_get_winspeed(obi, v3, 0); + s1 = RE_vertren_get_winspeed(obi, v1, 0); + s2 = RE_vertren_get_winspeed(obi, v2, 0); + s3 = RE_vertren_get_winspeed(obi, v3, 0); if (s1 && s2 && s3) { - shi->winspeed[0]= (l*s3[0] - u*s1[0] - v*s2[0]); - shi->winspeed[1]= (l*s3[1] - u*s1[1] - v*s2[1]); - shi->winspeed[2]= (l*s3[2] - u*s1[2] - v*s2[2]); - shi->winspeed[3]= (l*s3[3] - u*s1[3] - v*s2[3]); + shi->winspeed[0] = (l * s3[0] - u * s1[0] - v * s2[0]); + shi->winspeed[1] = (l * s3[1] - u * s1[1] - v * s2[1]); + shi->winspeed[2] = (l * s3[2] - u * s1[2] - v * s2[2]); + shi->winspeed[3] = (l * s3[3] - u * s1[3] - v * s2[3]); } else { - shi->winspeed[0]= shi->winspeed[1]= shi->winspeed[2]= shi->winspeed[3]= 0.0f; + shi->winspeed[0] = shi->winspeed[1] = shi->winspeed[2] = shi->winspeed[3] = 0.0f; } } /* pass option forces UV calc */ if (shi->passflag & SCE_PASS_UV) - texco |= (NEED_UV|TEXCO_UV); + texco |= (NEED_UV | TEXCO_UV); /* texture coordinates. shi->dxuv shi->dyuv have been set */ if (texco & NEED_UV) { @@ -1031,23 +1019,23 @@ void shade_input_set_shade_texco(ShadeInput *shi) if (v1->orco) { float *o1, *o2, *o3; - o1= v1->orco; - o2= v2->orco; - o3= v3->orco; - - shi->lo[0]= l*o3[0]-u*o1[0]-v*o2[0]; - shi->lo[1]= l*o3[1]-u*o1[1]-v*o2[1]; - shi->lo[2]= l*o3[2]-u*o1[2]-v*o2[2]; + o1 = v1->orco; + o2 = v2->orco; + o3 = v3->orco; + + shi->lo[0] = l * o3[0] - u * o1[0] - v * o2[0]; + shi->lo[1] = l * o3[1] - u * o1[1] - v * o2[1]; + shi->lo[2] = l * o3[2] - u * o1[2] - v * o2[2]; if (shi->osatex) { - dl= shi->dx_u+shi->dx_v; - shi->dxlo[0]= dl*o3[0]-shi->dx_u*o1[0]-shi->dx_v*o2[0]; - shi->dxlo[1]= dl*o3[1]-shi->dx_u*o1[1]-shi->dx_v*o2[1]; - shi->dxlo[2]= dl*o3[2]-shi->dx_u*o1[2]-shi->dx_v*o2[2]; - dl= shi->dy_u+shi->dy_v; - shi->dylo[0]= dl*o3[0]-shi->dy_u*o1[0]-shi->dy_v*o2[0]; - shi->dylo[1]= dl*o3[1]-shi->dy_u*o1[1]-shi->dy_v*o2[1]; - shi->dylo[2]= dl*o3[2]-shi->dy_u*o1[2]-shi->dy_v*o2[2]; + dl = shi->dx_u + shi->dx_v; + shi->dxlo[0] = dl * o3[0] - shi->dx_u * o1[0] - shi->dx_v * o2[0]; + shi->dxlo[1] = dl * o3[1] - shi->dx_u * o1[1] - shi->dx_v * o2[1]; + shi->dxlo[2] = dl * o3[2] - shi->dx_u * o1[2] - shi->dx_v * o2[2]; + dl = shi->dy_u + shi->dy_v; + shi->dylo[0] = dl * o3[0] - shi->dy_u * o1[0] - shi->dy_v * o2[0]; + shi->dylo[1] = dl * o3[1] - shi->dy_u * o1[1] - shi->dy_v * o2[1]; + shi->dylo[2] = dl * o3[2] - shi->dy_u * o1[2] - shi->dy_v * o2[2]; } } @@ -1066,113 +1054,113 @@ void shade_input_set_shade_texco(ShadeInput *shi) } if (texco & TEXCO_STRAND) { - shi->strandco= (l*v3->accum - u*v1->accum - v*v2->accum); + shi->strandco = (l * v3->accum - u * v1->accum - v * v2->accum); if (shi->osatex) { - dl= shi->dx_u+shi->dx_v; - shi->dxstrand= dl*v3->accum-shi->dx_u*v1->accum-shi->dx_v*v2->accum; - dl= shi->dy_u+shi->dy_v; - shi->dystrand= dl*v3->accum-shi->dy_u*v1->accum-shi->dy_v*v2->accum; + dl = shi->dx_u + shi->dx_v; + shi->dxstrand = dl * v3->accum - shi->dx_u * v1->accum - shi->dx_v * v2->accum; + dl = shi->dy_u + shi->dy_v; + shi->dystrand = dl * v3->accum - shi->dy_u * v1->accum - shi->dy_v * v2->accum; } } - if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE))) { - VlakRen *vlr= shi->vlr; + if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE))) { + VlakRen *vlr = shi->vlr; MTFace *tface; MCol *mcol; char *name; - int i, j1=shi->i1, j2=shi->i2, j3=shi->i3; + int i, j1 = shi->i1, j2 = shi->i2, j3 = shi->i3; /* uv and vcols are not copied on split, so set them according vlr divide flag */ vlr_set_uv_indices(vlr, &j1, &j2, &j3); - shi->totuv= 0; - shi->totcol= 0; - shi->actuv= obr->actmtface; - shi->actcol= obr->actmcol; + shi->totuv = 0; + shi->totcol = 0; + shi->actuv = obr->actmtface; + shi->actcol = obr->actmcol; - if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) { - for (i=0; (mcol=RE_vlakren_get_mcol(obr, vlr, i, &name, 0)); i++) { - ShadeInputCol *scol= &shi->col[i]; + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) { + for (i = 0; (mcol = RE_vlakren_get_mcol(obr, vlr, i, &name, 0)); i++) { + ShadeInputCol *scol = &shi->col[i]; char *cp1, *cp2, *cp3; float a[3]; shi->totcol++; - scol->name= name; + scol->name = name; - cp1= (char *)(mcol+j1); - cp2= (char *)(mcol+j2); - cp3= (char *)(mcol+j3); + cp1 = (char *)(mcol + j1); + cp2 = (char *)(mcol + j2); + cp3 = (char *)(mcol + j3); /* alpha values */ - a[0] = ((float)cp1[0])/255.f; - a[1] = ((float)cp2[0])/255.f; - a[2] = ((float)cp3[0])/255.f; - scol->col[3]= l*a[2] - u*a[0] - v*a[1]; + a[0] = ((float)cp1[0]) / 255.f; + a[1] = ((float)cp2[0]) / 255.f; + a[2] = ((float)cp3[0]) / 255.f; + scol->col[3] = l * a[2] - u * a[0] - v * a[1]; /* sample premultiplied color value */ - scol->col[0]= (l*((float)cp3[3])*a[2] - u*((float)cp1[3])*a[0] - v*((float)cp2[3])*a[1])/255.f; - scol->col[1]= (l*((float)cp3[2])*a[2] - u*((float)cp1[2])*a[0] - v*((float)cp2[2])*a[1])/255.f; - scol->col[2]= (l*((float)cp3[1])*a[2] - u*((float)cp1[1])*a[0] - v*((float)cp2[1])*a[1])/255.f; + scol->col[0] = (l * ((float)cp3[3]) * a[2] - u * ((float)cp1[3]) * a[0] - v * ((float)cp2[3]) * a[1]) / 255.f; + scol->col[1] = (l * ((float)cp3[2]) * a[2] - u * ((float)cp1[2]) * a[0] - v * ((float)cp2[2]) * a[1]) / 255.f; + scol->col[2] = (l * ((float)cp3[1]) * a[2] - u * ((float)cp1[1]) * a[0] - v * ((float)cp2[1]) * a[1]) / 255.f; /* if not zero alpha, restore non-multiplied color */ if (scol->col[3]) { - mul_v3_fl(scol->col, 1.0f/scol->col[3]); + mul_v3_fl(scol->col, 1.0f / scol->col[3]); } } if (shi->totcol) { - shi->vcol[0]= shi->col[shi->actcol].col[0]; - shi->vcol[1]= shi->col[shi->actcol].col[1]; - shi->vcol[2]= shi->col[shi->actcol].col[2]; - shi->vcol[3]= shi->col[shi->actcol].col[3]; + shi->vcol[0] = shi->col[shi->actcol].col[0]; + shi->vcol[1] = shi->col[shi->actcol].col[1]; + shi->vcol[2] = shi->col[shi->actcol].col[2]; + shi->vcol[3] = shi->col[shi->actcol].col[3]; } else { - shi->vcol[0]= 0.0f; - shi->vcol[1]= 0.0f; - shi->vcol[2]= 0.0f; - shi->vcol[3]= 1.0f; + shi->vcol[0] = 0.0f; + shi->vcol[1] = 0.0f; + shi->vcol[2] = 0.0f; + shi->vcol[3] = 1.0f; } } - for (i=0; (tface=RE_vlakren_get_tface(obr, vlr, i, &name, 0)); i++) { - ShadeInputUV *suv= &shi->uv[i]; + for (i = 0; (tface = RE_vlakren_get_tface(obr, vlr, i, &name, 0)); i++) { + ShadeInputUV *suv = &shi->uv[i]; float *uv1, *uv2, *uv3; shi->totuv++; - suv->name= name; - - uv1= tface->uv[j1]; - uv2= tface->uv[j2]; - uv3= tface->uv[j3]; + suv->name = name; - 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 */ + 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->osatex) { float duv[2]; - dl= shi->dx_u+shi->dx_v; - duv[0]= shi->dx_u; - duv[1]= shi->dx_v; - - 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]); + dl = shi->dx_u + shi->dx_v; + duv[0] = shi->dx_u; + duv[1] = shi->dx_v; + + 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 ((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 ((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); @@ -1182,79 +1170,79 @@ void shade_input_set_shade_texco(ShadeInput *shi) } - shi->dupliuv[0]= -1.0f + 2.0f*obi->dupliuv[0]; - shi->dupliuv[1]= -1.0f + 2.0f*obi->dupliuv[1]; - shi->dupliuv[2]= 0.0f; + shi->dupliuv[0] = -1.0f + 2.0f * obi->dupliuv[0]; + shi->dupliuv[1] = -1.0f + 2.0f * obi->dupliuv[1]; + shi->dupliuv[2] = 0.0f; if (shi->totuv == 0) { - ShadeInputUV *suv= &shi->uv[0]; + ShadeInputUV *suv = &shi->uv[0]; - suv->uv[0]= 2.0f*(u+.5f); - suv->uv[1]= 2.0f*(v+.5f); - suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ + suv->uv[0] = 2.0f * (u + .5f); + suv->uv[1] = 2.0f * (v + .5f); + suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ if (mode & MA_FACETEXTURE) { /* no tface? set at 1.0f */ - shi->vcol[0]= 1.0f; - shi->vcol[1]= 1.0f; - shi->vcol[2]= 1.0f; - shi->vcol[3]= 1.0f; + shi->vcol[0] = 1.0f; + shi->vcol[1] = 1.0f; + shi->vcol[2] = 1.0f; + shi->vcol[3] = 1.0f; } } } if (texco & TEXCO_NORM) { - shi->orn[0]= -shi->vn[0]; - shi->orn[1]= -shi->vn[1]; - shi->orn[2]= -shi->vn[2]; + shi->orn[0] = -shi->vn[0]; + shi->orn[1] = -shi->vn[1]; + shi->orn[2] = -shi->vn[2]; } if (texco & TEXCO_STRESS) { float *s1, *s2, *s3; - s1= RE_vertren_get_stress(obr, v1, 0); - s2= RE_vertren_get_stress(obr, v2, 0); - s3= RE_vertren_get_stress(obr, v3, 0); + s1 = RE_vertren_get_stress(obr, v1, 0); + s2 = RE_vertren_get_stress(obr, v2, 0); + s3 = RE_vertren_get_stress(obr, v3, 0); if (s1 && s2 && s3) { - shi->stress= l*s3[0] - u*s1[0] - v*s2[0]; - if (shi->stress<1.0f) shi->stress-= 1.0f; - else shi->stress= (shi->stress-1.0f)/shi->stress; + shi->stress = l * s3[0] - u * s1[0] - v * s2[0]; + if (shi->stress < 1.0f) shi->stress -= 1.0f; + else shi->stress = (shi->stress - 1.0f) / shi->stress; } - else shi->stress= 0.0f; + else shi->stress = 0.0f; } if (texco & TEXCO_TANGENT) { - if ((mode & MA_TANGENT_V)==0) { + if ((mode & MA_TANGENT_V) == 0) { /* just prevent surprises */ - shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; - shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; + shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f; + shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f; } } } /* this only avalailable for scanline renders */ - if (shi->depth==0) { - float x= shi->xs; - float y= shi->ys; + if (shi->depth == 0) { + float x = shi->xs; + float y = shi->ys; if (texco & TEXCO_WINDOW) { - shi->winco[0]= -1.0f + 2.0f*x/(float)R.winx; - shi->winco[1]= -1.0f + 2.0f*y/(float)R.winy; - shi->winco[2]= 0.0f; + shi->winco[0] = -1.0f + 2.0f * x / (float)R.winx; + shi->winco[1] = -1.0f + 2.0f * y / (float)R.winy; + shi->winco[2] = 0.0f; if (shi->osatex) { - shi->dxwin[0]= 2.0f/(float)R.winx; - shi->dywin[1]= 2.0f/(float)R.winy; - shi->dxwin[1]= shi->dxwin[2]= 0.0f; - shi->dywin[0]= shi->dywin[2]= 0.0f; + shi->dxwin[0] = 2.0f / (float)R.winx; + shi->dywin[1] = 2.0f / (float)R.winy; + shi->dxwin[1] = shi->dxwin[2] = 0.0f; + 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); + 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]; @@ -1263,7 +1251,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) float s00, s01, s10, s11, detsh; /* old globals, localized now */ - Zmulx= ((float)R.winx)/2.0f; Zmuly= ((float)R.winy)/2.0f; + Zmulx = ((float)R.winx) / 2.0f; Zmuly = ((float)R.winy) / 2.0f; zbuf_make_winmat(&R, winmat); if (shi->obi->flag & R_TRANSFORMED) @@ -1275,40 +1263,40 @@ void shade_input_set_shade_texco(ShadeInput *shi) 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; + 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; + 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]; + 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]; } } } @@ -1319,7 +1307,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) * else un-initialized values are used */ if (shi->do_manage) { - if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) { srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol); } } @@ -1334,16 +1322,16 @@ void shade_input_initialize(ShadeInput *shi, RenderPart *pa, RenderLayer *rl, in memset(shi, 0, sizeof(ShadeInput)); - 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); - shi->lay= rl->lay; - shi->layflag= rl->layflag; - shi->passflag= rl->passflag; - shi->combinedflag= ~rl->pass_xor; - shi->mat_override= rl->mat_override; - shi->light_override= rl->light_override; + 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); + shi->lay = rl->lay; + shi->layflag = rl->layflag; + shi->passflag = rl->passflag; + shi->combinedflag = ~rl->pass_xor; + shi->mat_override = rl->mat_override; + shi->light_override = rl->light_override; // shi->rl= rl; /* note shi.depth==0 means first hit, not raytracing */ @@ -1354,9 +1342,9 @@ void shade_sample_initialize(ShadeSample *ssamp, RenderPart *pa, RenderLayer *rl { int a, tot; - tot= R.osa==0?1:R.osa; + tot = R.osa == 0 ? 1 : R.osa; - for (a=0; a<tot; a++) { + for (a = 0; a < tot; a++) { shade_input_initialize(&ssamp->shi[a], pa, rl, a); memset(&ssamp->shr[a], 0, sizeof(ShadeResult)); } @@ -1372,16 +1360,16 @@ void shade_samples_do_AO(ShadeSample *ssamp) if (!(R.r.mode & R_RAYTRACE) && !(R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) return; - if (R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) { - ShadeInput *shi= &ssamp->shi[0]; + if (R.wrld.mode & (WO_AMB_OCC | WO_ENV_LIGHT | WO_INDIRECT_LIGHT)) { + ShadeInput *shi = &ssamp->shi[0]; int sample; - if (((shi->passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) || - (shi->passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) + if (((shi->passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO | SCE_PASS_ENVIRONMENT | SCE_PASS_INDIRECT))) || + (shi->passflag & (SCE_PASS_AO | SCE_PASS_ENVIRONMENT | SCE_PASS_INDIRECT))) { - for (sample=0; sample<ssamp->tot; shi++, sample++) + for (sample = 0; sample < ssamp->tot; shi++, sample++) if (!(shi->mode & MA_SHLESS)) - ambient_occlusion(shi); /* stores in shi->ao[] */ + ambient_occlusion(shi); /* stores in shi->ao[] */ } } } @@ -1392,55 +1380,55 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) ShadeInput *shi; float xs, ys; - ssamp->tot= 0; + ssamp->tot = 0; - for (shi= ssamp->shi; ps; ps= ps->next) { + for (shi = ssamp->shi; ps; ps = ps->next) { shade_input_set_triangle(shi, ps->obi, ps->facenr, 1); - if (shi->vlr) { /* NULL happens for env material or for 'all z' */ - unsigned short curmask= ps->mask; + if (shi->vlr) { /* NULL happens for env material or for 'all z' */ + unsigned short curmask = ps->mask; /* full osa is only set for OSA renders */ if (shi->vlr->flag & R_FULL_OSA) { - short shi_cp= 0, samp; + short shi_cp = 0, samp; - for (samp=0; samp<R.osa; samp++) { - if (curmask & (1<<samp)) { + for (samp = 0; samp < R.osa; samp++) { + if (curmask & (1 << samp)) { /* zbuffer has this inverse corrected, ensures xs,ys are inside pixel */ - xs= (float)x + R.jit[samp][0] + 0.5f; - ys= (float)y + R.jit[samp][1] + 0.5f; + xs = (float)x + R.jit[samp][0] + 0.5f; + ys = (float)y + R.jit[samp][1] + 0.5f; if (shi_cp) - shade_input_copy_triangle(shi, shi-1); + shade_input_copy_triangle(shi, shi - 1); - shi->mask= (1<<samp); + shi->mask = (1 << samp); // shi->rl= ssamp->rlpp[samp]; - shi->samplenr= R.shadowsamplenr[shi->thread]++; /* this counter is not being reset per pixel */ + shi->samplenr = R.shadowsamplenr[shi->thread]++; /* this counter is not being reset per pixel */ shade_input_set_viewco(shi, x, y, xs, ys, (float)ps->z); shade_input_set_uv(shi); - if (shi_cp==0) + if (shi_cp == 0) shade_input_set_normals(shi); else /* XXX shi->flippednor messes up otherwise */ shade_input_set_vertex_normals(shi); - shi_cp= 1; + shi_cp = 1; shi++; } } } else { if (R.osa) { - short b= R.samples->centmask[curmask]; - xs= (float)x + R.samples->centLut[b & 15] + 0.5f; - ys= (float)y + R.samples->centLut[b>>4] + 0.5f; + short b = R.samples->centmask[curmask]; + xs = (float)x + R.samples->centLut[b & 15] + 0.5f; + ys = (float)y + R.samples->centLut[b >> 4] + 0.5f; } else { - xs= (float)x + 0.5f; - ys= (float)y + 0.5f; + xs = (float)x + 0.5f; + ys = (float)y + 0.5f; } - shi->mask= curmask; - shi->samplenr= R.shadowsamplenr[shi->thread]++; + shi->mask = curmask; + shi->samplenr = R.shadowsamplenr[shi->thread]++; shade_input_set_viewco(shi, x, y, xs, ys, (float)ps->z); shade_input_set_uv(shi); shade_input_set_normals(shi); @@ -1448,8 +1436,8 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) } /* total sample amount, shi->sample is static set in initialize */ - if (shi!=ssamp->shi) - ssamp->tot= (shi-1)->sample + 1; + if (shi != ssamp->shi) + ssamp->tot = (shi - 1)->sample + 1; } } } @@ -1460,24 +1448,24 @@ int shade_samples(ShadeSample *ssamp, PixStr *ps, int x, int y) shade_samples_fill_with_ps(ssamp, ps, x, y); if (ssamp->tot) { - ShadeInput *shi= ssamp->shi; - ShadeResult *shr= ssamp->shr; + ShadeInput *shi = ssamp->shi; + ShadeResult *shr = ssamp->shr; int samp; /* if shadow or AO? */ shade_samples_do_AO(ssamp); /* if shade (all shadepinputs have same passflag) */ - if (ssamp->shi[0].passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) { + if (ssamp->shi[0].passflag & ~(SCE_PASS_Z | SCE_PASS_INDEXOB | SCE_PASS_INDEXMA)) { - for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) { + for (samp = 0; samp < ssamp->tot; samp++, shi++, shr++) { shade_input_set_shade_texco(shi); shade_input_do_shade(shi, shr); } } else if (shi->passflag & SCE_PASS_Z) { - for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) - shr->z= -shi->co[2]; + for (samp = 0; samp < ssamp->tot; samp++, shi++, shr++) + shr->z = -shi->co[2]; } return 1; diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index c2e21af4ad2..75afeb78868 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -173,7 +173,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) p1[1]= shi->co[1]-lar->co[1]; p1[2]= -lar->co[2]; mul_m3_v3(lar->imat, p1); - copy_v3db_v3fl(npos, p1); // npos is double! + copy_v3db_v3fl(npos, p1); /* npos is double! */ /* pre-scale */ npos[2] *= (double)lar->sh_zfac; @@ -371,11 +371,12 @@ void renderspothalo(ShadeInput *shi, float col[4], float alpha) continue; spothalo(lar, shi, &i); - if (i>0.0f) { - col[3]+= i*alpha; // all premul - col[0]+= i*lar->r*alpha; - col[1]+= i*lar->g*alpha; - col[2]+= i*lar->b*alpha; + if (i > 0.0f) { + const float i_alpha = i * alpha; + col[0] += i_alpha * lar->r; + col[1] += i_alpha * lar->g; + col[2] += i_alpha * lar->b; + col[3] += i_alpha; /* all premul */ } } } @@ -519,7 +520,7 @@ static float area_lamp_energy_multisample(LampRen *lar, const float co[3], float } intens /= (float)lar->ray_totsamp; - return pow(intens*lar->areasize, lar->k); // corrected for buttons size and lar->dist^2 + return pow(intens * lar->areasize, lar->k); /* corrected for buttons size and lar->dist^2 */ } static float spec(float inp, int hard) @@ -932,7 +933,7 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa /* MA_RAMP_IN_RESULT is exceptional */ if (ma->rampin_col==MA_RAMP_IN_RESULT) { - // normal add + /* normal add */ diff[0] += r * shi->r; diff[1] += g * shi->g; diff[2] += b * shi->b; @@ -1368,10 +1369,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* diffuse shaders */ if (lar->mode & LA_NO_DIFF) { - is= 0.0f; // skip shaders + is = 0.0f; /* skip shaders */ } else if (lar->type==LA_HEMI) { - is= 0.5f*inp + 0.5f; + is = 0.5f * inp + 0.5f; } else { @@ -1383,12 +1384,13 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int else if (ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(vn, lv, view, ma->param[0], ma->param[1]); else if (ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(inp, vn, view, ma->darkness); else if (ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(vn, lv, view, ma->param[0], ma->param[1]); - else is= inp; // Lambert + else is= inp; /* Lambert */ } - + /* 'is' is diffuse */ - if ((ma->shade_flag & MA_CUBIC) && is>0.0f && is<1.0f) - is= 3.0f*is*is - 2.0f*is*is*is; // nicer termination of shades + if ((ma->shade_flag & MA_CUBIC) && is > 0.0f && is < 1.0f) { + is= 3.0f * is * is - 2.0f * is * is * is; /* nicer termination of shades */ + } i= is*phongcorr; @@ -1397,7 +1399,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int } i_noshad= i; - vn= shi->vn; // bring back original vector, we use special specular shaders for tangent + vn = shi->vn; /* bring back original vector, we use special specular shaders for tangent */ if (ma->mode & MA_TANGENT_V) vn= shi->tang; @@ -1734,7 +1736,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) return; } - if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { // vertexcolor light + if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { /* vertexcolor light */ shr->emit[0]= shi->r*(shi->emit+shi->vcol[0]*shi->vcol[3]); shr->emit[1]= shi->g*(shi->emit+shi->vcol[1]*shi->vcol[3]); shr->emit[2]= shi->b*(shi->emit+shi->vcol[2]*shi->vcol[3]); @@ -1755,8 +1757,8 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if (shi->depth || shi->volume_depth) ambient_occlusion(shi); copy_v3_v3(shr->ao, shi->ao); - copy_v3_v3(shr->env, shi->env); // XXX multiply - copy_v3_v3(shr->indirect, shi->indirect); // XXX multiply + copy_v3_v3(shr->env, shi->env); /* XXX multiply */ + copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */ } } } diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index 9187bea641d..ddc7dff7b06 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -174,7 +174,7 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b DirectionToThetaPhi(sunsky->toSun, &sunsky->theta, &sunsky->phi); - sunsky->sunSolidAngle = 0.25 * M_PI * 1.39 * 1.39 / (150 * 150); // = 6.7443e-05 + sunsky->sunSolidAngle = 0.25 * M_PI * 1.39 * 1.39 / (150 * 150); /* = 6.7443e-05 */ theta2 = sunsky->theta * sunsky->theta; theta3 = theta2 * sunsky->theta; @@ -183,7 +183,7 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b chi = (4.0f / 9.0f - T / 120.0f) * ((float)M_PI - 2.0f * sunsky->theta); sunsky->zenith_Y = (4.0453f * T - 4.9710f) * tanf(chi) - 0.2155f * T + 2.4192f; - sunsky->zenith_Y *= 1000; // conversion from kcd/m^2 to cd/m^2 + sunsky->zenith_Y *= 1000; /* conversion from kcd/m^2 to cd/m^2 */ if (sunsky->zenith_Y <= 0) sunsky->zenith_Y = 1e-6; @@ -272,7 +272,7 @@ void GetSkyXYZRadiance(struct SunSky *sunsky, float theta, float phi, float colo gamma = AngleBetween(theta, phi, sunsky->theta, sunsky->phi); - // Compute xyY values + /* Compute xyY values */ x = PerezFunction(sunsky, sunsky->perez_x, theta, gamma, sunsky->zenith_x); y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y); Y = 6.666666667e-5f *nfade *hfade *PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y); @@ -340,13 +340,13 @@ static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3]) m = 1.0f / (cosf(theta) + 0.15f * powf(93.885f - theta / (float)M_PI * 180.0f, -1.253f)); for (i = 0; i < 3; i++) { - // Rayleigh Scattering + /* Rayleigh Scattering */ fTauR = expf(-m * 0.008735f * powf(fLambda[i], (float)(-4.08f))); - // Aerosal (water + dust) attenuation + /* Aerosal (water + dust) attenuation */ fTauA = exp(-m * fBeta * powf(fLambda[i], -fAlpha)); - fTau[i] = fTauR * fTauA; + fTau[i] = fTauR * fTauA; } } @@ -366,7 +366,7 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r float inscattf, float extincf, float disf) { const float pi = M_PI; - const float n = 1.003f; // refractive index + const float n = 1.003f; /* refractive index */ const float N = 2.545e25; const float pn = 0.035f; const float T = 2.0f; @@ -406,16 +406,16 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r vLambda4[1] = fLambda4[1]; vLambda4[2] = fLambda4[2]; - // Rayleigh scattering constants. + /* Rayleigh scattering constants. */ fTemp = pi * pi * (n * n - 1) * (n * n - 1) * (6 + 3 * pn) / (6 - 7 * pn) / N; fBeta = 8 * fTemp * pi / 3; - + VEC3OPF(sunSky->atm_BetaRay, vLambda4, *, fBeta); fBetaDash = fTemp / 2; VEC3OPF(sunSky->atm_BetaDashRay, vLambda4, *, fBetaDash); - - // Mie scattering constants. + + /* Mie scattering constants. */ fTemp2 = 0.434f * c * (2 * pi) * (2 * pi) * 0.5f; VEC3OPF(sunSky->atm_BetaDashMie, vLambda2, *, fTemp2); @@ -457,23 +457,23 @@ void AtmospherePixleShader(struct SunSky *sunSky, float view[3], float s, float sunDirection[0] = sunSky->toSun[0]; sunDirection[1] = sunSky->toSun[1]; sunDirection[2] = sunSky->toSun[2]; - - costheta = dot_v3v3(view, sunDirection); // cos(theta) - Phase_1 = 1 + (costheta * costheta); // Phase_1 - + + costheta = dot_v3v3(view, sunDirection); /* cos(theta) */ + Phase_1 = 1 + (costheta * costheta); /* Phase_1 */ + VEC3OPF(sunSky->atm_BetaRay, sunSky->atm_BetaRay, *, sunSky->atm_BetaRayMultiplier); VEC3OPF(sunSky->atm_BetaMie, sunSky->atm_BetaMie, *, sunSky->atm_BetaMieMultiplier); VEC3OPV(sunSky->atm_BetaRM, sunSky->atm_BetaRay, +, sunSky->atm_BetaMie); - - //e^(-(beta_1 + beta_2) * s) = E1 + + /* e^(-(beta_1 + beta_2) * s) = E1 */ VEC3OPF(E1, sunSky->atm_BetaRM, *, -s / (float)M_LN2); E1[0] = exp(E1[0]); E1[1] = exp(E1[1]); E1[2] = exp(E1[2]); copy_v3_v3(E, E1); - - //Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) + + /* Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) */ fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta; fTemp = fTemp * sqrtf(fTemp); Phase_2 = (1 - sunSky->atm_HGg * sunSky->atm_HGg) / fTemp; @@ -491,8 +491,8 @@ void AtmospherePixleShader(struct SunSky *sunSky, float view[3], float s, float VEC3OPF(I, I, *, sunSky->atm_InscatteringMultiplier); VEC3OPF(E, E, *, sunSky->atm_ExtinctionMultiplier); - - //scale to color sun + + /* scale to color sun */ ComputeAttenuatedSunlight(sunSky->theta, sunSky->turbidity, sunColor); VEC3OPV(E, E, *, sunColor); diff --git a/source/blender/render/intern/source/texture_ocean.c b/source/blender/render/intern/source/texture_ocean.c index 4ef88e4740a..5071303dff7 100644 --- a/source/blender/render/intern/source/texture_ocean.c +++ b/source/blender/render/intern/source/texture_ocean.c @@ -81,12 +81,12 @@ int ocean_texture(Tex *tex, float *texvec, TexResult *texres) if (omd->oceancache && omd->cached == TRUE) { CLAMP(cfra, omd->bakestart, omd->bakeend); - cfra -= omd->bakestart; // shift to 0 based + cfra -= omd->bakestart; /* shift to 0 based */ BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); } - else { // non-cached + else { /* non-cached */ if (G.rendering) BKE_ocean_eval_uv_catrom(omd->ocean, &ocr, u, v); diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index ea6b9b890ac..8a92695a15e 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -261,14 +261,14 @@ static void lightcache_filter2(VolumePrecache *vp) } #endif -BLI_INLINE int ms_I(int x, int y, int z, int *n) //has a pad of 1 voxel surrounding the core for boundary simulation -{ +BLI_INLINE int ms_I(int x, int y, int z, int *n) /* has a pad of 1 voxel surrounding the core for boundary simulation */ +{ /* different ordering to light cache */ - return x*(n[1]+2)*(n[2]+2) + y*(n[2]+2) + z; + return x*(n[1]+2)*(n[2]+2) + y*(n[2]+2) + z; } -BLI_INLINE int v_I_pad(int x, int y, int z, int *n) //has a pad of 1 voxel surrounding the core for boundary simulation -{ +BLI_INLINE int v_I_pad(int x, int y, int z, int *n) /* has a pad of 1 voxel surrounding the core for boundary simulation */ +{ /* same ordering to light cache, with padding */ return z*(n[1]+2)*(n[0]+2) + y*(n[0]+2) + x; } @@ -465,7 +465,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi -#if 0 // debug stuff +#if 0 /* debug stuff */ static void *vol_precache_part_test(void *data) { VolPrecachePart *pa = data; @@ -526,10 +526,10 @@ static void *vol_precache_part(void *data) /* convert from world->camera space for shading */ mul_v3_m4v3(cco, pa->viewmat, co); - + i = BLI_VOXEL_INDEX(x, y, z, res); - - // don't bother if the point is not inside the volume mesh + + /* don't bother if the point is not inside the volume mesh */ if (!point_inside_obi(tree, obi, cco)) { obi->volume_precache->data_r[i] = -1.0f; obi->volume_precache->data_g[i] = -1.0f; @@ -563,7 +563,7 @@ static void precache_setup_shadeinput(Render *re, ObjectInstanceRen *obi, Materi shi->mask= 1; shi->mat = ma; shi->vlr = NULL; - memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); // note, keep this synced with render_types.h + memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); /* note, keep this synced with render_types.h */ shi->har= shi->mat->har; shi->obi= obi; shi->obr= obi->obr; @@ -757,7 +757,8 @@ static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *o BLI_freelistN(&re->volume_precache_parts); if (tree) { - //TODO: makeraytree_object creates a tree and saves it on OBI, if we free this tree we should also clear other pointers to it + /* TODO: makeraytree_object creates a tree and saves it on OBI, + * if we free this tree we should also clear other pointers to it */ //RE_rayobject_free(tree); //tree= NULL; } diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index c1f85914479..67e453577e4 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -253,9 +253,9 @@ static float metadensity(Object *ob, const float co[3]) /* element rotation transform */ float tp[3] = {ml->x - tco[0], ml->y - tco[1], ml->z - tco[2]}; quat_to_mat3(bmat, ml->quat); - transpose_m3(bmat); // rot.only, so inverse == transpose + transpose_m3(bmat); /* rot.only, so inverse == transpose */ mul_m3_v3(bmat, tp); - + /* MB_BALL default */ switch (ml->type) { case MB_ELIPSOID: @@ -263,14 +263,14 @@ static float metadensity(Object *ob, const float co[3]) break; case MB_CUBE: tp[2] = (tp[2] > ml->expz) ? (tp[2] - ml->expz) : ((tp[2] < -ml->expz) ? (tp[2] + ml->expz) : 0.f); - // no break, xy as plane + /* no break, xy as plane */ case MB_PLANE: tp[1] = (tp[1] > ml->expy) ? (tp[1] - ml->expy) : ((tp[1] < -ml->expy) ? (tp[1] + ml->expy) : 0.f); - // no break, x as tube + /* no break, x as tube */ case MB_TUBE: tp[0] = (tp[0] > ml->expx) ? (tp[0] - ml->expx) : ((tp[0] < -ml->expx) ? (tp[0] + ml->expx) : 0.f); } - + /* ml->rad2 is not set */ dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad)); if (dist2 > 0.f) @@ -289,7 +289,7 @@ float vol_get_density(struct ShadeInput *shi, const float co[3]) if (shi->mat->mapto_textured & MAP_DENSITY) do_volume_tex(shi, co, MAP_DENSITY, NULL, &density, &R); - // if meta-object, modulate by metadensity without increasing it + /* if meta-object, modulate by metadensity without increasing it */ if (shi->obi->obr->ob->type == OB_MBALL) { const float md = metadensity(shi->obi->obr->ob, co); if (md < 1.f) density *= md; diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 7d54f77fc90..d73171648fb 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -240,7 +240,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) copy_v3_v3_int(vd->resol, smd->domain->res); totRes = vd_resol_size(vd); - // scaling heat values from -2.0-2.0 to 0.0-1.0 + /* scaling heat values from -2.0-2.0 to 0.0-1.0 */ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); @@ -250,7 +250,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) vd->dataset[i] = (heat[i] + 2.0f) / 4.0f; } - //vd->dataset = smoke_get_heat(smd->domain->fluid); + /* vd->dataset = smoke_get_heat(smd->domain->fluid); */ } else if (vd->smoked_type == TEX_VD_SMOKEVEL) { size_t totRes; @@ -260,7 +260,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) copy_v3_v3_int(vd->resol, smd->domain->res); totRes = vd_resol_size(vd); - // scaling heat values from -2.0-2.0 to 0.0-1.0 + /* scaling heat values from -2.0-2.0 to 0.0-1.0 */ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); xvel = smoke_get_velocity_x(smd->domain->fluid); @@ -290,7 +290,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) /* always store copy, as smoke internal data can change */ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); memcpy(vd->dataset, density, sizeof(float) * totRes); - } // end of fluid condition + } /* end of fluid condition */ } } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index c88858c44da..1ebb963a790 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -466,7 +466,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co vergz= v1[2]; vergz-= zspan->polygon_offset; dz= (v2[2]-v1[2])/dx; - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= (int *)(zspan->arectz+zspan->rectx*(oldy) +start); rectmask= (int *)(zspan->rectmask+zspan->rectx*(oldy) +start); @@ -537,7 +537,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co vergz= v1[2]; vergz-= zspan->polygon_offset; dz= (v2[2]-v1[2])/dy; - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= (int *)( zspan->arectz+ (start)*zspan->rectx+ oldx ); rectmask= (int *)( zspan->rectmask+ (start)*zspan->rectx+ oldx ); @@ -619,7 +619,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], cons vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dx); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + oldy*zspan->rectx+ start; rectp= zspan->rectp + oldy*zspan->rectx+ start; @@ -678,7 +678,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], cons vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dy); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + start*zspan->rectx+ oldx; rectp= zspan->rectp + start*zspan->rectx+ oldx; @@ -749,7 +749,7 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), con vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dx); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + oldy*zspan->rectx+ start; if (zspan->rectz1) @@ -806,8 +806,8 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), con vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dy); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow - + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ + rectz= zspan->rectz + start*zspan->rectx+ oldx; if (zspan->rectz1) rectz1= zspan->rectz1 + start*zspan->rectx+ oldx; @@ -1447,21 +1447,21 @@ void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, zxd= -(double)x0/(double)z0; zyd= -(double)y0/(double)z0; zy0= ((double)my2)*zyd + (double)xx1; - - z1= 1.0f; // (u1 - u2) - z2= 0.0f; // (u2 - u3) + + z1= 1.0f; /* (u1 - u2) */ + z2= 0.0f; /* (u2 - u3) */ x0= y1*z2-z1*y2; y0= z1*x2-x1*z2; - - xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; + + xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; uxd= -(double)x0/(double)z0; uyd= -(double)y0/(double)z0; uy0= ((double)my2)*uyd + (double)xx1; - z1= -1.0f; // (v1 - v2) - z2= 1.0f; // (v2 - v3) - + z1= -1.0f; /* (v1 - v2) */ + z2= 1.0f; /* (v2 - v3) */ + x0= y1*z2-z1*y2; y0= z1*x2-x1*z2; @@ -1535,23 +1535,23 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float * y1= v1[1]- v2[1]; y2= v2[1]- v3[1]; - z1= 1.0f; // (u1 - u2) - z2= 0.0f; // (u2 - u3) - + z1= 1.0f; /* (u1 - u2) */ + z2= 0.0f; /* (u2 - u3) */ + x0= y1*z2-z1*y2; y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - + if (z0==0.0f) return; - - xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; + + xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; uxd= -(double)x0/(double)z0; uyd= -(double)y0/(double)z0; uy0= ((double)my2)*uyd + (double)xx1; - z1= -1.0f; // (v1 - v2) - z2= 1.0f; // (v2 - v3) - + z1= -1.0f; /* (v1 - v2) */ + z2= 1.0f; /* (v2 - v3) */ + x0= y1*z2-z1*y2; y0= z1*x2-x1*z2; diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 039f3bff4d1..bb985802e23 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -191,7 +191,7 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds) if ((G.debug & G_DEBUG) == 0) { if (win && win->ghostwin) { const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); - // Note: There is no tabletdata on Windows if no tablet device is connected. + /* Note: There is no tabletdata on Windows if no tablet device is connected. */ if (!tabletdata) GHOST_SetCursorGrab(win->ghostwin, mode, bounds); else if (tabletdata->Active == GHOST_kTabletModeNone) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9795c482af2..4b762f94d34 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -919,7 +919,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P ScrArea *sa = CTX_wm_area(C); if (ar && ar->regiontype == RGN_TYPE_WINDOW && event && - BLI_in_rcti(&ar->winrct, event->x, event->y)) + BLI_in_rcti_v(&ar->winrct, &event->x)) { winrect = &ar->winrct; } @@ -1638,17 +1638,17 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event) rcti rect = *handler->bblocal; BLI_translate_rcti(&rect, handler->bbwin->xmin, handler->bbwin->ymin); - if (BLI_in_rcti(&rect, event->x, event->y)) + if (BLI_in_rcti_v(&rect, &event->x)) return 1; - else if (event->type == MOUSEMOVE && BLI_in_rcti(&rect, event->prevx, event->prevy)) + else if (event->type == MOUSEMOVE && BLI_in_rcti_v(&rect, &event->prevx)) return 1; else return 0; } else { - if (BLI_in_rcti(handler->bbwin, event->x, event->y)) + if (BLI_in_rcti_v(handler->bbwin, &event->x)) return 1; - else if (event->type == MOUSEMOVE && BLI_in_rcti(handler->bbwin, event->prevx, event->prevy)) + else if (event->type == MOUSEMOVE && BLI_in_rcti_v(handler->bbwin, &event->prevx)) return 1; else return 0; @@ -1826,10 +1826,10 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) { if (wm_event_always_pass(event)) return 1; - if (BLI_in_rcti(rect, event->x, event->y)) + if (BLI_in_rcti_v(rect, &event->x)) return 1; if (event->type == MOUSEMOVE) { - if (BLI_in_rcti(rect, event->prevx, event->prevy)) { + if (BLI_in_rcti_v(rect, &event->prevx)) { return 1; } return 0; @@ -1837,19 +1837,19 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) return 0; } -static ScrArea *area_event_inside(bContext *C, int x, int y) +static ScrArea *area_event_inside(bContext *C, const int xy[2]) { bScreen *screen = CTX_wm_screen(C); ScrArea *sa; if (screen) for (sa = screen->areabase.first; sa; sa = sa->next) - if (BLI_in_rcti(&sa->totrct, x, y)) + if (BLI_in_rcti_v(&sa->totrct, xy)) return sa; return NULL; } -static ARegion *region_event_inside(bContext *C, int x, int y) +static ARegion *region_event_inside(bContext *C, const int xy[2]) { bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); @@ -1857,7 +1857,7 @@ static ARegion *region_event_inside(bContext *C, int x, int y) if (screen && area) for (ar = area->regionbase.first; ar; ar = ar->next) - if (BLI_in_rcti(&ar->winrct, x, y)) + if (BLI_in_rcti_v(&ar->winrct, xy)) return ar; return NULL; } @@ -1888,11 +1888,11 @@ static void wm_paintcursor_test(bContext *C, wmEvent *event) wm_paintcursor_tag(C, wm->paintcursors.first, ar); /* if previous position was not in current region, we have to set a temp new context */ - if (ar == NULL || !BLI_in_rcti(&ar->winrct, event->prevx, event->prevy)) { + if (ar == NULL || !BLI_in_rcti_v(&ar->winrct, &event->prevx)) { ScrArea *sa = CTX_wm_area(C); - CTX_wm_area_set(C, area_event_inside(C, event->prevx, event->prevy)); - CTX_wm_region_set(C, region_event_inside(C, event->prevx, event->prevy)); + CTX_wm_area_set(C, area_event_inside(C, &event->prevx)); + CTX_wm_region_set(C, region_event_inside(C, &event->prevx)); wm_paintcursor_tag(C, wm->paintcursors.first, CTX_wm_region(C)); @@ -2000,8 +2000,8 @@ void wm_event_do_handlers(bContext *C) CTX_wm_window_set(C, win); /* we let modal handlers get active area/region, also wm_paintcursor_test needs it */ - CTX_wm_area_set(C, area_event_inside(C, event->x, event->y)); - CTX_wm_region_set(C, region_event_inside(C, event->x, event->y)); + CTX_wm_area_set(C, area_event_inside(C, &event->x)); + CTX_wm_region_set(C, region_event_inside(C, &event->x)); /* MVC demands to not draw in event handlers... but we need to leave it for ogl selecting etc */ wm_window_make_drawable(C, win); @@ -2061,7 +2061,7 @@ void wm_event_do_handlers(bContext *C) if (CTX_wm_window(C) == NULL) return; - doit |= (BLI_in_rcti(&ar->winrct, event->x, event->y)); + doit |= (BLI_in_rcti_v(&ar->winrct, &event->x)); if (action & WM_HANDLER_BREAK) break; @@ -2083,8 +2083,8 @@ void wm_event_do_handlers(bContext *C) if ((action & WM_HANDLER_BREAK) == 0) { /* also some non-modal handlers need active area/region */ - CTX_wm_area_set(C, area_event_inside(C, event->x, event->y)); - CTX_wm_region_set(C, region_event_inside(C, event->x, event->y)); + CTX_wm_area_set(C, area_event_inside(C, &event->x)); + CTX_wm_region_set(C, region_event_inside(C, &event->x)); wm_region_mouse_co(C, event); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ef6b4bb575e..e51625423cd 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -317,7 +317,7 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name) char header[7]; int retval; - // make sure we're not trying to read a directory.... + /* make sure we're not trying to read a directory.... */ len = strlen(name); if (ELEM(name[len - 1], '/', '\\')) { diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index b280b979280..c9f1a2587df 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -253,7 +253,7 @@ static void draw_filled_lasso(wmGesture *gt) /* highly unlikely this will fail, but could crash if (gt->points == 0) */ if (sf_vert_first) { - float zvec[3] = {0.0f, 0.0f, 1.0f}; + const float zvec[3] = {0.0f, 0.0f, 1.0f}; BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert); BLI_scanfill_calc_ex(&sf_ctx, FALSE, zvec); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 431094c9ec4..3dbb3b7ef66 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -226,21 +226,21 @@ int WM_init_game(bContext *C) Scene *scene = CTX_data_scene(C); if (!scene) { - // XXX, this should not be needed. + /* XXX, this should not be needed. */ Main *bmain = CTX_data_main(C); scene = bmain->scene.first; } win = wm->windows.first; - //first to get a valid window + /* first to get a valid window */ if (win) CTX_wm_window_set(C, win); sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - // if we have a valid 3D view + /* if we have a valid 3D view */ if (sa && ar) { ARegion *arhide; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 18caa8c2afe..eb6da146a73 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -329,7 +329,7 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi) kmi->id = keymap->kmi_id; } else { - kmi->id = -keymap->kmi_id; // User defined keymap entries have negative ids + kmi->id = -keymap->kmi_id; /* User defined keymap entries have negative ids */ } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 2aa010f012e..d905d981134 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1336,7 +1336,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemL(col, "Links", ICON_NONE); uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); - uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-263"); + uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-264"); uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.6/Manual"); uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); uiItemStringO(col, IFACE_("User Community"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community"); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index d599b9504e8..0b9dc441227 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -331,12 +331,12 @@ unsigned int index_to_framebuffer(int index) break; case 24: break; - default: // 18 bits... + default: /* 18 bits... */ i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2); i |= 0x010101; break; } - + return i; } @@ -365,7 +365,7 @@ unsigned int index_to_framebuffer(int index) break; case 24: break; - default: // 18 bits... + default: /* 18 bits... */ i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2); i |= 0x030303; break; |