From 4c64c111444383aaa8d282fd7cb5a000430d27ad Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 26 Mar 2014 16:58:47 -0700 Subject: [PATCH] making some type casts abide by coding standard --- interface/src/avatar/Hand.cpp | 4 ++-- interface/src/avatar/SkeletonModel.cpp | 2 +- interface/src/renderer/FBXReader.cpp | 6 +++--- interface/src/renderer/GeometryCache.cpp | 6 +++--- interface/src/ui/BandwidthMeter.cpp | 8 ++++---- interface/src/ui/Oscilloscope.cpp | 4 ++-- libraries/metavoxels/src/MetavoxelData.cpp | 2 +- libraries/shared/src/qtimespan.cpp | 4 ++-- tests/physics/src/ShapeColliderTests.cpp | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 77586dd7ae..8c202ae1b1 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -167,7 +167,7 @@ void Hand::collideAgainstAvatar(Avatar* avatar, bool isMyHand) { averagePenetration += collision->_penetration; averageContactPoint += collision->_contactPoint; } - averagePenetration /= float(handCollisions.size()); + averagePenetration /= (float)handCollisions.size(); if (isMyHand) { // our hand against other avatar // for now we resolve it to test shapes/collisions @@ -176,7 +176,7 @@ void Hand::collideAgainstAvatar(Avatar* avatar, bool isMyHand) { } else { // someone else's hand against MyAvatar // TODO: submit collision info to MyAvatar which should lean accordingly - averageContactPoint /= float(handCollisions.size()); + averageContactPoint /= (float)handCollisions.size(); } } } diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 9e4740df15..b0eac98913 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -129,7 +129,7 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector& fingerJoin direction += fingerVector / length; } fingerVector = glm::inverse(palmRotation) * fingerVector * -sign; - IndexValue indexValue = { int(i), atan2f(fingerVector.z, fingerVector.x) }; + IndexValue indexValue = { (int)i, atan2f(fingerVector.z, fingerVector.x) }; fingerIndices.append(indexValue); } qSort(fingerIndices.begin(), fingerIndices.end()); diff --git a/interface/src/renderer/FBXReader.cpp b/interface/src/renderer/FBXReader.cpp index 53f4e04b0b..c264fe70a2 100644 --- a/interface/src/renderer/FBXReader.cpp +++ b/interface/src/renderer/FBXReader.cpp @@ -1588,7 +1588,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) int numVertices = extracted.mesh.vertices.size(); jointShapeInfo.numVertices = numVertices; if (numVertices > 0) { - averageVertex /= float(jointShapeInfo.numVertices); + averageVertex /= (float)jointShapeInfo.numVertices; float averageRadius = 0.f; foreach (const glm::vec3& vertex, extracted.mesh.vertices) { averageRadius += glm::distance(vertex, averageVertex); @@ -1619,7 +1619,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) } else { // collide the joint like a sphere if (jointShapeInfo.numVertices > 0) { - jointShapeInfo.averageVertex /= float(jointShapeInfo.numVertices); + jointShapeInfo.averageVertex /= (float)jointShapeInfo.numVertices; joint.shapePosition = jointShapeInfo.averageVertex; } else { joint.shapePosition = glm::vec3(0.f); @@ -1629,7 +1629,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) && jointShapeInfo.numVertices > 0) { // the bone projection algorithm was not able to compute the joint radius // so we use an alternative measure - jointShapeInfo.averageRadius /= float(jointShapeInfo.numVertices); + jointShapeInfo.averageRadius /= (float)jointShapeInfo.numVertices; joint.boneRadius = jointShapeInfo.averageRadius; } } diff --git a/interface/src/renderer/GeometryCache.cpp b/interface/src/renderer/GeometryCache.cpp index c4a0d15baa..b835e91a12 100644 --- a/interface/src/renderer/GeometryCache.cpp +++ b/interface/src/renderer/GeometryCache.cpp @@ -31,11 +31,11 @@ void GeometryCache::renderHemisphere(int slices, int stacks) { GLfloat* vertexData = new GLfloat[vertices * 3]; GLfloat* vertex = vertexData; for (int i = 0; i < stacks - 1; i++) { - float phi = PI_OVER_TWO * float(i) / float(stacks - 1); + float phi = PI_OVER_TWO * (float)i / (float)(stacks - 1); float z = sinf(phi), radius = cosf(phi); for (int j = 0; j < slices; j++) { - float theta = TWO_PI * float(j) / float(slices); + float theta = TWO_PI * (float)j / (float)slices; *(vertex++) = sinf(theta) * radius; *(vertex++) = cosf(theta) * radius; @@ -181,7 +181,7 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { float y = (float)i / (stacks - 1); for (int j = 0; j <= slices; j++) { - float theta = 3.f * PI_OVER_TWO + PI * float(j) / float(slices); + float theta = 3.f * PI_OVER_TWO + PI * (float)j / (float)slices; //normals *(vertex++) = sinf(theta); diff --git a/interface/src/ui/BandwidthMeter.cpp b/interface/src/ui/BandwidthMeter.cpp index dfc142fb95..64ff74b846 100644 --- a/interface/src/ui/BandwidthMeter.cpp +++ b/interface/src/ui/BandwidthMeter.cpp @@ -160,7 +160,7 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { // Center of coordinate system -> upper left of bar glPushMatrix(); - glTranslatef(float(barX), float(y), 0.0f); + glTranslatef((float)barX, (float)y, 0.0f); // Render captions setColorRGBA(COLOR_TEXT); @@ -202,7 +202,7 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { // Render scale indicators setColorRGBA(COLOR_INDICATOR); for (int j = NUMBER_OF_MARKERS; --j > 0;) { - renderVerticalLine(int(barWidth * j / NUMBER_OF_MARKERS), 0, h); + renderVerticalLine((barWidth * j) / NUMBER_OF_MARKERS, 0, h); } // Render bars @@ -210,8 +210,8 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { for (size_t i = 0; i < N_CHANNELS; ++i) { ChannelIndex chIdx = ChannelIndex(i); - int wIn = int(barWidth * inputStream(chIdx).getValue() * UNIT_SCALE / scaleMax); - int wOut = int(barWidth * outputStream(chIdx).getValue() * UNIT_SCALE / scaleMax); + int wIn = (int)(barWidth * inputStream(chIdx).getValue() * UNIT_SCALE / scaleMax); + int wOut = (int)(barWidth * outputStream(chIdx).getValue() * UNIT_SCALE / scaleMax); setColorRGBA(channelInfo(chIdx).colorRGBA); diff --git a/interface/src/ui/Oscilloscope.cpp b/interface/src/ui/Oscilloscope.cpp index 90d2d49926..a47586b436 100644 --- a/interface/src/ui/Oscilloscope.cpp +++ b/interface/src/ui/Oscilloscope.cpp @@ -127,7 +127,7 @@ void Oscilloscope::render(int x, int y) { } // fetch low pass factor (and convert to fix point) / downsample factor - int lowPassFixPt = -int(std::numeric_limits::min()) * _lowPassCoeff; + int lowPassFixPt = -(int)(std::numeric_limits::min()) * _lowPassCoeff; unsigned downsample = _downsampleRatio; // keep half of the buffer for writing and ensure an even vertex count unsigned usedWidth = min(_width, MAX_SAMPLES_PER_CHANNEL / (downsample * 2)) & ~1u; @@ -141,7 +141,7 @@ void Oscilloscope::render(int x, int y) { short const* inPtr = _samples + _writePos[ch]; short* outPtr = _vertices + MAX_COORDS_PER_CHANNEL * ch; int sample = 0, x = usedWidth; - for (int i = int(usedSamples); --i >= 0 ;) { + for (int i = (int)usedSamples; --i >= 0 ;) { if (inPtr == basePtr) { // handle boundary, reading the circular sample buffer inPtr = endPtr; diff --git a/libraries/metavoxels/src/MetavoxelData.cpp b/libraries/metavoxels/src/MetavoxelData.cpp index 397e10d45f..cab5a73076 100644 --- a/libraries/metavoxels/src/MetavoxelData.cpp +++ b/libraries/metavoxels/src/MetavoxelData.cpp @@ -1096,7 +1096,7 @@ QScriptValue ScriptedMetavoxelGuide::visit(QScriptContext* context, QScriptEngin QScriptValue minimum = infoValue.property(guide->_minimumHandle); MetavoxelInfo info = { glm::vec3(minimum.property(0).toNumber(), minimum.property(1).toNumber(), minimum.property(2).toNumber()), - float(infoValue.property(guide->_sizeHandle).toNumber()), guide->_visitation->info.inputValues, + (float)infoValue.property(guide->_sizeHandle).toNumber(), guide->_visitation->info.inputValues, guide->_visitation->info.outputValues, infoValue.property(guide->_isLeafHandle).toBool() }; // extract and convert the values provided by the script diff --git a/libraries/shared/src/qtimespan.cpp b/libraries/shared/src/qtimespan.cpp index 2ddddb30f3..f3482cfb14 100644 --- a/libraries/shared/src/qtimespan.cpp +++ b/libraries/shared/src/qtimespan.cpp @@ -1594,7 +1594,7 @@ void QTimeSpan::setFromMonths(qreal months) { Q_ASSERT_X(hasValidReference(), "setFromMonths", "Can not set interval from time unit month if there is no reference date."); - int fullMonths = int(months); + int fullMonths = (int)months; qreal fractionalMonth = months - fullMonths; QDateTime endDate = d->reference; @@ -1631,7 +1631,7 @@ void QTimeSpan::setFromYears(qreal years) { Q_ASSERT_X(hasValidReference(), "setFromYears", "Can not set interval from time unit year if there is no reference date."); - int fullYears = int(years); + int fullYears = (int)years; qreal fractionalYear = years - fullYears; QDateTime endDate = d->reference; diff --git a/tests/physics/src/ShapeColliderTests.cpp b/tests/physics/src/ShapeColliderTests.cpp index 6d7e9a6db1..f19f6d6f95 100644 --- a/tests/physics/src/ShapeColliderTests.cpp +++ b/tests/physics/src/ShapeColliderTests.cpp @@ -189,7 +189,7 @@ void ShapeColliderTests::sphereMissesCapsule() { float delta = 1.3f * (totalRadius + halfHeightB) / (numberOfSteps - 1); for (int i = 0; i < numberOfSteps; ++i) { // translate sphereA into world-frame - glm::vec3 localPosition = localStartPosition + (float(i) * delta) * yAxis; + glm::vec3 localPosition = localStartPosition + ((float)i * delta) * yAxis; sphereA.setPosition(rotation * localPosition + translation); // sphereA agains capsuleB