Renamed constants to new style.

This commit is contained in:
Branimir Karadžić
2017-06-09 20:08:52 -07:00
parent bbdc0fbcbd
commit 3fbcddb4ef
19 changed files with 72 additions and 72 deletions

View File

@@ -224,8 +224,8 @@ class ExampleBump : public entry::AppI
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::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][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][2] = -2.5f;
lightPosRadius[ii][3] = 3.0f;
}

View File

@@ -126,7 +126,7 @@ int _main_(int _argc, char** _argv)
}
recomputeVisibleText |= imguiSlider("Scroll", textScroll, 0.0f, (lineCount-visibleLineCount) , 1.0f);
imguiSlider("Rotate", textRotation, 0.0f, bx::pi*2.0f , 0.1f);
imguiSlider("Rotate", textRotation, 0.0f, bx::kPi*2.0f , 0.1f);
recomputeVisibleText |= imguiSlider("Scale", textScale, 0.1f, 10.0f , 0.1f);
if (recomputeVisibleText)

View File

@@ -996,9 +996,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] = 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][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][3] = radius;
}
bx::memCopy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float) );

View File

@@ -2231,9 +2231,9 @@ int _main_(int _argc, char** _argv)
{
for (uint8_t ii = 0; ii < settings_numLights; ++ii)
{
lightPosRadius[ii][0] = bx::fcos(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
lightPosRadius[ii][0] = bx::fcos(2.0f*bx::kPi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
lightPosRadius[ii][1] = 20.0f;
lightPosRadius[ii][2] = bx::fsin(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
lightPosRadius[ii][2] = bx::fsin(2.0f*bx::kPi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
lightPosRadius[ii][3] = 20.0f;
}
}
@@ -2241,9 +2241,9 @@ int _main_(int _argc, char** _argv)
{
for (uint8_t ii = 0; ii < settings_numLights; ++ii)
{
lightPosRadius[ii][0] = bx::fcos(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::kPi) * 40.0f;
lightPosRadius[ii][1] = 20.0f;
lightPosRadius[ii][2] = bx::fsin(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::kPi) * 40.0f;
lightPosRadius[ii][3] = 20.0f;
}
}
@@ -2374,7 +2374,7 @@ int _main_(int _argc, char** _argv)
inst.m_scale[0] = 21.0f;
inst.m_scale[1] = 21.0f;
inst.m_scale[2] = 21.0f;
inst.m_rotation[0] = bx::pi;
inst.m_rotation[0] = bx::kPi;
inst.m_rotation[1] = 0.0f;
inst.m_rotation[2] = 0.0f;
inst.m_pos[0] = 0.0f;
@@ -2441,7 +2441,7 @@ int _main_(int _argc, char** _argv)
inst.m_scale[1] = 5.0f;
inst.m_scale[2] = 5.0f;
inst.m_rotation[0] = 0.0f;
inst.m_rotation[1] = bx::pi;
inst.m_rotation[1] = bx::kPi;
inst.m_rotation[2] = 0.0f;
inst.m_pos[0] = currX;
inst.m_pos[1] = 0.0f;

View File

@@ -223,7 +223,7 @@ int _main_(int _argc, char** _argv)
float mtxBunny[16];
bx::mtxSRT(mtxBunny
, 5.0f, 5.0f, 5.0f
, 0.0f, bx::pi - timeAccumulatorScene, 0.0f
, 0.0f, bx::kPi - timeAccumulatorScene, 0.0f
, 15.0f, 5.0f, 0.0f
);

View File

@@ -2220,9 +2220,9 @@ int _main_(int _argc, char** _argv)
, 0.0f
, float(ii)
, 0.0f
, bx::fsin(float(ii)*2.0f*bx::pi/float(numTrees) ) * 60.0f
, bx::fsin(float(ii)*2.0f*bx::kPi/float(numTrees) ) * 60.0f
, 0.0f
, bx::fcos(float(ii)*2.0f*bx::pi/float(numTrees) ) * 60.0f
, bx::fcos(float(ii)*2.0f*bx::kPi/float(numTrees) ) * 60.0f
);
}

View File

@@ -350,8 +350,8 @@ struct Camera
static inline void vecFromLatLong(float _vec[3], float _u, float _v)
{
const float phi = _u * 2.0f*bx::pi;
const float theta = _v * bx::pi;
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);
@@ -368,8 +368,8 @@ struct Camera
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;
_u = (bx::kPi + phi)*bx::kInvPi*0.5f;
_v = theta*bx::kInvPi;
}
struct Interp3f
@@ -760,7 +760,7 @@ int _main_(int _argc, char** _argv)
{
// Submit bunny.
float mtx[16];
bx::mtxSRT(mtx, 1.0f, 1.0f, 1.0f, 0.0f, bx::pi, 0.0f, 0.0f, -0.80f, 0.0f);
bx::mtxSRT(mtx, 1.0f, 1.0f, 1.0f, 0.0f, bx::kPi, 0.0f, 0.0f, -0.80f, 0.0f);
bgfx::setTexture(0, s_texCube, lightProbes[currentLightProbe].m_tex);
bgfx::setTexture(1, s_texCubeIrr, lightProbes[currentLightProbe].m_texIrr);
uniforms.submit();

View File

@@ -538,10 +538,10 @@ class ExampleDeferred : public entry::AppI
{
Sphere lightPosRadius;
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;
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;
lightPosRadius.m_radius = 2.0f;
Aabb aabb;

View File

@@ -144,10 +144,10 @@ int _main_(int _argc, char** _argv)
vd.drawBox(450.0f, 600.0f, 80.0f, 80.0f);
vd.setDrawColor(1.0f, 0.7f, 1.0f);
vd.drawWheel(bx::pi, 800.0f, 450.0f, 80.0f);
vd.drawWheel(3.0f * bx::pi / 4.0f, 95.0f, 450.0f, 60.0f);
vd.drawWheel(bx::pi / 2.0f, 1150.0f, 450.0f, 30.0f);
vd.drawWheel(bx::pi / 4.0f, 1250.0f, 450.0f, 10.0f);
vd.drawWheel(bx::kPi, 800.0f, 450.0f, 80.0f);
vd.drawWheel(3.0f * bx::kPi / 4.0f, 95.0f, 450.0f, 60.0f);
vd.drawWheel(bx::kPi / 2.0f, 1150.0f, 450.0f, 30.0f);
vd.drawWheel(bx::kPi / 4.0f, 1250.0f, 450.0f, 10.0f);
// draw moving shape
static float counter = 0.0f;

View File

@@ -47,7 +47,7 @@ bgfx::VertexDecl PosColorUvVertex::ms_decl;
inline float normalizef(float _a)
{
return bx::fwrap(_a, 2.0f * bx::pi);
return bx::fwrap(_a, 2.0f * bx::kPi);
}
VectorDisplay::VectorDisplay(bool _originBottomLeft, float _texelHalf)
@@ -368,12 +368,12 @@ void VectorDisplay::endDraw()
float a2pa = normalizef(line->a - pline->a);
float maxshorten = bx::fmin(line->len, pline->len) / 2.0f;
if (bx::fmin(a2pa, pa2a) <= (bx::pi / 2.0f + FLT_EPSILON) )
if (bx::fmin(a2pa, pa2a) <= (bx::kPi / 2.0f + FLT_EPSILON) )
{
if (a2pa < pa2a)
{
float shorten = t * bx::fsin(a2pa / 2.0f) / bx::fcos(a2pa / 2.0f);
float a = (bx::pi - a2pa) / 2.0f;
float a = (bx::kPi - a2pa) / 2.0f;
if (shorten > maxshorten)
{
line->s0 = pline->s1 = maxshorten;
@@ -389,7 +389,7 @@ void VectorDisplay::endDraw()
else
{
float shorten = t * bx::fsin(pa2a / 2.0f) / bx::fcos(pa2a / 2.0f);
float a = (bx::pi - pa2a) / 2.0f;
float a = (bx::kPi - pa2a) / 2.0f;
if (shorten > maxshorten)
{
line->s0 = pline->s1 = maxshorten;
@@ -474,11 +474,11 @@ void VectorDisplay::drawCircle(float _x, float _y, float _radius, float _steps)
float edgeangle = 0.0f;
float angadjust = 0.0f;
float step = bx::pi * 2.0f / _steps;
float step = bx::kPi * 2.0f / _steps;
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)
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) );
@@ -495,28 +495,28 @@ void VectorDisplay::drawWheel(float _angle, float _x, float _y, float _radius)
_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) );
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) );
float edgeangle = 0.0f;
float angadjust = 0.0f;
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)
for (edgeangle = 0; edgeangle < 2.0f * bx::kPi - 0.001f; edgeangle += bx::kPi / 4.0f)
{
drawTo(_x + _radius * bx::fsin(_angle + edgeangle + bx::pi / 4.0f - angadjust),
_y - _radius * bx::fcos(_angle + edgeangle + bx::pi / 4.0f - angadjust) );
drawTo(_x + _radius * bx::fsin(_angle + edgeangle + bx::kPi / 4.0f - angadjust),
_y - _radius * bx::fcos(_angle + edgeangle + bx::kPi / 4.0f - angadjust) );
}
endDraw();
@@ -603,7 +603,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::pi / 8.0f) ) );
nsteps = (int)bx::fmax(1, bx::fround(a2pa / (bx::kPi / 8.0f) ) );
angles = (float*)alloca(sizeof(float) * (nsteps + 1) );
for (i = 0; i <= nsteps; i++)
{
@@ -612,7 +612,7 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t,
}
else
{
nsteps = (int)bx::fmax(1, bx::fround(pa2a / (bx::pi / 8.0f) ) );
nsteps = (int)bx::fmax(1, bx::fround(pa2a / (bx::kPi / 8.0f) ) );
angles = (float*)alloca(sizeof(float) * (nsteps + 1) );
for (i = 0; i <= nsteps; i++)
{

View File

@@ -125,7 +125,7 @@ class ExampleTerrain : public entry::AppI
const float initialPos[3] = { s_terrainSize/2.0f, 100.0f, 0.0f };
cameraSetPosition(initialPos);
cameraSetVerticalAngle(-bx::pi/4.0f);
cameraSetVerticalAngle(-bx::kPi/4.0f);
}
virtual int shutdown() BX_OVERRIDE

View File

@@ -147,8 +147,8 @@ struct Camera
static inline void vecFromLatLong(float _vec[3], float _u, float _v)
{
const float phi = _u * 2.0f*bx::pi;
const float theta = _v * bx::pi;
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);
@@ -165,8 +165,8 @@ struct Camera
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;
_u = (bx::kPi + phi)*bx::kInvPi*0.5f;
_v = theta*bx::kInvPi;
}
struct Interp3f
@@ -337,7 +337,7 @@ class ExampleWireframe : public entry::AppI
m_uniforms.init();
m_meshes[0].init("meshes/bunny.bin", 1.0f, 0.0f, bx::pi, 0.0f, 0.0f, -0.8f, 0.0f);
m_meshes[0].init("meshes/bunny.bin", 1.0f, 0.0f, bx::kPi, 0.0f, 0.0f, -0.8f, 0.0f);
m_meshes[1].init("meshes/hollowcube.bin", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
m_meshes[2].init("meshes/orb.bin", 1.2f, 0.0f, 0.0f, 0.0f, 0.0f, -0.65f, 0.0f);

View File

@@ -672,8 +672,8 @@ public:
void updateLightDir()
{
float el = m_lightElevation * (bx::pi/180.0f);
float az = m_lightAzimuth * (bx::pi/180.0f);
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);

View File

@@ -216,7 +216,7 @@ void calcObb(Obb& _obb, const void* _vertices, uint32_t _numVertices, uint32_t _
Obb best;
aabbToObb(best, aabb);
float angleStep = float(bx::piHalf/_steps);
float angleStep = float(bx::kPiHalf/_steps);
float ax = 0.0f;
float mtx[16];

View File

@@ -173,9 +173,9 @@ struct Camera
float right[3] =
{
bx::fsin(m_horizontalAngle - bx::piHalf),
bx::fsin(m_horizontalAngle - bx::kPiHalf),
0,
bx::fcos(m_horizontalAngle - bx::piHalf),
bx::fcos(m_horizontalAngle - bx::kPiHalf),
};
float up[3];

View File

@@ -495,7 +495,7 @@ struct DebugDraw
Mesh::Enum id = Mesh::Enum(Mesh::Cone0+mesh);
const uint32_t num = getCircleLod(uint8_t(mesh) );
const float step = bx::pi * 2.0f / num;
const float step = bx::kPi * 2.0f / num;
const uint32_t numVertices = num+1;
const uint32_t numIndices = num*6;
@@ -556,7 +556,7 @@ struct DebugDraw
Mesh::Enum id = Mesh::Enum(Mesh::Cylinder0+mesh);
const uint32_t num = getCircleLod(uint8_t(mesh) );
const float step = bx::pi * 2.0f / num;
const float step = bx::kPi * 2.0f / num;
const uint32_t numVertices = num*2;
const uint32_t numIndices = num*12;
@@ -626,7 +626,7 @@ struct DebugDraw
Mesh::Enum id = Mesh::Enum(Mesh::Capsule0+mesh);
const uint32_t num = getCircleLod(uint8_t(mesh) );
const float step = bx::pi * 2.0f / num;
const float step = bx::kPi * 2.0f / num;
const uint32_t numVertices = num*2;
const uint32_t numIndices = num*6;
@@ -1202,7 +1202,7 @@ struct DebugDraw
{
const Attrib& attrib = m_attrib[m_stack];
const uint32_t num = getCircleLod(attrib.m_lod);
const float step = bx::pi * 2.0f / num;
const float step = bx::kPi * 2.0f / num;
_degrees = bx::fwrap(_degrees, 360.0f);
@@ -1244,7 +1244,7 @@ struct DebugDraw
{
const Attrib& attrib = m_attrib[m_stack];
const uint32_t num = getCircleLod(attrib.m_lod);
const float step = bx::pi * 2.0f / num;
const float step = bx::kPi * 2.0f / num;
_weight = bx::fclamp(_weight, 0.0f, 2.0f);
float udir[3];
@@ -1291,7 +1291,7 @@ struct DebugDraw
{
const Attrib& attrib = m_attrib[m_stack];
const uint32_t num = getCircleLod(attrib.m_lod);
const float step = bx::pi * 2.0f / num;
const float step = bx::kPi * 2.0f / num;
_weight = bx::fclamp(_weight, 0.0f, 2.0f);
float xy0[2];

View File

@@ -510,7 +510,7 @@ struct Imgui
for (int32_t ii = 0; ii < NUM_CIRCLE_VERTS; ++ii)
{
float a = (float)ii / (float)NUM_CIRCLE_VERTS * (float)(bx::pi * 2.0);
float a = (float)ii / (float)NUM_CIRCLE_VERTS * (float)(bx::kPi * 2.0);
m_circleVerts[ii * 2 + 0] = cosf(a);
m_circleVerts[ii * 2 + 1] = sinf(a);
}

View File

@@ -375,8 +375,8 @@ namespace ps
Aabb aabb =
{
{ bx::huge, bx::huge, bx::huge },
{ -bx::huge, -bx::huge, -bx::huge },
{ bx::kHuge, bx::kHuge, bx::kHuge },
{ -bx::kHuge, -bx::kHuge, -bx::kHuge },
};
for (uint32_t jj = 0, num = m_num, current = _first

View File

@@ -305,7 +305,7 @@ struct View
m_angle = bx::toRad(angle);
}
m_angle = bx::fwrap(m_angle, bx::pi*2.0f);
m_angle = bx::fwrap(m_angle, bx::kPi*2.0f);
}
else
{