diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-06-24 14:29:26 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-06-24 14:29:26 +0400 |
commit | 1f7ae143a29b090ed97cdd7eb47a9c2dbd7f72a2 (patch) | |
tree | fff560080a8bbf37ee087653df1b8a30173537b1 /source/blender/blenlib | |
parent | d38ba6b5d25ca42f76b6d1b746217a565f26228f (diff) | |
parent | 74c9c24d273863319a55c18234e03b7d27a43a87 (diff) |
Merged changes in the trunk up to revision 48227.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_file/filelist.c
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 11 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdtree.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/boxpack2d.c | 52 | ||||
-rw-r--r-- | source/blender/blenlib/intern/fnmatch.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_color_inline.c | 7 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 43 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string_utf8.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 18 | ||||
-rw-r--r-- | source/blender/blenlib/intern/voronoi.c | 32 | ||||
-rw-r--r-- | source/blender/blenlib/intern/voxel.c | 6 |
11 files changed, 101 insertions, 76 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 74f5e7fc2bd..9b68406cc54 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -89,7 +89,16 @@ void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen); void BLI_split_file_part(const char *string, char *file, const size_t filelen); void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file); char *BLI_path_basename(char *path); -int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir); + +typedef enum bli_rebase_state { + BLI_REBASE_NO_SRCDIR = 0, + BLI_REBASE_OK = 1, + BLI_REBASE_IDENTITY = 2 +} bli_rebase_state; + +int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir); +#define BKE_rebase_path BLI_rebase_path /* remove after a 2012 */ + char *BLI_last_slash(const char *string); int BLI_add_slash(char *string); void BLI_del_slash(char *string); diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index a265505cc8f..19985c56b84 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -399,7 +399,7 @@ int BLI_kdtree_range_search(KDTree *tree, float range, const float co[3], const } else { dist2 = squared_distance(root->co, co, root->nor, nor); - if (dist2 <= range2) + if (dist2 <= range2) add_in_range(&foundstack, found++, &totfoundstack, root->index, dist2, root->co); if (root->left) diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index feaa60b40b2..5da719cd500 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -63,35 +63,35 @@ typedef struct BoxVert { #define TL 2 #define BR 3 -#define BOXLEFT(b) ((b)->v[BL]->x) -#define BOXRIGHT(b) ((b)->v[TR]->x) -#define BOXBOTTOM(b) ((b)->v[BL]->y) -#define BOXTOP(b) ((b)->v[TR]->y) -#define BOXAREA(b) ((b)->w * (b)->h) - -#define UPDATE_V34X(b) ((b)->v[TL]->x = (b)->v[BL]->x); \ - ((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 BOXLEFT(b) ((b)->v[BL]->x) +#define BOXRIGHT(b) ((b)->v[TR]->x) +#define BOXBOTTOM(b) ((b)->v[BL]->y) +#define BOXTOP(b) ((b)->v[TR]->y) +#define BOXAREA(b) ((b)->w * (b)->h) + +#define UPDATE_V34X(b) ((b)->v[TL]->x = (b)->v[BL]->x); \ + ((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) -#define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \ - (b)->v[BL]->x = f; \ - UPDATE_V34X(b) -#define SET_BOXRIGHT(b, f) (b)->v[BL]->x = f - (b)->w; \ - (b)->v[TR]->x = f; \ - UPDATE_V34X(b) -#define SET_BOXBOTTOM(b, f) (b)->v[TR]->y = f + (b)->h; \ - (b)->v[BL]->y = f; \ - UPDATE_V34Y(b) -#define SET_BOXTOP(b, f) (b)->v[BL]->y = f - (b)->h; \ - (b)->v[TR]->y = f; \ - UPDATE_V34Y(b) +#define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \ + (b)->v[BL]->x = f; \ + UPDATE_V34X(b) +#define SET_BOXRIGHT(b, f) (b)->v[BL]->x = f - (b)->w; \ + (b)->v[TR]->x = f; \ + UPDATE_V34X(b) +#define SET_BOXBOTTOM(b, f) (b)->v[TR]->y = f + (b)->h; \ + (b)->v[BL]->y = f; \ + UPDATE_V34Y(b) +#define SET_BOXTOP(b, f) (b)->v[BL]->y = f - (b)->h; \ + (b)->v[TR]->y = f; \ + UPDATE_V34Y(b) #define BOXINTERSECT(b1, b2) \ - !(BOXLEFT(b1) + EPSILON >= BOXRIGHT(b2) || \ - BOXBOTTOM(b1) + EPSILON >= BOXTOP(b2) || \ - BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \ - BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2)) + !(BOXLEFT(b1) + EPSILON >= BOXRIGHT(b2) || \ + BOXBOTTOM(b1) + EPSILON >= BOXTOP(b2) || \ + 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)) diff --git a/source/blender/blenlib/intern/fnmatch.c b/source/blender/blenlib/intern/fnmatch.c index e29f31897c0..60e898a3f19 100644 --- a/source/blender/blenlib/intern/fnmatch.c +++ b/source/blender/blenlib/intern/fnmatch.c @@ -25,8 +25,8 @@ #endif #include <errno.h> -#include <BLI_fnmatch.h> #include <ctype.h> +#include "BLI_fnmatch.h" /* Comment out all this code if we are using the GNU C Library, and are not diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index ef2eb25a891..a0e72af8131 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -136,7 +136,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf onpoints[j]++; if (k < npoints[j] - 1) { - if (ftoutline.tags[l] == FT_Curve_Tag_Conic && + if (ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) { onpoints[j]++; diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 417c557af8a..23d70bd148b 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -222,6 +222,12 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack) r_col[2] = ((pack) >> 16) & 0xFF; } +/* XXX - investigate when/why rgb_to_bw & rgb_to_grayscale are different, + * and why we use both! whats the purpose of this? */ +MINLINE float rgb_to_bw(const float rgb[3]) +{ + return 0.35f * rgb[0] + 0.45f * rgb[1] + 0.2f * rgb[2]; +} MINLINE float rgb_to_grayscale(const float rgb[3]) { @@ -233,6 +239,7 @@ MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]) return (76 * (unsigned short) rgb[0] + 148 * (unsigned short) rgb[1] + 31 * (unsigned short) rgb[2]) / 255; } +/* luma from defined by 'YCC_JFIF', see #rgb_to_ycc */ MINLINE float rgb_to_luma(const float rgb[3]) { return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2]; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 1bda7b5ee7e..46a0ac630c1 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1547,31 +1547,40 @@ char *BLI_path_basename(char *path) /** * Produce image export path. - * - * Fails returning 0 if image filename is empty or if destination path - * matches image path (i.e. both are the same file). - * - * Trailing slash in dest_dir is optional. + * + * Returns: + * 0 if image filename is empty or if destination path + * matches image path (i.e. both are the same file). + * 2 if source is identical to destination. + * 1 if rebase was successfull + * ------------------------------------------------------------- + * Hint: Trailing slash in dest_dir is optional. * * Logic: * - * - if an image is "below" current .blend file directory, rebuild the - * same dir structure in dest_dir + * - if an image is "below" current .blend file directory: + * rebuild the same dir structure in dest_dir * - * For example //textures/foo/bar.png becomes - * [dest_dir]/textures/foo/bar.png. + * Example: + * src : //textures/foo/bar.png + * dest: [dest_dir]/textures/foo/bar.png. * * - if an image is not "below" current .blend file directory, - * disregard it's path and copy it in the same directory where 3D file - * goes. + * disregard it's path and copy it into the destination + * directory. * - * For example //../foo/bar.png becomes [dest_dir]/bar.png. + * Example: + * src : //../foo/bar.png becomes + * dest: [dest_dir]/bar.png. * - * This logic will help ensure that all image paths are relative and + * This logic ensures that all image paths are relative and * that a user gets his images in one place. It'll also provide * consistent behavior across exporters. + * IMPORTANT NOTE: If base_dir contains an empty string, then + * this function returns wrong results! + * XXX: test on empty base_dir and return an error ? */ -int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir) +int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir) { char path[FILE_MAX]; char dir[FILE_MAX]; @@ -1590,7 +1599,7 @@ int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const BLI_split_dir_part(base_dir, blend_dir, sizeof(blend_dir)); if (src_dir[0] == '\0') - return 0; + return BLI_REBASE_NO_SRCDIR; BLI_strncpy(path, src_dir, sizeof(path)); @@ -1637,10 +1646,10 @@ int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const /* return 2 if src=dest */ if (BLI_path_cmp(path, dest_path) == 0) { // if (G.debug & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path); - return 2; + return BLI_REBASE_IDENTITY; } - return 1; + return BLI_REBASE_OK; } char *BLI_first_slash(char *string) diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 9795d4dea2d..ff234a971aa 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -211,7 +211,7 @@ size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t max { size_t len = 0; while (*src && len < maxcpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */ - len += BLI_str_utf8_from_unicode(*src++, dst+len); + len += BLI_str_utf8_from_unicode(*src++, dst + len); } dst[len]= '\0'; diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index dc4c15a82fc..d591f98ddc0 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -44,14 +44,14 @@ /* for checking system threads - BLI_system_thread_count */ #ifdef WIN32 -#include "windows.h" -#include <sys/timeb.h> +# include <windows.h> +# include <sys/timeb.h> #elif defined(__APPLE__) -#include <sys/types.h> -#include <sys/sysctl.h> +# include <sys/types.h> +# include <sys/sysctl.h> #else -#include <unistd.h> -#include <sys/time.h> +# include <unistd.h> +# include <sys/time.h> #endif #if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) @@ -576,7 +576,7 @@ void *BLI_thread_queue_pop(ThreadQueue *queue) if (!BLI_gsqueue_is_empty(queue->queue)) { BLI_gsqueue_pop(queue->queue, &work); - if(BLI_gsqueue_is_empty(queue->queue)) + if (BLI_gsqueue_is_empty(queue->queue)) pthread_cond_broadcast(&queue->finish_cond); } @@ -642,7 +642,7 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms) if (!BLI_gsqueue_is_empty(queue->queue)) { BLI_gsqueue_pop(queue->queue, &work); - if(BLI_gsqueue_is_empty(queue->queue)) + if (BLI_gsqueue_is_empty(queue->queue)) pthread_cond_broadcast(&queue->finish_cond); } @@ -678,7 +678,7 @@ void BLI_thread_queue_wait_finish(ThreadQueue *queue) /* wait for finish condition */ pthread_mutex_lock(&queue->mutex); - while(!BLI_gsqueue_is_empty(queue->queue)) + while (!BLI_gsqueue_is_empty(queue->queue)) pthread_cond_wait(&queue->finish_cond, &queue->mutex); pthread_mutex_unlock(&queue->mutex); diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 0088d24d741..727e42dc8de 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -49,10 +49,10 @@ enum { typedef struct VoronoiEvent { struct VoronoiEvent *next, *prev; - int type; /* type of event (site or circle) */ - float site[2]; /* site for which event was generated */ + int type; /* type of event (site or circle) */ + float site[2]; /* site for which event was generated */ - struct VoronoiParabola *parabola; /* parabola for which event was generated */ + struct VoronoiParabola *parabola; /* parabola for which event was generated */ } VoronoiEvent; typedef struct VoronoiParabola { @@ -254,9 +254,9 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f b = b1 - b2; c = c1 - c2; - disc = b*b - 4 * a * c; - x1 = (-b + sqrtf(disc)) / (2*a); - x2 = (-b - sqrtf(disc)) / (2*a); + disc = b * b - 4 * a * c; + x1 = (-b + sqrtf(disc)) / (2 * a); + x2 = (-b - sqrtf(disc)) / (2 * a); if (p[1] < r[1]) ry = MAX2(x1, x2); @@ -268,7 +268,7 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f static VoronoiParabola *voronoi_getParabolaByX(VoronoiProcess *process, float xx) { - VoronoiParabola * par = process->root; + VoronoiParabola *par = process->root; float x = 0.0f; float ly = process->current_y; @@ -371,7 +371,7 @@ static void voronoi_addParabola(VoronoiProcess *process, float site[2]) s[0] = (site[0] + fp[0]) / 2.0f; s[1] = process->height; - if(site[0] > fp[0]) + if (site[0] > fp[0]) root->edge = voronoiEdge_new(s, fp, site); else root->edge = voronoiEdge_new(s, site, fp); @@ -506,12 +506,12 @@ void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) 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)) { + if (IN_RANGE_INCL(coord[0], 0, width - 1) && IN_RANGE_INCL(coord[1], 0, height - 1)) { return; } @@ -609,9 +609,9 @@ static int voronoi_getNextSideCoord(ListBase *edges, float coord[2], int dim, in static void voronoi_createBoundaryEdges(ListBase *edges, int width, int height) { const float corners[4][2] = {{width - 1, 0.0f}, - {width - 1, height - 1}, - {0.0f, height - 1}, - {0.0f, 0.0f}}; + {width - 1, height - 1}, + {0.0f, height - 1}, + {0.0f, 0.0f}}; int i, dim = 0, dir = 1; float coord[2] = {0.0f, 0.0f}; @@ -756,7 +756,7 @@ static void voronoi_addTriangle(int v1, int v2, int v3, int (**triangles)[3], in *triangles = MEM_callocN(sizeof(int[3]), "trianglulation triangles"); } - triangle = (int*)&(*triangles)[(*triangles_total)]; + triangle = (int *)&(*triangles)[(*triangles_total)]; triangle[0] = v1; triangle[1] = v2; diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 10eb4e82912..3a8705bbbba 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -93,9 +93,9 @@ float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3 const float w[2] = {1.f - dz, dz}; return w[0] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] ) ) - + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] ) ); + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] ) ) + + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] ) + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] ) ); } return 0.f; |