diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-23 22:50:56 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-23 22:50:56 +0400 |
commit | a42ba82f638e481d7fd3c3ed2ba05c331ef6717e (patch) | |
tree | 81a2b9221799707b49b74a5df8bb3ff964ba78bd /source/blender/blenlib | |
parent | 7afbdff1b6c348227e652e1c3071ab7ba7c91c44 (diff) | |
parent | a73dd3476e7d180d3320afc04d218ce22f2f3bfc (diff) |
Merged changes in the trunk up to revision 50829.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
Also addressed code inconsistency due to changes in the trunk revision 50628 (color
management with OCIO) and 50806 (UV project material). OCIO-related changes are marked
OCIO_TODO as in some other files modified in revision 50628.
Diffstat (limited to 'source/blender/blenlib')
31 files changed, 205 insertions, 71 deletions
diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h index 3b7f2d6bbaf..833c416c1c1 100644 --- a/source/blender/blenlib/BLI_dynstr.h +++ b/source/blender/blenlib/BLI_dynstr.h @@ -80,7 +80,11 @@ void BLI_dynstr_appendf(DynStr *ds, const char *format, ...) __attribute__ ((format(printf, 2, 3))) #endif ; -void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args); +void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args) +#ifdef __GNUC__ +__attribute__ ((format(printf, 2, 0))) +#endif +; /** * Find the length of a DynStr. @@ -107,7 +111,6 @@ char *BLI_dynstr_get_cstring(DynStr *ds); * * \param ds The DynStr of interest. * \param str The string to fill. - * \return The contents of \a ds as a c-string. */ void BLI_dynstr_get_cstring_ex(DynStr *ds, char *str); diff --git a/source/blender/blenlib/BLI_endian_switch.h b/source/blender/blenlib/BLI_endian_switch.h index 7017e7ba789..7cb2790525d 100644 --- a/source/blender/blenlib/BLI_endian_switch.h +++ b/source/blender/blenlib/BLI_endian_switch.h @@ -27,16 +27,36 @@ * \ingroup bli */ -#include "BLI_endian_switch_inline.h" +#ifdef __GNUC__ +# define ATTR_ENDIAN_SWITCH \ + __attribute__((nonnull(1))) \ + __attribute__((pure)) +#else +# define ATTR_ENDIAN_SWITCH +#endif + +/* BLI_endian_switch_inline.h */ +BLI_INLINE void BLI_endian_switch_int16(short *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_float(float *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_int64(int64_t *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) ATTR_ENDIAN_SWITCH; +BLI_INLINE void BLI_endian_switch_double(double *val) ATTR_ENDIAN_SWITCH; /* endian_switch.c */ -void BLI_endian_switch_int16_array(short *val, const int size); -void BLI_endian_switch_uint16_array(unsigned short *val, const int size); -void BLI_endian_switch_int32_array(int *val, const int size); -void BLI_endian_switch_uint32_array(unsigned int *val, const int size); -void BLI_endian_switch_float_array(float *val, const int size); -void BLI_endian_switch_int64_array(int64_t *val, const int size); -void BLI_endian_switch_uint64_array(uint64_t *val, const int size); -void BLI_endian_switch_double_array(double *val, const int size); +void BLI_endian_switch_int16_array(short *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_uint16_array(unsigned short *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_int32_array(int *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_uint32_array(unsigned int *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_float_array(float *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_int64_array(int64_t *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_uint64_array(uint64_t *val, const int size) ATTR_ENDIAN_SWITCH; +void BLI_endian_switch_double_array(double *val, const int size) ATTR_ENDIAN_SWITCH; + +#include "BLI_endian_switch_inline.h" + +#undef ATTR_ENDIAN_SWITCH #endif /* __BLI_ENDIAN_SWITCH_H__ */ diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h index a19909a8f26..1c6463eb6ea 100644 --- a/source/blender/blenlib/BLI_fileops_types.h +++ b/source/blender/blenlib/BLI_fileops_types.h @@ -46,7 +46,7 @@ struct direntry { mode_t type; char *relname; char *path; -#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER >= 1500) +#if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__) && (_MSC_VER >= 1500) struct _stat64 s; #elif defined(__MINGW32__) struct _stati64 s; diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 886ed6f495d..6ee1498c855 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -30,8 +30,8 @@ * \ingroup bli */ -#ifdef WIN32 -#define _USE_MATH_DEFINES +#ifdef _MSC_VER +# define _USE_MATH_DEFINES #endif #include <math.h> diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 7520f09fe95..7c8bf88943d 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -67,6 +67,8 @@ void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv); void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr, int colorspace); void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv); void rgb_to_hsv_v(const float rgb[3], float r_hsv[3]); +void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll); +void rgb_to_hsl_v(const float rgb[3], float r_hsl[3]); void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv); void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3]); void rgb_to_lab(float r, float g, float b, float *ll, float *la, float *lb); @@ -113,6 +115,8 @@ void rgba_float_to_uchar(unsigned char col_r[4], const float col_f[4]); void xyz_to_lab(float x, float y, float z, float *l, float *a, float *b); +MINLINE int compare_rgb_uchar(const unsigned char a[3], const unsigned char b[3], const int limit); + /***************** lift/gamma/gain / ASC-CDL conversion *****************/ void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power); diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 6c81ca3f0a9..de1d423bfad 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -173,6 +173,7 @@ MINLINE int is_one_v3(const float a[3]); MINLINE int equals_v2v2(const float v1[2], const float v2[2]); MINLINE int equals_v3v3(const float a[3], const float b[3]); +MINLINE int compare_v2v2(const float a[3], const float b[3], const float limit); MINLINE int compare_v3v3(const float a[3], const float b[3], const float limit); MINLINE int compare_len_v3v3(const float a[3], const float b[3], const float limit); diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index eb9915d6c9b..de4c2cf3a86 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -55,6 +55,8 @@ void BLI_rcti_resize(struct rcti *rect, int x, int y); void BLI_rctf_resize(struct rctf *rect, float x, float y); void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, const float fac); //void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac); +int BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]); +int BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]); int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit); int BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b); int BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest); @@ -75,14 +77,28 @@ void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src); void print_rctf(const char *str, const struct rctf *rect); void print_rcti(const char *str, const struct rcti *rect); -#define BLI_RCT_SIZE_X(rct) ((rct)->xmax - (rct)->xmin) -#define BLI_RCT_SIZE_Y(rct) ((rct)->ymax - (rct)->ymin) +/* hrmf, we need to work out this inline stuff */ +#if defined(_MSC_VER) +# define BLI_INLINE static __forceinline +#elif defined(__GNUC__) +# define BLI_INLINE static inline __attribute((always_inline)) +#else +/* #warning "MSC/GNUC defines not found, inline non-functional" */ +# define BLI_INLINE static +#endif -#define BLI_RCT_CENTER_X(rct) (((rct)->xmin + (rct)->xmax) / 2) -#define BLI_RCT_CENTER_Y(rct) (((rct)->ymin + (rct)->ymax) / 2) +#include "DNA_vec_types.h" +BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct) { return (float)(rct->xmin + rct->xmax) / 2.0f; } +BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct) { return (float)(rct->ymin + rct->ymax) / 2.0f; } +BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct) { return (rct->xmin + rct->xmax) / 2; } +BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct) { return (rct->ymin + rct->ymax) / 2; } +BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct) { return (rct->xmin + rct->xmax) / 2.0f; } +BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct) { return (rct->ymin + rct->ymax) / 2.0f; } -#define BLI_RCT_CENTER_X_FL(rct) ((float)((rct)->xmin + (rct)->xmax) / 2.0f) -#define BLI_RCT_CENTER_Y_FL(rct) ((float)((rct)->ymin + (rct)->ymax) / 2.0f) +BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct) { return (rct->xmax - rct->xmin); } +BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct) { return (rct->ymax - rct->ymin); } +BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct) { return (rct->xmax - rct->xmin); } +BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct) { return (rct->ymax - rct->ymin); } #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index b3d0df04eb1..666c74ca36f 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -144,7 +144,11 @@ __attribute__((nonnull)) /* * Replacement for vsnprintf */ -size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg); +size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg) +#ifdef __GNUC__ +__attribute__ ((format(printf, 3, 0))) +#endif +; /* * Print formatted string into a newly mallocN'd string diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 902373bcd6b..9cd801f819d 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -77,6 +77,7 @@ int BLI_system_thread_count(void); /* gets the number of threads the system #define LOCK_OPENGL 5 #define LOCK_NODES 6 #define LOCK_MOVIECLIP 7 +#define LOCK_COLORMANAGE 8 void BLI_lock_thread(int type); void BLI_unlock_thread(int type); diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index c1175192434..ee7d93ea1a9 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -58,7 +58,7 @@ struct Heap { #define HEAP_LEFT(i) ((i << 1) + 1) #define HEAP_RIGHT(i) ((i << 1) + 2) #define HEAP_COMPARE(a, b) (a->value < b->value) -#define HEAP_EQUALS(a, b) (a->value == b->value) +// #define HEAP_EQUALS(a, b) (a->value == b->value) // UNUSED #define HEAP_SWAP(heap, i, j) \ { \ SWAP(int, heap->tree[i]->index, heap->tree[j]->index); \ diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 2b3c314131b..167797946bc 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -42,7 +42,6 @@ #endif #define MAX_TREETYPE 32 -#define DEFAULT_FIND_NEAREST_HEAP_SIZE 1024 typedef struct BVHNode { struct BVHNode **children; @@ -114,6 +113,8 @@ static float KDOP_AXES[13][3] = { {0, 1.0, -1.0} }; +#if 0 + /* * Generic push and pop heap */ @@ -153,7 +154,6 @@ static float KDOP_AXES[13][3] = { heap[parent] = element; \ } (void)0 -#if 0 static int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_size, int size_per_item) { int new_max_size = *max_size * 2; @@ -1167,8 +1167,6 @@ typedef struct NodeDistance { } NodeDistance; -#define NodeDistance_priority(a, b) ( (a).dist < (b).dist) - // TODO: use a priority queue to reduce the number of nodes looked on static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node) { @@ -1211,6 +1209,11 @@ static void dfs_find_nearest_begin(BVHNearestData *data, BVHNode *node) #if 0 + +#define DEFAULT_FIND_NEAREST_HEAP_SIZE 1024 + +#define NodeDistance_priority(a, b) ( (a).dist < (b).dist) + static void NodeDistance_push_heap(NodeDistance *heap, int heap_size) PUSH_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 5da719cd500..1c70a612c4f 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -73,7 +73,9 @@ typedef struct BoxVert { ((b)->v[BR]->x = (b)->v[TR]->x) #define UPDATE_V34Y(b) ((b)->v[TL]->y = (b)->v[TR]->y); \ ((b)->v[BR]->y = (b)->v[BL]->y) -#define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b) + +/* UNUSED */ +// #define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b) #define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \ (b)->v[BL]->x = f; \ @@ -93,8 +95,8 @@ typedef struct BoxVert { BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \ BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2)) -#define MIN2(x, y) ((x) < (y) ? (x) : (y)) -#define MAX2(x, y) ((x) > (y) ? (x) : (y)) +/* compiler should inline */ +static float maxf(const float a, const float b) { return b > a ? b : a; } #if 0 #define BOXDEBUG(b) \ @@ -131,8 +133,8 @@ static int vertex_sort(const void *p1, const void *p2) v1 = vertarray + ((int *)p1)[0]; v2 = vertarray + ((int *)p2)[0]; - a1 = MAX2(v1->x + box_width, v1->y + box_height); - a2 = MAX2(v2->x + box_width, v2->y + box_height); + a1 = maxf(v1->x + box_width, v1->y + box_height); + a2 = maxf(v2->x + box_width, v2->y + box_height); /* sort largest to smallest */ if (a1 > a2) return 1; @@ -312,8 +314,8 @@ void BLI_box_pack_2D(BoxPack *boxarray, const int len, float *tot_width, float * if (!isect) { /* maintain the total width and height */ - (*tot_width) = MAX2(BOXRIGHT(box), (*tot_width)); - (*tot_height) = MAX2(BOXTOP(box), (*tot_height)); + (*tot_width) = maxf(BOXRIGHT(box), (*tot_width)); + (*tot_height) = maxf(BOXTOP(box), (*tot_height)); /* Place the box */ vert->free &= ~quad_flags[j]; diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index f3107b565b9..c2f0c38247a 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -341,7 +341,7 @@ void BLI_dir_create_recursive(const char *dirname) { char *lslash; char tmp[MAXPATHLEN]; - + /* First remove possible slash at the end of the dirname. * This routine otherwise tries to create * blah1/blah2/ (with slash) after creating @@ -349,23 +349,29 @@ void BLI_dir_create_recursive(const char *dirname) BLI_strncpy(tmp, dirname, sizeof(tmp)); lslash = BLI_last_slash(tmp); - - if (lslash == tmp + strlen(tmp) - 1) { - *lslash = 0; + + if (lslash && (*(lslash + 1) == '\0')) { + *lslash = '\0'; } - + + /* check special case "c:\foo", don't try create "c:", harmless but prints an error below */ + if (isalpha(tmp[0]) && (tmp[1] == ':') && tmp[2] == '\0') return; + if (BLI_exists(tmp)) return; lslash = BLI_last_slash(tmp); + if (lslash) { /* Split about the last slash and recurse */ *lslash = 0; BLI_dir_create_recursive(tmp); } - - if (dirname[0]) /* patch, this recursive loop tries to create a nameless directory */ - if (umkdir(dirname) == -1) + + if (dirname[0]) { /* patch, this recursive loop tries to create a nameless directory */ + if (umkdir(dirname) == -1) { printf("Unable to create directory %s\n", dirname); + } + } } int BLI_rename(const char *from, const char *to) diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 597a645eb9c..85239270541 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -58,9 +58,6 @@ #include "DNA_packedFile_types.h" #include "DNA_curve_types.h" -#define myMIN_ASCII 32 -#define myMAX_ASCII 255 - /* local variables */ static FT_Library library; static FT_Error err; diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index b93597bf107..64851dbf12c 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -293,6 +293,12 @@ void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll) *ll = l; } +/* convenience function for now */ +void rgb_to_hsl_v(const float rgb[3], float r_hsl[3]) +{ + rgb_to_hsl(rgb[0], rgb[1], rgb[2], &r_hsl[0], &r_hsl[1], &r_hsl[2]); +} + void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv) { float orig_h = *lh; diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 6b90cbfe9c3..f520b2318e5 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -273,5 +273,20 @@ MINLINE float rgb_to_luma_y(const float rgb[3]) return 0.212671f * rgb[0] + 0.71516f * rgb[1] + 0.072169f * rgb[2]; } +MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char col_b[3], const int limit) +{ + int r = (int)col_a[0] - (int)col_b[0]; + if (ABS(r) < limit) { + int g = (int)col_a[1] - (int)col_b[1]; + if (ABS(g) < limit) { + int b = (int)col_a[2] - (int)col_b[2]; + if (ABS(b) < limit) { + return 1; + } + } + } + + return 0; +} #endif /* __MATH_COLOR_INLINE_C__ */ diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 3fb3d2b58ff..1f61b37a1af 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -195,7 +195,7 @@ void mul_m3_m3m3(float m1[][3], float m3_[][3], float m2_[][3]) m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2]; } -void mul_m4_m4m3(float (*m1)[4], float (*m3_)[4], float (*m2_)[3]) +void mul_m4_m4m3(float m1[][4], float m3_[][4], float m2_[][3]) { float m2[3][3], m3[4][4]; @@ -215,8 +215,14 @@ void mul_m4_m4m3(float (*m1)[4], float (*m3_)[4], float (*m2_)[3]) } /* m1 = m2 * m3, ignore the elements on the 4th row/column of m3 */ -void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3]) +void mult_m3_m3m4(float m1[][3], float m3_[][4], float m2_[][3]) { + float m2[3][3], m3[4][4]; + + /* copy so it works when m1 is the same pointer as m2 or m3 */ + copy_m3_m3(m2, m2_); + copy_m4_m4(m3, m3_); + /* m1[i][j] = m2[i][k] * m3[k][j] */ m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0]; m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1]; @@ -231,8 +237,14 @@ void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3]) m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2]; } -void mul_m4_m3m4(float (*m1)[4], float (*m3)[3], float (*m2)[4]) +void mul_m4_m3m4(float m1[][4], float m3_[][3], float m2_[][4]) { + float m2[4][4], m3[3][3]; + + /* copy so it works when m1 is the same pointer as m2 or m3 */ + copy_m4_m4(m2, m2_); + copy_m3_m3(m3, m3_); + m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] + m2[0][2] * m3[2][0]; m1[0][1] = m2[0][0] * m3[0][1] + m2[0][1] * m3[1][1] + m2[0][2] * m3[2][1]; m1[0][2] = m2[0][0] * m3[0][2] + m2[0][1] * m3[1][2] + m2[0][2] * m3[2][2]; diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index f0ed23aabc9..e10b0b3298c 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -35,7 +35,9 @@ /******************************** Quaternions ********************************/ /* used to test is a quat is not normalized (only used for debug prints) */ -#define QUAT_EPSILON 0.0001 +#ifdef DEBUG +# define QUAT_EPSILON 0.0001 +#endif /* convenience, avoids setting Y axis everywhere */ void unit_axis_angle(float axis[3], float *angle) diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 0a8f57214d7..c409e536b45 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -724,6 +724,15 @@ MINLINE int equals_v4v4(const float v1[4], const float v2[4]) return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2]) && (v1[3] == v2[3])); } +MINLINE int compare_v2v2(const float v1[2], const float v2[2], const float limit) +{ + if (fabsf(v1[0] - v2[0]) < limit) + if (fabsf(v1[1] - v2[1]) < limit) + return 1; + + return 0; +} + MINLINE int compare_v3v3(const float v1[3], const float v2[3], const float limit) { if (fabsf(v1[0] - v2[0]) < limit) diff --git a/source/blender/blenlib/intern/md5.c b/source/blender/blenlib/intern/md5.c index a521d0e523b..4a09afe2e3d 100644 --- a/source/blender/blenlib/intern/md5.c +++ b/source/blender/blenlib/intern/md5.c @@ -2,6 +2,8 @@ * \ingroup imbuf */ +#include "BLI_md5.h" /* own include */ + /* md5.c - Functions to compute MD5 message digest of files or memory blocks according to the definition of MD5 in RFC 1321 from April 1992. Copyright (C) 1995 Software Foundation, Inc. diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index bd83c5e018c..792bf929182 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -45,7 +45,8 @@ static float noise3_perlin(float vec[3]); //static float turbulence_perlin(float *point, float lofreq, float hifreq); //static float turbulencep(float noisesize, float x, float y, float z, int nr); -#define HASHVEC(x, y, z) hashvectf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255] +/* UNUSED */ +// #define HASHVEC(x, y, z) hashvectf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255] /* needed for voronoi */ #define HASHPNT(x, y, z) hashpntf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255] diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index a7a66718445..cc482e2d3d8 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1368,7 +1368,7 @@ int BLI_testextensie(const char *str, const char *ext) retval = 0; } else if (BLI_strcasecmp(ext, str + a - b)) { - retval = 0; + retval = 0; } else { retval = 1; diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 22597c9f8e6..0bd9e68cb71 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -487,7 +487,7 @@ static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc, /* Return zero if all primitives in the node can be drawn with the * same material (including flat/smooth shading), non-zerootherwise */ -int leaf_needs_material_split(PBVH *bvh, int offset, int count) +static int leaf_needs_material_split(PBVH *bvh, int offset, int count) { int i, prim; @@ -1169,10 +1169,14 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) break; case PBVH_FACES: GPU_update_mesh_buffers(node->draw_buffers, + bvh->faces, + node->prim_indices, + node->totprim, bvh->verts, node->vert_indices, node->uniq_verts + node->face_verts, + node->face_vert_indices, CustomData_get_layer(bvh->vdata, CD_PAINT_MASK)); break; diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 225ede8a8ef..cab383b60f3 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -252,8 +252,8 @@ void BLI_rctf_translate(rctf *rect, float x, float y) /* change width & height around the central location */ void BLI_rcti_resize(rcti *rect, int x, int y) { - rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect); - rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect); + rect->xmin = rect->xmax = BLI_rcti_cent_x(rect); + rect->ymin = rect->ymax = BLI_rcti_cent_y(rect); rect->xmin -= x / 2; rect->ymin -= y / 2; rect->xmax = rect->xmin + x; @@ -262,8 +262,8 @@ void BLI_rcti_resize(rcti *rect, int x, int y) void BLI_rctf_resize(rctf *rect, float x, float y) { - rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect); - rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect); + rect->xmin = rect->xmax = BLI_rctf_cent_x(rect); + rect->ymin = rect->ymax = BLI_rctf_cent_y(rect); rect->xmin -= x * 0.5f; rect->ymin -= y * 0.5f; rect->xmax = rect->xmin + x; @@ -281,6 +281,27 @@ void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const f /* BLI_rcti_interp() not needed yet */ + +int BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]) +{ + int change = 0; + if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = 1; } + if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = 1; } + if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = 1; } + if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = 1; } + return change; +} + +int BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]) +{ + int change = 0; + if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = 1; } + if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = 1; } + if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = 1; } + if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = 1; } + return change; +} + int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit) { if (fabsf(rect_a->xmin - rect_b->xmin) < limit) @@ -366,9 +387,9 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) void BLI_rcti_rctf_copy(rcti *dst, const rctf *src) { dst->xmin = floorf(src->xmin + 0.5f); - dst->xmax = dst->xmin + floorf(BLI_RCT_SIZE_X(src) + 0.5f); + dst->xmax = dst->xmin + floorf(BLI_rctf_size_x(src) + 0.5f); dst->ymin = floorf(src->ymin + 0.5f); - dst->ymax = dst->ymin + floorf(BLI_RCT_SIZE_Y(src) + 0.5f); + dst->ymax = dst->ymin + floorf(BLI_rctf_size_y(src) + 0.5f); } void BLI_rctf_rcti_copy(rctf *dst, const rcti *src) @@ -382,11 +403,11 @@ void BLI_rctf_rcti_copy(rctf *dst, const rcti *src) void print_rctf(const char *str, const rctf *rect) { printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", str, - rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); + rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rctf_size_x(rect), BLI_rctf_size_y(rect)); } void print_rcti(const char *str, const rcti *rect) { printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str, - rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); + rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); } diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 32afaba2b5c..7ae27b83e67 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -211,7 +211,7 @@ ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3]) copy_v3_v3(eve->co, vec); - return eve; + return eve; } ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, ScanFillVert *v1, ScanFillVert *v2) @@ -521,7 +521,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf) while (eve) { printf("vert: %x co: %f %f\n", eve, eve->xy[0], eve->xy[1]); eve = eve->next; - } + } eed = sf_ctx->filledgebase.first; while (eed) { printf("edge: %x verts: %x %x\n", eed, eed->v1, eed->v2); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 0fccd91fc02..0d3f6aee30f 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -34,7 +34,7 @@ #include <sys/types.h> #include <stdio.h> -#include <stdlib.h> +#include <stdlib.h> #ifndef WIN32 #include <dirent.h> diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index 422a600e51c..bab144266a4 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -147,7 +147,7 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, int *pos, strCursorJumpDirection direction, strCursorJumpType jump) { - const short pos_prev = *pos; + const int pos_prev = *pos; if (direction == STRCUR_DIR_NEXT) { BLI_str_cursor_step_next_utf8(str, maxlen, pos); diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 9994f89acd5..66527b9b92a 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -113,6 +113,7 @@ static pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _opengl_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _nodes_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _movieclip_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t _colormanage_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_t mainid; static int thread_levels = 0; /* threads can be invoked inside threads */ @@ -351,6 +352,8 @@ void BLI_lock_thread(int type) pthread_mutex_lock(&_nodes_lock); else if (type == LOCK_MOVIECLIP) pthread_mutex_lock(&_movieclip_lock); + else if (type == LOCK_COLORMANAGE) + pthread_mutex_lock(&_colormanage_lock); } void BLI_unlock_thread(int type) @@ -371,6 +374,8 @@ void BLI_unlock_thread(int type) pthread_mutex_unlock(&_nodes_lock); else if (type == LOCK_MOVIECLIP) pthread_mutex_unlock(&_movieclip_lock); + else if (type == LOCK_COLORMANAGE) + pthread_mutex_unlock(&_colormanage_lock); } /* Mutex Locks */ diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index 1b59dc6a3f5..05ebc9500a1 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -105,7 +105,7 @@ void BLI_uvproject_from_view(float target[2], float source[3], float persmat[4][ /* rotmat is the object matrix in this case */ mul_m4_v4(rotmat, pv4); - /* almost project_short */ + /* almost ED_view3d_project_short */ mul_m4_v4(persmat, pv4); if (fabsf(pv4[3]) > 0.00001f) { /* avoid division by zero */ target[0] = winx / 2.0f + (winx / 2.0f) * pv4[0] / pv4[3]; diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 80a4da5cace..3030e54eb78 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -480,7 +480,7 @@ static void voronoi_removeParabola(VoronoiProcess *process, VoronoiEvent *event) voronoi_checkCircle(process, p2); } -void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) +static void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) { float mx; @@ -503,12 +503,12 @@ void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) MEM_freeN(parabola); } -void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord) +static void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord) { const float corners[4][2] = {{0.0f, 0.0f}, - {width - 1, 0.0f}, - {width - 1, height - 1}, - {0.0f, height - 1}}; + {width - 1, 0.0f}, + {width - 1, height - 1}, + {0.0f, height - 1}}; int i; if (IN_RANGE_INCL(coord[0], 0, width - 1) && IN_RANGE_INCL(coord[1], 0, height - 1)) { @@ -541,7 +541,7 @@ void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_c } } -void voronoi_clampEdges(ListBase *edges, int width, int height, ListBase *clamped_edges) +static void voronoi_clampEdges(ListBase *edges, int width, int height, ListBase *clamped_edges) { VoronoiEdge *edge; diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 5b5f4cf8b80..a0b31f8d5b8 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -68,7 +68,7 @@ int BLI_getInstallationDir(char *str) return 1; } -void RegisterBlendExtension_Fail(HKEY root) +static void RegisterBlendExtension_Fail(HKEY root) { printf("failed\n"); if (root) |