mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
bx math API cleanup.
This commit is contained in:
@@ -375,7 +375,7 @@ float vertLerp(float* __restrict _result, float _iso, uint32_t _idx0, float _v0,
|
||||
const float* __restrict edge0 = s_cube[_idx0];
|
||||
const float* __restrict edge1 = s_cube[_idx1];
|
||||
|
||||
if (bx::fabs(_iso-_v1) < 0.00001f)
|
||||
if (bx::abs(_iso-_v1) < 0.00001f)
|
||||
{
|
||||
_result[0] = edge1[0];
|
||||
_result[1] = edge1[1];
|
||||
@@ -383,8 +383,8 @@ float vertLerp(float* __restrict _result, float _iso, uint32_t _idx0, float _v0,
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
if (bx::fabs(_iso-_v0) < 0.00001f
|
||||
|| bx::fabs(_v0-_v1) < 0.00001f)
|
||||
if (bx::abs(_iso-_v0) < 0.00001f
|
||||
|| bx::abs(_v0-_v1) < 0.00001f)
|
||||
{
|
||||
_result[0] = edge0[0];
|
||||
_result[1] = edge0[1];
|
||||
@@ -621,10 +621,10 @@ public:
|
||||
float sphere[numSpheres][4];
|
||||
for (uint32_t ii = 0; ii < numSpheres; ++ii)
|
||||
{
|
||||
sphere[ii][0] = bx::fsin(time*(ii*0.21f)+ii*0.37f) * (DIMS * 0.5f - 8.0f);
|
||||
sphere[ii][1] = bx::fsin(time*(ii*0.37f)+ii*0.67f) * (DIMS * 0.5f - 8.0f);
|
||||
sphere[ii][2] = bx::fcos(time*(ii*0.11f)+ii*0.13f) * (DIMS * 0.5f - 8.0f);
|
||||
sphere[ii][3] = 1.0f/(2.0f + (bx::fsin(time*(ii*0.13f) )*0.5f+0.5f)*2.0f);
|
||||
sphere[ii][0] = bx::sin(time*(ii*0.21f)+ii*0.37f) * (DIMS * 0.5f - 8.0f);
|
||||
sphere[ii][1] = bx::sin(time*(ii*0.37f)+ii*0.67f) * (DIMS * 0.5f - 8.0f);
|
||||
sphere[ii][2] = bx::cos(time*(ii*0.11f)+ii*0.13f) * (DIMS * 0.5f - 8.0f);
|
||||
sphere[ii][3] = 1.0f/(2.0f + (bx::sin(time*(ii*0.13f) )*0.5f+0.5f)*2.0f);
|
||||
}
|
||||
|
||||
profUpdate = bx::getHPCounter();
|
||||
|
||||
@@ -221,9 +221,9 @@ public:
|
||||
mtx[14] = 0.0f;
|
||||
|
||||
float* color = (float*)&data[64];
|
||||
color[0] = bx::fsin(time+float(xx)/11.0f)*0.5f+0.5f;
|
||||
color[1] = bx::fcos(time+float(yy)/11.0f)*0.5f+0.5f;
|
||||
color[2] = bx::fsin(time*3.0f)*0.5f+0.5f;
|
||||
color[0] = bx::sin(time+float(xx)/11.0f)*0.5f+0.5f;
|
||||
color[1] = bx::cos(time+float(yy)/11.0f)*0.5f+0.5f;
|
||||
color[2] = bx::sin(time*3.0f)*0.5f+0.5f;
|
||||
color[3] = 1.0f;
|
||||
|
||||
data += instanceStride;
|
||||
|
||||
@@ -239,8 +239,8 @@ public:
|
||||
float lightPosRadius[4][4];
|
||||
for (uint32_t ii = 0; ii < m_numLights; ++ii)
|
||||
{
|
||||
lightPosRadius[ii][0] = bx::fsin( (time*(0.1f + ii*0.17f) + ii*bx::kPiHalf*1.37f ) )*3.0f;
|
||||
lightPosRadius[ii][1] = bx::fcos( (time*(0.2f + ii*0.29f) + ii*bx::kPiHalf*1.49f ) )*3.0f;
|
||||
lightPosRadius[ii][0] = bx::sin( (time*(0.1f + ii*0.17f) + ii*bx::kPiHalf*1.37f ) )*3.0f;
|
||||
lightPosRadius[ii][1] = bx::cos( (time*(0.2f + ii*0.29f) + ii*bx::kPiHalf*1.49f ) )*3.0f;
|
||||
lightPosRadius[ii][2] = -2.5f;
|
||||
lightPosRadius[ii][3] = 3.0f;
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ public:
|
||||
{
|
||||
union { uint32_t color; uint8_t bgra[4]; } cast = { m_lumBgra8 };
|
||||
float exponent = cast.bgra[3]/255.0f * 255.0f - 128.0f;
|
||||
float lumAvg = cast.bgra[2]/255.0f * bx::fexp2(exponent);
|
||||
float lumAvg = cast.bgra[2]/255.0f * bx::exp2(exponent);
|
||||
ImGui::SliderFloat("Lum Avg", &lumAvg, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ public:
|
||||
// Set view and projection matrix for view hdrMesh.
|
||||
bgfx::setViewTransform(hdrMesh, view, proj);
|
||||
|
||||
float tonemap[4] = { m_middleGray, bx::fsq(m_white), m_threshold, m_time };
|
||||
float tonemap[4] = { m_middleGray, bx::square(m_white), m_threshold, m_time };
|
||||
|
||||
// Render skybox into view hdrSkybox.
|
||||
bgfx::setTexture(0, s_texCube, m_uffizi);
|
||||
|
||||
@@ -1008,9 +1008,9 @@ public:
|
||||
const float radius = (m_scene == StencilReflectionScene) ? 15.0f : 25.0f;
|
||||
for (uint8_t ii = 0; ii < numLights; ++ii)
|
||||
{
|
||||
lightPosRadius[ii][0] = bx::fsin( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::kPiHalf*1.07f ) )*20.0f;
|
||||
lightPosRadius[ii][1] = 8.0f + (1.0f - bx::fcos( (lightTimeAccumulator*1.5f + ii*0.29f + bx::kPiHalf*1.49f ) ) )*4.0f;
|
||||
lightPosRadius[ii][2] = bx::fcos( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::kPiHalf*1.79f ) )*20.0f;
|
||||
lightPosRadius[ii][0] = bx::sin( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::kPiHalf*1.07f ) )*20.0f;
|
||||
lightPosRadius[ii][1] = 8.0f + (1.0f - bx::cos( (lightTimeAccumulator*1.5f + ii*0.29f + bx::kPiHalf*1.49f ) ) )*4.0f;
|
||||
lightPosRadius[ii][2] = bx::cos( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::kPiHalf*1.79f ) )*20.0f;
|
||||
lightPosRadius[ii][3] = radius;
|
||||
}
|
||||
bx::memCopy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float) );
|
||||
@@ -1080,9 +1080,9 @@ public:
|
||||
, 0.0f
|
||||
, 0.0f
|
||||
, 0.0f
|
||||
, bx::fsin(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
|
||||
, bx::sin(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
|
||||
, 4.0f
|
||||
, bx::fcos(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
|
||||
, bx::cos(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1713,7 +1713,7 @@ void createNearClipVolume(float* __restrict _outPlanes24f
|
||||
// -1.0f - behind near plane
|
||||
float lightSide = float( (d > delta) - (d < -delta) );
|
||||
|
||||
float t = bx::ftan(bx::toRad(_fovy)*0.5f) * _near;
|
||||
float t = bx::tan(bx::toRad(_fovy)*0.5f) * _near;
|
||||
float b = -t;
|
||||
float r = t * _aspect;
|
||||
float l = -r;
|
||||
@@ -1752,7 +1752,7 @@ void createNearClipVolume(float* __restrict _outPlanes24f
|
||||
normal[1] *= lightSide;
|
||||
normal[2] *= lightSide;
|
||||
|
||||
float lenInv = 1.0f / bx::fsqrt(bx::vec3Dot(normal, normal) );
|
||||
float lenInv = 1.0f / bx::sqrt(bx::vec3Dot(normal, normal) );
|
||||
|
||||
plane[0] = normal[0] * lenInv;
|
||||
plane[1] = normal[1] * lenInv;
|
||||
@@ -1775,7 +1775,7 @@ void createNearClipVolume(float* __restrict _outPlanes24f
|
||||
bx::vec3MulMtx(tmp, lightPlaneNormal, mtxViewInv);
|
||||
bx::vec3Sub(lightPlaneNormal, tmp, _lightPos);
|
||||
|
||||
float lenInv = 1.0f / bx::fsqrt(bx::vec3Dot(lightPlaneNormal, lightPlaneNormal) );
|
||||
float lenInv = 1.0f / bx::sqrt(bx::vec3Dot(lightPlaneNormal, lightPlaneNormal) );
|
||||
|
||||
lightPlane[0] = lightPlaneNormal[0] * lenInv;
|
||||
lightPlane[1] = lightPlaneNormal[1] * lenInv;
|
||||
@@ -2322,9 +2322,9 @@ public:
|
||||
{
|
||||
for (uint8_t ii = 0; ii < m_numLights; ++ii)
|
||||
{
|
||||
lightPosRadius[ii][0] = bx::fcos(2.0f*bx::kPi/float(m_numLights) * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
|
||||
lightPosRadius[ii][0] = bx::cos(2.0f*bx::kPi/float(m_numLights) * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
|
||||
lightPosRadius[ii][1] = 20.0f;
|
||||
lightPosRadius[ii][2] = bx::fsin(2.0f*bx::kPi/float(m_numLights) * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
|
||||
lightPosRadius[ii][2] = bx::sin(2.0f*bx::kPi/float(m_numLights) * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
|
||||
lightPosRadius[ii][3] = 20.0f;
|
||||
}
|
||||
}
|
||||
@@ -2332,9 +2332,9 @@ public:
|
||||
{
|
||||
for (uint8_t ii = 0; ii < m_numLights; ++ii)
|
||||
{
|
||||
lightPosRadius[ii][0] = bx::fcos(float(ii) * 2.0f/float(m_numLights) + lightTimeAccumulator * 1.3f + bx::kPi) * 40.0f;
|
||||
lightPosRadius[ii][0] = bx::cos(float(ii) * 2.0f/float(m_numLights) + lightTimeAccumulator * 1.3f + bx::kPi) * 40.0f;
|
||||
lightPosRadius[ii][1] = 20.0f;
|
||||
lightPosRadius[ii][2] = bx::fsin(float(ii) * 2.0f/float(m_numLights) + lightTimeAccumulator * 1.3f + bx::kPi) * 40.0f;
|
||||
lightPosRadius[ii][2] = bx::sin(float(ii) * 2.0f/float(m_numLights) + lightTimeAccumulator * 1.3f + bx::kPi) * 40.0f;
|
||||
lightPosRadius[ii][3] = 20.0f;
|
||||
}
|
||||
}
|
||||
@@ -2406,9 +2406,9 @@ public:
|
||||
inst.m_rotation[0] = 0.0f;
|
||||
inst.m_rotation[1] = 0.0f;
|
||||
inst.m_rotation[2] = 0.0f;
|
||||
inst.m_pos[0] = bx::fsin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
|
||||
inst.m_pos[0] = bx::sin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
|
||||
inst.m_pos[1] = 6.0f;
|
||||
inst.m_pos[2] = bx::fcos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
|
||||
inst.m_pos[2] = bx::cos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
|
||||
inst.m_model = &m_cubeModel;
|
||||
}
|
||||
|
||||
@@ -2423,9 +2423,9 @@ public:
|
||||
inst.m_rotation[0] = 0.0f;
|
||||
inst.m_rotation[1] = 0.0f;
|
||||
inst.m_rotation[2] = 0.0f;
|
||||
inst.m_pos[0] = bx::fsin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
|
||||
inst.m_pos[0] = bx::sin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
|
||||
inst.m_pos[1] = 22.0f;
|
||||
inst.m_pos[2] = bx::fcos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
|
||||
inst.m_pos[2] = bx::cos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
|
||||
inst.m_model = &m_cubeModel;
|
||||
}
|
||||
|
||||
|
||||
@@ -275,9 +275,9 @@ public:
|
||||
|
||||
// Setup lights.
|
||||
float lightPos[4];
|
||||
lightPos[0] = -bx::fcos(time);
|
||||
lightPos[0] = -bx::cos(time);
|
||||
lightPos[1] = -1.0f;
|
||||
lightPos[2] = -bx::fsin(time);
|
||||
lightPos[2] = -bx::sin(time);
|
||||
lightPos[3] = 0.0f;
|
||||
|
||||
bgfx::setUniform(u_lightPos, lightPos);
|
||||
|
||||
@@ -213,12 +213,12 @@ void mtxYawPitchRoll(float* __restrict _result
|
||||
, float _roll
|
||||
)
|
||||
{
|
||||
float sroll = bx::fsin(_roll);
|
||||
float croll = bx::fcos(_roll);
|
||||
float spitch = bx::fsin(_pitch);
|
||||
float cpitch = bx::fcos(_pitch);
|
||||
float syaw = bx::fsin(_yaw);
|
||||
float cyaw = bx::fcos(_yaw);
|
||||
float sroll = bx::sin(_roll);
|
||||
float croll = bx::cos(_roll);
|
||||
float spitch = bx::sin(_pitch);
|
||||
float cpitch = bx::cos(_pitch);
|
||||
float syaw = bx::sin(_yaw);
|
||||
float cyaw = bx::cos(_yaw);
|
||||
|
||||
_result[ 0] = sroll * spitch * syaw + croll * cyaw;
|
||||
_result[ 1] = sroll * cpitch;
|
||||
@@ -1114,7 +1114,7 @@ void splitFrustum(float* _splits, uint8_t _numSplits, float _near, float _far, f
|
||||
{
|
||||
float si = float(int8_t(ff) ) / numSlicesf;
|
||||
|
||||
const float nearp = l*(_near*bx::fpow(ratio, si) ) + (1 - l)*(_near + (_far - _near)*si);
|
||||
const float nearp = l*(_near*bx::pow(ratio, si) ) + (1 - l)*(_near + (_far - _near)*si);
|
||||
_splits[nn] = nearp; //near
|
||||
_splits[ff] = nearp * 1.005f; //far from previous split
|
||||
}
|
||||
@@ -1957,7 +1957,7 @@ public:
|
||||
const float camAspect = float(int32_t(m_viewState.m_width) ) / float(int32_t(m_viewState.m_height) );
|
||||
const float camNear = 0.1f;
|
||||
const float camFar = 2000.0f;
|
||||
const float projHeight = 1.0f/bx::ftan(bx::toRad(camFovy)*0.5f);
|
||||
const float projHeight = 1.0f/bx::tan(bx::toRad(camFovy)*0.5f);
|
||||
const float projWidth = projHeight * camAspect;
|
||||
bx::mtxProj(m_viewState.m_proj, camFovy, camAspect, camNear, camFar, caps->homogeneousDepth);
|
||||
cameraGetViewMtx(m_viewState.m_view);
|
||||
@@ -2204,16 +2204,16 @@ public:
|
||||
if (m_settings.m_updateScene) { m_timeAccumulatorScene += deltaTime; }
|
||||
|
||||
// Setup lights.
|
||||
m_pointLight.m_position.m_x = bx::fcos(m_timeAccumulatorLight) * 20.0f;
|
||||
m_pointLight.m_position.m_x = bx::cos(m_timeAccumulatorLight) * 20.0f;
|
||||
m_pointLight.m_position.m_y = 26.0f;
|
||||
m_pointLight.m_position.m_z = bx::fsin(m_timeAccumulatorLight) * 20.0f;
|
||||
m_pointLight.m_position.m_z = bx::sin(m_timeAccumulatorLight) * 20.0f;
|
||||
m_pointLight.m_spotDirectionInner.m_x = -m_pointLight.m_position.m_x;
|
||||
m_pointLight.m_spotDirectionInner.m_y = -m_pointLight.m_position.m_y;
|
||||
m_pointLight.m_spotDirectionInner.m_z = -m_pointLight.m_position.m_z;
|
||||
|
||||
m_directionalLight.m_position.m_x = -bx::fcos(m_timeAccumulatorLight);
|
||||
m_directionalLight.m_position.m_x = -bx::cos(m_timeAccumulatorLight);
|
||||
m_directionalLight.m_position.m_y = -1.0f;
|
||||
m_directionalLight.m_position.m_z = -bx::fsin(m_timeAccumulatorLight);
|
||||
m_directionalLight.m_position.m_z = -bx::sin(m_timeAccumulatorLight);
|
||||
|
||||
// Setup instance matrices.
|
||||
float mtxFloor[16];
|
||||
@@ -2280,9 +2280,9 @@ public:
|
||||
, 0.0f
|
||||
, float(ii)
|
||||
, 0.0f
|
||||
, bx::fsin(float(ii)*2.0f*bx::kPi/float(numTrees) ) * 60.0f
|
||||
, bx::sin(float(ii)*2.0f*bx::kPi/float(numTrees) ) * 60.0f
|
||||
, 0.0f
|
||||
, bx::fcos(float(ii)*2.0f*bx::kPi/float(numTrees) ) * 60.0f
|
||||
, bx::cos(float(ii)*2.0f*bx::kPi/float(numTrees) ) * 60.0f
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2347,7 +2347,7 @@ public:
|
||||
{
|
||||
const float fovx = 143.98570868f + 3.51f + m_settings.m_fovXAdjust;
|
||||
const float fovy = 125.26438968f + 9.85f + m_settings.m_fovYAdjust;
|
||||
const float aspect = bx::ftan(bx::toRad(fovx*0.5f) )/bx::ftan(bx::toRad(fovy*0.5f) );
|
||||
const float aspect = bx::tan(bx::toRad(fovx*0.5f) )/bx::tan(bx::toRad(fovy*0.5f) );
|
||||
|
||||
bx::mtxProj(
|
||||
lightProj[ProjType::Vertical]
|
||||
@@ -2373,7 +2373,7 @@ public:
|
||||
|
||||
const float fovx = 143.98570868f + 7.8f + m_settings.m_fovXAdjust;
|
||||
const float fovy = 125.26438968f + 3.0f + m_settings.m_fovYAdjust;
|
||||
const float aspect = bx::ftan(bx::toRad(fovx*0.5f) )/bx::ftan(bx::toRad(fovy*0.5f) );
|
||||
const float aspect = bx::tan(bx::toRad(fovx*0.5f) )/bx::tan(bx::toRad(fovy*0.5f) );
|
||||
|
||||
bx::mtxProj(
|
||||
lightProj[ProjType::Horizontal]
|
||||
@@ -2500,8 +2500,8 @@ public:
|
||||
if (m_settings.m_stabilize)
|
||||
{
|
||||
const float quantizer = 64.0f;
|
||||
scalex = quantizer / bx::fceil(quantizer / scalex);
|
||||
scaley = quantizer / bx::fceil(quantizer / scaley);
|
||||
scalex = quantizer / bx::ceil(quantizer / scalex);
|
||||
scaley = quantizer / bx::ceil(quantizer / scaley);
|
||||
}
|
||||
|
||||
offsetx = 0.5f * (maxproj[0] + minproj[0]) * scalex;
|
||||
@@ -2510,8 +2510,8 @@ public:
|
||||
if (m_settings.m_stabilize)
|
||||
{
|
||||
const float halfSize = currentShadowMapSizef * 0.5f;
|
||||
offsetx = bx::fceil(offsetx * halfSize) / halfSize;
|
||||
offsety = bx::fceil(offsety * halfSize) / halfSize;
|
||||
offsetx = bx::ceil(offsetx * halfSize) / halfSize;
|
||||
offsety = bx::ceil(offsety * halfSize) / halfSize;
|
||||
}
|
||||
|
||||
float mtxCrop[16];
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
bgfx::reset(m_width, m_height, m_reset);
|
||||
|
||||
const bgfx::Caps* caps = bgfx::getCaps();
|
||||
m_maxDim = (int32_t)bx::fpow(float(caps->limits.maxDrawCalls), 1.0f/3.0f);
|
||||
m_maxDim = (int32_t)bx::pow(float(caps->limits.maxDrawCalls), 1.0f/3.0f);
|
||||
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(m_debug);
|
||||
|
||||
@@ -296,12 +296,12 @@ struct Camera
|
||||
|
||||
consumeOrbit(amount);
|
||||
|
||||
m_target.curr[0] = bx::flerp(m_target.curr[0], m_target.dest[0], amount);
|
||||
m_target.curr[1] = bx::flerp(m_target.curr[1], m_target.dest[1], amount);
|
||||
m_target.curr[2] = bx::flerp(m_target.curr[2], m_target.dest[2], amount);
|
||||
m_pos.curr[0] = bx::flerp(m_pos.curr[0], m_pos.dest[0], amount);
|
||||
m_pos.curr[1] = bx::flerp(m_pos.curr[1], m_pos.dest[1], amount);
|
||||
m_pos.curr[2] = bx::flerp(m_pos.curr[2], m_pos.dest[2], amount);
|
||||
m_target.curr[0] = bx::lerp(m_target.curr[0], m_target.dest[0], amount);
|
||||
m_target.curr[1] = bx::lerp(m_target.curr[1], m_target.dest[1], amount);
|
||||
m_target.curr[2] = bx::lerp(m_target.curr[2], m_target.dest[2], amount);
|
||||
m_pos.curr[0] = bx::lerp(m_pos.curr[0], m_pos.dest[0], amount);
|
||||
m_pos.curr[1] = bx::lerp(m_pos.curr[1], m_pos.dest[1], amount);
|
||||
m_pos.curr[2] = bx::lerp(m_pos.curr[2], m_pos.dest[2], amount);
|
||||
}
|
||||
|
||||
void envViewMtx(float* _mtx)
|
||||
@@ -356,10 +356,10 @@ struct Camera
|
||||
const float phi = _u * 2.0f*bx::kPi;
|
||||
const float theta = _v * bx::kPi;
|
||||
|
||||
const float st = bx::fsin(theta);
|
||||
const float sp = bx::fsin(phi);
|
||||
const float ct = bx::fcos(theta);
|
||||
const float cp = bx::fcos(phi);
|
||||
const float st = bx::sin(theta);
|
||||
const float sp = bx::sin(phi);
|
||||
const float ct = bx::cos(theta);
|
||||
const float cp = bx::cos(phi);
|
||||
|
||||
_vec[0] = -st*sp;
|
||||
_vec[1] = ct;
|
||||
@@ -368,8 +368,8 @@ struct Camera
|
||||
|
||||
static inline void latLongFromVec(float& _u, float& _v, const float _vec[3])
|
||||
{
|
||||
const float phi = bx::fatan2(_vec[0], _vec[2]);
|
||||
const float theta = bx::facos(_vec[1]);
|
||||
const float phi = bx::atan2(_vec[0], _vec[2]);
|
||||
const float theta = bx::acos(_vec[1]);
|
||||
|
||||
_u = (bx::kPi + phi)*bx::kInvPi*0.5f;
|
||||
_v = theta*bx::kInvPi;
|
||||
@@ -830,7 +830,7 @@ public:
|
||||
|
||||
// Env rotation.
|
||||
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);
|
||||
m_settings.m_envRotCurr = bx::lerp(m_settings.m_envRotCurr, m_settings.m_envRotDest, amount);
|
||||
|
||||
// Env mtx.
|
||||
float mtxEnvView[16];
|
||||
|
||||
@@ -402,7 +402,7 @@ public:
|
||||
if (m_fadeInOut
|
||||
&& zz == 1)
|
||||
{
|
||||
color[3] = bx::fsin(time*3.0f)*0.49f+0.5f;
|
||||
color[3] = bx::sin(time*3.0f)*0.49f+0.5f;
|
||||
}
|
||||
|
||||
bgfx::setUniform(u_color, color);
|
||||
|
||||
@@ -1108,11 +1108,11 @@ void drawParagraph(struct NVGcontext* vg, float x, float y, float width, float h
|
||||
nvgBeginPath(vg);
|
||||
nvgFillColor(vg, nvgRGBA(255,192,0,255) );
|
||||
nvgRoundedRect(vg
|
||||
, bx::fround(bounds[0])-4.0f
|
||||
, bx::fround(bounds[1])-2.0f
|
||||
, bx::fround(bounds[2]-bounds[0])+8.0f
|
||||
, bx::fround(bounds[3]-bounds[1])+4.0f
|
||||
, (bx::fround(bounds[3]-bounds[1])+4.0f)/2.0f-1.0f
|
||||
, bx::round(bounds[0])-4.0f
|
||||
, bx::round(bounds[1])-2.0f
|
||||
, bx::round(bounds[2]-bounds[0])+8.0f
|
||||
, bx::round(bounds[3]-bounds[1])+4.0f
|
||||
, (bx::round(bounds[3]-bounds[1])+4.0f)/2.0f-1.0f
|
||||
);
|
||||
nvgFill(vg);
|
||||
|
||||
@@ -1130,10 +1130,10 @@ void drawParagraph(struct NVGcontext* vg, float x, float y, float width, float h
|
||||
nvgBeginPath(vg);
|
||||
nvgFillColor(vg, nvgRGBA(220,220,220,255) );
|
||||
nvgRoundedRect(vg
|
||||
, bx::fround(bounds[0]-2.0f)
|
||||
, bx::fround(bounds[1]-2.0f)
|
||||
, bx::fround(bounds[2]-bounds[0])+4.0f
|
||||
, bx::fround(bounds[3]-bounds[1])+4.0f
|
||||
, bx::round(bounds[0]-2.0f)
|
||||
, bx::round(bounds[1]-2.0f)
|
||||
, bx::round(bounds[2]-bounds[0])+4.0f
|
||||
, bx::round(bounds[3]-bounds[1])+4.0f
|
||||
, 3.0f
|
||||
);
|
||||
px = float( (int)( (bounds[2]+bounds[0])/2) );
|
||||
|
||||
@@ -548,10 +548,10 @@ public:
|
||||
{
|
||||
Sphere lightPosRadius;
|
||||
|
||||
float lightTime = time * m_lightAnimationSpeed * (bx::fsin(light/float(m_numLights) * bx::kPiHalf ) * 0.5f + 0.5f);
|
||||
lightPosRadius.m_center[0] = bx::fsin( ( (lightTime + light*0.47f) + bx::kPiHalf*1.37f ) )*offset;
|
||||
lightPosRadius.m_center[1] = bx::fcos( ( (lightTime + light*0.69f) + bx::kPiHalf*1.49f ) )*offset;
|
||||
lightPosRadius.m_center[2] = bx::fsin( ( (lightTime + light*0.37f) + bx::kPiHalf*1.57f ) )*2.0f;
|
||||
float lightTime = time * m_lightAnimationSpeed * (bx::sin(light/float(m_numLights) * bx::kPiHalf ) * 0.5f + 0.5f);
|
||||
lightPosRadius.m_center[0] = bx::sin( ( (lightTime + light*0.47f) + bx::kPiHalf*1.37f ) )*offset;
|
||||
lightPosRadius.m_center[1] = bx::cos( ( (lightTime + light*0.69f) + bx::kPiHalf*1.49f ) )*offset;
|
||||
lightPosRadius.m_center[2] = bx::sin( ( (lightTime + light*0.37f) + bx::kPiHalf*1.57f ) )*2.0f;
|
||||
lightPosRadius.m_radius = 2.0f;
|
||||
|
||||
Aabb aabb;
|
||||
|
||||
@@ -23,10 +23,10 @@ struct PosColorVertex
|
||||
static void init()
|
||||
{
|
||||
ms_decl
|
||||
.begin()
|
||||
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
|
||||
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
|
||||
.end();
|
||||
.begin()
|
||||
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
|
||||
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
|
||||
.end();
|
||||
}
|
||||
|
||||
static bgfx::VertexDecl ms_decl;
|
||||
@@ -182,8 +182,9 @@ public:
|
||||
// draw moving shape
|
||||
static float counter = 0.0f;
|
||||
counter += 0.01f;
|
||||
float posX = m_width / 2.0f + bx::fsin(counter * 3.18378f) * (m_width / 2.0f);
|
||||
float posY = m_height / 2.0f + bx::fcos(counter) * (m_height / 2.0f);
|
||||
|
||||
const float posX = m_width / 2.0f + bx::sin(counter * 3.18378f) * (m_width / 2.0f);
|
||||
const float posY = m_height / 2.0f + bx::cos(counter) * (m_height / 2.0f);
|
||||
m_vd.drawCircle(posX, posY, 5.0f, 10.0f);
|
||||
|
||||
m_vd.endFrame();
|
||||
|
||||
@@ -47,7 +47,7 @@ bgfx::VertexDecl PosColorUvVertex::ms_decl;
|
||||
|
||||
inline float normalizef(float _a)
|
||||
{
|
||||
return bx::fwrap(_a, 2.0f * bx::kPi);
|
||||
return bx::wrap(_a, 2.0f * bx::kPi);
|
||||
}
|
||||
|
||||
VectorDisplay::VectorDisplay()
|
||||
@@ -187,7 +187,7 @@ void VectorDisplay::endFrame()
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha = bx::fpow(m_decayValue, stepi - 1.0f) * m_initialDecay;
|
||||
alpha = bx::pow(m_decayValue, stepi - 1.0f) * m_initialDecay;
|
||||
}
|
||||
|
||||
float params[4] = { 0.0f, 0.0f, 0.0f, alpha };
|
||||
@@ -343,8 +343,10 @@ void VectorDisplay::endDraw()
|
||||
Line* lines = (Line*)alloca(nlines * sizeof(Line) );
|
||||
|
||||
float t = effectiveThickness();
|
||||
int first_last_same = bx::fabs(m_pendingPoints[0].x - m_pendingPoints[m_pendingPoints.size() - 1].x) < 0.1
|
||||
&& bx::fabs(m_pendingPoints[0].y - m_pendingPoints[m_pendingPoints.size() - 1].y) < 0.1;
|
||||
int first_last_same = true
|
||||
&& bx::abs(m_pendingPoints[0].x - m_pendingPoints[m_pendingPoints.size() - 1].x) < 0.1
|
||||
&& bx::abs(m_pendingPoints[0].y - m_pendingPoints[m_pendingPoints.size() - 1].y) < 0.1
|
||||
;
|
||||
|
||||
// compute basics
|
||||
for (size_t i = 1; i < m_pendingPoints.size(); i++)
|
||||
@@ -358,10 +360,10 @@ void VectorDisplay::endDraw()
|
||||
line->y0 = m_pendingPoints[i - 1].y;
|
||||
line->x1 = m_pendingPoints[i].x;
|
||||
line->y1 = m_pendingPoints[i].y;
|
||||
line->a = bx::fatan2(line->y1 - line->y0, line->x1 - line->x0); // angle from positive x axis, increasing ccw, [-pi, pi]
|
||||
line->sin_a = bx::fsin(line->a);
|
||||
line->cos_a = bx::fcos(line->a);
|
||||
line->len = bx::fsqrt( (line->x1 - line->x0) * (line->x1 - line->x0) + (line->y1 - line->y0) * (line->y1 - line->y0) );
|
||||
line->a = bx::atan2(line->y1 - line->y0, line->x1 - line->x0); // angle from positive x axis, increasing ccw, [-pi, pi]
|
||||
line->sin_a = bx::sin(line->a);
|
||||
line->cos_a = bx::cos(line->a);
|
||||
line->len = bx::sqrt( (line->x1 - line->x0) * (line->x1 - line->x0) + (line->y1 - line->y0) * (line->y1 - line->y0) );
|
||||
|
||||
// figure out what connections we have
|
||||
line->has_prev = (!line->is_first
|
||||
@@ -391,12 +393,12 @@ void VectorDisplay::endDraw()
|
||||
{
|
||||
if (a2pa < pa2a)
|
||||
{
|
||||
float shorten = t * bx::fsin(a2pa / 2.0f) / bx::fcos(a2pa / 2.0f);
|
||||
float shorten = t * bx::sin(a2pa / 2.0f) / bx::cos(a2pa / 2.0f);
|
||||
float a = (bx::kPi - a2pa) / 2.0f;
|
||||
if (shorten > maxshorten)
|
||||
{
|
||||
line->s0 = pline->s1 = maxshorten;
|
||||
line->tr0 = pline->tr1 = maxshorten * bx::fsin(a) / bx::fcos(a);
|
||||
line->tr0 = pline->tr1 = maxshorten * bx::sin(a) / bx::cos(a);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -407,12 +409,13 @@ void VectorDisplay::endDraw()
|
||||
}
|
||||
else
|
||||
{
|
||||
float shorten = t * bx::fsin(pa2a / 2.0f) / bx::fcos(pa2a / 2.0f);
|
||||
float shorten = t * bx::sin(pa2a / 2.0f) / bx::cos(pa2a / 2.0f);
|
||||
float a = (bx::kPi - pa2a) / 2.0f;
|
||||
if (shorten > maxshorten)
|
||||
{
|
||||
line->s0 = pline->s1 = maxshorten;
|
||||
line->tl0 = pline->tl1 = maxshorten * bx::fsin(a) / bx::fcos(a);
|
||||
line->s0 = pline->s1 = maxshorten;
|
||||
line->tl0 =
|
||||
pline->tl1 = maxshorten * bx::sin(a) / bx::cos(a);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -495,12 +498,12 @@ void VectorDisplay::drawCircle(float _x, float _y, float _radius, float _steps)
|
||||
|
||||
float step = bx::kPi * 2.0f / _steps;
|
||||
|
||||
beginDraw(_x + _radius * bx::fsin(edgeangle + angadjust),
|
||||
_y - _radius * bx::fcos(edgeangle + angadjust) );
|
||||
beginDraw(_x + _radius * bx::sin(edgeangle + angadjust),
|
||||
_y - _radius * bx::cos(edgeangle + angadjust) );
|
||||
for (edgeangle = 0; edgeangle < 2.0f * bx::kPi - 0.001; edgeangle += step)
|
||||
{
|
||||
drawTo(_x + _radius * bx::fsin(edgeangle + step - angadjust),
|
||||
_y - _radius * bx::fcos(edgeangle + step - angadjust) );
|
||||
drawTo(_x + _radius * bx::sin(edgeangle + step - angadjust),
|
||||
_y - _radius * bx::cos(edgeangle + step - angadjust) );
|
||||
}
|
||||
|
||||
endDraw();
|
||||
@@ -510,32 +513,39 @@ void VectorDisplay::drawWheel(float _angle, float _x, float _y, float _radius)
|
||||
{
|
||||
float spokeradius = _radius - 2.0f;
|
||||
// draw spokes
|
||||
drawLine(_x + spokeradius * bx::fsin(_angle),
|
||||
_y - spokeradius * bx::fcos(_angle),
|
||||
_x - spokeradius * bx::fsin(_angle),
|
||||
_y + spokeradius * bx::fcos(_angle) );
|
||||
drawLine(_x + spokeradius * bx::fsin(_angle + bx::kPi / 4.0f),
|
||||
_y - spokeradius * bx::fcos(_angle + bx::kPi / 4.0f),
|
||||
_x - spokeradius * bx::fsin(_angle + bx::kPi / 4.0f),
|
||||
_y + spokeradius * bx::fcos(_angle + bx::kPi / 4.0f) );
|
||||
drawLine(_x + spokeradius * bx::fsin(_angle + bx::kPi / 2.0f),
|
||||
_y - spokeradius * bx::fcos(_angle + bx::kPi / 2.0f),
|
||||
_x - spokeradius * bx::fsin(_angle + bx::kPi / 2.0f),
|
||||
_y + spokeradius * bx::fcos(_angle + bx::kPi / 2.0f) );
|
||||
drawLine(_x + spokeradius * bx::fsin(_angle + 3.0f * bx::kPi / 4.0f),
|
||||
_y - spokeradius * bx::fcos(_angle + 3.0f * bx::kPi / 4.0f),
|
||||
_x - spokeradius * bx::fsin(_angle + 3.0f * bx::kPi / 4.0f),
|
||||
_y + spokeradius * bx::fcos(_angle + 3.0f * bx::kPi / 4.0f) );
|
||||
drawLine(_x + spokeradius * bx::sin(_angle),
|
||||
_y - spokeradius * bx::cos(_angle),
|
||||
_x - spokeradius * bx::sin(_angle),
|
||||
_y + spokeradius * bx::cos(_angle)
|
||||
);
|
||||
drawLine(_x + spokeradius * bx::sin(_angle + bx::kPi / 4.0f),
|
||||
_y - spokeradius * bx::cos(_angle + bx::kPi / 4.0f),
|
||||
_x - spokeradius * bx::sin(_angle + bx::kPi / 4.0f),
|
||||
_y + spokeradius * bx::cos(_angle + bx::kPi / 4.0f)
|
||||
);
|
||||
drawLine(_x + spokeradius * bx::sin(_angle + bx::kPi / 2.0f),
|
||||
_y - spokeradius * bx::cos(_angle + bx::kPi / 2.0f),
|
||||
_x - spokeradius * bx::sin(_angle + bx::kPi / 2.0f),
|
||||
_y + spokeradius * bx::cos(_angle + bx::kPi / 2.0f)
|
||||
);
|
||||
drawLine(_x + spokeradius * bx::sin(_angle + 3.0f * bx::kPi / 4.0f),
|
||||
_y - spokeradius * bx::cos(_angle + 3.0f * bx::kPi / 4.0f),
|
||||
_x - spokeradius * bx::sin(_angle + 3.0f * bx::kPi / 4.0f),
|
||||
_y + spokeradius * bx::cos(_angle + 3.0f * bx::kPi / 4.0f)
|
||||
);
|
||||
|
||||
float edgeangle = 0.0f;
|
||||
float angadjust = 0.0f;
|
||||
|
||||
beginDraw(_x + _radius * bx::fsin(_angle + edgeangle + angadjust),
|
||||
_y - _radius * bx::fcos(_angle + edgeangle + angadjust) );
|
||||
beginDraw(
|
||||
_x + _radius * bx::sin(_angle + edgeangle + angadjust)
|
||||
, _y - _radius * bx::cos(_angle + edgeangle + angadjust)
|
||||
);
|
||||
|
||||
for (edgeangle = 0; edgeangle < 2.0f * bx::kPi - 0.001f; edgeangle += bx::kPi / 4.0f)
|
||||
{
|
||||
drawTo(_x + _radius * bx::fsin(_angle + edgeangle + bx::kPi / 4.0f - angadjust),
|
||||
_y - _radius * bx::fcos(_angle + edgeangle + bx::kPi / 4.0f - angadjust) );
|
||||
drawTo(_x + _radius * bx::sin(_angle + edgeangle + bx::kPi / 4.0f - angadjust),
|
||||
_y - _radius * bx::cos(_angle + edgeangle + bx::kPi / 4.0f - angadjust) );
|
||||
}
|
||||
|
||||
endDraw();
|
||||
@@ -547,12 +557,10 @@ float VectorDisplay::effectiveThickness()
|
||||
{
|
||||
return m_thickness * m_drawScale / 2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this makes thickness=16 at 2048x1536
|
||||
float vv = (0.01f * (m_screenWidth + m_screenHeight) / 2.0f) * m_drawScale / 2.0f;
|
||||
return bx::max(vv, 6.0f);
|
||||
}
|
||||
|
||||
// this makes thickness=16 at 2048x1536
|
||||
float vv = (0.01f * (m_screenWidth + m_screenHeight) / 2.0f) * m_drawScale / 2.0f;
|
||||
return bx::max(vv, 6.0f);
|
||||
}
|
||||
|
||||
void VectorDisplay::setTransform(float _offsetX, float _offsetY, float _scale)
|
||||
@@ -622,7 +630,7 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t,
|
||||
if (a2pa < pa2a)
|
||||
{
|
||||
_t = -_t;
|
||||
nsteps = (int32_t)bx::max(1.0f, bx::fround(a2pa / (bx::kPi / 8.0f) ) );
|
||||
nsteps = (int32_t)bx::max(1.0f, bx::round(a2pa / (bx::kPi / 8.0f) ) );
|
||||
angles = (float*)alloca(sizeof(float) * (nsteps + 1) );
|
||||
for (i = 0; i <= nsteps; i++)
|
||||
{
|
||||
@@ -631,7 +639,7 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t,
|
||||
}
|
||||
else
|
||||
{
|
||||
nsteps = (int32_t)bx::max(1.0f, bx::fround(pa2a / (bx::kPi / 8.0f) ) );
|
||||
nsteps = (int32_t)bx::max(1.0f, bx::round(pa2a / (bx::kPi / 8.0f) ) );
|
||||
angles = (float*)alloca(sizeof(float) * (nsteps + 1) );
|
||||
for (i = 0; i <= nsteps; i++)
|
||||
{
|
||||
@@ -641,9 +649,9 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t,
|
||||
|
||||
for (i = 1; i <= nsteps; i++)
|
||||
{
|
||||
appendTexpoint(_cx + _t * bx::fsin(angles[i - 1]), _cy - _t * bx::fcos(angles[i - 1]), _e, (float)HALF_TEXTURE_SIZE);
|
||||
appendTexpoint(_cx + _t * bx::sin(angles[i - 1]), _cy - _t * bx::cos(angles[i - 1]), _e, (float)HALF_TEXTURE_SIZE);
|
||||
appendTexpoint(_cx, _cy, _s, (float)HALF_TEXTURE_SIZE);
|
||||
appendTexpoint(_cx + _t * bx::fsin(angles[i]), _cy - _t * bx::fcos(angles[i]), _e, (float)HALF_TEXTURE_SIZE);
|
||||
appendTexpoint(_cx + _t * bx::sin(angles[i]), _cy - _t * bx::cos(angles[i]), _e, (float)HALF_TEXTURE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -854,11 +862,11 @@ void VectorDisplay::genLinetex() // generate
|
||||
for (y = 0; y < TEXTURE_SIZE; y++)
|
||||
{
|
||||
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
|
||||
, bx::sqrt( (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;
|
||||
float line = bx::pow(16.0f, -2.0f * distance);
|
||||
float glow = bx::pow( 2.0f, -4.0f * distance) / 10.0f;
|
||||
glow = 0;
|
||||
float val = bx::clamp(line + glow, 0.0f, 1.0f);
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ public:
|
||||
// Brush attenuation
|
||||
float a2 = (float)(area_x * area_x);
|
||||
float b2 = (float)(area_y * area_y);
|
||||
float brushAttn = m_brush.m_size - bx::fsqrt(a2 + b2);
|
||||
float brushAttn = m_brush.m_size - bx::sqrt(a2 + b2);
|
||||
|
||||
// Raise/Lower and scale by brush power.
|
||||
height += 0.0f < bx::clamp(brushAttn*m_brush.m_power, 0.0f, m_brush.m_power) && m_brush.m_raise
|
||||
|
||||
@@ -140,12 +140,12 @@ struct Camera
|
||||
|
||||
consumeOrbit(amount);
|
||||
|
||||
m_target.curr[0] = bx::flerp(m_target.curr[0], m_target.dest[0], amount);
|
||||
m_target.curr[1] = bx::flerp(m_target.curr[1], m_target.dest[1], amount);
|
||||
m_target.curr[2] = bx::flerp(m_target.curr[2], m_target.dest[2], amount);
|
||||
m_pos.curr[0] = bx::flerp(m_pos.curr[0], m_pos.dest[0], amount);
|
||||
m_pos.curr[1] = bx::flerp(m_pos.curr[1], m_pos.dest[1], amount);
|
||||
m_pos.curr[2] = bx::flerp(m_pos.curr[2], m_pos.dest[2], amount);
|
||||
m_target.curr[0] = bx::lerp(m_target.curr[0], m_target.dest[0], amount);
|
||||
m_target.curr[1] = bx::lerp(m_target.curr[1], m_target.dest[1], amount);
|
||||
m_target.curr[2] = bx::lerp(m_target.curr[2], m_target.dest[2], amount);
|
||||
m_pos.curr[0] = bx::lerp(m_pos.curr[0], m_pos.dest[0], amount);
|
||||
m_pos.curr[1] = bx::lerp(m_pos.curr[1], m_pos.dest[1], amount);
|
||||
m_pos.curr[2] = bx::lerp(m_pos.curr[2], m_pos.dest[2], amount);
|
||||
}
|
||||
|
||||
struct Interp3f
|
||||
|
||||
@@ -692,7 +692,7 @@ public:
|
||||
bx::mtxSRT(bunny, 0.03f, 0.03f, 0.03f, 0.0f, 0.0f, 0.0f, -3.0f, 0.0f, 0.0f);
|
||||
|
||||
ddSetTransform(bunny);
|
||||
const bool wireframe = bx::fmod(time, 2.0f) > 1.0f;
|
||||
const bool wireframe = bx::mod(time, 2.0f) > 1.0f;
|
||||
ddSetWireframe(wireframe);
|
||||
ddSetColor(wireframe ? 0xffff00ff : 0xff00ff00);
|
||||
ddDraw(m_bunny);
|
||||
@@ -738,7 +738,7 @@ public:
|
||||
ddPush();
|
||||
ddSetStipple(true, 1.0f, time*0.1f);
|
||||
ddSetColor(0xff0000ff);
|
||||
ddDrawCircle(normal, center, 1.0f, 0.5f + bx::fsin(time*10.0f) );
|
||||
ddDrawCircle(normal, center, 1.0f, 0.5f + bx::sin(time*10.0f) );
|
||||
ddPop();
|
||||
|
||||
ddSetSpin(time);
|
||||
|
||||
@@ -236,9 +236,9 @@ public:
|
||||
float eyeDist = 2.5f;
|
||||
float eye[3] =
|
||||
{
|
||||
-eyeDist * bx::fsin(time*cameraSpin*camSpeed),
|
||||
-eyeDist * bx::sin(time*cameraSpin*camSpeed),
|
||||
0.0f,
|
||||
-eyeDist * bx::fcos(time*cameraSpin*camSpeed),
|
||||
-eyeDist * bx::cos(time*cameraSpin*camSpeed),
|
||||
};
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
|
||||
@@ -676,9 +676,9 @@ public:
|
||||
{
|
||||
float el = m_lightElevation * (bx::kPi/180.0f);
|
||||
float az = m_lightAzimuth * (bx::kPi/180.0f);
|
||||
m_lightDir[0] = bx::fcos(el)*bx::fcos(az);
|
||||
m_lightDir[2] = bx::fcos(el)*bx::fsin(az);
|
||||
m_lightDir[1] = bx::fsin(el);
|
||||
m_lightDir[0] = bx::cos(el)*bx::cos(az);
|
||||
m_lightDir[2] = bx::cos(el)*bx::sin(az);
|
||||
m_lightDir[1] = bx::sin(el);
|
||||
m_lightDir[3] = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -279,21 +279,21 @@ namespace
|
||||
float day = 30.0f * m_month + 15.0f;
|
||||
float lambda = 280.46f + 0.9856474f * day;
|
||||
lambda = bx::toRad(lambda);
|
||||
m_delta = bx::fasin(bx::fsin(m_eclipticObliquity) * bx::fsin(lambda));
|
||||
m_delta = bx::asin(bx::sin(m_eclipticObliquity) * bx::sin(lambda));
|
||||
}
|
||||
|
||||
void UpdateSunPosition(float hour)
|
||||
{
|
||||
float latitude = bx::toRad(m_latitude);
|
||||
float h = hour * bx::kPi / 12.0f;
|
||||
float azimuth = bx::fatan2(
|
||||
bx::fsin(h),
|
||||
bx::fcos(h) * bx::fsin(latitude) - bx::ftan(m_delta) * bx::fcos(latitude)
|
||||
float azimuth = bx::atan2(
|
||||
bx::sin(h),
|
||||
bx::cos(h) * bx::sin(latitude) - bx::tan(m_delta) * bx::cos(latitude)
|
||||
);
|
||||
|
||||
float altitude = bx::fasin(
|
||||
bx::fsin(latitude) * bx::fsin(m_delta) + bx::fcos(latitude) * bx::fcos(m_delta) * bx::fcos(h)
|
||||
);
|
||||
float altitude = bx::asin(
|
||||
bx::sin(latitude) * bx::sin(m_delta) + bx::cos(latitude) * bx::cos(m_delta) * bx::cos(h)
|
||||
);
|
||||
float rotation[4];
|
||||
bx::quatRotateAxis(rotation, m_upvector, -azimuth);
|
||||
float direction[3];
|
||||
@@ -544,25 +544,25 @@ namespace
|
||||
const double freq = double(bx::getHPFrequency());
|
||||
const float deltaTime = float(frameTime / freq);
|
||||
m_time += m_timeScale * deltaTime;
|
||||
m_time = bx::fmod(m_time, 24.0f);
|
||||
m_time = bx::mod(m_time, 24.0f);
|
||||
m_sun.Update(m_time);
|
||||
|
||||
imguiBeginFrame(m_mouseState.m_mx
|
||||
, m_mouseState.m_my
|
||||
, (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0)
|
||||
| (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0)
|
||||
, (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0)
|
||||
| (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0)
|
||||
| (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
|
||||
, m_mouseState.m_mz
|
||||
, uint16_t(m_width)
|
||||
, uint16_t(m_height)
|
||||
);
|
||||
);
|
||||
|
||||
showExampleDialog(this);
|
||||
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(m_width - m_width / 5.0f - 10.0f, 10.0f)
|
||||
, ImGuiCond_FirstUseEver
|
||||
);
|
||||
);
|
||||
|
||||
imgui(m_width / 5.0f - 10.0f);
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ void toAabb(Aabb& _aabb, const Disk& _disk)
|
||||
const float inv = 1.0f / (tmp[0]*tmp[1]*tmp[2]);
|
||||
|
||||
float extent[3];
|
||||
extent[0] = _disk.m_radius * tmp[0] * bx::fsqrt( (nsq[0] + nsq[1] * nsq[2]) * inv);
|
||||
extent[1] = _disk.m_radius * tmp[1] * bx::fsqrt( (nsq[1] + nsq[2] * nsq[0]) * inv);
|
||||
extent[2] = _disk.m_radius * tmp[2] * bx::fsqrt( (nsq[2] + nsq[0] * nsq[1]) * inv);
|
||||
extent[0] = _disk.m_radius * tmp[0] * bx::sqrt( (nsq[0] + nsq[1] * nsq[2]) * inv);
|
||||
extent[1] = _disk.m_radius * tmp[1] * bx::sqrt( (nsq[1] + nsq[2] * nsq[0]) * inv);
|
||||
extent[2] = _disk.m_radius * tmp[2] * bx::sqrt( (nsq[2] + nsq[0] * nsq[1]) * inv);
|
||||
|
||||
bx::vec3Sub(_aabb.m_min, _disk.m_center, extent);
|
||||
bx::vec3Add(_aabb.m_max, _disk.m_center, extent);
|
||||
@@ -88,9 +88,9 @@ void toAabb(Aabb& _aabb, const Cylinder& _cylinder)
|
||||
const float inv = 1.0f / (tmp[0]*tmp[1]*tmp[2]);
|
||||
|
||||
float extent[3];
|
||||
extent[0] = _cylinder.m_radius * tmp[0] * bx::fsqrt( (nsq[0] + nsq[1] * nsq[2]) * inv);
|
||||
extent[1] = _cylinder.m_radius * tmp[1] * bx::fsqrt( (nsq[1] + nsq[2] * nsq[0]) * inv);
|
||||
extent[2] = _cylinder.m_radius * tmp[2] * bx::fsqrt( (nsq[2] + nsq[0] * nsq[1]) * inv);
|
||||
extent[0] = _cylinder.m_radius * tmp[0] * bx::sqrt( (nsq[0] + nsq[1] * nsq[2]) * inv);
|
||||
extent[1] = _cylinder.m_radius * tmp[1] * bx::sqrt( (nsq[1] + nsq[2] * nsq[0]) * inv);
|
||||
extent[2] = _cylinder.m_radius * tmp[2] * bx::sqrt( (nsq[2] + nsq[0] * nsq[1]) * inv);
|
||||
|
||||
float minP[3];
|
||||
bx::vec3Sub(minP, _cylinder.m_pos, extent);
|
||||
@@ -304,7 +304,7 @@ void calcMaxBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _num
|
||||
}
|
||||
|
||||
bx::vec3Move(_sphere.m_center, center);
|
||||
_sphere.m_radius = bx::fsqrt(maxDistSq);
|
||||
_sphere.m_radius = bx::sqrt(maxDistSq);
|
||||
}
|
||||
|
||||
void calcMinBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _numVertices, uint32_t _stride, float _step)
|
||||
@@ -353,7 +353,7 @@ void calcMinBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _num
|
||||
center[0] += xx * radiusStep;
|
||||
center[1] += yy * radiusStep;
|
||||
center[2] += zz * radiusStep;
|
||||
maxDistSq = bx::flerp(maxDistSq, distSq, _step);
|
||||
maxDistSq = bx::lerp(maxDistSq, distSq, _step);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ void calcMinBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _num
|
||||
} while (!done);
|
||||
|
||||
bx::vec3Move(_sphere.m_center, center);
|
||||
_sphere.m_radius = bx::fsqrt(maxDistSq);
|
||||
_sphere.m_radius = bx::sqrt(maxDistSq);
|
||||
}
|
||||
|
||||
void calcPlaneUv(const Plane& _plane, float* _udir, float* _vdir)
|
||||
@@ -588,7 +588,7 @@ bool intersect(const Ray& _ray, const Disk& _disk, Hit* _hit)
|
||||
{
|
||||
float tmp[3];
|
||||
bx::vec3Sub(tmp, _disk.m_center, _hit->m_pos);
|
||||
return bx::vec3Dot(tmp, tmp) <= bx::fsq(_disk.m_radius);
|
||||
return bx::vec3Dot(tmp, tmp) <= bx::square(_disk.m_radius);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -606,7 +606,7 @@ static bool intersect(const Ray& _ray, const Cylinder& _cylinder, bool _capsule,
|
||||
bx::vec3Cross(normal, _ray.m_dir, axis);
|
||||
|
||||
const float len = bx::vec3Norm(normal, normal);
|
||||
const float dist = bx::fabs(bx::vec3Dot(rc, normal) );
|
||||
const float dist = bx::abs(bx::vec3Dot(rc, normal) );
|
||||
|
||||
if (dist > _cylinder.m_radius)
|
||||
{
|
||||
@@ -620,9 +620,9 @@ static bool intersect(const Ray& _ray, const Cylinder& _cylinder, bool _capsule,
|
||||
bx::vec3Cross(vo, normal, axis);
|
||||
bx::vec3Norm(vo, vo);
|
||||
|
||||
const float rsq = bx::fsq(_cylinder.m_radius);
|
||||
const float rsq = bx::square(_cylinder.m_radius);
|
||||
const float ddoto = bx::vec3Dot(_ray.m_dir, vo);
|
||||
const float ss = t0 - bx::fabs(bx::fsqrt(rsq - bx::fsq(dist) ) / ddoto);
|
||||
const float ss = t0 - bx::abs(bx::sqrt(rsq - bx::square(dist) ) / ddoto);
|
||||
|
||||
if (0.0f > ss)
|
||||
{
|
||||
@@ -746,14 +746,14 @@ bool intersect(const Ray& _ray, const Cone& _cone, Hit* _hit)
|
||||
float ro[3];
|
||||
bx::vec3Sub(ro, _ray.m_pos, _cone.m_end);
|
||||
|
||||
const float hyp = bx::fsqrt(bx::fsq(_cone.m_radius) + bx::fsq(len) );
|
||||
const float cosaSq = bx::fsq(len/hyp);
|
||||
const float hyp = bx::sqrt(bx::square(_cone.m_radius) + bx::square(len) );
|
||||
const float cosaSq = bx::square(len/hyp);
|
||||
const float ndoto = bx::vec3Dot(normal, ro);
|
||||
const float ndotd = bx::vec3Dot(normal, _ray.m_dir);
|
||||
|
||||
const float aa = bx::fsq(ndotd) - cosaSq;
|
||||
const float aa = bx::square(ndotd) - cosaSq;
|
||||
const float bb = 2.0f * (ndotd*ndoto - bx::vec3Dot(_ray.m_dir, ro)*cosaSq);
|
||||
const float cc = bx::fsq(ndoto) - bx::vec3Dot(ro, ro)*cosaSq;
|
||||
const float cc = bx::square(ndoto) - bx::vec3Dot(ro, ro)*cosaSq;
|
||||
|
||||
float det = bb*bb - 4.0f*aa*cc;
|
||||
|
||||
@@ -762,7 +762,7 @@ bool intersect(const Ray& _ray, const Cone& _cone, Hit* _hit)
|
||||
return hit;
|
||||
}
|
||||
|
||||
det = bx::fsqrt(det);
|
||||
det = bx::sqrt(det);
|
||||
const float invA2 = 1.0f / (2.0f*aa);
|
||||
const float t1 = (-bb - det) * invA2;
|
||||
const float t2 = (-bb + det) * invA2;
|
||||
@@ -854,7 +854,7 @@ bool intersect(const Ray& _ray, const Sphere& _sphere, Hit* _hit)
|
||||
}
|
||||
|
||||
const float aa = bx::vec3Dot(_ray.m_dir, _ray.m_dir);
|
||||
const float cc = bx::vec3Dot(rs, rs) - bx::fsq(_sphere.m_radius);
|
||||
const float cc = bx::vec3Dot(rs, rs) - bx::square(_sphere.m_radius);
|
||||
|
||||
const float discriminant = bb*bb - aa*cc;
|
||||
|
||||
@@ -863,7 +863,7 @@ bool intersect(const Ray& _ray, const Sphere& _sphere, Hit* _hit)
|
||||
return false;
|
||||
}
|
||||
|
||||
const float sqrtDiscriminant = bx::fsqrt(discriminant);
|
||||
const float sqrtDiscriminant = bx::sqrt(discriminant);
|
||||
const float invA = 1.0f / aa;
|
||||
const float tt = -(bb + sqrtDiscriminant)*invA;
|
||||
|
||||
|
||||
@@ -166,16 +166,16 @@ struct Camera
|
||||
|
||||
float direction[3] =
|
||||
{
|
||||
bx::fcos(m_verticalAngle) * bx::fsin(m_horizontalAngle),
|
||||
bx::fsin(m_verticalAngle),
|
||||
bx::fcos(m_verticalAngle) * bx::fcos(m_horizontalAngle),
|
||||
bx::cos(m_verticalAngle) * bx::sin(m_horizontalAngle),
|
||||
bx::sin(m_verticalAngle),
|
||||
bx::cos(m_verticalAngle) * bx::cos(m_horizontalAngle),
|
||||
};
|
||||
|
||||
float right[3] =
|
||||
{
|
||||
bx::fsin(m_horizontalAngle - bx::kPiHalf),
|
||||
bx::sin(m_horizontalAngle - bx::kPiHalf),
|
||||
0,
|
||||
bx::fcos(m_horizontalAngle - bx::kPiHalf),
|
||||
bx::cos(m_horizontalAngle - bx::kPiHalf),
|
||||
};
|
||||
|
||||
float up[3];
|
||||
|
||||
@@ -146,18 +146,18 @@ static uint8_t getCircleLod(uint8_t _lod)
|
||||
|
||||
static void circle(float* _out, float _angle)
|
||||
{
|
||||
float sa = bx::fsin(_angle);
|
||||
float ca = bx::fcos(_angle);
|
||||
float sa = bx::sin(_angle);
|
||||
float ca = bx::cos(_angle);
|
||||
_out[0] = sa;
|
||||
_out[1] = ca;
|
||||
}
|
||||
|
||||
static void squircle(float* _out, float _angle)
|
||||
{
|
||||
float sa = bx::fsin(_angle);
|
||||
float ca = bx::fcos(_angle);
|
||||
_out[0] = bx::fsqrt(bx::fabs(sa) ) * bx::fsign(sa);
|
||||
_out[1] = bx::fsqrt(bx::fabs(ca) ) * bx::fsign(ca);
|
||||
float sa = bx::sin(_angle);
|
||||
float ca = bx::cos(_angle);
|
||||
_out[0] = bx::sqrt(bx::abs(sa) ) * bx::sign(sa);
|
||||
_out[1] = bx::sqrt(bx::abs(ca) ) * bx::sign(ca);
|
||||
}
|
||||
|
||||
uint32_t genSphere(uint8_t _subdiv0, void* _pos0 = NULL, uint16_t _posStride0 = 0, void* _normals0 = NULL, uint16_t _normalStride0 = 0)
|
||||
@@ -174,7 +174,7 @@ uint32_t genSphere(uint8_t _subdiv0, void* _pos0 = NULL, uint16_t _posStride0 =
|
||||
{
|
||||
static const float scale = 1.0f;
|
||||
static const float golden = 1.6180339887f;
|
||||
static const float len = bx::fsqrt(golden*golden + 1.0f);
|
||||
static const float len = bx::sqrt(golden*golden + 1.0f);
|
||||
static const float ss = 1.0f/len * scale;
|
||||
static const float ll = ss*golden;
|
||||
|
||||
@@ -285,7 +285,7 @@ uint32_t genSphere(uint8_t _subdiv0, void* _pos0 = NULL, uint16_t _posStride0 =
|
||||
} gen(_pos0, _posStride0, _normals0, _normalStride0, _subdiv0);
|
||||
}
|
||||
|
||||
uint32_t numVertices = 20*3*bx::uint32_max(1, (uint32_t)bx::fpow(4.0f, _subdiv0) );
|
||||
uint32_t numVertices = 20*3*bx::uint32_max(1, (uint32_t)bx::pow(4.0f, _subdiv0) );
|
||||
return numVertices;
|
||||
}
|
||||
|
||||
@@ -1512,12 +1512,12 @@ struct DebugDraw
|
||||
const uint32_t num = getCircleLod(attrib.m_lod);
|
||||
const float step = bx::kPi * 2.0f / num;
|
||||
|
||||
_degrees = bx::fwrap(_degrees, 360.0f);
|
||||
_degrees = bx::wrap(_degrees, 360.0f);
|
||||
|
||||
float pos[3];
|
||||
getPoint(pos, _axis
|
||||
, bx::fsin(step * 0)*_radius
|
||||
, bx::fcos(step * 0)*_radius
|
||||
, bx::sin(step * 0)*_radius
|
||||
, bx::cos(step * 0)*_radius
|
||||
);
|
||||
|
||||
moveTo(pos[0] + _x, pos[1] + _y, pos[2] + _z);
|
||||
@@ -1527,22 +1527,22 @@ struct DebugDraw
|
||||
for (uint32_t ii = 1; ii < n+1; ++ii)
|
||||
{
|
||||
getPoint(pos, _axis
|
||||
, bx::fsin(step * ii)*_radius
|
||||
, bx::fcos(step * ii)*_radius
|
||||
, bx::sin(step * ii)*_radius
|
||||
, bx::cos(step * ii)*_radius
|
||||
);
|
||||
lineTo(pos[0] + _x, pos[1] + _y, pos[2] + _z);
|
||||
}
|
||||
|
||||
moveTo(_x, _y, _z);
|
||||
getPoint(pos, _axis
|
||||
, bx::fsin(step * 0)*_radius
|
||||
, bx::fcos(step * 0)*_radius
|
||||
, bx::sin(step * 0)*_radius
|
||||
, bx::cos(step * 0)*_radius
|
||||
);
|
||||
lineTo(pos[0] + _x, pos[1] + _y, pos[2] + _z);
|
||||
|
||||
getPoint(pos, _axis
|
||||
, bx::fsin(step * n)*_radius
|
||||
, bx::fcos(step * n)*_radius
|
||||
, bx::sin(step * n)*_radius
|
||||
, bx::cos(step * n)*_radius
|
||||
);
|
||||
moveTo(pos[0] + _x, pos[1] + _y, pos[2] + _z);
|
||||
lineTo(_x, _y, _z);
|
||||
@@ -1568,8 +1568,8 @@ struct DebugDraw
|
||||
circle(xy0, 0.0f);
|
||||
squircle(xy1, 0.0f);
|
||||
|
||||
bx::vec3Mul(pos, udir, bx::flerp(xy0[0], xy1[0], _weight)*_radius);
|
||||
bx::vec3Mul(tmp0, vdir, bx::flerp(xy0[1], xy1[1], _weight)*_radius);
|
||||
bx::vec3Mul(pos, udir, bx::lerp(xy0[0], xy1[0], _weight)*_radius);
|
||||
bx::vec3Mul(tmp0, vdir, bx::lerp(xy0[1], xy1[1], _weight)*_radius);
|
||||
bx::vec3Add(tmp1, pos, tmp0);
|
||||
bx::vec3Add(pos, tmp1, _center);
|
||||
moveTo(pos);
|
||||
@@ -1580,8 +1580,8 @@ struct DebugDraw
|
||||
circle(xy0, angle);
|
||||
squircle(xy1, angle);
|
||||
|
||||
bx::vec3Mul(pos, udir, bx::flerp(xy0[0], xy1[0], _weight)*_radius);
|
||||
bx::vec3Mul(tmp0, vdir, bx::flerp(xy0[1], xy1[1], _weight)*_radius);
|
||||
bx::vec3Mul(pos, udir, bx::lerp(xy0[0], xy1[0], _weight)*_radius);
|
||||
bx::vec3Mul(tmp0, vdir, bx::lerp(xy0[1], xy1[1], _weight)*_radius);
|
||||
bx::vec3Add(tmp1, pos, tmp0);
|
||||
bx::vec3Add(pos, tmp1, _center);
|
||||
lineTo(pos);
|
||||
@@ -1609,8 +1609,8 @@ struct DebugDraw
|
||||
|
||||
float pos[3];
|
||||
getPoint(pos, _axis
|
||||
, bx::flerp(xy0[0], xy1[0], _weight)*_radius
|
||||
, bx::flerp(xy0[1], xy1[1], _weight)*_radius
|
||||
, bx::lerp(xy0[0], xy1[0], _weight)*_radius
|
||||
, bx::lerp(xy0[1], xy1[1], _weight)*_radius
|
||||
);
|
||||
|
||||
moveTo(pos[0] + _x, pos[1] + _y, pos[2] + _z);
|
||||
@@ -1621,8 +1621,8 @@ struct DebugDraw
|
||||
squircle(xy1, angle);
|
||||
|
||||
getPoint(pos, _axis
|
||||
, bx::flerp(xy0[0], xy1[0], _weight)*_radius
|
||||
, bx::flerp(xy0[1], xy1[1], _weight)*_radius
|
||||
, bx::lerp(xy0[0], xy1[0], _weight)*_radius
|
||||
, bx::lerp(xy0[1], xy1[1], _weight)*_radius
|
||||
);
|
||||
lineTo(pos[0] + _x, pos[1] + _y, pos[2] + _z);
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ public:
|
||||
auto dpi = DisplayInformation::GetForCurrentView()->LogicalDpi;
|
||||
static const float dipsPerInch = 96.0f;
|
||||
g_eventQueue.postSizeEvent(g_defaultWindow
|
||||
, lround(bx::ffloor(bounds.Width * dpi / dipsPerInch + 0.5f) )
|
||||
, lround(bx::ffloor(bounds.Height * dpi / dipsPerInch + 0.5f) )
|
||||
, lround(bx::floor(bounds.Width * dpi / dipsPerInch + 0.5f) )
|
||||
, lround(bx::floor(bounds.Height * dpi / dipsPerInch + 0.5f) )
|
||||
);
|
||||
#endif // BX_PLATFORM_WINRT
|
||||
|
||||
|
||||
@@ -617,6 +617,11 @@ const GlyphInfo* FontManager::getGlyphInfo(FontHandle _handle, CodePoint _codePo
|
||||
|
||||
bool FontManager::addBitmap(GlyphInfo& _glyphInfo, const uint8_t* _data)
|
||||
{
|
||||
_glyphInfo.regionIndex = m_atlas->addRegion( (uint16_t)bx::fceil(_glyphInfo.width), (uint16_t)bx::fceil(_glyphInfo.height), _data, AtlasRegion::TYPE_GRAY);
|
||||
_glyphInfo.regionIndex = m_atlas->addRegion(
|
||||
(uint16_t)bx::ceil(_glyphInfo.width)
|
||||
, (uint16_t)bx::ceil(_glyphInfo.height)
|
||||
, _data
|
||||
, AtlasRegion::TYPE_GRAY
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -294,18 +294,18 @@ namespace ps
|
||||
|
||||
float start[3];
|
||||
float end[3];
|
||||
const float startOffset = bx::flerp(m_uniforms.m_offsetStart[0], m_uniforms.m_offsetStart[1], bx::frnd(&m_rng) );
|
||||
const float startOffset = bx::lerp(m_uniforms.m_offsetStart[0], m_uniforms.m_offsetStart[1], bx::frnd(&m_rng) );
|
||||
bx::vec3Mul(start, pos, startOffset);
|
||||
|
||||
const float endOffset = bx::flerp(m_uniforms.m_offsetEnd[0], m_uniforms.m_offsetEnd[1], bx::frnd(&m_rng) );
|
||||
const float endOffset = bx::lerp(m_uniforms.m_offsetEnd[0], m_uniforms.m_offsetEnd[1], bx::frnd(&m_rng) );
|
||||
float tmp1[3];
|
||||
bx::vec3Mul(tmp1, dir, endOffset);
|
||||
bx::vec3Add(end, tmp1, start);
|
||||
|
||||
particle.life = time;
|
||||
particle.lifeSpan = bx::flerp(m_uniforms.m_lifeSpan[0], m_uniforms.m_lifeSpan[1], bx::frnd(&m_rng) );
|
||||
particle.lifeSpan = bx::lerp(m_uniforms.m_lifeSpan[0], m_uniforms.m_lifeSpan[1], bx::frnd(&m_rng) );
|
||||
|
||||
float gravity[3] = { 0.0f, -9.81f * m_uniforms.m_gravityScale * bx::fsq(particle.lifeSpan), 0.0f };
|
||||
float gravity[3] = { 0.0f, -9.81f * m_uniforms.m_gravityScale * bx::square(particle.lifeSpan), 0.0f };
|
||||
|
||||
bx::vec3MulMtx(particle.start, start, mtx);
|
||||
bx::vec3MulMtx(particle.end[0], end, mtx);
|
||||
@@ -313,11 +313,11 @@ namespace ps
|
||||
|
||||
bx::memCopy(particle.rgba, m_uniforms.m_rgba, BX_COUNTOF(m_uniforms.m_rgba)*sizeof(uint32_t) );
|
||||
|
||||
particle.blendStart = bx::flerp(m_uniforms.m_blendStart[0], m_uniforms.m_blendStart[1], bx::frnd(&m_rng) );
|
||||
particle.blendEnd = bx::flerp(m_uniforms.m_blendEnd[0], m_uniforms.m_blendEnd[1], bx::frnd(&m_rng) );
|
||||
particle.blendStart = bx::lerp(m_uniforms.m_blendStart[0], m_uniforms.m_blendStart[1], bx::frnd(&m_rng) );
|
||||
particle.blendEnd = bx::lerp(m_uniforms.m_blendEnd[0], m_uniforms.m_blendEnd[1], bx::frnd(&m_rng) );
|
||||
|
||||
particle.scaleStart = bx::flerp(m_uniforms.m_scaleStart[0], m_uniforms.m_scaleStart[1], bx::frnd(&m_rng) );
|
||||
particle.scaleEnd = bx::flerp(m_uniforms.m_scaleEnd[0], m_uniforms.m_scaleEnd[1], bx::frnd(&m_rng) );
|
||||
particle.scaleStart = bx::lerp(m_uniforms.m_scaleStart[0], m_uniforms.m_scaleStart[1], bx::frnd(&m_rng) );
|
||||
particle.scaleEnd = bx::lerp(m_uniforms.m_scaleEnd[0], m_uniforms.m_scaleEnd[1], bx::frnd(&m_rng) );
|
||||
|
||||
time += timePerParticle;
|
||||
}
|
||||
@@ -360,21 +360,21 @@ namespace ps
|
||||
ParticleSort& sort = _outSort[current];
|
||||
float tmp[3];
|
||||
bx::vec3Sub(tmp, _eye, pos);
|
||||
sort.dist = bx::fsqrt(bx::vec3Dot(tmp, tmp) );
|
||||
sort.dist = bx::sqrt(bx::vec3Dot(tmp, tmp) );
|
||||
sort.idx = current;
|
||||
|
||||
uint32_t idx = uint32_t(ttRgba*4);
|
||||
float ttmod = bx::fmod(ttRgba, 0.25f)/0.25f;
|
||||
float ttmod = bx::mod(ttRgba, 0.25f)/0.25f;
|
||||
uint32_t rgbaStart = particle.rgba[idx];
|
||||
uint32_t rgbaEnd = particle.rgba[idx+1];
|
||||
|
||||
float rr = bx::flerp( ( (uint8_t*)&rgbaStart)[0], ( (uint8_t*)&rgbaEnd)[0], ttmod)/255.0f;
|
||||
float gg = bx::flerp( ( (uint8_t*)&rgbaStart)[1], ( (uint8_t*)&rgbaEnd)[1], ttmod)/255.0f;
|
||||
float bb = bx::flerp( ( (uint8_t*)&rgbaStart)[2], ( (uint8_t*)&rgbaEnd)[2], ttmod)/255.0f;
|
||||
float aa = bx::flerp( ( (uint8_t*)&rgbaStart)[3], ( (uint8_t*)&rgbaEnd)[3], ttmod)/255.0f;
|
||||
float rr = bx::lerp( ( (uint8_t*)&rgbaStart)[0], ( (uint8_t*)&rgbaEnd)[0], ttmod)/255.0f;
|
||||
float gg = bx::lerp( ( (uint8_t*)&rgbaStart)[1], ( (uint8_t*)&rgbaEnd)[1], ttmod)/255.0f;
|
||||
float bb = bx::lerp( ( (uint8_t*)&rgbaStart)[2], ( (uint8_t*)&rgbaEnd)[2], ttmod)/255.0f;
|
||||
float aa = bx::lerp( ( (uint8_t*)&rgbaStart)[3], ( (uint8_t*)&rgbaEnd)[3], ttmod)/255.0f;
|
||||
|
||||
float blend = bx::flerp(particle.blendStart, particle.blendEnd, ttBlend);
|
||||
float scale = bx::flerp(particle.scaleStart, particle.scaleEnd, ttScale);
|
||||
float blend = bx::lerp(particle.blendStart, particle.blendEnd, ttBlend);
|
||||
float scale = bx::lerp(particle.scaleStart, particle.scaleEnd, ttScale);
|
||||
|
||||
uint32_t abgr = toAbgr(rr, gg, bb, aa);
|
||||
|
||||
|
||||
@@ -450,7 +450,7 @@ namespace bgfx
|
||||
if (_hasMips)
|
||||
{
|
||||
const uint32_t max = bx::uint32_max(bx::uint32_max(_width, _height), _depth);
|
||||
const uint32_t num = 1 + uint32_t(bx::flog2(float(max) ) );
|
||||
const uint32_t num = 1 + uint32_t(bx::log2(float(max) ) );
|
||||
|
||||
return uint8_t(num);
|
||||
}
|
||||
@@ -4299,7 +4299,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::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
BX_CHECK(bx::equal(_depth, bx::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
, "Clear depth value must be between 0.0 and 1.0 (_depth %f)."
|
||||
, _depth
|
||||
);
|
||||
@@ -4309,7 +4309,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::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
BX_CHECK(bx::equal(_depth, bx::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
, "Clear depth value must be between 0.0 and 1.0 (_depth %f)."
|
||||
, _depth
|
||||
);
|
||||
|
||||
@@ -1469,7 +1469,7 @@ namespace bgfx { namespace gl
|
||||
if (_array)
|
||||
{
|
||||
glTexStorage3D(target
|
||||
, 1 + GLsizei(bx::flog2(float(_dim) ) )
|
||||
, 1 + GLsizei(bx::log2(float(_dim) ) )
|
||||
, internalFmt
|
||||
, _dim
|
||||
, _dim
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace bgfx
|
||||
{
|
||||
float tmp[3];
|
||||
bx::vec3Sub(tmp, _pos, vertexPos(_vertices, _stride, _index) );
|
||||
return bx::fsqrt(bx::vec3Dot(tmp, tmp) );
|
||||
return bx::sqrt(bx::vec3Dot(tmp, tmp) );
|
||||
}
|
||||
|
||||
typedef float (*KeyFn)(float, float, float);
|
||||
|
||||
@@ -432,7 +432,7 @@ struct View
|
||||
m_angle = bx::toRad(angle);
|
||||
}
|
||||
|
||||
m_angle = bx::fwrap(m_angle, bx::kPi*2.0f);
|
||||
m_angle = bx::wrap(m_angle, bx::kPi*2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -974,9 +974,9 @@ struct InterpolatorT
|
||||
}
|
||||
};
|
||||
|
||||
typedef InterpolatorT<bx::flerp, bx::easeInOutQuad> Interpolator;
|
||||
typedef InterpolatorT<bx::lerp, bx::easeInOutQuad> Interpolator;
|
||||
typedef InterpolatorT<bx::angleLerp, bx::easeInOutCubic> InterpolatorAngle;
|
||||
typedef InterpolatorT<bx::flerp, bx::easeLinear> InterpolatorLinear;
|
||||
typedef InterpolatorT<bx::lerp, bx::easeLinear> InterpolatorLinear;
|
||||
|
||||
void keyBindingHelp(const char* _bindings, const char* _description)
|
||||
{
|
||||
@@ -1523,7 +1523,7 @@ int _main_(int _argc, char** _argv)
|
||||
ImGui::PushFont(ImGui::Font::Mono);
|
||||
const float itemHeight = ImGui::GetTextLineHeightWithSpacing();
|
||||
const float listHeight =
|
||||
std::max(1.0f, bx::ffloor(ImGui::GetWindowHeight()/itemHeight) )
|
||||
bx::max(1.0f, bx::floor(ImGui::GetWindowHeight()/itemHeight) )
|
||||
* itemHeight
|
||||
;
|
||||
|
||||
@@ -1791,8 +1791,8 @@ int _main_(int _argc, char** _argv)
|
||||
float wh[3] = { float(view.m_textureInfo.width), float(view.m_textureInfo.height), 0.0f };
|
||||
float result[3];
|
||||
bx::vec3MulMtx(result, wh, orientation);
|
||||
result[0] = bx::fround(bx::fabs(result[0]) );
|
||||
result[1] = bx::fround(bx::fabs(result[1]) );
|
||||
result[0] = bx::round(bx::abs(result[0]) );
|
||||
result[1] = bx::round(bx::abs(result[1]) );
|
||||
|
||||
scale.set(bx::min(float(width) / result[0]
|
||||
, float(height) / result[1])
|
||||
|
||||
Reference in New Issue
Block a user