mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Removed redundant functions.
This commit is contained in:
@@ -97,36 +97,6 @@ namespace bx
|
||||
return ffloor(_f + 0.5f);
|
||||
}
|
||||
|
||||
inline float fmin(float _a, float _b)
|
||||
{
|
||||
return _a < _b ? _a : _b;
|
||||
}
|
||||
|
||||
inline float fmax(float _a, float _b)
|
||||
{
|
||||
return _a > _b ? _a : _b;
|
||||
}
|
||||
|
||||
inline float fmin3(float _a, float _b, float _c)
|
||||
{
|
||||
return fmin(_a, fmin(_b, _c) );
|
||||
}
|
||||
|
||||
inline float fmax3(float _a, float _b, float _c)
|
||||
{
|
||||
return fmax(_a, fmax(_b, _c) );
|
||||
}
|
||||
|
||||
inline float fclamp(float _a, float _min, float _max)
|
||||
{
|
||||
return fmin(fmax(_a, _min), _max);
|
||||
}
|
||||
|
||||
inline float fsaturate(float _a)
|
||||
{
|
||||
return fclamp(_a, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
inline float flerp(float _a, float _b, float _t)
|
||||
{
|
||||
return _a + (_b - _a) * _t;
|
||||
@@ -166,7 +136,7 @@ namespace bx
|
||||
{
|
||||
// http://realtimecollisiondetection.net/blog/?p=89
|
||||
const float lhs = fabs(_a - _b);
|
||||
const float rhs = _epsilon * fmax3(1.0f, fabs(_a), fabs(_b) );
|
||||
const float rhs = _epsilon * max(1.0f, fabs(_a), fabs(_b) );
|
||||
return lhs <= rhs;
|
||||
}
|
||||
|
||||
@@ -334,16 +304,16 @@ namespace bx
|
||||
|
||||
inline void vec3Min(float* _result, const float* _a, const float* _b)
|
||||
{
|
||||
_result[0] = fmin(_a[0], _b[0]);
|
||||
_result[1] = fmin(_a[1], _b[1]);
|
||||
_result[2] = fmin(_a[2], _b[2]);
|
||||
_result[0] = min(_a[0], _b[0]);
|
||||
_result[1] = min(_a[1], _b[1]);
|
||||
_result[2] = min(_a[2], _b[2]);
|
||||
}
|
||||
|
||||
inline void vec3Max(float* _result, const float* _a, const float* _b)
|
||||
{
|
||||
_result[0] = fmax(_a[0], _b[0]);
|
||||
_result[1] = fmax(_a[1], _b[1]);
|
||||
_result[2] = fmax(_a[2], _b[2]);
|
||||
_result[0] = max(_a[0], _b[0]);
|
||||
_result[1] = max(_a[1], _b[1]);
|
||||
_result[2] = max(_a[2], _b[2]);
|
||||
}
|
||||
|
||||
inline void vec3Rcp(float* _result, const float* _a)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace bx
|
||||
{
|
||||
inline uint32_t toUnorm(float _value, float _scale)
|
||||
{
|
||||
return uint32_t(fround(fsaturate(_value) * _scale) );
|
||||
return uint32_t(fround(clamp(_value, 0.0f, 1.0f) * _scale) );
|
||||
}
|
||||
|
||||
inline float fromUnorm(uint32_t _value, float _scale)
|
||||
@@ -22,13 +22,13 @@ namespace bx
|
||||
inline int32_t toSnorm(float _value, float _scale)
|
||||
{
|
||||
return int32_t(fround(
|
||||
fclamp(_value, -1.0f, 1.0f) * _scale)
|
||||
clamp(_value, -1.0f, 1.0f) * _scale)
|
||||
);
|
||||
}
|
||||
|
||||
inline float fromSnorm(int32_t _value, float _scale)
|
||||
{
|
||||
return fmax(-1.0f, float(_value) / _scale);
|
||||
return max(-1.0f, float(_value) / _scale);
|
||||
}
|
||||
|
||||
// R8
|
||||
@@ -713,15 +713,15 @@ namespace bx
|
||||
const int32_t expBias = (1<<(ExpBits - 1) ) - 1;
|
||||
const float sharedExpMax = float(expMax) / float(expMax + 1) * float(1 << (expMax - expBias) );
|
||||
|
||||
const float rr = fclamp(_src[0], 0.0f, sharedExpMax);
|
||||
const float gg = fclamp(_src[1], 0.0f, sharedExpMax);
|
||||
const float bb = fclamp(_src[2], 0.0f, sharedExpMax);
|
||||
const float max = fmax3(rr, gg, bb);
|
||||
union { float ff; uint32_t ui; } cast = { max };
|
||||
const float rr = clamp(_src[0], 0.0f, sharedExpMax);
|
||||
const float gg = clamp(_src[1], 0.0f, sharedExpMax);
|
||||
const float bb = clamp(_src[2], 0.0f, sharedExpMax);
|
||||
const float mm = max(rr, gg, bb);
|
||||
union { float ff; uint32_t ui; } cast = { mm };
|
||||
int32_t expShared = int32_t(uint32_imax(uint32_t(-expBias-1), ( ( (cast.ui>>23) & 0xff) - 127) ) ) + 1 + expBias;
|
||||
float denom = fpow(2.0f, float(expShared - expBias - MantissaBits) );
|
||||
|
||||
if ( (1<<MantissaBits) == int32_t(fround(max/denom) ) )
|
||||
if ( (1<<MantissaBits) == int32_t(fround(mm/denom) ) )
|
||||
{
|
||||
denom *= 2.0f;
|
||||
++expShared;
|
||||
|
||||
@@ -92,24 +92,6 @@ namespace bx
|
||||
///
|
||||
float fround(float _f);
|
||||
|
||||
///
|
||||
float fmin(float _a, float _b);
|
||||
|
||||
///
|
||||
float fmax(float _a, float _b);
|
||||
|
||||
///
|
||||
float fmin3(float _a, float _b, float _c);
|
||||
|
||||
///
|
||||
float fmax3(float _a, float _b, float _c);
|
||||
|
||||
///
|
||||
float fclamp(float _a, float _min, float _max);
|
||||
|
||||
///
|
||||
float fsaturate(float _a);
|
||||
|
||||
///
|
||||
float flerp(float _a, float _b, float _t);
|
||||
|
||||
|
||||
@@ -736,9 +736,9 @@ namespace bx
|
||||
const float py = fabs(ffract(hh + 2.0f/3.0f) * 6.0f - 3.0f);
|
||||
const float pz = fabs(ffract(hh + 1.0f/3.0f) * 6.0f - 3.0f);
|
||||
|
||||
_rgb[0] = vv * flerp(1.0f, fsaturate(px - 1.0f), ss);
|
||||
_rgb[1] = vv * flerp(1.0f, fsaturate(py - 1.0f), ss);
|
||||
_rgb[2] = vv * flerp(1.0f, fsaturate(pz - 1.0f), ss);
|
||||
_rgb[0] = vv * flerp(1.0f, clamp(px - 1.0f, 0.0f, 1.0f), ss);
|
||||
_rgb[1] = vv * flerp(1.0f, clamp(py - 1.0f, 0.0f, 1.0f), ss);
|
||||
_rgb[2] = vv * flerp(1.0f, clamp(pz - 1.0f, 0.0f, 1.0f), ss);
|
||||
}
|
||||
|
||||
} // namespace bx
|
||||
|
||||
Reference in New Issue
Block a user