diff --git a/examples/02-metaballs/metaballs.cpp b/examples/02-metaballs/metaballs.cpp index cd6865da7..10ca1cc83 100644 --- a/examples/02-metaballs/metaballs.cpp +++ b/examples/02-metaballs/metaballs.cpp @@ -371,7 +371,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 (fabsf(_iso-_v1) < 0.00001f) + if (bx::fabsolute(_iso-_v1) < 0.00001f) { _result[0] = edge1[0]; _result[1] = edge1[1]; @@ -379,8 +379,8 @@ float vertLerp(float* __restrict _result, float _iso, uint32_t _idx0, float _v0, return 1.0f; } - if (fabsf(_iso-_v0) < 0.00001f - || fabsf(_v0-_v1) < 0.00001f) + if (bx::fabsolute(_iso-_v0) < 0.00001f + || bx::fabsolute(_v0-_v1) < 0.00001f) { _result[0] = edge0[0]; _result[1] = edge0[1]; @@ -598,10 +598,10 @@ class ExampleMetaballs : public entry::AppI float sphere[numSpheres][4]; for (uint32_t ii = 0; ii < numSpheres; ++ii) { - sphere[ii][0] = sinf(time*(ii*0.21f)+ii*0.37f) * (DIMS * 0.5f - 8.0f); - sphere[ii][1] = sinf(time*(ii*0.37f)+ii*0.67f) * (DIMS * 0.5f - 8.0f); - sphere[ii][2] = cosf(time*(ii*0.11f)+ii*0.13f) * (DIMS * 0.5f - 8.0f); - sphere[ii][3] = 1.0f/(2.0f + (sinf(time*(ii*0.13f) )*0.5f+0.5f)*2.0f); + 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); } profUpdate = bx::getHPCounter(); diff --git a/examples/05-instancing/instancing.cpp b/examples/05-instancing/instancing.cpp index 84351d570..b06f28894 100644 --- a/examples/05-instancing/instancing.cpp +++ b/examples/05-instancing/instancing.cpp @@ -199,9 +199,9 @@ class ExampleInstancing : public entry::AppI mtx[14] = 0.0f; float* color = (float*)&data[64]; - color[0] = sinf(time+float(xx)/11.0f)*0.5f+0.5f; - color[1] = cosf(time+float(yy)/11.0f)*0.5f+0.5f; - color[2] = sinf(time*3.0f)*0.5f+0.5f; + 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[3] = 1.0f; data += instanceStride; diff --git a/examples/06-bump/bump.cpp b/examples/06-bump/bump.cpp index e154a086c..89ec40112 100644 --- a/examples/06-bump/bump.cpp +++ b/examples/06-bump/bump.cpp @@ -249,8 +249,8 @@ class ExampleBump : public entry::AppI float lightPosRadius[4][4]; for (uint32_t ii = 0; ii < m_numLights; ++ii) { - lightPosRadius[ii][0] = sinf( (time*(0.1f + ii*0.17f) + ii*bx::piHalf*1.37f ) )*3.0f; - lightPosRadius[ii][1] = cosf( (time*(0.2f + ii*0.29f) + ii*bx::piHalf*1.49f ) )*3.0f; + lightPosRadius[ii][0] = bx::fsin( (time*(0.1f + ii*0.17f) + ii*bx::piHalf*1.37f ) )*3.0f; + lightPosRadius[ii][1] = bx::fcos( (time*(0.2f + ii*0.29f) + ii*bx::piHalf*1.49f ) )*3.0f; lightPosRadius[ii][2] = -2.5f; lightPosRadius[ii][3] = 3.0f; } diff --git a/examples/13-stencil/stencil.cpp b/examples/13-stencil/stencil.cpp index fdd98ff01..abf7b2b17 100644 --- a/examples/13-stencil/stencil.cpp +++ b/examples/13-stencil/stencil.cpp @@ -1021,9 +1021,9 @@ int _main_(int _argc, char** _argv) const float radius = (scene == StencilReflectionScene) ? 15.0f : 25.0f; for (uint8_t ii = 0; ii < numLights; ++ii) { - lightPosRadius[ii][0] = sinf( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::piHalf*1.07f ) )*20.0f; - lightPosRadius[ii][1] = 8.0f + (1.0f - cosf( (lightTimeAccumulator*1.5f + ii*0.29f + bx::piHalf*1.49f ) ) )*4.0f; - lightPosRadius[ii][2] = cosf( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::piHalf*1.79f ) )*20.0f; + lightPosRadius[ii][0] = bx::fsin( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::piHalf*1.07f ) )*20.0f; + lightPosRadius[ii][1] = 8.0f + (1.0f - bx::fcos( (lightTimeAccumulator*1.5f + ii*0.29f + bx::piHalf*1.49f ) ) )*4.0f; + lightPosRadius[ii][2] = bx::fcos( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::piHalf*1.79f ) )*20.0f; lightPosRadius[ii][3] = radius; } bx::memCopy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float) ); @@ -1093,9 +1093,9 @@ int _main_(int _argc, char** _argv) , 0.0f , 0.0f , 0.0f - , sinf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f + , bx::fsin(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f , 4.0f - , cosf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f + , bx::fcos(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f ); } diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index f0e806dc4..9ca6c7269 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -1735,7 +1735,7 @@ void createNearClipVolume(float* __restrict _outPlanes24f // -1.0f - behind near plane float lightSide = float( (d > delta) - (d < -delta) ); - float t = tanf(bx::toRad(_fovy)*0.5f) * _near; + float t = bx::ftan(bx::toRad(_fovy)*0.5f) * _near; float b = -t; float r = t * _aspect; float l = -r; @@ -1774,7 +1774,7 @@ void createNearClipVolume(float* __restrict _outPlanes24f normal[1] *= lightSide; normal[2] *= lightSide; - float lenInv = 1.0f / sqrtf(bx::vec3Dot(normal, normal) ); + float lenInv = 1.0f / bx::fsqrt(bx::vec3Dot(normal, normal) ); plane[0] = normal[0] * lenInv; plane[1] = normal[1] * lenInv; @@ -1797,7 +1797,7 @@ void createNearClipVolume(float* __restrict _outPlanes24f bx::vec3MulMtx(tmp, lightPlaneNormal, mtxViewInv); bx::vec3Sub(lightPlaneNormal, tmp, _lightPos); - float lenInv = 1.0f / sqrtf(bx::vec3Dot(lightPlaneNormal, lightPlaneNormal) ); + float lenInv = 1.0f / bx::fsqrt(bx::vec3Dot(lightPlaneNormal, lightPlaneNormal) ); lightPlane[0] = lightPlaneNormal[0] * lenInv; lightPlane[1] = lightPlaneNormal[1] * lenInv; @@ -2256,9 +2256,9 @@ int _main_(int _argc, char** _argv) { for (uint8_t ii = 0; ii < settings_numLights; ++ii) { - lightPosRadius[ii][0] = cosf(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f; + lightPosRadius[ii][0] = bx::fcos(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f; lightPosRadius[ii][1] = 20.0f; - lightPosRadius[ii][2] = sinf(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f; + lightPosRadius[ii][2] = bx::fsin(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f; lightPosRadius[ii][3] = 20.0f; } } @@ -2266,9 +2266,9 @@ int _main_(int _argc, char** _argv) { for (uint8_t ii = 0; ii < settings_numLights; ++ii) { - lightPosRadius[ii][0] = cosf(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f; + lightPosRadius[ii][0] = bx::fcos(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f; lightPosRadius[ii][1] = 20.0f; - lightPosRadius[ii][2] = sinf(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f; + lightPosRadius[ii][2] = bx::fsin(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f; lightPosRadius[ii][3] = 20.0f; } } @@ -2342,9 +2342,9 @@ int _main_(int _argc, char** _argv) inst.m_rotation[0] = 0.0f; inst.m_rotation[1] = 0.0f; inst.m_rotation[2] = 0.0f; - inst.m_pos[0] = sinf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f; + inst.m_pos[0] = bx::fsin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f; inst.m_pos[1] = 6.0f; - inst.m_pos[2] = cosf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f; + inst.m_pos[2] = bx::fcos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f; inst.m_model = &cubeModel; } @@ -2359,9 +2359,9 @@ int _main_(int _argc, char** _argv) inst.m_rotation[0] = 0.0f; inst.m_rotation[1] = 0.0f; inst.m_rotation[2] = 0.0f; - inst.m_pos[0] = sinf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f; + inst.m_pos[0] = bx::fsin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f; inst.m_pos[1] = 22.0f; - inst.m_pos[2] = cosf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f; + inst.m_pos[2] = bx::fcos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f; inst.m_model = &cubeModel; } diff --git a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp index 274e5f404..1f8732a6f 100644 --- a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp +++ b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp @@ -230,9 +230,9 @@ int _main_(int _argc, char** _argv) // Setup lights. float lightPos[4]; - lightPos[0] = -cosf(timeAccumulatorLight); + lightPos[0] = -bx::fcos(timeAccumulatorLight); lightPos[1] = -1.0f; - lightPos[2] = -sinf(timeAccumulatorLight); + lightPos[2] = -bx::fsin(timeAccumulatorLight); lightPos[3] = 0.0f; bgfx::setUniform(u_lightPos, lightPos); diff --git a/examples/16-shadowmaps/shadowmaps.cpp b/examples/16-shadowmaps/shadowmaps.cpp index 262b3c6e8..1b2494c0e 100644 --- a/examples/16-shadowmaps/shadowmaps.cpp +++ b/examples/16-shadowmaps/shadowmaps.cpp @@ -257,12 +257,12 @@ void mtxYawPitchRoll(float* __restrict _result , float _roll ) { - float sroll = sinf(_roll); - float croll = cosf(_roll); - float spitch = sinf(_pitch); - float cpitch = cosf(_pitch); - float syaw = sinf(_yaw); - float cyaw = cosf(_yaw); + 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); _result[ 0] = sroll * spitch * syaw + croll * cyaw; _result[ 1] = sroll * cpitch; @@ -1163,7 +1163,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*powf(ratio, si) ) + (1 - l)*(_near + (_far - _near)*si); + const float nearp = l*(_near*bx::fpow(ratio, si) ) + (1 - l)*(_near + (_far - _near)*si); _splits[nn] = nearp; //near _splits[ff] = nearp * 1.005f; //far from previous split } @@ -1956,7 +1956,7 @@ int _main_(int _argc, char** _argv) const float camAspect = float(int32_t(viewState.m_width) ) / float(int32_t(viewState.m_height) ); const float camNear = 0.1f; const float camFar = 2000.0f; - const float projHeight = 1.0f/tanf(bx::toRad(camFovy)*0.5f); + const float projHeight = 1.0f/bx::ftan(bx::toRad(camFovy)*0.5f); const float projWidth = projHeight * camAspect; bx::mtxProj(viewState.m_proj, camFovy, camAspect, camNear, camFar); cameraGetViewMtx(viewState.m_view); @@ -2169,16 +2169,16 @@ int _main_(int _argc, char** _argv) if (settings.m_updateScene) { timeAccumulatorScene += deltaTime; } // Setup lights. - pointLight.m_position.m_x = cosf(timeAccumulatorLight) * 20.0f; + pointLight.m_position.m_x = bx::fcos(timeAccumulatorLight) * 20.0f; pointLight.m_position.m_y = 26.0f; - pointLight.m_position.m_z = sinf(timeAccumulatorLight) * 20.0f; + pointLight.m_position.m_z = bx::fsin(timeAccumulatorLight) * 20.0f; pointLight.m_spotDirectionInner.m_x = -pointLight.m_position.m_x; pointLight.m_spotDirectionInner.m_y = -pointLight.m_position.m_y; pointLight.m_spotDirectionInner.m_z = -pointLight.m_position.m_z; - directionalLight.m_position.m_x = -cosf(timeAccumulatorLight); + directionalLight.m_position.m_x = -bx::fcos(timeAccumulatorLight); directionalLight.m_position.m_y = -1.0f; - directionalLight.m_position.m_z = -sinf(timeAccumulatorLight); + directionalLight.m_position.m_z = -bx::fsin(timeAccumulatorLight); // Setup instance matrices. float mtxFloor[16]; @@ -2245,9 +2245,9 @@ int _main_(int _argc, char** _argv) , 0.0f , float(ii) , 0.0f - , sinf(float(ii)*2.0f*bx::pi/float(numTrees) ) * 60.0f + , bx::fsin(float(ii)*2.0f*bx::pi/float(numTrees) ) * 60.0f , 0.0f - , cosf(float(ii)*2.0f*bx::pi/float(numTrees) ) * 60.0f + , bx::fcos(float(ii)*2.0f*bx::pi/float(numTrees) ) * 60.0f ); } @@ -2294,7 +2294,7 @@ int _main_(int _argc, char** _argv) { const float fovx = 143.98570868f + 3.51f + settings.m_fovXAdjust; const float fovy = 125.26438968f + 9.85f + settings.m_fovYAdjust; - const float aspect = tanf(bx::toRad(fovx*0.5f) )/tanf(bx::toRad(fovy*0.5f) ); + const float aspect = bx::ftan(bx::toRad(fovx*0.5f) )/bx::ftan(bx::toRad(fovy*0.5f) ); bx::mtxProj(lightProj[ProjType::Vertical] , fovx @@ -2318,7 +2318,7 @@ int _main_(int _argc, char** _argv) const float fovx = 143.98570868f + 7.8f + settings.m_fovXAdjust; const float fovy = 125.26438968f + 3.0f + settings.m_fovYAdjust; - const float aspect = tanf(bx::toRad(fovx*0.5f) )/tanf(bx::toRad(fovy*0.5f) ); + const float aspect = bx::ftan(bx::toRad(fovx*0.5f) )/bx::ftan(bx::toRad(fovy*0.5f) ); bx::mtxProj(lightProj[ProjType::Horizontal], fovy, aspect, currentSmSettings->m_near, currentSmSettings->m_far); @@ -2423,8 +2423,8 @@ int _main_(int _argc, char** _argv) if (settings.m_stabilize) { const float quantizer = 64.0f; - scalex = quantizer / ceilf(quantizer / scalex); - scaley = quantizer / ceilf(quantizer / scaley); + scalex = quantizer / bx::fceil(quantizer / scalex); + scaley = quantizer / bx::fceil(quantizer / scaley); } offsetx = 0.5f * (maxproj[0] + minproj[0]) * scalex; @@ -2433,8 +2433,8 @@ int _main_(int _argc, char** _argv) if (settings.m_stabilize) { const float halfSize = currentShadowMapSizef * 0.5f; - offsetx = ceilf(offsetx * halfSize) / halfSize; - offsety = ceilf(offsety * halfSize) / halfSize; + offsetx = bx::fceil(offsetx * halfSize) / halfSize; + offsety = bx::fceil(offsety * halfSize) / halfSize; } float mtxCrop[16]; diff --git a/examples/18-ibl/ibl.cpp b/examples/18-ibl/ibl.cpp index 56975a308..0dd96beb7 100644 --- a/examples/18-ibl/ibl.cpp +++ b/examples/18-ibl/ibl.cpp @@ -365,8 +365,8 @@ struct Camera static inline void latLongFromVec(float& _u, float& _v, const float _vec[3]) { - const float phi = atan2f(_vec[0], _vec[2]); - const float theta = acosf(_vec[1]); + const float phi = bx::fatan2(_vec[0], _vec[2]); + const float theta = bx::facos(_vec[1]); _u = (bx::pi + phi)*bx::invPi*0.5f; _v = theta*bx::invPi; diff --git a/examples/19-oit/oit.cpp b/examples/19-oit/oit.cpp index 22f5d8525..59fefbf4b 100644 --- a/examples/19-oit/oit.cpp +++ b/examples/19-oit/oit.cpp @@ -382,7 +382,7 @@ class ExampleOIT : public entry::AppI if (m_fadeInOut && zz == 1) { - color[3] = sinf(time*3.0f)*0.49f+0.5f; + color[3] = bx::fsin(time*3.0f)*0.49f+0.5f; } bgfx::setUniform(u_color, color); diff --git a/examples/21-deferred/deferred.cpp b/examples/21-deferred/deferred.cpp index 71ffe55dc..fb3f91ac4 100644 --- a/examples/21-deferred/deferred.cpp +++ b/examples/21-deferred/deferred.cpp @@ -571,10 +571,10 @@ class ExampleDeferred : public entry::AppI { Sphere lightPosRadius; - float lightTime = time * m_lightAnimationSpeed * (sinf(light/float(m_numLights) * bx::piHalf ) * 0.5f + 0.5f); - lightPosRadius.m_center[0] = sinf( ( (lightTime + light*0.47f) + bx::piHalf*1.37f ) )*offset; - lightPosRadius.m_center[1] = cosf( ( (lightTime + light*0.69f) + bx::piHalf*1.49f ) )*offset; - lightPosRadius.m_center[2] = sinf( ( (lightTime + light*0.37f) + bx::piHalf*1.57f ) )*2.0f; + float lightTime = time * m_lightAnimationSpeed * (bx::fsin(light/float(m_numLights) * bx::piHalf ) * 0.5f + 0.5f); + lightPosRadius.m_center[0] = bx::fsin( ( (lightTime + light*0.47f) + bx::piHalf*1.37f ) )*offset; + lightPosRadius.m_center[1] = bx::fcos( ( (lightTime + light*0.69f) + bx::piHalf*1.49f ) )*offset; + lightPosRadius.m_center[2] = bx::fsin( ( (lightTime + light*0.37f) + bx::piHalf*1.57f ) )*2.0f; lightPosRadius.m_radius = 2.0f; Aabb aabb; diff --git a/examples/23-vectordisplay/main.cpp b/examples/23-vectordisplay/main.cpp index 36472d534..0dfa572b2 100644 --- a/examples/23-vectordisplay/main.cpp +++ b/examples/23-vectordisplay/main.cpp @@ -152,8 +152,8 @@ int _main_(int _argc, char** _argv) // draw moving shape static float counter = 0.0f; counter += 0.01f; - float posX = width / 2.0f + sinf(counter * 3.18378f) * (width / 2.0f); - float posY = height / 2.0f + cosf(counter) * (height / 2.0f); + float posX = width / 2.0f + bx::fsin(counter * 3.18378f) * (width / 2.0f); + float posY = height / 2.0f + bx::fcos(counter) * (height / 2.0f); vd.drawCircle(posX, posY, 5.0f, 10.0f); vd.endFrame(); diff --git a/examples/23-vectordisplay/vectordisplay.cpp b/examples/23-vectordisplay/vectordisplay.cpp index 7b245375e..79985a2ac 100644 --- a/examples/23-vectordisplay/vectordisplay.cpp +++ b/examples/23-vectordisplay/vectordisplay.cpp @@ -168,7 +168,7 @@ void VectorDisplay::endFrame() } else { - alpha = powf(m_decayValue, stepi - 1.0f) * m_initialDecay; + alpha = bx::fpow(m_decayValue, stepi - 1.0f) * m_initialDecay; } float params[4] = { 0.0f, 0.0f, 0.0f, alpha }; @@ -339,10 +339,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 = atan2f(line->y1 - line->y0, line->x1 - line->x0); // angle from positive x axis, increasing ccw, [-pi, pi] - line->sin_a = sinf(line->a); - line->cos_a = cosf(line->a); - line->len = sqrtf( (line->x1 - line->x0) * (line->x1 - line->x0) + (line->y1 - line->y0) * (line->y1 - line->y0) ); + 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) ); // figure out what connections we have line->has_prev = (!line->is_first @@ -372,12 +372,12 @@ void VectorDisplay::endDraw() { if (a2pa < pa2a) { - float shorten = t * sinf(a2pa / 2) / cosf(a2pa / 2); + float shorten = t * bx::fsin(a2pa / 2.0f) / bx::fcos(a2pa / 2.0f); float a = (bx::pi - a2pa) / 2.0f; if (shorten > maxshorten) { line->s0 = pline->s1 = maxshorten; - line->tr0 = pline->tr1 = maxshorten * sinf(a) / cosf(a); + line->tr0 = pline->tr1 = maxshorten * bx::fsin(a) / bx::fcos(a); } else { @@ -388,12 +388,12 @@ void VectorDisplay::endDraw() } else { - float shorten = t * sinf(pa2a / 2.0f) / cosf(pa2a / 2.0f); + float shorten = t * bx::fsin(pa2a / 2.0f) / bx::fcos(pa2a / 2.0f); float a = (bx::pi - pa2a) / 2.0f; if (shorten > maxshorten) { line->s0 = pline->s1 = maxshorten; - line->tl0 = pline->tl1 = maxshorten * sinf(a) / cosf(a); + line->tl0 = pline->tl1 = maxshorten * bx::fsin(a) / bx::fcos(a); } else { @@ -476,12 +476,12 @@ void VectorDisplay::drawCircle(float _x, float _y, float _radius, float _steps) float step = bx::pi * 2.0f / _steps; - beginDraw(_x + _radius * sinf(edgeangle + angadjust), - _y - _radius * cosf(edgeangle + angadjust) ); + beginDraw(_x + _radius * bx::fsin(edgeangle + angadjust), + _y - _radius * bx::fcos(edgeangle + angadjust) ); for (edgeangle = 0; edgeangle < 2.0f * bx::pi - 0.001; edgeangle += step) { - drawTo(_x + _radius * sinf(edgeangle + step - angadjust), - _y - _radius * cosf(edgeangle + step - angadjust) ); + drawTo(_x + _radius * bx::fsin(edgeangle + step - angadjust), + _y - _radius * bx::fcos(edgeangle + step - angadjust) ); } endDraw(); @@ -491,32 +491,32 @@ void VectorDisplay::drawWheel(float _angle, float _x, float _y, float _radius) { float spokeradius = _radius - 2.0f; // draw spokes - drawLine(_x + spokeradius * sinf(_angle), - _y - spokeradius * cosf(_angle), - _x - spokeradius * sinf(_angle), - _y + spokeradius * cosf(_angle) ); - drawLine(_x + spokeradius * sinf(_angle + bx::pi / 4.0f), - _y - spokeradius * cosf(_angle + bx::pi / 4.0f), - _x - spokeradius * sinf(_angle + bx::pi / 4.0f), - _y + spokeradius * cosf(_angle + bx::pi / 4.0f) ); - drawLine(_x + spokeradius * sinf(_angle + bx::pi / 2.0f), - _y - spokeradius * cosf(_angle + bx::pi / 2.0f), - _x - spokeradius * sinf(_angle + bx::pi / 2.0f), - _y + spokeradius * cosf(_angle + bx::pi / 2.0f) ); - drawLine(_x + spokeradius * sinf(_angle + 3.0f * bx::pi / 4.0f), - _y - spokeradius * cosf(_angle + 3.0f * bx::pi / 4.0f), - _x - spokeradius * sinf(_angle + 3.0f * bx::pi / 4.0f), - _y + spokeradius * cosf(_angle + 3.0f * bx::pi / 4.0f) ); + 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::pi / 4.0f), + _y - spokeradius * bx::fcos(_angle + bx::pi / 4.0f), + _x - spokeradius * bx::fsin(_angle + bx::pi / 4.0f), + _y + spokeradius * bx::fcos(_angle + bx::pi / 4.0f) ); + drawLine(_x + spokeradius * bx::fsin(_angle + bx::pi / 2.0f), + _y - spokeradius * bx::fcos(_angle + bx::pi / 2.0f), + _x - spokeradius * bx::fsin(_angle + bx::pi / 2.0f), + _y + spokeradius * bx::fcos(_angle + bx::pi / 2.0f) ); + drawLine(_x + spokeradius * bx::fsin(_angle + 3.0f * bx::pi / 4.0f), + _y - spokeradius * bx::fcos(_angle + 3.0f * bx::pi / 4.0f), + _x - spokeradius * bx::fsin(_angle + 3.0f * bx::pi / 4.0f), + _y + spokeradius * bx::fcos(_angle + 3.0f * bx::pi / 4.0f) ); float edgeangle = 0.0f; float angadjust = 0.0f; - beginDraw(_x + _radius * sinf(_angle + edgeangle + angadjust), - _y - _radius * cosf(_angle + edgeangle + angadjust) ); + beginDraw(_x + _radius * bx::fsin(_angle + edgeangle + angadjust), + _y - _radius * bx::fcos(_angle + edgeangle + angadjust) ); for (edgeangle = 0; edgeangle < 2.0f * bx::pi - 0.001f; edgeangle += bx::pi / 4.0f) { - drawTo(_x + _radius * sinf(_angle + edgeangle + bx::pi / 4.0f - angadjust), - _y - _radius * cosf(_angle + edgeangle + bx::pi / 4.0f - angadjust) ); + drawTo(_x + _radius * bx::fsin(_angle + edgeangle + bx::pi / 4.0f - angadjust), + _y - _radius * bx::fcos(_angle + edgeangle + bx::pi / 4.0f - angadjust) ); } endDraw(); @@ -622,9 +622,9 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t, for (i = 1; i <= nsteps; i++) { - appendTexpoint(_cx + _t * sinf(angles[i - 1]), _cy - _t * cosf(angles[i - 1]), _e, (float)HALF_TEXTURE_SIZE); + appendTexpoint(_cx + _t * bx::fsin(angles[i - 1]), _cy - _t * bx::fcos(angles[i - 1]), _e, (float)HALF_TEXTURE_SIZE); appendTexpoint(_cx, _cy, _s, (float)HALF_TEXTURE_SIZE); - appendTexpoint(_cx + _t * sinf(angles[i]), _cy - _t * cosf(angles[i]), _e, (float)HALF_TEXTURE_SIZE); + appendTexpoint(_cx + _t * bx::fsin(angles[i]), _cy - _t * bx::fcos(angles[i]), _e, (float)HALF_TEXTURE_SIZE); } } @@ -838,8 +838,8 @@ void VectorDisplay::genLinetex() // generate , 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 = powf(16.0f, -2.0f * distance); - float glow = powf( 2.0f, -4.0f * distance) / 10.0f; + 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); diff --git a/examples/28-wireframe/wireframe.cpp b/examples/28-wireframe/wireframe.cpp index b8bb2d7a5..a4f798d11 100644 --- a/examples/28-wireframe/wireframe.cpp +++ b/examples/28-wireframe/wireframe.cpp @@ -162,8 +162,8 @@ struct Camera static inline void latLongFromVec(float& _u, float& _v, const float _vec[3]) { - const float phi = atan2f(_vec[0], _vec[2]); - const float theta = acosf(_vec[1]); + const float phi = bx::fatan2(_vec[0], _vec[2]); + const float theta = bx::facos(_vec[1]); _u = (bx::pi + phi)*bx::invPi*0.5f; _v = theta*bx::invPi;