diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-09 09:35:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-09 09:35:49 +0400 |
commit | 221a383366cb40e4ddf4e4edcc82baed25525d39 (patch) | |
tree | 06d26acd96cf1d41ecfa4e85ddc66f702bb37096 /source/blender/blenlib | |
parent | ddddb7bab173b040342ef99270ee71ae076d45e8 (diff) |
use 'bool' for BLI_/BKE_ functions.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_ghash.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_gsqueue.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_heap.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_lasso.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_rect.h | 28 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_heap.c | 5 | ||||
-rw-r--r-- | source/blender/blenlib/intern/gsqueue.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/lasso.c | 30 | ||||
-rw-r--r-- | source/blender/blenlib/intern/rct.c | 136 |
10 files changed, 109 insertions, 106 deletions
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 2ccc28dc07b..97564ca5363 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -130,7 +130,7 @@ void BLI_ghashIterator_step(GHashIterator *ghi); * \param ghi The iterator. * \return True if done, False otherwise. */ -int BLI_ghashIterator_notDone(GHashIterator *ghi); +bool BLI_ghashIterator_notDone(GHashIterator *ghi); #define GHASH_ITER(gh_iter_, ghash_) \ for (BLI_ghashIterator_init(&gh_iter_, ghash_); \ diff --git a/source/blender/blenlib/BLI_gsqueue.h b/source/blender/blenlib/BLI_gsqueue.h index b4cb1edd45a..b9d8a8f9d14 100644 --- a/source/blender/blenlib/BLI_gsqueue.h +++ b/source/blender/blenlib/BLI_gsqueue.h @@ -47,7 +47,7 @@ GSQueue *BLI_gsqueue_new(int elem_size); /** * Query if the queue is empty */ -int BLI_gsqueue_is_empty(GSQueue *gq); +bool BLI_gsqueue_is_empty(GSQueue *gq); /** * Query number elements in the queue diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h index c0941e00c9b..bc7b6000322 100644 --- a/source/blender/blenlib/BLI_heap.h +++ b/source/blender/blenlib/BLI_heap.h @@ -54,7 +54,7 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr); void BLI_heap_remove(Heap *heap, HeapNode *node); /* Return 0 if the heap is empty, 1 otherwise. */ -int BLI_heap_is_empty(Heap *heap); +bool BLI_heap_is_empty(Heap *heap); /* Return the size of the heap. */ unsigned int BLI_heap_size(Heap *heap); diff --git a/source/blender/blenlib/BLI_lasso.h b/source/blender/blenlib/BLI_lasso.h index a7e90a51e86..0addd463a70 100644 --- a/source/blender/blenlib/BLI_lasso.h +++ b/source/blender/blenlib/BLI_lasso.h @@ -35,7 +35,7 @@ struct rcti; void BLI_lasso_boundbox(struct rcti *rect, const int mcords[][2], const short moves); -int BLI_lasso_is_point_inside(const int mcords[][2], const short moves, const int sx, const int sy, const int error_value); -int BLI_lasso_is_edge_inside(const int mcords[][2], const short moves, int x0, int y0, int x1, int y1, const int error_value); +bool BLI_lasso_is_point_inside(const int mcords[][2], const short moves, const int sx, const int sy, const int error_value); +bool BLI_lasso_is_edge_inside(const int mcords[][2], const short moves, int x0, int y0, int x1, int y1, const int error_value); #endif diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 3c9363039b2..9ce75de5ea8 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -43,8 +43,8 @@ struct rcti; extern "C" { #endif -int BLI_rcti_is_empty(const struct rcti *rect); -int BLI_rctf_is_empty(const struct rctf *rect); +bool BLI_rcti_is_empty(const struct rcti *rect); +bool 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); @@ -60,18 +60,18 @@ void BLI_rcti_scale(rcti *rect, const float scale); void BLI_rctf_scale(rctf *rect, const float scale); 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); -int BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest); -int BLI_rcti_isect_pt(const struct rcti *rect, const int x, const int y); -int BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2]); -int BLI_rctf_isect_pt(const struct rctf *rect, const float x, const float y); -int BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]); -int BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]); -int BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2]); +bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]); +bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]); +bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit); +bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b); +bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest); +bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest); +bool BLI_rcti_isect_pt(const struct rcti *rect, const int x, const int y); +bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2]); +bool BLI_rctf_isect_pt(const struct rctf *rect, const float x, const float y); +bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]); +bool BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]); +bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2]); void BLI_rctf_union(struct rctf *rctf1, const struct rctf *rctf2); void BLI_rcti_union(struct rcti *rcti1, const struct rcti *rcti2); void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src); diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index c3b3a3e348c..ebc40ebc5e3 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -271,7 +271,7 @@ void BLI_ghashIterator_step(GHashIterator *ghi) } } } -int BLI_ghashIterator_notDone(GHashIterator *ghi) +bool BLI_ghashIterator_notDone(GHashIterator *ghi) { return ghi->curEntry != NULL; } diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index aa54969b6f8..53489c76962 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -33,9 +33,10 @@ #include <string.h> #include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" #include "BLI_memarena.h" #include "BLI_heap.h" -#include "BLI_utildefines.h" /***/ @@ -183,7 +184,7 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr) return node; } -int BLI_heap_is_empty(Heap *heap) +bool BLI_heap_is_empty(Heap *heap) { return (heap->size == 0); } diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c index d569534f2f3..272f840296e 100644 --- a/source/blender/blenlib/intern/gsqueue.c +++ b/source/blender/blenlib/intern/gsqueue.c @@ -32,6 +32,8 @@ #include <string.h> #include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" #include "BLI_gsqueue.h" typedef struct _GSQueueElem GSQueueElem; @@ -54,7 +56,7 @@ GSQueue *BLI_gsqueue_new(int elem_size) return gq; } -int BLI_gsqueue_is_empty(GSQueue *gq) +bool BLI_gsqueue_is_empty(GSQueue *gq) { return (gq->head == NULL); } diff --git a/source/blender/blenlib/intern/lasso.c b/source/blender/blenlib/intern/lasso.c index 5cd8bb813a1..024c1010765 100644 --- a/source/blender/blenlib/intern/lasso.c +++ b/source/blender/blenlib/intern/lasso.c @@ -53,9 +53,9 @@ void BLI_lasso_boundbox(rcti *rect, const int mcords[][2], const short moves) } -int BLI_lasso_is_point_inside(const int mcords[][2], const short moves, - const int sx, const int sy, - const int error_value) +bool BLI_lasso_is_point_inside(const int mcords[][2], const short moves, + const int sx, const int sy, + const int error_value) { /* we do the angle rule, define that all added angles should be about zero or (2 * PI) */ float angletot = 0.0, dot, ang, cross, fp1[2], fp2[2]; @@ -63,7 +63,7 @@ int BLI_lasso_is_point_inside(const int mcords[][2], const short moves, const int *p1, *p2; if (sx == error_value) { - return 0; + return false; } p1 = mcords[moves - 1]; @@ -95,35 +95,35 @@ int BLI_lasso_is_point_inside(const int mcords[][2], const short moves, p2 = mcords[a + 1]; } - if (fabsf(angletot) > 4.0f) return 1; - return 0; + if (fabsf(angletot) > 4.0f) return true; + return false; } /* edge version for lasso select. we assume boundbox check was done */ -int BLI_lasso_is_edge_inside(const int mcords[][2], const short moves, - int x0, int y0, int x1, int y1, - const int error_value) +bool BLI_lasso_is_edge_inside(const int mcords[][2], const short moves, + int x0, int y0, int x1, int y1, + const int error_value) { int v1[2], v2[2]; int a; if (x0 == error_value || x1 == error_value) { - return 0; + return false; } v1[0] = x0, v1[1] = y0; v2[0] = x1, v2[1] = y1; /* check points in lasso */ - if (BLI_lasso_is_point_inside(mcords, moves, v1[0], v1[1], error_value)) return 1; - if (BLI_lasso_is_point_inside(mcords, moves, v2[0], v2[1], error_value)) return 1; + if (BLI_lasso_is_point_inside(mcords, moves, v1[0], v1[1], error_value)) return true; + if (BLI_lasso_is_point_inside(mcords, moves, v2[0], v2[1], error_value)) return true; /* no points in lasso, so we have to intersect with lasso edge */ - if (isect_line_line_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return 1; + if (isect_line_line_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return true; for (a = 0; a < moves - 1; a++) { - if (isect_line_line_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return 1; + if (isect_line_line_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return true; } - return 0; + return false; } diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 4bd7715ea7a..127855161c0 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -48,23 +48,23 @@ * * \return True if \a rect is empty. */ -int BLI_rcti_is_empty(const rcti *rect) +bool BLI_rcti_is_empty(const rcti *rect) { return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin)); } -int BLI_rctf_is_empty(const rctf *rect) +bool BLI_rctf_is_empty(const rctf *rect) { return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin)); } -int BLI_rcti_isect_pt(const rcti *rect, const int x, const int y) +bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y) { - if (x < rect->xmin) return 0; - if (x > rect->xmax) return 0; - if (y < rect->ymin) return 0; - if (y > rect->ymax) return 0; - return 1; + if (x < rect->xmin) return false; + if (x > rect->xmax) return false; + if (y < rect->ymin) return false; + if (y > rect->ymax) return false; + return true; } /** @@ -74,31 +74,31 @@ int BLI_rcti_isect_pt(const rcti *rect, const int x, const int y) * * \return True if \a rect is empty. */ -int BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2]) +bool BLI_rcti_isect_pt_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; + if (xy[0] < rect->xmin) return false; + if (xy[0] > rect->xmax) return false; + if (xy[1] < rect->ymin) return false; + if (xy[1] > rect->ymax) return false; + return true; } -int BLI_rctf_isect_pt(const rctf *rect, const float x, const float y) +bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y) { - if (x < rect->xmin) return 0; - if (x > rect->xmax) return 0; - if (y < rect->ymin) return 0; - if (y > rect->ymax) return 0; - return 1; + if (x < rect->xmin) return false; + if (x > rect->xmax) return false; + if (y < rect->ymin) return false; + if (y > rect->ymax) return false; + return true; } -int BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2]) +bool BLI_rctf_isect_pt_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; + if (xy[0] < rect->xmin) return false; + if (xy[0] > rect->xmax) return false; + if (xy[1] < rect->ymin) return false; + if (xy[1] > rect->ymax) return false; + return true; } /* based closely on 'isect_line_line_v2_int', but in modified so corner cases are treated as intersections */ @@ -127,17 +127,17 @@ static int isect_segments_fl(const float v1[2], const float v2[2], const float v } } -int BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2]) +bool BLI_rcti_isect_segment(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; - if (s1[0] > rect->xmax && s2[0] > rect->xmax) return 0; - if (s1[1] < rect->ymin && s2[1] < rect->ymin) return 0; - if (s1[1] > rect->ymax && s2[1] > rect->ymax) return 0; + if (s1[0] < rect->xmin && s2[0] < rect->xmin) return false; + if (s1[0] > rect->xmax && s2[0] > rect->xmax) return false; + if (s1[1] < rect->ymin && s2[1] < rect->ymin) return false; + if (s1[1] > rect->ymax && s2[1] > rect->ymax) return false; /* if either points intersect then we definetly intersect */ if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) { - return 1; + return true; } else { /* both points are outside but may insersect the rect */ @@ -147,32 +147,32 @@ int BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2]) tvec1[0] = rect->xmin; tvec1[1] = rect->ymin; tvec2[0] = rect->xmin; tvec2[1] = rect->ymax; if (isect_segments_i(s1, s2, tvec1, tvec2)) { - return 1; + return true; } /* diagonal: [\] */ tvec1[0] = rect->xmin; tvec1[1] = rect->ymax; tvec2[0] = rect->xmax; tvec2[1] = rect->ymin; if (isect_segments_i(s1, s2, tvec1, tvec2)) { - return 1; + return true; } /* no intersection */ - return 0; + return false; } } -int BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2]) +bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2]) { /* first do outside-bounds check for both points of the segment */ - if (s1[0] < rect->xmin && s2[0] < rect->xmin) return 0; - if (s1[0] > rect->xmax && s2[0] > rect->xmax) return 0; - if (s1[1] < rect->ymin && s2[1] < rect->ymin) return 0; - if (s1[1] > rect->ymax && s2[1] > rect->ymax) return 0; + if (s1[0] < rect->xmin && s2[0] < rect->xmin) return false; + if (s1[0] > rect->xmax && s2[0] > rect->xmax) return false; + if (s1[1] < rect->ymin && s2[1] < rect->ymin) return false; + if (s1[1] > rect->ymax && s2[1] > rect->ymax) return false; /* if either points intersect then we definetly intersect */ if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) { - return 1; + return true; } else { /* both points are outside but may insersect the rect */ @@ -182,18 +182,18 @@ int BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2 tvec1[0] = rect->xmin; tvec1[1] = rect->ymin; tvec2[0] = rect->xmin; tvec2[1] = rect->ymax; if (isect_segments_fl(s1, s2, tvec1, tvec2)) { - return 1; + return true; } /* diagonal: [\] */ tvec1[0] = rect->xmin; tvec1[1] = rect->ymax; tvec2[0] = rect->xmax; tvec2[1] = rect->ymin; if (isect_segments_fl(s1, s2, tvec1, tvec2)) { - return 1; + return true; } /* no intersection */ - return 0; + return false; } } @@ -353,49 +353,49 @@ 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]) +bool 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; } + bool change = false; + if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = true; } + if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = true; } + if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = true; } + if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = true; } return change; } -int BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]) +bool 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; } + bool change = false; + if (xy[0] < rect->xmin) { xy[0] = rect->xmin; change = true; } + if (xy[0] > rect->xmax) { xy[0] = rect->xmax; change = true; } + if (xy[1] < rect->ymin) { xy[1] = rect->ymin; change = true; } + if (xy[1] > rect->ymax) { xy[1] = rect->ymax; change = true; } return change; } -int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit) +bool 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) if (fabsf(rect_a->xmax - rect_b->xmax) < limit) if (fabsf(rect_a->ymin - rect_b->ymin) < limit) if (fabsf(rect_a->ymax - rect_b->ymax) < limit) - return 1; + return true; - return 0; + return false; } -int BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b) +bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b) { if (rect_a->xmin == rect_b->xmin) if (rect_a->xmax == rect_b->xmax) if (rect_a->ymin == rect_b->ymin) if (rect_a->ymax == rect_b->ymax) - return 1; + return true; - return 0; + return false; } -int BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest) +bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest) { float xmin, xmax; float ymin, ymax; @@ -412,7 +412,7 @@ int BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest) dest->ymin = ymin; dest->ymax = ymax; } - return 1; + return true; } else { if (dest) { @@ -421,11 +421,11 @@ int BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest) dest->ymin = 0; dest->ymax = 0; } - return 0; + return false; } } -int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) +bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) { int xmin, xmax; int ymin, ymax; @@ -442,7 +442,7 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) dest->ymin = ymin; dest->ymax = ymax; } - return 1; + return true; } else { if (dest) { @@ -451,7 +451,7 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) dest->ymin = 0; dest->ymax = 0; } - return 0; + return false; } } |