diff --git a/clib.json b/clib.json index 88e8d41..27c495f 100644 --- a/clib.json +++ b/clib.json @@ -1,6 +1,6 @@ { "name": "nuklear", - "version": "4.9.5", + "version": "4.9.6", "repo": "Immediate-Mode-UI/Nuklear", "description": "A small ANSI C gui toolkit", "keywords": ["gl", "ui", "toolkit"], diff --git a/nuklear.h b/nuklear.h index 6699d61..9a33488 100644 --- a/nuklear.h +++ b/nuklear.h @@ -147,7 +147,7 @@ /// NK_ASSERT | If you don't define this, nuklear will use with assert(). /// NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version. /// NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version. -/// NK_SQRT | You can define this to 'sqrt' or your own sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version. +/// NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version. /// NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation. /// NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation. /// NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). @@ -5838,7 +5838,9 @@ NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255}; else (*(s)) = NK_WIDGET_STATE_INACTIVE; /* math */ +#ifndef NK_INV_SQRT NK_LIB float nk_inv_sqrt(float n); +#endif #ifndef NK_SIN NK_LIB float nk_sin(float x); #endif @@ -6132,6 +6134,8 @@ nk_stbtt_free(void *ptr, void *user_data) { (it can actually approximate a lot more functions) can be found here: www.lolengine.net/wiki/oss/lolremez */ +#ifndef NK_INV_SQRT +#define NK_INV_SQRT nk_inv_sqrt NK_LIB float nk_inv_sqrt(float n) { @@ -6144,6 +6148,7 @@ nk_inv_sqrt(float n) conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f)); return conv.f; } +#endif #ifndef NK_SIN #define NK_SIN nk_sin NK_LIB float @@ -9854,7 +9859,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p /* vec2 inverted length */ len = nk_vec2_len_sqr(diff); if (len != 0.0f) - len = nk_inv_sqrt(len); + len = NK_INV_SQRT(len); else len = 1.0f; diff = nk_vec2_muls(diff, len); @@ -10005,7 +10010,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p /* vec2 inverted length */ len = nk_vec2_len_sqr(diff); if (len != 0.0f) - len = nk_inv_sqrt(len); + len = NK_INV_SQRT(len); else len = 1.0f; diff = nk_vec2_muls(diff, len); @@ -10095,7 +10100,7 @@ nk_draw_list_fill_poly_convex(struct nk_draw_list *list, /* vec2 inverted length */ float len = nk_vec2_len_sqr(diff); if (len != 0.0f) - len = nk_inv_sqrt(len); + len = NK_INV_SQRT(len); else len = 1.0f; diff = nk_vec2_muls(diff, len); @@ -29624,6 +29629,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args) /// - [y]: Minor version with non-breaking API and library changes /// - [z]: Patch version with no direct changes to the API /// +/// - 2022/02/03 (4.9.6) - Allow overriding the NK_INV_SQRT function, similar to NK_SIN and NK_COS /// - 2021/12/22 (4.9.5) - Revert layout bounds not accounting for padding due to regressions /// - 2021/12/22 (4.9.4) - Fix checking hovering when window is minimized /// - 2021/12/22 (4.09.3) - Fix layout bounds not accounting for padding diff --git a/src/CHANGELOG b/src/CHANGELOG index bbd956f..4be9f04 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -7,6 +7,7 @@ /// - [y]: Minor version with non-breaking API and library changes /// - [z]: Patch version with no direct changes to the API /// +/// - 2022/02/03 (4.9.6) - Allow overriding the NK_INV_SQRT function, similar to NK_SIN and NK_COS /// - 2021/12/22 (4.9.5) - Revert layout bounds not accounting for padding due to regressions /// - 2021/12/22 (4.9.4) - Fix checking hovering when window is minimized /// - 2021/12/22 (4.09.3) - Fix layout bounds not accounting for padding diff --git a/src/HEADER b/src/HEADER index a0c749f..3a5bffe 100644 --- a/src/HEADER +++ b/src/HEADER @@ -146,7 +146,7 @@ /// NK_ASSERT | If you don't define this, nuklear will use with assert(). /// NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version. /// NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version. -/// NK_SQRT | You can define this to 'sqrt' or your own sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version. +/// NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version. /// NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation. /// NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation. /// NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). diff --git a/src/nuklear_internal.h b/src/nuklear_internal.h index ec8081b..8d1b785 100644 --- a/src/nuklear_internal.h +++ b/src/nuklear_internal.h @@ -94,7 +94,9 @@ NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255}; else (*(s)) = NK_WIDGET_STATE_INACTIVE; /* math */ +#ifndef NK_INV_SQRT NK_LIB float nk_inv_sqrt(float n); +#endif #ifndef NK_SIN NK_LIB float nk_sin(float x); #endif diff --git a/src/nuklear_math.c b/src/nuklear_math.c index b70651b..c288a0b 100644 --- a/src/nuklear_math.c +++ b/src/nuklear_math.c @@ -33,6 +33,8 @@ (it can actually approximate a lot more functions) can be found here: www.lolengine.net/wiki/oss/lolremez */ +#ifndef NK_INV_SQRT +#define NK_INV_SQRT nk_inv_sqrt NK_LIB float nk_inv_sqrt(float n) { @@ -45,6 +47,7 @@ nk_inv_sqrt(float n) conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f)); return conv.f; } +#endif #ifndef NK_SIN #define NK_SIN nk_sin NK_LIB float diff --git a/src/nuklear_vertex.c b/src/nuklear_vertex.c index fe881c8..b98eb1e 100644 --- a/src/nuklear_vertex.c +++ b/src/nuklear_vertex.c @@ -477,7 +477,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p /* vec2 inverted length */ len = nk_vec2_len_sqr(diff); if (len != 0.0f) - len = nk_inv_sqrt(len); + len = NK_INV_SQRT(len); else len = 1.0f; diff = nk_vec2_muls(diff, len); @@ -628,7 +628,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p /* vec2 inverted length */ len = nk_vec2_len_sqr(diff); if (len != 0.0f) - len = nk_inv_sqrt(len); + len = NK_INV_SQRT(len); else len = 1.0f; diff = nk_vec2_muls(diff, len); @@ -718,7 +718,7 @@ nk_draw_list_fill_poly_convex(struct nk_draw_list *list, /* vec2 inverted length */ float len = nk_vec2_len_sqr(diff); if (len != 0.0f) - len = nk_inv_sqrt(len); + len = NK_INV_SQRT(len); else len = 1.0f; diff = nk_vec2_muls(diff, len);