From a30c9f710a64d0adca1597c0d0404713a26a401e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Oct 2018 09:07:40 +1100 Subject: Partial revert '#if 0' cleanup Partially revert 41216d5ad4c722e2ad9f15c968af454fc7566d5e Some of this code had comments to be left as is for readability, or comment the code should be kept. Other functions were only for debugging. --- source/blender/blenlib/intern/BLI_heap.c | 6 ++++ source/blender/blenlib/intern/math_geom.c | 8 +++++ source/blender/blenlib/intern/math_interp.c | 52 +++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index 97605640be4..5658c1fd103 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -87,6 +87,11 @@ 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; @@ -94,6 +99,7 @@ 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/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d59d7b4fe6a..eae82ff2f4f 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -534,11 +534,19 @@ 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); diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c index 71da270e1f2..b93a7f55821 100644 --- a/source/blender/blenlib/intern/math_interp.c +++ b/source/blender/blenlib/intern/math_interp.c @@ -57,6 +57,19 @@ 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) { @@ -166,6 +179,45 @@ 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]; -- cgit v1.2.3