mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Internals: Standard math functions default redirection uses a define instead of an extraneous inline function call
This commit is contained in:
parent
8bcac7d95c
commit
15c6abe4be
@ -297,22 +297,21 @@ IMGUI_API void* ImFileLoadToMemory(const char* filename, const char*
|
|||||||
// Helpers: Maths
|
// Helpers: Maths
|
||||||
// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
|
// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
|
||||||
#ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
|
#ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
|
||||||
static inline float ImFabs(float x) { return fabsf(x); }
|
#define ImFabs(X) fabsf(X)
|
||||||
static inline float ImSqrt(float x) { return sqrtf(x); }
|
#define ImSqrt(X) sqrtf(X)
|
||||||
static inline float ImPow(float x, float y) { return powf(x, y); }
|
#define ImFmod(X, Y) fmodf((X), (Y))
|
||||||
static inline double ImPow(double x, double y) { return pow(x, y); }
|
#define ImCos(X) cosf(X)
|
||||||
static inline float ImFmod(float x, float y) { return fmodf(x, y); }
|
#define ImSin(X) sinf(X)
|
||||||
static inline double ImFmod(double x, double y) { return fmod(x, y); }
|
#define ImAcos(X) acosf(X)
|
||||||
static inline float ImCos(float x) { return cosf(x); }
|
#define ImAtan2(Y, X) atan2f((Y), (X))
|
||||||
static inline float ImSin(float x) { return sinf(x); }
|
#define ImAtof(STR) atof(STR)
|
||||||
static inline float ImAcos(float x) { return acosf(x); }
|
#define ImFloorStd(X) floorf(X) // We already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by e.g. stb_truetype)
|
||||||
static inline float ImAtan2(float y, float x) { return atan2f(y, x); }
|
#define ImCeil(X) ceilf(X)
|
||||||
static inline double ImAtof(const char* s) { return atof(s); }
|
static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
|
||||||
static inline float ImFloorStd(float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
|
static inline double ImPow(double x, double y) { return pow(x, y); }
|
||||||
static inline float ImCeil(float x) { return ceilf(x); }
|
|
||||||
#endif
|
#endif
|
||||||
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double
|
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
|
||||||
// (Exceptionally using templates here but we could also redefine them for variety of types)
|
// (Exceptionally using templates here but we could also redefine them for those types)
|
||||||
template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
|
template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
|
||||||
template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
|
template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
|
||||||
template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||||
|
Loading…
Reference in New Issue
Block a user