mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Cleanup.
This commit is contained in:
@@ -1786,7 +1786,7 @@ void createNearClipVolume(float* __restrict _outPlanes24f
|
||||
bool clipTest(const float* _planes, uint8_t _planeNum, const Mesh& _mesh, const float* _scale, const float* _translate)
|
||||
{
|
||||
float (*volumePlanes)[4] = (float(*)[4])_planes;
|
||||
float scale = bx::fmax(bx::fmax(_scale[0], _scale[1]), _scale[2]);
|
||||
float scale = bx::max(_scale[0], _scale[1], _scale[2]);
|
||||
|
||||
const GroupArray& groups = _mesh.m_groups;
|
||||
for (GroupArray::const_iterator it = groups.begin(), itEnd = groups.end(); it != itEnd; ++it)
|
||||
|
||||
@@ -2478,12 +2478,12 @@ public:
|
||||
bx::vec3MulMtx(lightSpaceFrustumCorner, frustumCorners[ii][jj], lightView[0]);
|
||||
|
||||
// Update bounding box.
|
||||
min[0] = bx::fmin(min[0], lightSpaceFrustumCorner[0]);
|
||||
max[0] = bx::fmax(max[0], lightSpaceFrustumCorner[0]);
|
||||
min[1] = bx::fmin(min[1], lightSpaceFrustumCorner[1]);
|
||||
max[1] = bx::fmax(max[1], lightSpaceFrustumCorner[1]);
|
||||
min[2] = bx::fmin(min[2], lightSpaceFrustumCorner[2]);
|
||||
max[2] = bx::fmax(max[2], lightSpaceFrustumCorner[2]);
|
||||
min[0] = bx::min(min[0], lightSpaceFrustumCorner[0]);
|
||||
max[0] = bx::max(max[0], lightSpaceFrustumCorner[0]);
|
||||
min[1] = bx::min(min[1], lightSpaceFrustumCorner[1]);
|
||||
max[1] = bx::max(max[1], lightSpaceFrustumCorner[1]);
|
||||
min[2] = bx::min(min[2], lightSpaceFrustumCorner[2]);
|
||||
max[2] = bx::max(max[2], lightSpaceFrustumCorner[2]);
|
||||
}
|
||||
|
||||
float minproj[3];
|
||||
|
||||
@@ -272,7 +272,7 @@ struct Camera
|
||||
latLongFromVec(ll[0], ll[1], toPosNorm);
|
||||
ll[0] += consume[0];
|
||||
ll[1] -= consume[1];
|
||||
ll[1] = bx::fclamp(ll[1], 0.02f, 0.98f);
|
||||
ll[1] = bx::clamp(ll[1], 0.02f, 0.98f);
|
||||
|
||||
float tmp[3];
|
||||
vecFromLatLong(tmp, ll[0], ll[1]);
|
||||
@@ -292,7 +292,7 @@ struct Camera
|
||||
|
||||
void update(float _dt)
|
||||
{
|
||||
const float amount = bx::fmin(_dt/0.12f, 1.0f);
|
||||
const float amount = bx::min(_dt/0.12f, 1.0f);
|
||||
|
||||
consumeOrbit(amount);
|
||||
|
||||
@@ -829,7 +829,7 @@ public:
|
||||
bgfx::setViewRect(1, 0, 0, uint16_t(m_width), uint16_t(m_height) );
|
||||
|
||||
// Env rotation.
|
||||
const float amount = bx::fmin(deltaTimeSec/0.12f, 1.0f);
|
||||
const float amount = bx::min(deltaTimeSec/0.12f, 1.0f);
|
||||
m_settings.m_envRotCurr = bx::flerp(m_settings.m_envRotCurr, m_settings.m_envRotDest, amount);
|
||||
|
||||
// Env mtx.
|
||||
|
||||
@@ -580,20 +580,20 @@ public:
|
||||
for (uint32_t ii = 1; ii < 8; ++ii)
|
||||
{
|
||||
bx::vec3MulMtxH(xyz, box[ii], vp);
|
||||
minx = bx::fmin(minx, xyz[0]);
|
||||
miny = bx::fmin(miny, xyz[1]);
|
||||
maxx = bx::fmax(maxx, xyz[0]);
|
||||
maxy = bx::fmax(maxy, xyz[1]);
|
||||
maxz = bx::fmax(maxz, xyz[2]);
|
||||
minx = bx::min(minx, xyz[0]);
|
||||
miny = bx::min(miny, xyz[1]);
|
||||
maxx = bx::max(maxx, xyz[0]);
|
||||
maxy = bx::max(maxy, xyz[1]);
|
||||
maxz = bx::max(maxz, xyz[2]);
|
||||
}
|
||||
|
||||
// Cull light if it's fully behind camera.
|
||||
if (maxz >= 0.0f)
|
||||
{
|
||||
float x0 = bx::fclamp( (minx * 0.5f + 0.5f) * m_width, 0.0f, (float)m_width);
|
||||
float y0 = bx::fclamp( (miny * 0.5f + 0.5f) * m_height, 0.0f, (float)m_height);
|
||||
float x1 = bx::fclamp( (maxx * 0.5f + 0.5f) * m_width, 0.0f, (float)m_width);
|
||||
float y1 = bx::fclamp( (maxy * 0.5f + 0.5f) * m_height, 0.0f, (float)m_height);
|
||||
float x0 = bx::clamp( (minx * 0.5f + 0.5f) * m_width, 0.0f, (float)m_width);
|
||||
float y0 = bx::clamp( (miny * 0.5f + 0.5f) * m_height, 0.0f, (float)m_height);
|
||||
float x1 = bx::clamp( (maxx * 0.5f + 0.5f) * m_width, 0.0f, (float)m_width);
|
||||
float y1 = bx::clamp( (maxy * 0.5f + 0.5f) * m_height, 0.0f, (float)m_height);
|
||||
|
||||
if (m_showScissorRects)
|
||||
{
|
||||
|
||||
@@ -385,9 +385,9 @@ void VectorDisplay::endDraw()
|
||||
{
|
||||
float pa2a = normalizef(pline->a - line->a);
|
||||
float a2pa = normalizef(line->a - pline->a);
|
||||
float maxshorten = bx::fmin(line->len, pline->len) / 2.0f;
|
||||
float maxshorten = bx::min(line->len, pline->len) / 2.0f;
|
||||
|
||||
if (bx::fmin(a2pa, pa2a) <= (bx::kPi / 2.0f + FLT_EPSILON) )
|
||||
if (bx::min(a2pa, pa2a) <= (bx::kPi / 2.0f + FLT_EPSILON) )
|
||||
{
|
||||
if (a2pa < pa2a)
|
||||
{
|
||||
@@ -550,8 +550,8 @@ float VectorDisplay::effectiveThickness()
|
||||
else
|
||||
{
|
||||
// this makes thickness=16 at 2048x1536
|
||||
float v = (0.01f * (m_screenWidth + m_screenHeight) / 2.0f) * m_drawScale / 2.0f;
|
||||
return bx::fmax(v, 6.0f);
|
||||
float vv = (0.01f * (m_screenWidth + m_screenHeight) / 2.0f) * m_drawScale / 2.0f;
|
||||
return bx::max(vv, 6.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,7 +622,7 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t,
|
||||
if (a2pa < pa2a)
|
||||
{
|
||||
_t = -_t;
|
||||
nsteps = (int)bx::fmax(1, bx::fround(a2pa / (bx::kPi / 8.0f) ) );
|
||||
nsteps = (int32_t)bx::max(1.0f, bx::fround(a2pa / (bx::kPi / 8.0f) ) );
|
||||
angles = (float*)alloca(sizeof(float) * (nsteps + 1) );
|
||||
for (i = 0; i <= nsteps; i++)
|
||||
{
|
||||
@@ -631,7 +631,7 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t,
|
||||
}
|
||||
else
|
||||
{
|
||||
nsteps = (int)bx::fmax(1, bx::fround(pa2a / (bx::kPi / 8.0f) ) );
|
||||
nsteps = (int32_t)bx::max(1.0f, bx::fround(pa2a / (bx::kPi / 8.0f) ) );
|
||||
angles = (float*)alloca(sizeof(float) * (nsteps + 1) );
|
||||
for (i = 0; i <= nsteps; i++)
|
||||
{
|
||||
@@ -853,14 +853,14 @@ void VectorDisplay::genLinetex() // generate
|
||||
{
|
||||
for (y = 0; y < TEXTURE_SIZE; y++)
|
||||
{
|
||||
float distance = bx::fmin(1.0f
|
||||
float distance = bx::min(1.0f
|
||||
, bx::fsqrt( (float)( (x - HALF_TEXTURE_SIZE) * (x - HALF_TEXTURE_SIZE) + (y - HALF_TEXTURE_SIZE) * (y - HALF_TEXTURE_SIZE) ) ) / (float)HALF_TEXTURE_SIZE
|
||||
);
|
||||
|
||||
float line = bx::fpow(16.0f, -2.0f * distance);
|
||||
float glow = bx::fpow( 2.0f, -4.0f * distance) / 10.0f;
|
||||
glow = 0;
|
||||
float val = bx::fsaturate(line + glow);
|
||||
float val = bx::clamp(line + glow, 0.0f, 1.0f);
|
||||
|
||||
texbuf[(x + y * TEXTURE_SIZE) * 4 + 0] = 0xff;
|
||||
texbuf[(x + y * TEXTURE_SIZE) * 4 + 1] = 0xff;
|
||||
|
||||
@@ -319,12 +319,12 @@ public:
|
||||
float brushAttn = m_brush.m_size - bx::fsqrt(a2 + b2);
|
||||
|
||||
// Raise/Lower and scale by brush power.
|
||||
height += 0.0f < bx::fclamp(brushAttn*m_brush.m_power, 0.0f, m_brush.m_power) && m_brush.m_raise
|
||||
height += 0.0f < bx::clamp(brushAttn*m_brush.m_power, 0.0f, m_brush.m_power) && m_brush.m_raise
|
||||
? 1.0f
|
||||
: -1.0f
|
||||
;
|
||||
|
||||
m_terrain.m_heightMap[heightMapPos] = (uint8_t)bx::fclamp(height, 0.0f, 255.0f);
|
||||
m_terrain.m_heightMap[heightMapPos] = (uint8_t)bx::clamp(height, 0.0f, 255.0f);
|
||||
m_terrain.m_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ struct Camera
|
||||
bx::vec3ToLatLong(&ll[0], &ll[1], toPosNorm);
|
||||
ll[0] += consume[0];
|
||||
ll[1] -= consume[1];
|
||||
ll[1] = bx::fclamp(ll[1], 0.02f, 0.98f);
|
||||
ll[1] = bx::clamp(ll[1], 0.02f, 0.98f);
|
||||
|
||||
float tmp[3];
|
||||
bx::vec3FromLatLong(tmp, ll[0], ll[1]);
|
||||
@@ -136,7 +136,7 @@ struct Camera
|
||||
|
||||
void update(float _dt)
|
||||
{
|
||||
const float amount = bx::fmin(_dt/0.12f, 1.0f);
|
||||
const float amount = bx::min(_dt/0.12f, 1.0f);
|
||||
|
||||
consumeOrbit(amount);
|
||||
|
||||
|
||||
@@ -134,12 +134,12 @@ void toAabb(Aabb& _aabb, const void* _vertices, uint32_t _numVertices, uint32_t
|
||||
float xx = position[0];
|
||||
float yy = position[1];
|
||||
float zz = position[2];
|
||||
min[0] = bx::fmin(xx, min[0]);
|
||||
min[1] = bx::fmin(yy, min[1]);
|
||||
min[2] = bx::fmin(zz, min[2]);
|
||||
max[0] = bx::fmax(xx, max[0]);
|
||||
max[1] = bx::fmax(yy, max[1]);
|
||||
max[2] = bx::fmax(zz, max[2]);
|
||||
min[0] = bx::min(xx, min[0]);
|
||||
min[1] = bx::min(yy, min[1]);
|
||||
min[2] = bx::min(zz, min[2]);
|
||||
max[0] = bx::max(xx, max[0]);
|
||||
max[1] = bx::max(yy, max[1]);
|
||||
max[2] = bx::max(zz, max[2]);
|
||||
}
|
||||
|
||||
_aabb.m_min[0] = min[0];
|
||||
@@ -170,12 +170,12 @@ void toAabb(Aabb& _aabb, const float* _mtx, const void* _vertices, uint32_t _num
|
||||
float xx = position[0];
|
||||
float yy = position[1];
|
||||
float zz = position[2];
|
||||
min[0] = bx::fmin(xx, min[0]);
|
||||
min[1] = bx::fmin(yy, min[1]);
|
||||
min[2] = bx::fmin(zz, min[2]);
|
||||
max[0] = bx::fmax(xx, max[0]);
|
||||
max[1] = bx::fmax(yy, max[1]);
|
||||
max[2] = bx::fmax(zz, max[2]);
|
||||
min[0] = bx::min(xx, min[0]);
|
||||
min[1] = bx::min(yy, min[1]);
|
||||
min[2] = bx::min(zz, min[2]);
|
||||
max[0] = bx::max(xx, max[0]);
|
||||
max[1] = bx::max(yy, max[1]);
|
||||
max[2] = bx::max(zz, max[2]);
|
||||
}
|
||||
|
||||
_aabb.m_min[0] = min[0];
|
||||
@@ -300,7 +300,7 @@ void calcMaxBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _num
|
||||
float zz = position[2] - center[2];
|
||||
|
||||
float distSq = xx*xx + yy*yy + zz*zz;
|
||||
maxDistSq = bx::fmax(distSq, maxDistSq);
|
||||
maxDistSq = bx::max(distSq, maxDistSq);
|
||||
}
|
||||
|
||||
bx::vec3Move(_sphere.m_center, center);
|
||||
@@ -512,8 +512,8 @@ bool intersect(const Ray& _ray, const Aabb& _aabb, Hit* _hit)
|
||||
float max[3];
|
||||
bx::vec3Max(max, t0, t1);
|
||||
|
||||
const float tmin = bx::fmax3(min[0], min[1], min[2]);
|
||||
const float tmax = bx::fmin3(max[0], max[1], max[2]);
|
||||
const float tmin = bx::max(min[0], min[1], min[2]);
|
||||
const float tmax = bx::min(max[0], max[1], max[2]);
|
||||
|
||||
if (tmax < 0.0f
|
||||
|| tmin > tmax)
|
||||
|
||||
@@ -1301,7 +1301,7 @@ struct DebugDraw
|
||||
const Attrib& attrib = m_attrib[m_stack];
|
||||
const uint32_t num = getCircleLod(attrib.m_lod);
|
||||
const float step = bx::kPi * 2.0f / num;
|
||||
_weight = bx::fclamp(_weight, 0.0f, 2.0f);
|
||||
_weight = bx::clamp(_weight, 0.0f, 2.0f);
|
||||
|
||||
float udir[3];
|
||||
float vdir[3];
|
||||
@@ -1348,7 +1348,7 @@ struct DebugDraw
|
||||
const Attrib& attrib = m_attrib[m_stack];
|
||||
const uint32_t num = getCircleLod(attrib.m_lod);
|
||||
const float step = bx::kPi * 2.0f / num;
|
||||
_weight = bx::fclamp(_weight, 0.0f, 2.0f);
|
||||
_weight = bx::clamp(_weight, 0.0f, 2.0f);
|
||||
|
||||
float xy0[2];
|
||||
float xy1[2];
|
||||
|
||||
@@ -250,7 +250,7 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText)
|
||||
|
||||
const float maxWidth = 30.0f*scale;
|
||||
const float cpuMs = float( (encoderStats.cpuTimeEnd-encoderStats.cpuTimeBegin)*toCpuMs);
|
||||
const float cpuWidth = bx::fclamp(cpuMs*scale, 1.0f, maxWidth);
|
||||
const float cpuWidth = bx::clamp(cpuMs*scale, 1.0f, maxWidth);
|
||||
|
||||
if (bar(cpuWidth, maxWidth, itemHeight, cpuColor) )
|
||||
{
|
||||
@@ -280,8 +280,8 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText)
|
||||
ImGui::Text("%3d %3d %s", pos, viewStats.view, viewStats.name);
|
||||
|
||||
const float maxWidth = 30.0f*scale;
|
||||
const float cpuWidth = bx::fclamp(float(viewStats.cpuTimeElapsed*toCpuMs)*scale, 1.0f, maxWidth);
|
||||
const float gpuWidth = bx::fclamp(float(viewStats.gpuTimeElapsed*toGpuMs)*scale, 1.0f, maxWidth);
|
||||
const float cpuWidth = bx::clamp(float(viewStats.cpuTimeElapsed*toCpuMs)*scale, 1.0f, maxWidth);
|
||||
const float gpuWidth = bx::clamp(float(viewStats.gpuTimeElapsed*toGpuMs)*scale, 1.0f, maxWidth);
|
||||
|
||||
ImGui::SameLine(64.0f);
|
||||
|
||||
|
||||
@@ -172,11 +172,11 @@ struct OcornutImguiContext
|
||||
state |= BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA);
|
||||
}
|
||||
|
||||
const uint16_t xx = uint16_t(bx::fmax(cmd->ClipRect.x, 0.0f) );
|
||||
const uint16_t yy = uint16_t(bx::fmax(cmd->ClipRect.y, 0.0f) );
|
||||
const uint16_t xx = uint16_t(bx::max(cmd->ClipRect.x, 0.0f) );
|
||||
const uint16_t yy = uint16_t(bx::max(cmd->ClipRect.y, 0.0f) );
|
||||
bgfx::setScissor(xx, yy
|
||||
, uint16_t(bx::fmin(cmd->ClipRect.z, 65535.0f)-xx)
|
||||
, uint16_t(bx::fmin(cmd->ClipRect.w, 65535.0f)-yy)
|
||||
, uint16_t(bx::min(cmd->ClipRect.z, 65535.0f)-xx)
|
||||
, uint16_t(bx::min(cmd->ClipRect.w, 65535.0f)-yy)
|
||||
);
|
||||
|
||||
bgfx::setState(state);
|
||||
|
||||
@@ -345,8 +345,8 @@ namespace ps
|
||||
|
||||
const float ttPos = easePos(particle.life);
|
||||
const float ttScale = easeScale(particle.life);
|
||||
const float ttBlend = bx::fsaturate(easeBlend(particle.life) );
|
||||
const float ttRgba = bx::fsaturate(easeRgba(particle.life) );
|
||||
const float ttBlend = bx::clamp(easeBlend(particle.life), 0.0f, 1.0f);
|
||||
const float ttRgba = bx::clamp(easeRgba(particle.life), 0.0f, 1.0f);
|
||||
|
||||
float p0[3];
|
||||
bx::vec3Lerp(p0, particle.start, particle.end[0], ttPos);
|
||||
|
||||
@@ -4272,7 +4272,7 @@ namespace bgfx
|
||||
|
||||
BGFX_API_FUNC(void setViewClear(ViewId _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) )
|
||||
{
|
||||
BX_CHECK(bx::fequal(_depth, bx::fclamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
BX_CHECK(bx::fequal(_depth, bx::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
, "Clear depth value must be between 0.0 and 1.0 (_depth %f)."
|
||||
, _depth
|
||||
);
|
||||
@@ -4282,7 +4282,7 @@ namespace bgfx
|
||||
|
||||
BGFX_API_FUNC(void setViewClear(ViewId _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _0, uint8_t _1, uint8_t _2, uint8_t _3, uint8_t _4, uint8_t _5, uint8_t _6, uint8_t _7) )
|
||||
{
|
||||
BX_CHECK(bx::fequal(_depth, bx::fclamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
BX_CHECK(bx::fequal(_depth, bx::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
, "Clear depth value must be between 0.0 and 1.0 (_depth %f)."
|
||||
, _depth
|
||||
);
|
||||
|
||||
@@ -223,6 +223,16 @@ namespace bgfx
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline float fmin3(float _a, float _b, float _c)
|
||||
{
|
||||
return bx::min(_a, _b, _c);
|
||||
}
|
||||
|
||||
inline float fmax3(float _a, float _b, float _c)
|
||||
{
|
||||
return bx::max(_a, _b, _c);
|
||||
}
|
||||
|
||||
inline float favg3(float _a, float _b, float _c)
|
||||
{
|
||||
return (_a + _b + _c) * 1.0f/3.0f;
|
||||
|
||||
@@ -308,7 +308,7 @@ struct View
|
||||
float ev = m_ev;
|
||||
bx::fromString(&ev, _argv[2]);
|
||||
|
||||
m_ev = bx::fclamp(ev, kEvMin, kEvMax);
|
||||
m_ev = bx::clamp(ev, kEvMin, kEvMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -406,7 +406,7 @@ struct View
|
||||
m_zoom = zoom;
|
||||
}
|
||||
|
||||
m_zoom = bx::fclamp(m_zoom, 0.01f, 10.0f);
|
||||
m_zoom = bx::clamp(m_zoom, 0.01f, 10.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -478,7 +478,7 @@ struct View
|
||||
{
|
||||
float time;
|
||||
bx::fromString(&time, _argv[2]);
|
||||
m_transitionTime = bx::fclamp(time, 0.0f, 5.0f);
|
||||
m_transitionTime = bx::clamp(time, 0.0f, 5.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -963,7 +963,7 @@ struct InterpolatorT
|
||||
const double freq = double(bx::getHPFrequency() );
|
||||
int64_t now = bx::getHPCounter();
|
||||
float time = (float)(double(now - offset) / freq);
|
||||
float lerp = bx::fclamp(time, 0.0, duration) / duration;
|
||||
float lerp = bx::clamp(time, 0.0f, duration) / duration;
|
||||
return lerpT(from, to, easeT(lerp) );
|
||||
}
|
||||
|
||||
@@ -1782,8 +1782,8 @@ int _main_(int _argc, char** _argv)
|
||||
result[0] = bx::fround(bx::fabs(result[0]) );
|
||||
result[1] = bx::fround(bx::fabs(result[1]) );
|
||||
|
||||
scale.set(bx::fmin(float(width) / result[0]
|
||||
, float(height) / result[1])
|
||||
scale.set(bx::min(float(width) / result[0]
|
||||
, float(height) / result[1])
|
||||
, 0.1f*view.m_transitionTime
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user