From 41216d5ad4c722e2ad9f15c968af454fc7566d5e Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 18 Oct 2018 15:43:06 +0200 Subject: Cleanup: Remove more #if 0 blocks Continuation of https://developer.blender.org/D3802 Reviewers: brecht Differential Revision: https://developer.blender.org/D3808 --- source/blender/blenlib/BLI_math_solvers.h | 7 - source/blender/blenlib/BLI_math_statistics.h | 6 - source/blender/blenlib/intern/BLI_array.c | 5 - source/blender/blenlib/intern/BLI_ghash.c | 51 ---- source/blender/blenlib/intern/BLI_ghash_utils.c | 10 +- source/blender/blenlib/intern/BLI_heap.c | 6 - source/blender/blenlib/intern/BLI_kdopbvh.c | 287 ---------------------- source/blender/blenlib/intern/array_store_utils.c | 4 - source/blender/blenlib/intern/edgehash.c | 43 ---- source/blender/blenlib/intern/freetypefont.c | 67 ----- source/blender/blenlib/intern/math_geom.c | 129 +--------- source/blender/blenlib/intern/math_interp.c | 52 ---- source/blender/blenlib/intern/noise.c | 33 --- source/blender/blenlib/intern/path_util.c | 10 - source/blender/blenlib/intern/scanfill.c | 32 --- 15 files changed, 3 insertions(+), 739 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_math_solvers.h b/source/blender/blenlib/BLI_math_solvers.h index 3c1cb90937d..4352779d9ee 100644 --- a/source/blender/blenlib/BLI_math_solvers.h +++ b/source/blender/blenlib/BLI_math_solvers.h @@ -53,13 +53,6 @@ void BLI_svd_m3(const float m3[3][3], float r_U[3][3], float r_S[], float r_V[3] bool BLI_tridiagonal_solve(const float *a, const float *b, const float *c, const float *d, float *r_x, const int count); bool BLI_tridiagonal_solve_cyclic(const float *a, const float *b, const float *c, const float *d, float *r_x, const int count); -/**************************** Inline Definitions ******************************/ -#if 0 /* None so far. */ -# if BLI_MATH_DO_INLINE -# include "intern/math_geom_inline.c" -# endif -#endif - #ifdef BLI_MATH_GCC_WARN_PRAGMA # pragma GCC diagnostic pop #endif diff --git a/source/blender/blenlib/BLI_math_statistics.h b/source/blender/blenlib/BLI_math_statistics.h index 210d41bcf59..40641c05e08 100644 --- a/source/blender/blenlib/BLI_math_statistics.h +++ b/source/blender/blenlib/BLI_math_statistics.h @@ -51,12 +51,6 @@ void BLI_covariance_m3_v3n( const float (*cos_v3)[3], const int nbr_cos_v3, const bool use_sample_correction, float r_covmat[3][3], float r_center[3]); -/**************************** Inline Definitions ******************************/ -#if 0 /* None so far. */ -# if BLI_MATH_DO_INLINE -# include "intern/math_geom_inline.c" -# endif -#endif #ifdef BLI_MATH_GCC_WARN_PRAGMA # pragma GCC diagnostic pop diff --git a/source/blender/blenlib/intern/BLI_array.c b/source/blender/blenlib/intern/BLI_array.c index d16dd36763d..0380656a33a 100644 --- a/source/blender/blenlib/intern/BLI_array.c +++ b/source/blender/blenlib/intern/BLI_array.c @@ -90,9 +90,4 @@ void _bli_array_grow_func( } *arr_p = arr_tmp; - - /* caller must do */ -#if 0 - arr_len += num; -#endif } diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index ec75c140159..071a7e2dc0e 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -1108,57 +1108,6 @@ void BLI_ghashIterator_free(GHashIterator *ghi) MEM_freeN(ghi); } -/* inline functions now */ -#if 0 -/** - * Retrieve the key from an iterator. - * - * \param ghi The iterator. - * \return The key at the current index, or NULL if the - * iterator is done. - */ -void *BLI_ghashIterator_getKey(GHashIterator *ghi) -{ - return ghi->curEntry->key; -} - -/** - * Retrieve the value from an iterator. - * - * \param ghi The iterator. - * \return The value at the current index, or NULL if the - * iterator is done. - */ -void *BLI_ghashIterator_getValue(GHashIterator *ghi) -{ - return ghi->curEntry->val; -} - -/** - * Retrieve the value from an iterator. - * - * \param ghi The iterator. - * \return The value at the current index, or NULL if the - * iterator is done. - */ -void **BLI_ghashIterator_getValue_p(GHashIterator *ghi) -{ - return &ghi->curEntry->val; -} - -/** - * Determine if an iterator is done (has reached the end of - * the hash table). - * - * \param ghi The iterator. - * \return True if done, False otherwise. - */ -bool BLI_ghashIterator_done(GHashIterator *ghi) -{ - return ghi->curEntry == NULL; -} -#endif - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenlib/intern/BLI_ghash_utils.c b/source/blender/blenlib/intern/BLI_ghash_utils.c index 953ceb3442b..6b8c9b5226c 100644 --- a/source/blender/blenlib/intern/BLI_ghash_utils.c +++ b/source/blender/blenlib/intern/BLI_ghash_utils.c @@ -47,13 +47,7 @@ /** \name Generic Key Hash & Comparison Functions * \{ */ -#if 0 -/* works but slower */ -uint BLI_ghashutil_ptrhash(const void *key) -{ - return (uint)(intptr_t)key; -} -#else + /* based python3.3's pointer hashing function */ uint BLI_ghashutil_ptrhash(const void *key) { @@ -63,7 +57,7 @@ uint BLI_ghashutil_ptrhash(const void *key) y = (y >> 4) | (y << (8 * sizeof(void *) - 4)); return (uint)y; } -#endif + bool BLI_ghashutil_ptrcmp(const void *a, const void *b) { return (a != b); diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index 5658c1fd103..97605640be4 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -87,11 +87,6 @@ struct Heap { BLI_INLINE void heap_swap(Heap *heap, const uint i, const uint j) { - -#if 0 - SWAP(uint, heap->tree[i]->index, heap->tree[j]->index); - SWAP(HeapNode *, heap->tree[i], heap->tree[j]); -#else HeapNode **tree = heap->tree; union { uint index; @@ -99,7 +94,6 @@ BLI_INLINE void heap_swap(Heap *heap, const uint i, const uint j) } tmp; SWAP_TVAL(tmp.index, tree[i]->index, tree[j]->index); SWAP_TVAL(tmp.node, tree[i], tree[j]); -#endif } static void heap_down(Heap *heap, uint i) diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index ddfb75fc2ce..45198af0515 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -213,74 +213,6 @@ MINLINE axis_t max_axis(axis_t a, axis_t b) } #endif -#if 0 - -/* - * Generic push and pop heap - */ -#define PUSH_HEAP_BODY(HEAP_TYPE, PRIORITY, heap, heap_size) \ - { \ - HEAP_TYPE element = heap[heap_size - 1]; \ - int child = heap_size - 1; \ - while (child != 0) { \ - int parent = (child - 1) / 2; \ - if (PRIORITY(element, heap[parent])) { \ - heap[child] = heap[parent]; \ - child = parent; \ - } \ - else { \ - break; \ - } \ - } \ - heap[child] = element; \ - } (void)0 - -#define POP_HEAP_BODY(HEAP_TYPE, PRIORITY, heap, heap_size) \ - { \ - HEAP_TYPE element = heap[heap_size - 1]; \ - int parent = 0; \ - while (parent < (heap_size - 1) / 2) { \ - int child2 = (parent + 1) * 2; \ - if (PRIORITY(heap[child2 - 1], heap[child2])) { \ - child2--; \ - } \ - if (PRIORITY(element, heap[child2])) { \ - break; \ - } \ - heap[parent] = heap[child2]; \ - parent = child2; \ - } \ - heap[parent] = element; \ - } (void)0 - -static bool ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_size, int size_per_item) -{ - int new_max_size = *max_size * 2; - void *new_memblock = NULL; - - if (new_size <= *max_size) { - return true; - } - - if (*memblock == local_memblock) { - new_memblock = malloc(size_per_item * new_max_size); - memcpy(new_memblock, *memblock, size_per_item * *max_size); - } - else { - new_memblock = realloc(*memblock, size_per_item * new_max_size); - } - - if (new_memblock) { - *memblock = new_memblock; - *max_size = new_max_size; - return true; - } - else { - return false; - } -} -#endif - /** * Introsort * with permission deriven from the following Java code: @@ -288,17 +220,7 @@ static bool ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, i * and he derived it from the SUN STL */ -//static int size_threshold = 16; -#if 0 -/** - * Common methods for all algorithms - */ -static int floor_lg(int a) -{ - return (int)(floor(log(a) / log(2))); -} -#endif static void node_minmax_init(const BVHTree *tree, BVHNode *node) { @@ -356,39 +278,6 @@ static int bvh_partition(BVHNode **a, int lo, int hi, BVHNode *x, int axis) } } -#if 0 -/** - * Heapsort algorithm - */ -static void bvh_downheap(BVHNode **a, int i, int n, int lo, int axis) -{ - BVHNode *d = a[lo + i - 1]; - int child; - while (i <= n / 2) { - child = 2 * i; - if ((child < n) && ((a[lo + child - 1])->bv[axis] < (a[lo + child])->bv[axis])) { - child++; - } - if (!(d->bv[axis] < (a[lo + child - 1])->bv[axis])) break; - a[lo + i - 1] = a[lo + child - 1]; - i = child; - } - a[lo + i - 1] = d; -} - -static void bvh_heapsort(BVHNode **a, int lo, int hi, int axis) -{ - int n = hi - lo, i; - for (i = n / 2; i >= 1; i = i - 1) { - bvh_downheap(a, i, n, lo, axis); - } - for (i = n; i > 1; i = i - 1) { - SWAP(BVHNode *, a[lo], a[lo + i - 1]); - bvh_downheap(a, 1, i - 1, lo, axis); - } -} -#endif - static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis) /* returns Sortable */ { if ((a[mid])->bv[axis] < (a[lo])->bv[axis]) { @@ -413,41 +302,6 @@ static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis) / } } -#if 0 -/* - * Quicksort algorithm modified for Introsort - */ -static void bvh_introsort_loop(BVHNode **a, int lo, int hi, int depth_limit, int axis) -{ - int p; - - while (hi - lo > size_threshold) { - if (depth_limit == 0) { - bvh_heapsort(a, lo, hi, axis); - return; - } - depth_limit = depth_limit - 1; - p = bvh_partition(a, lo, hi, bvh_medianof3(a, lo, lo + ((hi - lo) / 2) + 1, hi - 1, axis), axis); - bvh_introsort_loop(a, p, hi, depth_limit, axis); - hi = p; - } -} - -static void sort(BVHNode **a0, int begin, int end, int axis) -{ - if (begin < end) { - BVHNode **a = a0; - bvh_introsort_loop(a, begin, end, 2 * floor_lg(end - begin), axis); - bvh_insertionsort(a, begin, end, axis); - } -} - -static void sort_along_axis(BVHTree *tree, int start, int end, int axis) -{ - sort(tree->nodes, start, end, axis); -} -#endif - /** * \note after a call to this function you can expect one of: * - every node to left of a[n] are smaller or equal to it @@ -1420,23 +1274,6 @@ static float calc_nearest_point_squared(const float proj[3], BVHNode *node, floa nearest[i] = proj[i]; } -#if 0 - /* nearest on a general hull */ - copy_v3_v3(nearest, data->co); - for (i = data->tree->start_axis; i != data->tree->stop_axis; i++, bv += 2) { - float proj = dot_v3v3(nearest, bvhtree_kdop_axes[i]); - float dl = bv[0] - proj; - float du = bv[1] - proj; - - if (dl > 0) { - madd_v3_v3fl(nearest, bvhtree_kdop_axes[i], dl); - } - else if (du < 0) { - madd_v3_v3fl(nearest, bvhtree_kdop_axes[i], du); - } - } -#endif - return len_squared_v3v3(proj, nearest); } @@ -1484,101 +1321,6 @@ static void dfs_find_nearest_begin(BVHNearestData *data, BVHNode *node) dfs_find_nearest_dfs(data, node); } - -#if 0 - -typedef struct NodeDistance { - BVHNode *node; - float dist; - -} NodeDistance; - -#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) - -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 thread safe */ -static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) -{ - int i; - NodeDistance default_heap[DEFAULT_FIND_NEAREST_HEAP_SIZE]; - NodeDistance *heap = default_heap, current; - int heap_size = 0, max_heap_size = sizeof(default_heap) / sizeof(default_heap[0]); - float nearest[3]; - - int callbacks = 0, push_heaps = 0; - - if (node->totnode == 0) { - dfs_find_nearest_dfs(data, node); - return; - } - - current.node = node; - current.dist = calc_nearest_point(data->proj, node, nearest); - - while (current.dist < data->nearest.dist) { -// printf("%f : %f\n", current.dist, data->nearest.dist); - for (i = 0; i < current.node->totnode; i++) { - BVHNode *child = current.node->children[i]; - if (child->totnode == 0) { - callbacks++; - dfs_find_nearest_dfs(data, child); - } - else { - /* adjust heap size */ - if ((heap_size >= max_heap_size) && - ADJUST_MEMORY(default_heap, (void **)&heap, - heap_size + 1, &max_heap_size, sizeof(heap[0])) == false) - { - printf("WARNING: bvh_find_nearest got out of memory\n"); - - if (heap != default_heap) - free(heap); - - return; - } - - heap[heap_size].node = current.node->children[i]; - heap[heap_size].dist = calc_nearest_point(data->proj, current.node->children[i], nearest); - - if (heap[heap_size].dist >= data->nearest.dist) continue; - heap_size++; - - NodeDistance_push_heap(heap, heap_size); - // PUSH_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size); - push_heaps++; - } - } - - if (heap_size == 0) break; - - current = heap[0]; - NodeDistance_pop_heap(heap, heap_size); -// POP_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size); - heap_size--; - } - -// printf("hsize=%d, callbacks=%d, pushs=%d\n", heap_size, callbacks, push_heaps); - - if (heap != default_heap) - free(heap); -} -#endif - - int BLI_bvhtree_find_nearest( BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata) @@ -1768,35 +1510,6 @@ static void dfs_raycast_all(BVHRayCastData *data, BVHNode *node) } } -#if 0 -static void iterative_raycast(BVHRayCastData *data, BVHNode *node) -{ - while (node) { - float dist = fast_ray_nearest_hit(data, node); - if (dist >= data->hit.dist) { - node = node->skip[1]; - continue; - } - - if (node->totnode == 0) { - if (data->callback) { - data->callback(data->userdata, node->index, &data->ray, &data->hit); - } - else { - data->hit.index = node->index; - data->hit.dist = dist; - madd_v3_v3v3fl(data->hit.co, data->ray.origin, data->ray.direction, dist); - } - - node = node->skip[1]; - } - else { - node = node->children[0]; - } - } -} -#endif - static void bvhtree_ray_cast_data_precalc(BVHRayCastData *data, int flag) { int i; diff --git a/source/blender/blenlib/intern/array_store_utils.c b/source/blender/blenlib/intern/array_store_utils.c index 83cd28ddf11..97e4207328b 100644 --- a/source/blender/blenlib/intern/array_store_utils.c +++ b/source/blender/blenlib/intern/array_store_utils.c @@ -43,9 +43,6 @@ BArrayStore *BLI_array_store_at_size_ensure( BArrayStore **bs_p = &bs_stride->stride_table[stride - 1]; if ((*bs_p) == NULL) { -#if 0 - unsigned int chunk_count = chunk_size; -#else /* calculate best chunk-count to fit a power of two */ unsigned int chunk_count = chunk_size; { @@ -54,7 +51,6 @@ BArrayStore *BLI_array_store_at_size_ensure( size = MEM_SIZE_OPTIMAL(size); chunk_count = size / stride; } -#endif (*bs_p) = BLI_array_store_create(stride, chunk_count); } diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index 7074a776aaf..1ba26b06c18 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -659,49 +659,6 @@ void BLI_edgehashIterator_free(EdgeHashIterator *ehi) MEM_freeN(ehi); } -/* inline functions now */ -#if 0 -/** - * Retrieve the key from an iterator. - */ -void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, uint *r_v0, uint *r_v1) -{ - *r_v0 = ehi->curEntry->v0; - *r_v1 = ehi->curEntry->v1; -} - -/** - * Retrieve the value from an iterator. - */ -void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi) -{ - return ehi->curEntry->val; -} - -/** - * Retrieve the pointer to the value from an iterator. - */ -void **BLI_edgehashIterator_getValue_p(EdgeHashIterator *ehi) -{ - return &ehi->curEntry->val; -} - -/** - * Set the value for an iterator. - */ -void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val) -{ - ehi->curEntry->val = val; -} - -/** - * Determine if an iterator is done. - */ -bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi) -{ - return (ehi->curEntry == NULL); -} -#endif /** \} */ diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 9045012af00..0bed7d42e9f 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -291,14 +291,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) const char *fontname; VFontData *vfd; -#if 0 - FT_CharMap found = 0; - FT_CharMap charmap; - FT_UShort my_platform_id = TT_PLATFORM_MICROSOFT; - FT_UShort my_encoding_id = TT_MS_ID_UNICODE_CS; - int n; -#endif - /* load the freetype font */ err = FT_New_Memory_Face(library, pf->data, @@ -308,25 +300,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) if (err) return NULL; -#if 0 - for (n = 0; n < face->num_charmaps; n++) - { - charmap = face->charmaps[n]; - if (charmap->platform_id == my_platform_id && - charmap->encoding_id == my_encoding_id) - { - found = charmap; - break; - } - } - - if (!found) { return NULL; } - - /* now, select the charmap for the face object */ - err = FT_Set_Charmap(face, found); - if (err) { return NULL; } -#endif - /* allocate blender font */ vfd = MEM_callocN(sizeof(*vfd), "FTVFontData"); @@ -410,13 +383,6 @@ static int check_freetypefont(PackedFile *pf) FT_Face face; FT_GlyphSlot glyph; FT_UInt glyph_index; -#if 0 - FT_CharMap charmap; - FT_CharMap found; - FT_UShort my_platform_id = TT_PLATFORM_MICROSOFT; - FT_UShort my_encoding_id = TT_MS_ID_UNICODE_CS; - int n; -#endif int success = 0; err = FT_New_Memory_Face(library, @@ -429,23 +395,6 @@ static int check_freetypefont(PackedFile *pf) //XXX error("This is not a valid font"); } else { - -#if 0 - for (n = 0; n < face->num_charmaps; n++) { - charmap = face->charmaps[n]; - if (charmap->platform_id == my_platform_id && charmap->encoding_id == my_encoding_id) { - found = charmap; - break; - } - } - - if (!found) { return 0; } - - /* now, select the charmap for the face object */ - err = FT_Set_Charmap(face, found); - if (err) { return 0; } -#endif - glyph_index = FT_Get_Char_Index(face, 'A'); err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP); if (err) { @@ -550,22 +499,6 @@ VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int UNUSED(flag)) return vchar_dst; } -#if 0 - -/* Freetype2 Outline struct */ - -typedef struct FT_Outline_ { - short n_contours; /* number of contours in glyph */ - short n_points; /* number of points in the glyph */ - - FT_Vector *points; /* the outline's points */ - char *tags; /* the points flags */ - short *contours; /* the contour end points */ - - int flags; /* outline masks */ -} FT_Outline; - -#endif /* * from: http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-1 diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index a5c84ed7645..d59d7b4fe6a 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -534,21 +534,11 @@ float dist_signed_squared_to_corner_v3v3v3( cross_v3_v3v3(plane_a, dir_a, axis); cross_v3_v3v3(plane_b, axis, dir_b); -#if 0 - plane_from_point_normal_v3(plane_a, v2, plane_a); - plane_from_point_normal_v3(plane_b, v2, plane_b); - - dist_a = dist_signed_squared_to_plane_v3(p, plane_a); - dist_b = dist_signed_squared_to_plane_v3(p, plane_b); -#else /* calculate without the planes 4th component to avoid float precision issues */ sub_v3_v3v3(s_p_v2, p, v2); dist_a = dist_signed_squared_to_plane3_v3(s_p_v2, plane_a); dist_b = dist_signed_squared_to_plane3_v3(s_p_v2, plane_b); -#endif - - if (flip) { return min_ff(dist_a, dist_b); @@ -1456,90 +1446,6 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2], } /* point in polygon (keep float and int versions in sync) */ -#if 0 -bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr, - const bool use_holes) -{ - /* we do the angle rule, define that all added angles should be about zero or (2 * PI) */ - float angletot = 0.0; - float fp1[2], fp2[2]; - unsigned int i; - const float *p1, *p2; - - p1 = verts[nr - 1]; - - /* first vector */ - fp1[0] = (float)(p1[0] - pt[0]); - fp1[1] = (float)(p1[1] - pt[1]); - - for (i = 0; i < nr; i++) { - p2 = verts[i]; - - /* second vector */ - fp2[0] = (float)(p2[0] - pt[0]); - fp2[1] = (float)(p2[1] - pt[1]); - - /* dot and angle and cross */ - angletot += angle_signed_v2v2(fp1, fp2); - - /* circulate */ - copy_v2_v2(fp1, fp2); - p1 = p2; - } - - angletot = fabsf(angletot); - if (use_holes) { - const float nested = floorf((angletot / (float)(M_PI * 2.0)) + 0.00001f); - angletot -= nested * (float)(M_PI * 2.0); - return (angletot > 4.0f) != ((int)nested % 2); - } - else { - return (angletot > 4.0f); - } -} -bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsigned int nr, - const bool use_holes) -{ - /* we do the angle rule, define that all added angles should be about zero or (2 * PI) */ - float angletot = 0.0; - float fp1[2], fp2[2]; - unsigned int i; - const int *p1, *p2; - - p1 = verts[nr - 1]; - - /* first vector */ - fp1[0] = (float)(p1[0] - pt[0]); - fp1[1] = (float)(p1[1] - pt[1]); - - for (i = 0; i < nr; i++) { - p2 = verts[i]; - - /* second vector */ - fp2[0] = (float)(p2[0] - pt[0]); - fp2[1] = (float)(p2[1] - pt[1]); - - /* dot and angle and cross */ - angletot += angle_signed_v2v2(fp1, fp2); - - /* circulate */ - copy_v2_v2(fp1, fp2); - p1 = p2; - } - - angletot = fabsf(angletot); - if (use_holes) { - const float nested = floorf((angletot / (float)(M_PI * 2.0)) + 0.00001f); - angletot -= nested * (float)(M_PI * 2.0); - return (angletot > 4.0f) != ((int)nested % 2); - } - else { - return (angletot > 4.0f); - } -} - -#else - bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr, const bool UNUSED(use_holes)) { @@ -1569,8 +1475,6 @@ bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsign return isect; } -#endif - /* point in tri */ /* only single direction */ @@ -2592,18 +2496,6 @@ bool isect_axial_line_segment_tri_v3( float u, v, f; int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3; -#if 0 - return isect_line_segment_tri_v3(p1, p2, v0, v1, v2, lambda); - - /* first a simple bounding box test */ - if (min_fff(v0[a1], v1[a1], v2[a1]) > p1[a1]) return false; - if (min_fff(v0[a2], v1[a2], v2[a2]) > p1[a2]) return false; - if (max_fff(v0[a1], v1[a1], v2[a1]) < p1[a1]) return false; - if (max_fff(v0[a2], v1[a2], v2[a2]) < p1[a2]) return false; - - /* then a full intersection test */ -#endif - sub_v3_v3v3(e1, v1, v0); sub_v3_v3v3(e2, v2, v0); sub_v3_v3v3(p, v0, p1); @@ -2920,13 +2812,10 @@ float line_point_factor_v3_ex( float dot; sub_v3_v3v3(u, l2, l1); sub_v3_v3v3(h, p, l1); -#if 0 - return (dot_v3v3(u, h) / dot_v3v3(u, u)); -#else + /* better check for zero */ dot = len_squared_v3(u); return (dot > epsilon) ? (dot_v3v3(u, h) / dot) : fallback; -#endif } float line_point_factor_v3( const float p[3], const float l1[3], const float l2[3]) @@ -2942,13 +2831,9 @@ float line_point_factor_v2_ex( float dot; sub_v2_v2v2(u, l2, l1); sub_v2_v2v2(h, p, l1); -#if 0 - return (dot_v2v2(u, h) / dot_v2v2(u, u)); -#else /* better check for zero */ dot = len_squared_v2(u); return (dot > epsilon) ? (dot_v2v2(u, h) / dot) : fallback; -#endif } float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2]) @@ -3063,18 +2948,6 @@ bool point_in_slice_seg(float p[3], float l1[3], float l2[3]) return point_in_slice_as(p, l1, normal); } -#if 0 -/*mama (knowing the squared length of the normal) */ -static int point_in_slice_m(float p[3], float origin[3], float normal[3], float lns) -{ - float h, rp[3]; - sub_v3_v3v3(rp, p, origin); - h = dot_v3v3(normal, rp) / lns; - if (h < 0.0f || h > 1.0f) return 0; - return 1; -} -#endif - bool isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3]) { if (!point_in_slice(p, v1, v2, v3)) return false; diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c index b93a7f55821..71da270e1f2 100644 --- a/source/blender/blenlib/intern/math_interp.c +++ b/source/blender/blenlib/intern/math_interp.c @@ -57,19 +57,6 @@ static float P(float k) return (float)(1.0f / 6.0f) * (p1 * p1 * p1 - 4.0f * p2 * p2 * p2 + 6.0f * p3 * p3 * p3 - 4.0f * p4 * p4 * p4); } - -#if 0 -/* older, slower function, works the same as above */ -static float P(float k) -{ - return (float)(1.0f / 6.0f) * - (pow(MAX2(k + 2.0f, 0), 3.0f) - 4.0f * - pow(MAX2(k + 1.0f, 0), 3.0f) + 6.0f * - pow(MAX2(k, 0), 3.0f) - 4.0f * - pow(MAX2(k - 1.0f, 0), 3.0f)); -} -#endif - static void vector_from_float(const float *data, float vector[4], int components) { if (components == 1) { @@ -179,45 +166,6 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl /* Done with optimized part */ -#if 0 - /* older, slower function, works the same as above */ - for (n = -1; n <= 2; n++) { - for (m = -1; m <= 2; m++) { - x1 = i + n; - y1 = j + m; - if (x1 > 0 && x1 < width && y1 > 0 && y1 < height) { - float data[4]; - - if (float_output) { - const float *float_data = float_buffer + width * y1 * components + components * x1; - - vector_from_float(float_data, data, components); - } - else { - const unsigned char *byte_data = byte_buffer + width * y1 * components + components * x1; - - vector_from_byte(byte_data, data, components); - } - - if (components == 1) { - out[0] += data[0] * P(n - a) * P(b - m); - } - else if (components == 3) { - out[0] += data[0] * P(n - a) * P(b - m); - out[1] += data[1] * P(n - a) * P(b - m); - out[2] += data[2] * P(n - a) * P(b - m); - } - else { - out[0] += data[0] * P(n - a) * P(b - m); - out[1] += data[1] * P(n - a) * P(b - m); - out[2] += data[2] * P(n - a) * P(b - m); - out[3] += data[3] * P(n - a) * P(b - m); - } - } - } - } -#endif - if (float_output) { if (components == 1) { float_output[0] = out[0]; diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 075ae2f5357..8ee99544ca5 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -1092,26 +1092,6 @@ static float noise3_perlin(float vec[3]) #undef SURVE } -#if 0 -static float turbulence_perlin(const float point[3], float lofreq, float hifreq) -{ - float freq, t, p[3]; - - p[0] = point[0] + 123.456; - p[1] = point[1]; - p[2] = point[2]; - - t = 0; - for (freq = lofreq; freq < hifreq; freq *= 2.0) { - t += fabsf(noise3_perlin(p)) / freq; - p[0] *= 2.0f; - p[1] *= 2.0f; - p[2] *= 2.0f; - } - return t - 0.3; /* readjust to make mean value = 0.0 */ -} -#endif - /* for use with BLI_gNoise/gTurbulence, returns signed noise */ static float orgPerlinNoise(float x, float y, float z) { @@ -1147,19 +1127,6 @@ float BLI_hnoisep(float noisesize, float x, float y, float z) return noise3_perlin(vec); } -#if 0 -static float turbulencep(float noisesize, float x, float y, float z, int nr) -{ - float vec[3]; - - vec[0] = x / noisesize; - vec[1] = y / noisesize; - vec[2] = z / noisesize; - nr++; - return turbulence_perlin(vec, 1.0, (float)(1 << nr)); -} -#endif - /******************/ /* VORONOI/WORLEY */ /******************/ diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 52bc27caa1f..a7118a583b5 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1343,16 +1343,6 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c return; /* string is NULL, probably shouldnt happen but return anyway */ } - - /* we first push all slashes into unix mode, just to make sure we don't get - * any mess with slashes later on. -jesterKing */ - /* constant strings can be passed for those parameters - don't change them - elubie */ -#if 0 - BLI_str_replace_char(relabase, '\\', '/'); - BLI_str_replace_char(dir, '\\', '/'); - BLI_str_replace_char(file, '\\', '/'); -#endif - /* Resolve relative references */ if (relabase && dir[0] == '/' && dir[1] == '/') { char *lslash; diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index f1564d132e3..427a3eb1edb 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -811,38 +811,6 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const } #endif -#if 0 - if (flag & BLI_SCANFILL_CALC_QUADTRI_FASTPATH) { - const int totverts = BLI_listbase_count(&sf_ctx->fillvertbase); - - if (totverts == 3) { - eve = sf_ctx->fillvertbase.first; - - addfillface(sf_ctx, eve, eve->next, eve->next->next); - return 1; - } - else if (totverts == 4) { - float vec1[3], vec2[3]; - - eve = sf_ctx->fillvertbase.first; - /* no need to check 'eve->next->next->next' is valid, already counted */ - /* use shortest diagonal for quad */ - sub_v3_v3v3(vec1, eve->co, eve->next->next->co); - sub_v3_v3v3(vec2, eve->next->co, eve->next->next->next->co); - - if (dot_v3v3(vec1, vec1) < dot_v3v3(vec2, vec2)) { - addfillface(sf_ctx, eve, eve->next, eve->next->next); - addfillface(sf_ctx, eve->next->next, eve->next->next->next, eve); - } - else { - addfillface(sf_ctx, eve->next, eve->next->next, eve->next->next->next); - addfillface(sf_ctx, eve->next->next->next, eve, eve->next); - } - return 2; - } - } -#endif - /* first test vertices if they are in edges */ /* including resetting of flags */ for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) { -- cgit v1.2.3