Enlightenment CVS committal Author : turran Project : e17 Module : proto/enesim
Dir : e17/proto/enesim/src/lib/util Modified Files: Makefile.am curve_decasteljau.c Added Files: fixed_16p16.h fixed_24p8.h Log Message: + De Casteljau flat's test works now a simple manhattan distance between the control point and the ends + Added fixed precision code on utils + Make Kiia's algorithm use this header instead of its own implementation of fixed points =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/util/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- Makefile.am 10 Dec 2007 23:04:04 -0000 1.1 +++ Makefile.am 11 Dec 2007 16:03:26 -0000 1.2 @@ -4,7 +4,9 @@ ENESIM_UTILHEADERS = \ curve.h \ extender_int.h \ -extender_float.h +extender_float.h \ +fixed_16p16.h \ +fixed_24p8.h installed_headersdir = $(prefix)/include/enesim installed_headers_DATA = $(ENESIM_UTILHEADERS) =================================================================== RCS file: /cvs/e/e17/proto/enesim/src/lib/util/curve_decasteljau.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- curve_decasteljau.c 10 Dec 2007 23:04:04 -0000 1.1 +++ curve_decasteljau.c 11 Dec 2007 16:03:26 -0000 1.2 @@ -1,16 +1,17 @@ #include "curve.h" +#include "fixed_16p16.h" -#define curve_is_flat level > 2 - -static inline void midpoint_get(float c1, float c2, float *r) +static inline void midpoint_get(enesim_16p16_t c1, enesim_16p16_t c2, enesim_16p16_t *r) { - *r = (c1 + c2) / 2; + *r = enesim_16p16_float_from(enesim_16p16_float_to(enesim_16p16_add(c1, c2)) / 2); } -static void curve3_recursive(float x1, float y1, float x2, float y2, float x3, - float y3, int level, Enesim_Curve_Vertex_Add_Callback cb, void *data) +static void curve3_recursive(enesim_16p16_t x1, enesim_16p16_t y1, enesim_16p16_t x2, + enesim_16p16_t y2, enesim_16p16_t x3, enesim_16p16_t y3, int level, + Enesim_Curve_Vertex_Add_Callback cb, void *data) { - float x12, y12, x23, y23, x123, y123; + enesim_16p16_t x12, y12, x23, y23, x123, y123; + enesim_16p16_t rx, ry; /* mid points */ midpoint_get(x1, x2, &x12); @@ -20,14 +21,14 @@ midpoint_get(x12, x23, &x123); midpoint_get(y12, y23, &y123); - if (curve_is_flat) + rx = abs(x1 + x3 - x2 - x2); + ry = abs(y1 + y3 - y2 - y2); + if ((rx + ry) <= (1 << 16)) { - /* line from x1, y1 to x3, y3 */ - cb(x1, y1, data); - cb(x3, y3, data); + cb(enesim_16p16_float_to(x123), enesim_16p16_float_to(y123), data); return; } - + curve3_recursive(x1, y1, x12, y12, x123, y123, level + 1, cb, data); curve3_recursive(x123, y123, x23, y23, x3, y3, level + 1, cb, data); } @@ -36,7 +37,9 @@ float x3, float y3, Enesim_Curve_Vertex_Add_Callback cb, void *data) { cb(x1, y1, data); - curve3_recursive(x1, y1, x2, y2, x3, y3, 0, cb, data); + curve3_recursive(enesim_16p16_float_from(x1), enesim_16p16_float_from(y1), + enesim_16p16_float_from(x2), enesim_16p16_float_from(y2), + enesim_16p16_float_from(x3), enesim_16p16_float_from(y3), 0, cb, data); cb(x3, y3, data); } @@ -46,4 +49,3 @@ { } - ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs