diff options
114 files changed, 974 insertions, 984 deletions
diff --git a/demos/qt3d/cubehouse/cubeview.cpp b/demos/qt3d/cubehouse/cubeview.cpp index 191fad658..66b5ec3d4 100644 --- a/demos/qt3d/cubehouse/cubeview.cpp +++ b/demos/qt3d/cubehouse/cubeview.cpp @@ -331,9 +331,9 @@ void CubeView::paintGL(QGLPainter *painter) QVector3D direction = projectorCamera->center() - projectorCamera->eye(); QVector3D normal = projectorCamera->upVector().normalized(); - qreal nearPlane = projectorCamera->nearPlane(); - qreal farPlane = projectorCamera->farPlane(); - qreal fieldOfView = projectorCamera->fieldOfView(); + float nearPlane = projectorCamera->nearPlane(); + float farPlane = projectorCamera->farPlane(); + float fieldOfView = projectorCamera->fieldOfView(); QVector3D nearTopLeft; QVector3D nearTopRight; @@ -346,7 +346,7 @@ void CubeView::paintGL(QGLPainter *painter) QSizeF viewSize = projectorCamera->viewSize(); - qreal fieldDepthRatio = farPlane / nearPlane; + float fieldDepthRatio = farPlane / nearPlane; QVector3D rightVector = QVector3D::crossProduct(direction, normal).normalized() * viewSize.width() / 2.0; QVector3D topVector = normal * viewSize.height() / 2.0; @@ -397,7 +397,7 @@ void CubeView::paintGL(QGLPainter *painter) // useProjectiveTextureEffect = value; //} -void CubeView::setCubeAngle(qreal angle) +void CubeView::setCubeAngle(float angle) { cangle = angle; accelerometerTimeout(); @@ -416,10 +416,10 @@ QVector3D CubeView::gravity() const // Access the raw accelerometer data on the N900. FILE *file = fopen("/sys/class/i2c-adapter/i2c-3/3-001d/coord", "r"); if (!file) - return QVector3D(0, 0, -1); - float x = 0; - float y = 0; - float z = 0; + return QVector3D(0.0f, 0.0f, -1.0f); + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; int numValues = fscanf(file, "%f %f %f", &x, &y, &z); fclose(file); @@ -429,9 +429,9 @@ QVector3D CubeView::gravity() const // Smooth out the reported values. Large changes are applied as-is, // and small jitters smooth to the rest position. if (havePrev) { - qreal xdiff = x - prevX; - qreal ydiff = y - prevY; - qreal zdiff = z - prevZ; + float xdiff = x - prevX; + float ydiff = y - prevY; + float zdiff = z - prevZ; if (qAbs(xdiff) < 20.0f && qAbs(ydiff) < 20.0f && qAbs(zdiff) < 20.0f) { x = prevX + xdiff * 0.1f; y = prevY + ydiff * 0.1f; @@ -456,7 +456,7 @@ void CubeView::updateProjectorViewMatrix() void CubeView::updateProjectorProjectionMatrix() { - qreal projectorAspectRatio = 1.0; + float projectorAspectRatio = 1.0f; projectiveTextureEffect->setProjectorProjectionMatrix(projectorCamera->projectionMatrix(projectorAspectRatio)); updateProjectiveTextureEffect(); } diff --git a/demos/qt3d/cubehouse/cubeview.h b/demos/qt3d/cubehouse/cubeview.h index 7194a5a81..165467d63 100644 --- a/demos/qt3d/cubehouse/cubeview.h +++ b/demos/qt3d/cubehouse/cubeview.h @@ -52,7 +52,7 @@ class ProjectiveTextureEffect; class CubeView : public QGLView { Q_OBJECT - Q_PROPERTY(qreal cubeAngle READ cubeAngle WRITE setCubeAngle) + Q_PROPERTY(float cubeAngle READ cubeAngle WRITE setCubeAngle) public: CubeView(QWindow *parent = 0); ~CubeView(); @@ -64,8 +64,8 @@ public: useProjectiveTextureEffect = value; } - qreal cubeAngle() const { return cangle; } - void setCubeAngle(qreal angle); + float cubeAngle() const { return cangle; } + void setCubeAngle(float angle); protected: void initializeGL(QGLPainter *painter); @@ -85,7 +85,7 @@ private: QGLSceneNode *room; QGLCamera *roomCamera; QGLCamera *projectorCamera; - qreal sensitivity; + float sensitivity; QGLLightModel *roomModel; QGLLightModel *normalModel; QGLLightParameters *lightParameters; @@ -93,8 +93,8 @@ private: bool stereo; bool useProjectiveTextureEffect; QTime time; - qreal cangle; - mutable qreal prevX, prevY, prevZ; + float cangle; + mutable float prevX, prevY, prevZ; mutable bool havePrev; QVector3D gravity() const; diff --git a/demos/qt3d/pageflip/pageflip.cpp b/demos/qt3d/pageflip/pageflip.cpp index 08101b2b1..305266f14 100644 --- a/demos/qt3d/pageflip/pageflip.cpp +++ b/demos/qt3d/pageflip/pageflip.cpp @@ -86,7 +86,7 @@ private: bool blend; bool vertical; - qreal posn; // Position within the animation - 0...1 + float posn; // Position within the animation - 0...1 QSize pageSize; // Size of a page within the window. QRect pageRect1; diff --git a/demos/qt3d/pageflip/pageflipmath.cpp b/demos/qt3d/pageflip/pageflipmath.cpp index 4853fc28a..b22a0c45d 100644 --- a/demos/qt3d/pageflip/pageflipmath.cpp +++ b/demos/qt3d/pageflip/pageflipmath.cpp @@ -76,7 +76,7 @@ void PageFlipMath::drawOutline(int page) const glDrawArrays(GL_LINE_LOOP, page * 5, pageCount[page]); } -void PageFlipMath::compute(qreal t) +void PageFlipMath::compute(float t) { int page, vertex; @@ -236,7 +236,7 @@ void PageFlipMath::compute(qreal t) // The flip starts at the bottom-right corner and proceeds leftwards // across the page. All other flip directions and starting corners // can be derived from this basic reference flip animation. -void PageFlipMath::flip(qreal pageWidth, qreal pageHeight, qreal t) +void PageFlipMath::flip(float pageWidth, float pageHeight, float t) { // Handle the simple start and end position cases first. if (t <= 0.0f) { @@ -383,40 +383,40 @@ void PageFlipMath::flip(qreal pageWidth, qreal pageHeight, qreal t) // Get the angle of the "curling" dividing line to the bottom of the page. // Basically: 45deg + (45deg * t) = 45deg * (1 + t), where t is between // 0 and 1 but is neither 0 nor 1. - qreal angle = (M_PI / 4.0f) * (1.0f + t); + float angle = (M_PI / 4.0f) * (1.0f + t); // We need the cos and sin of both the angle and angle * 2. - qreal cosAngle = qCos(angle); - qreal sinAngle = qSin(angle); - qreal cosAngle2 = qCos(angle * 2.0f); - qreal sinAngle2 = qSin(angle * 2.0f); + float cosAngle = cosf(angle); + float sinAngle = sinf(angle); + float cosAngle2 = cosf(angle * 2.0f); + float sinAngle2 = sinf(angle * 2.0f); // Find the reference point. This is the point along the bottom of // the page where the dividing line intersects the page bottom. - qreal refx = pageWidth * (1.0f - t); - qreal refy = 0.0f; + float refx = pageWidth * (1.0f - t); + float refy = 0.0f; // Distance from the reference point to the right side of the page. - qreal d = pageWidth - refx; + float d = pageWidth - refx; // Determine the intersection of the dividing line with the // top of the page. If the intersection is not on the page (k >= d), // then we need to generate similar triangles. If the intersection is // on the page (k < d), then we need to generate similar trapezoids. - qreal k = (pageHeight * cosAngle) / sinAngle; + float k = (pageHeight * cosAngle) / sinAngle; if (k >= d) { // Generate similar triangles. Find the intersection with // the right-hand side of the page at x == pageWidth. - qreal intx = pageWidth; - qreal inty = refy + (d * sinAngle) / cosAngle; + float intx = pageWidth; + float inty = refy + (d * sinAngle) / cosAngle; // Find the opposite triangle corner on the back page. - qreal oppx = refx + d * cosAngle2; - qreal oppy = refy + d * sinAngle2; + float oppx = refx + d * cosAngle2; + float oppy = refy + d * sinAngle2; // Generate vertices and texture co-ordinates for the back page. - qreal texa = 1.0f - (d * sinAngle) / (pageHeight * cosAngle); - qreal texb = d / pageWidth; + float texa = 1.0f - (d * sinAngle) / (pageHeight * cosAngle); + float texb = d / pageWidth; vertices[2][0][0] = intx; vertices[2][0][1] = inty; vertices[2][0][2] = 0.0f; @@ -493,21 +493,21 @@ void PageFlipMath::flip(qreal pageWidth, qreal pageHeight, qreal t) } else { // Generate similar trapezoids. Find the intersection with // the top of the page at y == pageHeight. - qreal intx = refx + (pageHeight * cosAngle) / sinAngle; - qreal inty = pageHeight; + float intx = refx + (pageHeight * cosAngle) / sinAngle; + float inty = pageHeight; // Get the distance between the intersection and the right of the page. - qreal e = pageWidth - intx; + float e = pageWidth - intx; // Find the opposite trapezoid corners to "ref" and "int". - qreal opprefx = refx + d * cosAngle2; - qreal opprefy = refy + d * sinAngle2; - qreal oppintx = intx + e * cosAngle2; - qreal oppinty = inty + e * sinAngle2; + float opprefx = refx + d * cosAngle2; + float opprefy = refy + d * sinAngle2; + float oppintx = intx + e * cosAngle2; + float oppinty = inty + e * sinAngle2; // Generate vertices and texture co-ordinates for the back page. - qreal texa = e / pageWidth; - qreal texb = d / pageWidth; + float texa = e / pageWidth; + float texb = d / pageWidth; vertices[2][0][0] = intx; vertices[2][0][1] = inty; vertices[2][0][2] = texa; diff --git a/demos/qt3d/pageflip/pageflipmath_p.h b/demos/qt3d/pageflip/pageflipmath_p.h index 8ef572855..a4dcc682c 100644 --- a/demos/qt3d/pageflip/pageflipmath_p.h +++ b/demos/qt3d/pageflip/pageflipmath_p.h @@ -96,7 +96,7 @@ public: void drawOutline(int page) const; // Compute the frame at position t (0...1) in the animation. - void compute(qreal t); + void compute(float t); private: StartCorner m_startCorner; @@ -114,7 +114,7 @@ private: // Number of vertices for drawing the triangle fan for each page. int pageCount[4]; - void flip(qreal pageWidth, qreal pageHeight, qreal t); + void flip(float pageWidth, float pageHeight, float t); }; QT_END_NAMESPACE diff --git a/demos/qt3d/photobrowser3d/imagedisplay.cpp b/demos/qt3d/photobrowser3d/imagedisplay.cpp index 79bb3d208..2d8040bea 100644 --- a/demos/qt3d/photobrowser3d/imagedisplay.cpp +++ b/demos/qt3d/photobrowser3d/imagedisplay.cpp @@ -91,7 +91,7 @@ static inline void qAddPane(QSizeF size, QGeometryData *data) data->appendIndices(k, k+2, k+3); } -ImageDisplay::ImageDisplay(QObject *parent, QSharedPointer<QGLMaterialCollection> materials, qreal wallSize) +ImageDisplay::ImageDisplay(QObject *parent, QSharedPointer<QGLMaterialCollection> materials, float wallSize) : QGLSceneNode(parent) , m_wall(0) , m_frames(0) diff --git a/demos/qt3d/photobrowser3d/imagedisplay.h b/demos/qt3d/photobrowser3d/imagedisplay.h index 462b07567..fdd24ed82 100644 --- a/demos/qt3d/photobrowser3d/imagedisplay.h +++ b/demos/qt3d/photobrowser3d/imagedisplay.h @@ -60,7 +60,7 @@ class ImageDisplay : public QGLSceneNode { Q_OBJECT public: - ImageDisplay(QObject *parent, QSharedPointer<QGLMaterialCollection> materials, qreal wallSize = 4.0); + ImageDisplay(QObject *parent, QSharedPointer<QGLMaterialCollection> materials, float wallSize = 4.0); ~ImageDisplay(); int maxImages() const { return m_maxImages; } void setMaxImages(int max) { m_maxImages = max; } @@ -77,8 +77,8 @@ private: QList<QGLTexture2D*> m_LoadedTextures; bool m_imageSetToDefault; int m_count; - qreal m_size; - qreal m_frameSize; + float m_size; + float m_frameSize; int m_maxImages; QImage m_frameImage; int m_frameLoadingMaterial; diff --git a/demos/qt3d/photobrowser3d/pancontroller.cpp b/demos/qt3d/photobrowser3d/pancontroller.cpp index b0c6d4b3b..abd0ae684 100644 --- a/demos/qt3d/photobrowser3d/pancontroller.cpp +++ b/demos/qt3d/photobrowser3d/pancontroller.cpp @@ -69,17 +69,17 @@ public: void calculateValues(); - qreal speed; - qreal angle; + float speed; + float angle; Qt::ArrowType arrowDirection; QGLView *view; QTime panTime; - qreal maxSpeed; - qreal defaultDistance; - qreal panDistance; - qreal panViewAngle; + float maxSpeed; + float defaultDistance; + float panDistance; + float panViewAngle; bool animating; - qreal elapsed; + float elapsed; }; PanController::PanController(QObject *parent) @@ -96,49 +96,49 @@ PanController::~PanController() delete d; } -qreal PanController::defaultDistance() const +float PanController::defaultDistance() const { return d->defaultDistance; } -void PanController::setDefaultDistance(qreal dist) +void PanController::setDefaultDistance(float dist) { d->defaultDistance = dist; } -qreal PanController::panDistance() const +float PanController::panDistance() const { return d->panDistance; } -void PanController::setPanDistance(qreal dist) +void PanController::setPanDistance(float dist) { d->panDistance = dist; } -qreal PanController::panViewAngle() const +float PanController::panViewAngle() const { return d->panViewAngle; } -void PanController::setPanViewAngle(qreal angle) +void PanController::setPanViewAngle(float angle) { d->panViewAngle = angle; } -void PanController::setMaxSpeed(qreal maxSpeed) +void PanController::setMaxSpeed(float maxSpeed) { d->maxSpeed = maxSpeed; } -qreal PanController::maxSpeed() const +float PanController::maxSpeed() const { return d->maxSpeed; } -void PanController::setSpeed(qreal speed) +void PanController::setSpeed(float speed) { - qreal t = d->panTime.restart(); + float t = d->panTime.restart(); if (d->speed != speed) { d->speed = speed; @@ -151,7 +151,7 @@ void PanController::setSpeed(qreal speed) } } -qreal PanController::speed() const +float PanController::speed() const { return d->speed; } @@ -160,7 +160,7 @@ void PanController::pan() { if (d->animating) { - qreal t = d->panTime.restart(); + float t = d->panTime.restart(); d->elapsed += t; // dont recalculate every single time // 30ms frame time == 33fps - more than enough @@ -195,12 +195,12 @@ void PanControllerPrivate::calculateValues() // the view angle is a direct function of the speed see setSpeed() above // and as view angle increases we look further along the x-axis - qreal opp = (e.z() - c.z()) * qTan(angle); + float opp = (e.z() - c.z()) * qTan(angle); // velocity along the x axis is controlled by speed (a value from 0 -> 1 // which is a modifier for the maxSpeed, a constant). the velocity gives // us the incremental change in x for this unit time - qreal dx = (speed * maxSpeed * elapsed); + float dx = (speed * maxSpeed * elapsed); if (arrowDirection == Qt::LeftArrow) { diff --git a/demos/qt3d/photobrowser3d/pancontroller.h b/demos/qt3d/photobrowser3d/pancontroller.h index c67ef2e3b..5e809914e 100644 --- a/demos/qt3d/photobrowser3d/pancontroller.h +++ b/demos/qt3d/photobrowser3d/pancontroller.h @@ -54,25 +54,25 @@ class PanControllerPrivate; class PanController : public QObject { Q_OBJECT - Q_PROPERTY(qreal speed READ speed WRITE setSpeed NOTIFY speedChanged) + Q_PROPERTY(float speed READ speed WRITE setSpeed NOTIFY speedChanged) public: explicit PanController(QObject *parent = 0); ~PanController(); - qreal defaultDistance() const; - void setDefaultDistance(qreal d); + float defaultDistance() const; + void setDefaultDistance(float d); - qreal panDistance() const; - void setPanDistance(qreal d); + float panDistance() const; + void setPanDistance(float d); - qreal panViewAngle() const; - void setPanViewAngle(qreal angle); + float panViewAngle() const; + void setPanViewAngle(float angle); - qreal maxSpeed() const; - void setMaxSpeed(qreal maxSpeed); + float maxSpeed() const; + void setMaxSpeed(float maxSpeed); - qreal speed() const; - void setSpeed(qreal speed); + float speed() const; + void setSpeed(float speed); Qt::ArrowType direction() const; void setDirection(Qt::ArrowType arrow); diff --git a/demos/qt3d/photobrowser3d/photobrowser3dview.cpp b/demos/qt3d/photobrowser3d/photobrowser3dview.cpp index 5a163c0c4..37a779a61 100644 --- a/demos/qt3d/photobrowser3d/photobrowser3dview.cpp +++ b/demos/qt3d/photobrowser3d/photobrowser3dview.cpp @@ -264,8 +264,8 @@ void PhotoBrowser3DView::wheelEvent(QWheelEvent *e) { e->accept(); QVector3D viewVec = camera()->eye() - camera()->center(); - qreal zoomMag = viewVec.length(); - qreal inc = float(e->delta()) / 50.0f; + float zoomMag = viewVec.length(); + float inc = float(e->delta()) / 50.0f; if (!qFuzzyIsNull(inc)) { zoomMag += inc; @@ -297,7 +297,7 @@ void PhotoBrowser3DView::keyPressEvent(QKeyEvent *e) else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down) { QVector3D viewVec = camera()->eye() - camera()->center(); - qreal zoomMag = viewVec.length(); + float zoomMag = viewVec.length(); zoomMag += (e->key() == Qt::Key_Up) ? -0.5f : 0.5f; if (zoomMag < 5.0f) zoomMag = 5.0f; @@ -358,8 +358,8 @@ void PhotoBrowser3DView::initializeGL(QGLPainter *painter) QAtlas::instance()->initialize(painter); camera()->setEye(QVector3D(0.0f, 0.0f, 4.0f * m_displaySize)); registerPickableNodes(); - qreal q = camera()->eye().z(); - qreal r = qBound(camera()->nearPlane(), q / 2.0f, camera()->nearPlane() * 3.0f); + float q = camera()->eye().z(); + float r = qBound(camera()->nearPlane(), q / 2.0f, camera()->nearPlane() * 3.0f); m_pc->setDefaultDistance(q); m_pc->setPanDistance(r); } diff --git a/demos/qt3d/photobrowser3d/photobrowser3dview.h b/demos/qt3d/photobrowser3d/photobrowser3dview.h index c6af5c403..898eb059b 100644 --- a/demos/qt3d/photobrowser3d/photobrowser3dview.h +++ b/demos/qt3d/photobrowser3d/photobrowser3dview.h @@ -107,7 +107,7 @@ private: QFocusAdaptor *m_fa; PanController *m_pc; bool m_pickableDirty; - qreal m_displaySize; + float m_displaySize; bool m_done; bool m_closing; bool m_updateRequired; diff --git a/demos/qt3d/photobrowser3d/qfocusadaptor.cpp b/demos/qt3d/photobrowser3d/qfocusadaptor.cpp index 297890224..11e356bcb 100644 --- a/demos/qt3d/photobrowser3d/qfocusadaptor.cpp +++ b/demos/qt3d/photobrowser3d/qfocusadaptor.cpp @@ -54,7 +54,7 @@ public: , target(0) , view(0) {} - qreal progress; + float progress; QVector3D targetEye; QVector3D targetCenter; QVector3D sourceEye; @@ -78,12 +78,12 @@ QFocusAdaptor::~QFocusAdaptor() delete d; } -qreal QFocusAdaptor::progress() const +float QFocusAdaptor::progress() const { return d->progress; } -void QFocusAdaptor::setProgress(qreal progress) +void QFocusAdaptor::setProgress(float progress) { if (d->progress != progress) { @@ -152,26 +152,26 @@ void QFocusAdaptor::calculateValues() box.unite(g.vertexAt(inxs.at(i))); QVector3D sz = box.size(); - qreal nearDist = cam->nearPlane(); + float nearDist = cam->nearPlane(); QSizeF v = cam->viewSize(); - qreal vh = d->view->geometry().height(); - qreal vw = d->view->geometry().width(); + float vh(d->view->geometry().height()); + float vw(d->view->geometry().width()); if (!qFuzzyIsNull(vw - vh)) { - qreal asp = vh / vw; + float asp = vh / vw; if (vh > vw) v.setHeight(v.height() * asp); else v.setWidth(v.width() / asp); } - qreal qh = (nearDist * sz.y()) / v.height(); - qreal qw = (nearDist * sz.x()) / v.width(); + float qh = (nearDist * sz.y()) / v.height(); + float qw = (nearDist * sz.x()) / v.width(); - qreal q = qMax(qh, qw); - q = qMax(q, qreal(nearDist * 1.05)); + float q = qMax(qh, qw); + q = qMax(q, float(nearDist * 1.05f)); d->sourceCenter = cam->center(); d->sourceEye = cam->eye(); diff --git a/demos/qt3d/photobrowser3d/qfocusadaptor.h b/demos/qt3d/photobrowser3d/qfocusadaptor.h index ac91467f5..2e3466247 100644 --- a/demos/qt3d/photobrowser3d/qfocusadaptor.h +++ b/demos/qt3d/photobrowser3d/qfocusadaptor.h @@ -54,13 +54,13 @@ class QFocusAdaptorPrivate; class QFocusAdaptor : public QObject { Q_OBJECT - Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged) + Q_PROPERTY(float progress READ progress WRITE setProgress NOTIFY progressChanged) public: explicit QFocusAdaptor(QObject *parent = 0); ~QFocusAdaptor(); - qreal progress() const; - void setProgress(qreal progress); + float progress() const; + void setProgress(float progress); QGLView *view() const; void setView(QGLView *view); diff --git a/demos/qt3d/photobrowser3d/thumbnailableimage.cpp b/demos/qt3d/photobrowser3d/thumbnailableimage.cpp index abed822dd..4d3f5dc2e 100644 --- a/demos/qt3d/photobrowser3d/thumbnailableimage.cpp +++ b/demos/qt3d/photobrowser3d/thumbnailableimage.cpp @@ -77,7 +77,7 @@ public: QGLTexture2D *tex; QGLMaterial *mat; QRect frame; - qreal scale; + float scale; QGL::IndexArray indices; }; @@ -217,9 +217,9 @@ QRectF ThumbnailableImage::frame() const return result; } -qreal ThumbnailableImage::scale() const +float ThumbnailableImage::scale() const { - qreal result = 0.0f; + float result = 0.0f; if (d) result = d->scale; return result; diff --git a/demos/qt3d/photobrowser3d/thumbnailableimage.h b/demos/qt3d/photobrowser3d/thumbnailableimage.h index 17843f2de..ff131095d 100644 --- a/demos/qt3d/photobrowser3d/thumbnailableimage.h +++ b/demos/qt3d/photobrowser3d/thumbnailableimage.h @@ -74,7 +74,7 @@ public: void setUrl(const QUrl &url); QRectF frame() const; - qreal scale() const; + float scale() const; void minimize(); bool isMinimized() const; diff --git a/demos/qt3d/photobrowser3d/thumbnailnode.cpp b/demos/qt3d/photobrowser3d/thumbnailnode.cpp index d419e6165..0e1494b69 100644 --- a/demos/qt3d/photobrowser3d/thumbnailnode.cpp +++ b/demos/qt3d/photobrowser3d/thumbnailnode.cpp @@ -176,7 +176,7 @@ void ThumbnailNode::draw(QGLPainter *painter) QMatrix4x4 m = painter->modelViewMatrix().top(); QVector3D pos = m.map(position()); - qreal magSquared = pos.lengthSquared(); + float magSquared = pos.lengthSquared(); Distance distance = Unknown; diff --git a/demos/qt3d/photobrowser3d/thumbnailnode.h b/demos/qt3d/photobrowser3d/thumbnailnode.h index 4a77c907e..914b13dc3 100644 --- a/demos/qt3d/photobrowser3d/thumbnailnode.h +++ b/demos/qt3d/photobrowser3d/thumbnailnode.h @@ -65,8 +65,8 @@ public: ~ThumbnailNode(); QUrl url() const { return m_url; } void setUrl(const QUrl &url); - void setThreshold(qreal threshold) { m_thresholdSquared = threshold * threshold; } - qreal threshold() const { return qSqrt(m_thresholdSquared); } + void setThreshold(float threshold) { m_thresholdSquared = threshold * threshold; } + float threshold() const { return qSqrt(m_thresholdSquared); } void draw(QGLPainter *painter); void drawGeometry(QGLPainter *painter); ThumbnailableImage image() const { return m_image; } @@ -83,7 +83,7 @@ private: void loadFullImage(); ThumbnailableImage m_image; - qreal m_thresholdSquared; + float m_thresholdSquared; int m_defaultMaterial; QUrl m_url; bool m_loading; diff --git a/demos/qt3d/teaservice/meshobject.h b/demos/qt3d/teaservice/meshobject.h index 65b622a57..1791ee194 100644 --- a/demos/qt3d/teaservice/meshobject.h +++ b/demos/qt3d/teaservice/meshobject.h @@ -64,11 +64,11 @@ public: QVector3D position() const { return m_position; } void setPosition(const QVector3D& value) { m_position = value; } - qreal scale() const { return m_scale; } - void setScale(qreal value) { m_scale = value; } + float scale() const { return m_scale; } + void setScale(float value) { m_scale = value; } - qreal rotationAngle() const { return m_rotationAngle; } - void setRotationAngle(qreal value) { m_rotationAngle = value; } + float rotationAngle() const { return m_rotationAngle; } + void setRotationAngle(float value) { m_rotationAngle = value; } QVector3D rotationVector() const { return m_rotationVector; } void setRotationVector(const QVector3D& value) { m_rotationVector = value; } @@ -104,8 +104,8 @@ private: QGLSceneNode *m_meshObject; QGLAbstractScene *m_scene; QVector3D m_position; - qreal m_scale; - qreal m_rotationAngle; + float m_scale; + float m_rotationAngle; QVector3D m_rotationVector; QGLMaterial *m_material; QGLMaterial *m_hoverMaterial; diff --git a/examples/qt3d/basket/basketview.h b/examples/qt3d/basket/basketview.h index 1069652ed..182345e14 100644 --- a/examples/qt3d/basket/basketview.h +++ b/examples/qt3d/basket/basketview.h @@ -52,10 +52,10 @@ QT_END_NAMESPACE class BasketView : public QGLView { Q_OBJECT - Q_PROPERTY(qreal angle READ angle WRITE setAngle) + Q_PROPERTY(float angle READ angle WRITE setAngle) public: - qreal angle() const { return m_angle; } - void setAngle(qreal angle) { m_angle = angle; update(); } + float angle() const { return m_angle; } + void setAngle(float angle) { m_angle = angle; update(); } //! [1] BasketView(QWindow *parent = 0); @@ -66,7 +66,7 @@ protected: private: QGLSceneNode *basket; - qreal m_angle; + float m_angle; }; #endif diff --git a/examples/qt3d/builder/builder.cpp b/examples/qt3d/builder/builder.cpp index 2e1db9842..8d3af543a 100644 --- a/examples/qt3d/builder/builder.cpp +++ b/examples/qt3d/builder/builder.cpp @@ -141,8 +141,8 @@ QGLSceneNode *BuilderView::buildGeometry() //! [2] // size data for can - const qreal canRadius = 1.0f; - const qreal canHeight = 2.5f; + const float canRadius = 1.0f; + const float canHeight = 2.5f; const int numSlices = 32; QGeometryData canRim; @@ -151,9 +151,9 @@ QGLSceneNode *BuilderView::buildGeometry() // do the math for the defining points for (int i = 0; i < numSlices; ++i) { - qreal angle = (qreal(i) * 2.0 * M_PI) / numSlices; - canRim.appendVertex(QVector3D(canRadius * qCos(angle), - canRadius * qSin(angle), + float angle = (float(i) * 2.0 * M_PI) / numSlices; + canRim.appendVertex(QVector3D(canRadius * cosf(angle), + canRadius * sinf(angle), canHeight / 2.0f)); } diff --git a/examples/qt3d/geometry/quadplane.cpp b/examples/qt3d/geometry/quadplane.cpp index 60429e10b..1737b286a 100644 --- a/examples/qt3d/geometry/quadplane.cpp +++ b/examples/qt3d/geometry/quadplane.cpp @@ -72,12 +72,12 @@ QuadPlane::QuadPlane(QObject *parent, QSizeF size, int level) QGeometryData zip2; for (int yy = 0; yy <= divisions; ++yy) { - qreal y = half.height() - float(yy) * div.height(); - qreal texY = float(yy) / divisions; + float y = half.height() - float(yy) * div.height(); + float texY = float(yy) / divisions; for (int xx = 0; xx <= divisions; ++xx) { - qreal x = half.width() - float(xx) * div.width(); - qreal texX = float(xx) / divisions; + float x = half.width() - float(xx) * div.width(); + float texX = float(xx) / divisions; zip.appendVertex(QVector3D(x, y, 0)); zip.appendTexCoord(QVector2D(1.0f - texX, 1.0f - texY)); } diff --git a/examples/qt3d/load_model/load_model.h b/examples/qt3d/load_model/load_model.h index eae7442e0..16b01bef5 100644 --- a/examples/qt3d/load_model/load_model.h +++ b/examples/qt3d/load_model/load_model.h @@ -51,21 +51,21 @@ QT_END_NAMESPACE class LoadModelView : public QGLView { Q_OBJECT - Q_PROPERTY(qreal angleTeapot READ angleTeapot WRITE setAngleTeapot) - Q_PROPERTY(qreal angleTeapotOrbit READ angleTeapotOrbit WRITE setAngleTeapotOrbit) - Q_PROPERTY(qreal angleLander READ angleLander WRITE setAngleLander) + Q_PROPERTY(float angleTeapot READ angleTeapot WRITE setAngleTeapot) + Q_PROPERTY(float angleTeapotOrbit READ angleTeapotOrbit WRITE setAngleTeapotOrbit) + Q_PROPERTY(float angleLander READ angleLander WRITE setAngleLander) public: LoadModelView(QWindow *parent = 0); ~LoadModelView(); - qreal angleTeapot() const { return m_AngleTeapot; } - void setAngleTeapot(qreal angle) { m_AngleTeapot = angle; update(); } + float angleTeapot() const { return m_AngleTeapot; } + void setAngleTeapot(float angle) { m_AngleTeapot = angle; update(); } - qreal angleTeapotOrbit() const { return m_AngleTeapotOrbit; } - void setAngleTeapotOrbit(qreal angle) { m_AngleTeapotOrbit = angle; update(); } + float angleTeapotOrbit() const { return m_AngleTeapotOrbit; } + void setAngleTeapotOrbit(float angle) { m_AngleTeapotOrbit = angle; update(); } - qreal angleLander() const { return m_AngleLander; } - void setAngleLander(qreal angle) { m_AngleLander = angle; update(); } + float angleLander() const { return m_AngleLander; } + void setAngleLander(float angle) { m_AngleLander = angle; update(); } protected: void paintGL(QGLPainter *painter); @@ -75,12 +75,12 @@ private: QGLAbstractScene* m_pTeapotScene; QGLTexture2D* m_pTeapotTexture; - qreal m_AngleTeapot; - qreal m_AngleTeapotOrbit; + float m_AngleTeapot; + float m_AngleTeapotOrbit; QGLAbstractScene* m_pLanderScene; QGLTexture2D* m_pLanderTexture; - qreal m_AngleLander; + float m_AngleLander; }; #endif diff --git a/examples/qt3d/nesting/cubeview.h b/examples/qt3d/nesting/cubeview.h index a128a0dac..c4c0057e7 100644 --- a/examples/qt3d/nesting/cubeview.h +++ b/examples/qt3d/nesting/cubeview.h @@ -53,21 +53,21 @@ QT_END_NAMESPACE class CubeView : public QGLView { Q_OBJECT - Q_PROPERTY(qreal teapotAngle READ teapotAngle WRITE setTeapotAngle) - Q_PROPERTY(qreal cubeAngle READ cubeAngle WRITE setCubeAngle) - Q_PROPERTY(qreal orbitAngle READ orbitAngle WRITE setOrbitAngle) + Q_PROPERTY(float teapotAngle READ teapotAngle WRITE setTeapotAngle) + Q_PROPERTY(float cubeAngle READ cubeAngle WRITE setCubeAngle) + Q_PROPERTY(float orbitAngle READ orbitAngle WRITE setOrbitAngle) public: CubeView(QWindow *parent = 0); ~CubeView(); - qreal teapotAngle() const { return tangle; } - void setTeapotAngle(qreal angle) { tangle = angle; update(); } + float teapotAngle() const { return tangle; } + void setTeapotAngle(float angle) { tangle = angle; update(); } - qreal cubeAngle() const { return cangle; } - void setCubeAngle(qreal angle) { cangle = angle; update(); } + float cubeAngle() const { return cangle; } + void setCubeAngle(float angle) { cangle = angle; update(); } - qreal orbitAngle() const { return oangle; } - void setOrbitAngle(qreal angle) { oangle = angle; update(); } + float orbitAngle() const { return oangle; } + void setOrbitAngle(float angle) { oangle = angle; update(); } protected: void initializeGL(QGLPainter *painter); @@ -81,9 +81,9 @@ private: QOpenGLFramebufferObject *fbo; QGLFramebufferObjectSurface fboSurface; QGLCamera *innerCamera; - qreal tangle; - qreal cangle; - qreal oangle; + float tangle; + float cangle; + float oangle; void drawCube1(QGLPainter *painter, const QVector3D &posn); void drawCube2(QGLPainter *painter, const QVector3D &posn); diff --git a/examples/qt3d/solarsystem/solarsystem.h b/examples/qt3d/solarsystem/solarsystem.h index 53c89674a..572e3d0cc 100644 --- a/examples/qt3d/solarsystem/solarsystem.h +++ b/examples/qt3d/solarsystem/solarsystem.h @@ -53,34 +53,34 @@ QT_END_NAMESPACE class SolarSystemView : public QGLView { Q_OBJECT - Q_PROPERTY(qreal angle1 READ angle1 WRITE setAngle1) - Q_PROPERTY(qreal angle2 READ angle2 WRITE setAngle2) - Q_PROPERTY(qreal angle3 READ angle3 WRITE setAngle3) - Q_PROPERTY(qreal glowFactor READ glowFactor WRITE setGlowFactor) + Q_PROPERTY(float angle1 READ angle1 WRITE setAngle1) + Q_PROPERTY(float angle2 READ angle2 WRITE setAngle2) + Q_PROPERTY(float angle3 READ angle3 WRITE setAngle3) + Q_PROPERTY(float glowFactor READ glowFactor WRITE setGlowFactor) public: SolarSystemView(QWindow *parent = 0); ~SolarSystemView(); - qreal angle1() const { return m_angle1; } - void setAngle1(qreal angle) { m_angle1 = angle; update(); } + float angle1() const { return m_angle1; } + void setAngle1(float angle) { m_angle1 = angle; update(); } - qreal angle2() const { return m_angle2; } - void setAngle2(qreal angle) { m_angle2 = angle; update(); } + float angle2() const { return m_angle2; } + void setAngle2(float angle) { m_angle2 = angle; update(); } - qreal angle3() const { return m_angle3; } - void setAngle3(qreal angle) { m_angle3 = angle; update(); } + float angle3() const { return m_angle3; } + void setAngle3(float angle) { m_angle3 = angle; update(); } - qreal glowFactor() const { return m_glowFactor; } - void setGlowFactor(qreal arg) { m_glowFactor = arg; update(); } + float glowFactor() const { return m_glowFactor; } + void setGlowFactor(float arg) { m_glowFactor = arg; update(); } protected: void initializeGL(QGLPainter *painter); void paintGL(QGLPainter *painter); private: - qreal m_angle1; - qreal m_angle2; - qreal m_angle3; + float m_angle1; + float m_angle2; + float m_angle3; float m_glowFactor; QGraphicsRotation3D *sunRotation; QGraphicsRotation3D *planetRotation; diff --git a/examples/qt3d/tank/quadplane.cpp b/examples/qt3d/tank/quadplane.cpp index 16935c912..f8aea0a9a 100644 --- a/examples/qt3d/tank/quadplane.cpp +++ b/examples/qt3d/tank/quadplane.cpp @@ -86,12 +86,12 @@ QuadPlane::QuadPlane(QObject *parent, QSizeF size, int level) QGeometryData zip2; for (int yy = 0; yy <= divisions; ++yy) { - qreal y = half.height() - float(yy) * div.height(); - qreal texY = float(yy) / divisions; + float y = half.height() - float(yy) * div.height(); + float texY = float(yy) / divisions; for (int xx = 0; xx <= divisions; ++xx) { - qreal x = half.width() - float(xx) * div.width(); - qreal texX = float(xx) / divisions; + float x = half.width() - float(xx) * div.width(); + float texX = float(xx) / divisions; zip.appendVertex(QVector3D(x, y, 0)); zip.appendTexCoord(QVector2D(1.0f - texX, 1.0f - texY)); } diff --git a/examples/qt3d/tank/tank.cpp b/examples/qt3d/tank/tank.cpp index f10daee42..39158afca 100644 --- a/examples/qt3d/tank/tank.cpp +++ b/examples/qt3d/tank/tank.cpp @@ -61,7 +61,7 @@ static inline int rval() { // return an int 64 <--> 192 inclusive - return (qreal(qrand()) / qreal(RAND_MAX)) * 128 + 64; + return (float(qrand()) / float(RAND_MAX)) * 128 + 64; } static QGLMaterial *qCreateFluid() diff --git a/src/imports/threed/qgraphicslookattransform.cpp b/src/imports/threed/qgraphicslookattransform.cpp index 56b02bcf2..910c7de4a 100644 --- a/src/imports/threed/qgraphicslookattransform.cpp +++ b/src/imports/threed/qgraphicslookattransform.cpp @@ -279,9 +279,9 @@ void QGraphicsLookAtTransformPrivate::calculateRotationValues() const primaryRotationAxis = QVector3D(0,1,0); } - qreal angleCosine = + float angleCosine = QVector3D::dotProduct(forwards, subjectProjection); - qreal angle = qAcos(angleCosine); + float angle = acosf(angleCosine); rotationCache.primaryRotation.setAxis(primaryRotationAxis); rotationCache.primaryRotation.setAngle(angle * RADS_TO_DEGREES ); @@ -293,7 +293,7 @@ void QGraphicsLookAtTransformPrivate::calculateRotationValues() const relativePositionVector.normalize(); - qreal secondaryAngleCosine = QVector3D::dotProduct( subjectProjection, + float secondaryAngleCosine = QVector3D::dotProduct(subjectProjection, relativePositionVector); // Sanity check in case of rounding errors if (secondaryAngleCosine <= 1.0 && secondaryAngleCosine >= -1.0) diff --git a/src/imports/threed/qt3dnamespace.cpp b/src/imports/threed/qt3dnamespace.cpp index f7472ccb2..727d2a705 100644 --- a/src/imports/threed/qt3dnamespace.cpp +++ b/src/imports/threed/qt3dnamespace.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE Returns a Vector2D with the specified \c x and \c y. */ -QVector2D Qt3DNamespace::vector2d(qreal x, qreal y) +QVector2D Qt3DNamespace::vector2d(float x, float y) { return QVector2D(x, y); } @@ -65,7 +65,7 @@ QVector2D Qt3DNamespace::vector2d(qreal x, qreal y) Returns a Vector4D with the specified \c x, \c y, \c z, and \c w. */ -QVector4D Qt3DNamespace::vector4d(qreal x, qreal y, qreal z, qreal w) +QVector4D Qt3DNamespace::vector4d(float x, float y, float z, float w) { return QVector4D(x, y, z, w); } @@ -75,7 +75,7 @@ QVector4D Qt3DNamespace::vector4d(qreal x, qreal y, qreal z, qreal w) Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z. */ -QQuaternion Qt3DNamespace::quaternion(qreal scalar, qreal x, qreal y, qreal z) +QQuaternion Qt3DNamespace::quaternion(float scalar, float x, float y, float z) { return QQuaternion(scalar, x, y, z); } @@ -87,10 +87,10 @@ QQuaternion Qt3DNamespace::quaternion(qreal scalar, qreal x, qreal y, qreal z) */ QMatrix4x4 Qt3DNamespace::matrix4x4 - (qreal m11, qreal m12, qreal m13, qreal m14, - qreal m21, qreal m22, qreal m23, qreal m24, - qreal m31, qreal m32, qreal m33, qreal m34, - qreal m41, qreal m42, qreal m43, qreal m44) + (float m11, float m12, float m13, float m14, + float m21, float m22, float m23, float m24, + float m31, float m32, float m33, float m34, + float m41, float m42, float m43, float m44) { return QMatrix4x4(m11, m12, m13, m14, m21, m22, m23, m24, diff --git a/src/imports/threed/qt3dnamespace.h b/src/imports/threed/qt3dnamespace.h index 963d683aa..3a13f0aa5 100644 --- a/src/imports/threed/qt3dnamespace.h +++ b/src/imports/threed/qt3dnamespace.h @@ -62,13 +62,13 @@ public: ~Qt3DNamespace() {} public Q_SLOTS: - QVector2D vector2d(qreal x, qreal y); - QVector4D vector4d(qreal x, qreal y, qreal z, qreal w); - QQuaternion quaternion(qreal scalar, qreal x, qreal y, qreal z); - QMatrix4x4 matrix4x4(qreal m11, qreal m12, qreal m13, qreal m14, - qreal m21, qreal m22, qreal m23, qreal m24, - qreal m31, qreal m32, qreal m33, qreal m34, - qreal m41, qreal m42, qreal m43, qreal m44); + QVector2D vector2d(float x, float y); + QVector4D vector4d(float x, float y, float z, float w); + QQuaternion quaternion(float scalar, float x, float y, float z); + QMatrix4x4 matrix4x4(float m11, float m12, float m13, float m14, + float m21, float m22, float m23, float m24, + float m31, float m32, float m33, float m34, + float m41, float m42, float m43, float m44); }; QT_END_NAMESPACE diff --git a/src/imports/threed/scale3d.cpp b/src/imports/threed/scale3d.cpp index 5b2755749..1873a2994 100644 --- a/src/imports/threed/scale3d.cpp +++ b/src/imports/threed/scale3d.cpp @@ -50,12 +50,12 @@ void Scale3D::setScale(const QVariant &value) newScale = value.value<QVector3D>(); } else { bool ok = false; - double val = value.toDouble(&ok); + float val = value.toFloat(&ok); if (!ok) { qWarning("Scale3D: scale value is not a vector3D or single floating-point value"); return; } - newScale = QVector3D(qreal(val), qreal(val), qreal(val)); + newScale = QVector3D(val, val, val); } if (newScale != QGraphicsScale3D::scale()) { QGraphicsScale3D::setScale(newScale); diff --git a/src/imports/threed/viewport.cpp b/src/imports/threed/viewport.cpp index 325bdd94a..6865124b4 100644 --- a/src/imports/threed/viewport.cpp +++ b/src/imports/threed/viewport.cpp @@ -768,7 +768,7 @@ void Viewport::setLightModel(QGLLightModel *value) class ViewportSubsurface : public QGLSubsurface { public: - ViewportSubsurface(QGLAbstractSurface *surface, const QRect ®ion, qreal adjust) + ViewportSubsurface(QGLAbstractSurface *surface, const QRect ®ion, float adjust) : QGLSubsurface(surface, region) , m_adjust(adjust) { @@ -777,13 +777,13 @@ public: { } - qreal aspectRatio() const; + float aspectRatio() const; private: - qreal m_adjust; + float m_adjust; }; -qreal ViewportSubsurface::aspectRatio() const +float ViewportSubsurface::aspectRatio() const { return QGLSubsurface::aspectRatio() * m_adjust; } @@ -1094,9 +1094,9 @@ void Viewport::setupPickPaint(QGLPainter *painter, const QPointF &pt) cam.reset(new QGLCamera); } - qreal vw = cam->viewSize().width(); - qreal vh = cam->viewSize().height(); - qreal asp = 1.0f; + float vw = cam->viewSize().width(); + float vh = cam->viewSize().height(); + float asp = 1.0f; if (cam->adjustForAspectRatio()) { // see QGLCamera::projectionMatrix for this logic @@ -1117,12 +1117,12 @@ void Viewport::setupPickPaint(QGLPainter *painter, const QPointF &pt) cam->setAdjustForAspectRatio(false); // map the pick to coordinate system with origin at center of viewport - qreal dx = pt.x() - (width() / 2.0); - qreal dy = pt.y() - (height() / 2.0); + float dx = pt.x() - (width() / 2.0f); + float dy = pt.y() - (height() / 2.0f); dy = -dy; // near plane coord system is correct, opengl style, not upside down like qt dx *= vw / width(); dy *= vh / height(); - qreal dim = qMin(width(), height()); + float dim = qMin(width(), height()); Q_ASSERT(cam->viewSize().width() == cam->viewSize().height()); // viewsize is square painter->setCamera(cam.data()); @@ -1136,7 +1136,7 @@ void Viewport::setupPickPaint(QGLPainter *painter, const QPointF &pt) m.translate(tx); QMatrix4x4 s; - qreal fac = dim / qreal(FBO_SIZE); + float fac = dim / float(FBO_SIZE); s.scale(QVector3D(fac, fac, 0.0f)); painter->projectionMatrix() = s * m * painter->projectionMatrix().top(); @@ -1577,7 +1577,7 @@ void Viewport::wheelEvent(QWheelEvent *e) void Viewport::keyPressEvent(QKeyEvent *e) { // Process the "Keys" property on the item first. - qreal sep; + float sep; if (!d->navigation) { QQuickItem::keyPressEvent(e); @@ -1704,18 +1704,18 @@ void Viewport::processMouseHover(quint64 eventId) } // Zoom in and out according to the change in wheel delta. -void Viewport::wheel(qreal delta) +void Viewport::wheel(float delta) { if (d->fovzoom) { //Use field-of view as zoom (much like a traditional camera) - qreal scale = qAbs(viewDelta(delta, delta).x()); + float scale = qAbs(viewDelta(delta, delta).x()); if (delta < 0) scale = -scale; if (scale >= 0.0f) scale += 1.0f; else scale = 1.0f / (1.0f - scale); - qreal fov = d->camera->fieldOfView(); + float fov = d->camera->fieldOfView(); if (fov != 0.0f) d->camera->setFieldOfView(d->camera->fieldOfView() / scale); else @@ -1724,8 +1724,8 @@ void Viewport::wheel(qreal delta) // enable this to get wheel navigation that actually zooms by moving the // camera back, as opposed to making the angle of view wider. QVector3D viewVector= camera()->eye() - camera()->center(); - qreal zoomMag = viewVector.length(); - qreal zoomIncrement = -float(delta) / 100.0f; + float zoomMag = viewVector.length(); + float zoomIncrement = -float(delta) / 100.0f; if (!qFuzzyIsNull(zoomIncrement)) { zoomMag += zoomIncrement; @@ -1739,7 +1739,7 @@ void Viewport::wheel(qreal delta) } // Pan left/right/up/down without rotating about the object. -void Viewport::pan(qreal deltax, qreal deltay) +void Viewport::pan(float deltax, float deltay) { QPointF delta = viewDelta(deltax, deltay); QVector3D t = d->camera->translation(delta.x(), -delta.y(), 0.0f); @@ -1754,7 +1754,7 @@ void Viewport::pan(qreal deltax, qreal deltay) } // Rotate about the object being viewed. -void Viewport::rotate(qreal deltax, qreal deltay) +void Viewport::rotate(float deltax, float deltay) { QRectF rect = boundingRect(); int rotation = d->camera->screenRotation(); @@ -1767,8 +1767,8 @@ void Viewport::rotate(qreal deltax, qreal deltay) if (rotation == 180 || rotation == 270) { deltay = -deltay; } - qreal anglex = deltax * 90.0f / rect.width(); - qreal angley = deltay * 90.0f / rect.height(); + float anglex = deltax * 90.0f / rect.width(); + float angley = deltay * 90.0f / rect.height(); QQuaternion q = d->camera->pan(-anglex); q *= d->camera->tilt(-angley); d->camera->rotateCenter(q); @@ -1776,13 +1776,13 @@ void Viewport::rotate(qreal deltax, qreal deltay) // Convert deltas in the X and Y directions into percentages of // the view width and height. -QPointF Viewport::viewDelta(qreal deltax, qreal deltay) +QPointF Viewport::viewDelta(float deltax, float deltay) { QRectF rect = boundingRect(); - qreal w = rect.width(); - qreal h = rect.height(); + float w = rect.width(); + float h = rect.height(); bool scaleToWidth; - qreal scaleFactor, scaleX, scaleY; + float scaleFactor, scaleX, scaleY; QSizeF viewSize = d->camera->viewSize(); if (w >= h) { if (viewSize.width() >= viewSize.height()) diff --git a/src/imports/threed/viewport.h b/src/imports/threed/viewport.h index 528e579d9..5766cf8de 100644 --- a/src/imports/threed/viewport.h +++ b/src/imports/threed/viewport.h @@ -175,10 +175,10 @@ private: bool hoverEvent(QHoverEvent *event); - void wheel(qreal delta); - void pan(qreal deltax, qreal deltay); - void rotate(qreal deltax, qreal deltay); - QPointF viewDelta(qreal deltax, qreal deltay); + void wheel(float delta); + void pan(float deltax, float deltay); + void rotate(float deltax, float deltay); + QPointF viewDelta(float deltax, float deltay); static const int FBO_SIZE; }; diff --git a/src/quick3d/capsulemesh.cpp b/src/quick3d/capsulemesh.cpp index 3d65fbb23..5fd2a10ad 100644 --- a/src/quick3d/capsulemesh.cpp +++ b/src/quick3d/capsulemesh.cpp @@ -139,8 +139,8 @@ public: QMap<int, QGLSceneNode *> lodGeometry; QGLSceneNode *topNode; QGLSceneNode *currentCapsule; - qreal radius; - qreal length; + float radius; + float length; int lod; bool sceneSet; }; @@ -206,12 +206,12 @@ CapsuleMesh::~CapsuleMesh() This property defines the radius of the capsule. The default value is 1. */ -qreal CapsuleMesh::radius() const +float CapsuleMesh::radius() const { return d->radius; } -void CapsuleMesh::setRadius(qreal radius) +void CapsuleMesh::setRadius(float radius) { if (qFuzzyCompare(radius, 1)) radius = 1.0f; @@ -229,12 +229,12 @@ void CapsuleMesh::setRadius(qreal radius) This property defines the length of the capsule. The default value is 1. */ -qreal CapsuleMesh::length() const +float CapsuleMesh::length() const { return d->length; } -void CapsuleMesh::setLength(qreal length) +void CapsuleMesh::setLength(float length) { if (qFuzzyCompare(length, 1)) length = 1.0f; @@ -319,16 +319,16 @@ void CapsuleMesh::createGeometry(bool bForce) // Sanity check - the height of the capsule must not be less than its // diameter. A minimal capsule is a sphere - where diameter == height. - if (d->length < 2.0 * d->radius) + if (d->length < 2.0f * d->radius) { qWarning() << "Length of capsule must exceed its diameter" << " - correcting length."; - d->length = 2 * d->radius; + d->length = 2.0f * d->radius; } - qreal diameter = d->radius+d->radius; - qreal cylinderHeight = d->length - diameter; - qreal offset = cylinderHeight/2.0; + float diameter = d->radius+d->radius; + float cylinderHeight = d->length - diameter; + float offset = cylinderHeight/2.0f; builder << QGL::Faceted; QGLSceneNode *s = 0; @@ -342,15 +342,15 @@ void CapsuleMesh::createGeometry(bool bForce) builder << QGLDome(diameter, divisions, false); QMatrix4x4 translateMatrix; translateMatrix.setToIdentity(); - translateMatrix.rotate(180, 0, 1,0); - translateMatrix.translate(0, 0, offset); + translateMatrix.rotate(180.0f, 0.0f, 1.0f, 0.0f); + translateMatrix.translate(0.0f, 0.0f, offset); builder.currentNode()->setLocalTransform(translateMatrix); s = builder.newNode(); s->setObjectName(QLatin1String("RightEndCap")); builder << QGLDome(diameter, divisions, false); translateMatrix.setToIdentity(); - translateMatrix.translate(0, 0, offset); + translateMatrix.translate(0.0f, 0.0f, offset); builder.currentNode()->setLocalTransform(translateMatrix); geometry = builder.finalizedSceneNode(); diff --git a/src/quick3d/capsulemesh.h b/src/quick3d/capsulemesh.h index e315f2eed..d9dc0d602 100644 --- a/src/quick3d/capsulemesh.h +++ b/src/quick3d/capsulemesh.h @@ -53,19 +53,19 @@ class CapsuleMeshPrivate; class Q_QT3D_QUICK_EXPORT CapsuleMesh : public QQuickMesh { Q_OBJECT - Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) - Q_PROPERTY(qreal length READ length WRITE setLength NOTIFY lengthChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged) Q_PROPERTY(int levelOfDetail READ levelOfDetail WRITE setLevelOfDetail NOTIFY levelOfDetailChanged) public: explicit CapsuleMesh(QObject *parent = 0); ~CapsuleMesh(); - qreal radius() const; - void setRadius(qreal radius); + float radius() const; + void setRadius(float radius); - qreal length() const; - void setLength(qreal length); + float length() const; + void setLength(float length); int levelOfDetail() const; void setLevelOfDetail(int lod); diff --git a/src/quick3d/cylindermesh.cpp b/src/quick3d/cylindermesh.cpp index f884ac9af..6accc2cd5 100644 --- a/src/quick3d/cylindermesh.cpp +++ b/src/quick3d/cylindermesh.cpp @@ -132,8 +132,8 @@ public: QGLSceneNode *topNode; QGLSceneNode *currentCylinder; QGraphicsScale3D *scale; - qreal radius; - qreal length; + float radius; + float length; int lod; bool sceneSet; }; @@ -200,12 +200,12 @@ CylinderMesh::~CylinderMesh() This property defines the radius of the cylinder. The default value is 1. */ -qreal CylinderMesh::radius() const +float CylinderMesh::radius() const { return d->radius; } -void CylinderMesh::setRadius(qreal radius) +void CylinderMesh::setRadius(float radius) { if (qFuzzyCompare(radius, 1)) radius = 1.0f; @@ -223,12 +223,12 @@ void CylinderMesh::setRadius(qreal radius) This property defines the length of the cylinder. The default value is 1. */ -qreal CylinderMesh::length() const +float CylinderMesh::length() const { return d->length; } -void CylinderMesh::setLength(qreal length) +void CylinderMesh::setLength(float length) { if (qFuzzyCompare(length, 1)) length = 1.0f; diff --git a/src/quick3d/cylindermesh.h b/src/quick3d/cylindermesh.h index 1260e7296..8c05c1aa3 100644 --- a/src/quick3d/cylindermesh.h +++ b/src/quick3d/cylindermesh.h @@ -53,19 +53,19 @@ class CylinderMeshPrivate; class Q_QT3D_QUICK_EXPORT CylinderMesh : public QQuickMesh { Q_OBJECT - Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) - Q_PROPERTY(qreal length READ length WRITE setLength NOTIFY lengthChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged) Q_PROPERTY(int levelOfDetail READ levelOfDetail WRITE setLevelOfDetail NOTIFY levelOfDetailChanged) public: explicit CylinderMesh(QObject *parent = 0); ~CylinderMesh(); - qreal radius() const; - void setRadius(qreal radius); + float radius() const; + void setRadius(float radius); - qreal length() const; - void setLength(qreal length); + float length() const; + void setLength(float length); int levelOfDetail() const; void setLevelOfDetail(int lod); diff --git a/src/quick3d/library.xml b/src/quick3d/library.xml index f28c310c5..6ab8794fd 100644 --- a/src/quick3d/library.xml +++ b/src/quick3d/library.xml @@ -4,8 +4,8 @@ <exports> <export module="Qt3D.Shapes" version="1.0" type="Capsule" /> </exports> - <property name="radius" type="qreal" /> - <property name="length" type="qreal" /> + <property name="radius" type="float" /> + <property name="length" type="float" /> <property name="levelOfDetail" type="int" /> <signal name="radiusChanged" /> <signal name="lengthChanged" /> @@ -15,8 +15,8 @@ <exports> <export module="Qt3D.Shapes" version="1.0" type="Cylinder" /> </exports> - <property name="radius" type="qreal" /> - <property name="length" type="qreal" /> + <property name="radius" type="float" /> + <property name="length" type="float" /> <property name="levelOfDetail" type="int" /> <signal name="radiusChanged" /> <signal name="lengthChanged" /> @@ -26,7 +26,7 @@ <exports> <export module="Qt3D.Shapes" version="1.0" type="Line" /> </exports> - <property name="width" type="qreal" /> + <property name="width" type="float" /> <property name="vertices" type="QVariant" /> <signal name="verticesChanged" /> <signal name="widthChanged" /> @@ -35,7 +35,7 @@ <exports> <export module="Qt3D.Shapes" version="1.0" type="Point" /> </exports> - <property name="pointSize" type="qreal" /> + <property name="pointSize" type="float" /> <property name="vertices" type="QVariant" /> <signal name="verticesChanged" /> <signal name="pointSizeChanged" /> @@ -44,7 +44,7 @@ <exports> <export module="Qt3D.Shapes" version="1.0" type="Sphere" /> </exports> - <property name="radius" type="qreal" /> + <property name="radius" type="float" /> <property name="levelOfDetail" type="int" /> <property name="axis" type="Qt.Axis" /> <signal name="radiusChanged" /> diff --git a/src/quick3d/line.cpp b/src/quick3d/line.cpp index b9062ae5a..302e531cd 100644 --- a/src/quick3d/line.cpp +++ b/src/quick3d/line.cpp @@ -119,7 +119,7 @@ void Line::setVertices(const QVariant &value) m_vertexArray.clear(); QVariantList vertlist = m_vertices.toList(); for (int index = 0; (index + 2) < vertlist.size(); index += 3) { - m_vertexArray.append(qreal(vertlist.at(index).toDouble()), qreal(vertlist.at(index + 1).toDouble()), qreal(vertlist.at(index + 2).toDouble())); + m_vertexArray.append(vertlist.at(index).toFloat(), vertlist.at(index + 1).toFloat(), vertlist.at(index + 2).toFloat()); } m_changeFlag=true; emit verticesChanged(); @@ -133,7 +133,7 @@ void Line::setVertices(const QVariant &value) This property defines the width of the line. The default is 1.0 */ -void Line::setWidth(qreal width) +void Line::setWidth(float width) { if (m_width != width) { m_width = width; diff --git a/src/quick3d/line.h b/src/quick3d/line.h index e5c5dcc1c..63bfe2ba4 100644 --- a/src/quick3d/line.h +++ b/src/quick3d/line.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE class Q_QT3D_QUICK_EXPORT Line : public QQuickItem3D { Q_OBJECT - Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(QVariant vertices READ vertices WRITE setVertices NOTIFY verticesChanged) public: @@ -62,8 +62,8 @@ public: QVariant vertices() const; void setVertices(const QVariant &value); - qreal width() const {return m_width;} - void setWidth(qreal width); + float width() const {return m_width;} + void setWidth(float width); Q_SIGNALS: void verticesChanged(); @@ -73,7 +73,7 @@ protected: void drawItem(QGLPainter *painter); private: - qreal m_width; + float m_width; QVariant m_vertices; QVector3DArray m_vertexArray; QGLSceneNode * m_geometry; diff --git a/src/quick3d/plugins.qmltypes b/src/quick3d/plugins.qmltypes index ee9e9d352..482c31b24 100644 --- a/src/quick3d/plugins.qmltypes +++ b/src/quick3d/plugins.qmltypes @@ -11,8 +11,8 @@ Module { exports: [ "Capsule 1.0" ] - Property { name: "radius"; type: "qreal" } - Property { name: "length"; type: "qreal" } + Property { name: "radius"; type: "float" } + Property { name: "length"; type: "float" } Property { name: "levelOfDetail"; type: "int" } Signal { name: "radiusChanged" } Signal { name: "lengthChanged" } @@ -25,8 +25,8 @@ Module { exports: [ "Cylinder 1.0" ] - Property { name: "radius"; type: "qreal" } - Property { name: "length"; type: "qreal" } + Property { name: "radius"; type: "float" } + Property { name: "length"; type: "float" } Property { name: "levelOfDetail"; type: "int" } Signal { name: "radiusChanged" } Signal { name: "lengthChanged" } @@ -39,7 +39,7 @@ Module { exports: [ "Line 1.0" ] - Property { name: "width"; type: "qreal" } + Property { name: "width"; type: "float" } Property { name: "vertices"; type: "QVariant" } Signal { name: "verticesChanged" } Signal { name: "widthChanged" } @@ -51,7 +51,7 @@ Module { exports: [ "Point 1.0" ] - Property { name: "pointSize"; type: "qreal" } + Property { name: "pointSize"; type: "float" } Property { name: "vertices"; type: "QVariant" } Signal { name: "verticesChanged" } Signal { name: "pointSizeChanged" } @@ -88,10 +88,10 @@ Module { } } Property { name: "position"; type: "QVector3D" } - Property { name: "x"; type: "qreal" } - Property { name: "y"; type: "qreal" } - Property { name: "z"; type: "qreal" } - Property { name: "scale"; type: "qreal" } + Property { name: "x"; type: "float" } + Property { name: "y"; type: "float" } + Property { name: "z"; type: "float" } + Property { name: "scale"; type: "float" } Property { name: "transform"; type: "QQuickQGraphicsTransform3D"; isList: true; isReadonly: true } Property { name: "pretransform"; type: "QQuickQGraphicsTransform3D"; isList: true; isReadonly: true } Property { name: "mesh"; type: "QQuickMesh"; isPointer: true } @@ -149,7 +149,7 @@ Module { exports: [ "Sphere 1.0" ] - Property { name: "radius"; type: "qreal" } + Property { name: "radius"; type: "float" } Property { name: "levelOfDetail"; type: "int" } Property { name: "axis"; type: "Qt::Axis" } Signal { name: "radiusChanged" } diff --git a/src/quick3d/point.cpp b/src/quick3d/point.cpp index 271026fa1..f07c4643a 100644 --- a/src/quick3d/point.cpp +++ b/src/quick3d/point.cpp @@ -121,7 +121,7 @@ void Point::setVertices(const QVariant &value) m_vertexArray.clear(); QVariantList vertlist = m_vertices.toList(); for (int index = 0; (index + 2) < vertlist.size(); index += 3) { - m_vertexArray.append(qreal(vertlist.at(index).toDouble()), qreal(vertlist.at(index + 1).toDouble()), qreal(vertlist.at(index + 2).toDouble())); + m_vertexArray.append(vertlist.at(index).toFloat(), vertlist.at(index + 1).toFloat(), vertlist.at(index + 2).toFloat()); } m_changeFlag=true; emit verticesChanged(); @@ -130,12 +130,12 @@ void Point::setVertices(const QVariant &value) /*! - \qmlproperty qreal Point::pointSize + \qmlproperty float Point::pointSize This property defines the size of the point. The default is 1.0 */ -void Point::setPointSize(qreal pointSize) +void Point::setPointSize(float pointSize) { if (m_pointSize != pointSize) { m_pointSize = pointSize; diff --git a/src/quick3d/point.h b/src/quick3d/point.h index f5d568b58..9d56c60e7 100644 --- a/src/quick3d/point.h +++ b/src/quick3d/point.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE class Q_QT3D_QUICK_EXPORT Point : public QQuickItem3D { Q_OBJECT - Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize NOTIFY pointSizeChanged) + Q_PROPERTY(float pointSize READ pointSize WRITE setPointSize NOTIFY pointSizeChanged) Q_PROPERTY(QVariant vertices READ vertices WRITE setVertices NOTIFY verticesChanged) public: @@ -62,8 +62,8 @@ public: QVariant vertices() const; void setVertices(const QVariant &value); - qreal pointSize() const {return m_pointSize;} - void setPointSize(qreal pointSize); + float pointSize() const {return m_pointSize;} + void setPointSize(float pointSize); Q_SIGNALS: void verticesChanged(); @@ -73,7 +73,7 @@ protected: void drawItem(QGLPainter *painter); private: - qreal m_pointSize; + float m_pointSize; QVariant m_vertices; QVector3DArray m_vertexArray; QGLSceneNode * m_geometry; diff --git a/src/quick3d/qquickeffect.cpp b/src/quick3d/qquickeffect.cpp index ef1215f39..d12108337 100644 --- a/src/quick3d/qquickeffect.cpp +++ b/src/quick3d/qquickeffect.cpp @@ -152,7 +152,7 @@ public: bool blending; QSharedPointer<QGLMaterialCollection> palette; int materialIndex; - qreal progress; + float progress; void cleanupResources(); }; @@ -530,7 +530,7 @@ QGLTexture2D *QQuickEffect::texture2D() /*! Returns the progress of remote resource loading. */ -qreal QQuickEffect::progress() +float QQuickEffect::progress() { return d->progress; } diff --git a/src/quick3d/qquickeffect.h b/src/quick3d/qquickeffect.h index a9cb6ad9b..a4a85ee27 100644 --- a/src/quick3d/qquickeffect.h +++ b/src/quick3d/qquickeffect.h @@ -73,7 +73,7 @@ class Q_QT3D_QUICK_EXPORT QQuickEffect : public QObject Q_PROPERTY(QUrl texture READ texture WRITE setTexture NOTIFY effectChanged) Q_PROPERTY(QImage textureImage READ textureImage WRITE setTextureImage NOTIFY effectChanged) Q_PROPERTY(QGLMaterial *material READ material WRITE setMaterial NOTIFY effectChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) + Q_PROPERTY(float progress READ progress NOTIFY progressChanged) public: QQuickEffect(QObject *parent = 0); virtual ~QQuickEffect(); @@ -103,13 +103,13 @@ public: virtual void disableEffect(QGLPainter *painter); virtual void applyTo(QGLSceneNode *node); - virtual qreal progress(); + virtual float progress(); void openglContextIsAboutToBeDestroyed(); Q_SIGNALS: void effectChanged(); - void progressChanged(qreal progress); + void progressChanged(float progress); protected: QGLTexture2D *texture2D(); diff --git a/src/quick3d/qquickitem3d.cpp b/src/quick3d/qquickitem3d.cpp index e8ff72afd..f06169d15 100644 --- a/src/quick3d/qquickitem3d.cpp +++ b/src/quick3d/qquickitem3d.cpp @@ -290,7 +290,7 @@ public: QVector3D position; QVector3D pivot; bool usePivot; - qreal scale; + float scale; QQuickMesh *mesh; QQuickEffect *effect; bool requireBlockingEffectsCheck; @@ -639,12 +639,12 @@ void QQuickItem3D::setPosition(const QVector3D& value) \sa position, y, z */ -qreal QQuickItem3D::x() const +float QQuickItem3D::x() const { return d->position.x(); } -void QQuickItem3D::setX(qreal value) +void QQuickItem3D::setX(float value) { d->position.setX(value); emit position3dChanged(); @@ -660,12 +660,12 @@ void QQuickItem3D::setX(qreal value) \sa position, x, z */ -qreal QQuickItem3D::y() const +float QQuickItem3D::y() const { return d->position.y(); } -void QQuickItem3D::setY(qreal value) +void QQuickItem3D::setY(float value) { d->position.setY(value); emit position3dChanged(); @@ -681,12 +681,12 @@ void QQuickItem3D::setY(qreal value) \sa position, x, y */ -qreal QQuickItem3D::z() const +float QQuickItem3D::z() const { return d->position.z(); } -void QQuickItem3D::setZ(qreal value) +void QQuickItem3D::setZ(float value) { d->position.setZ(value); emit position3dChanged(); @@ -703,12 +703,12 @@ void QQuickItem3D::setZ(qreal value) \sa transform */ -qreal QQuickItem3D::scale() const +float QQuickItem3D::scale() const { return d->scale; } -void QQuickItem3D::setScale(qreal value) +void QQuickItem3D::setScale(float value) { d->scale = value; emit scale3dChanged(); @@ -1236,11 +1236,11 @@ void QQuickItem3D::drawChildren(QGLPainter *painter) if (d->sortChildren == QQuickItem3D::BackToFront) { // Collect up the transformed z positions of all children. - QList<QPair<qreal, QQuickItem3D*> > zlist; + QList<QPair<float, QQuickItem3D*> > zlist; QMatrix4x4 mv = painter->modelViewMatrix(); for (int index = 0; index < list.size(); ++index) { QVector3D position = list.at(index)->position(); - zlist.append(QPair<qreal, QQuickItem3D*> (mv.map(position).z(), list.at(index))); + zlist.append(QPair<float, QQuickItem3D*> (mv.map(position).z(), list.at(index))); } qSort(zlist); diff --git a/src/quick3d/qquickitem3d.h b/src/quick3d/qquickitem3d.h index 13e345f0f..339a547d8 100644 --- a/src/quick3d/qquickitem3d.h +++ b/src/quick3d/qquickitem3d.h @@ -72,10 +72,10 @@ class Q_QT3D_QUICK_EXPORT QQuickItem3D : public QQuickItem Q_ENUMS(CullFace) Q_FLAGS(CullFaces) Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY position3dChanged) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY position3dChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY position3dChanged) - Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY position3dChanged) - Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scale3dChanged) + Q_PROPERTY(float x READ x WRITE setX NOTIFY position3dChanged) + Q_PROPERTY(float y READ y WRITE setY NOTIFY position3dChanged) + Q_PROPERTY(float z READ z WRITE setZ NOTIFY position3dChanged) + Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scale3dChanged) Q_PROPERTY(QQmlListProperty<QQuickQGraphicsTransform3D> transform READ transform DESIGNABLE false FINAL) Q_PROPERTY(QQmlListProperty<QQuickQGraphicsTransform3D> pretransform READ pretransform DESIGNABLE false FINAL) Q_PROPERTY(QQuickMesh *mesh READ mesh WRITE setMesh NOTIFY meshChanged) @@ -113,15 +113,15 @@ public: QVector3D position() const; void setPosition(const QVector3D& value); - qreal x() const; - void setX(qreal value); - qreal y() const; - void setY(qreal value); - qreal z() const; - void setZ(qreal value); + float x() const; + void setX(float value); + float y() const; + void setY(float value); + float z() const; + void setZ(float value); - qreal scale() const; - void setScale(qreal value); + float scale() const; + void setScale(float value); QQuickMesh *mesh() const; void setMesh(QQuickMesh* value); diff --git a/src/quick3d/spheremesh.cpp b/src/quick3d/spheremesh.cpp index d2ea02c02..4d3b0bff1 100644 --- a/src/quick3d/spheremesh.cpp +++ b/src/quick3d/spheremesh.cpp @@ -159,7 +159,7 @@ public: QGLSceneNode *currentSphere; QGraphicsRotation3D *rot; QGraphicsScale3D *scale; - qreal radius; + float radius; int lod; Qt::Axis axis; bool sceneSet; @@ -228,12 +228,12 @@ SphereMesh::~SphereMesh() This property defines the radius of the sphere. The default value is 0.5. */ -qreal SphereMesh::radius() const +float SphereMesh::radius() const { return d->radius; } -void SphereMesh::setRadius(qreal radius) +void SphereMesh::setRadius(float radius) { if (qFuzzyCompare(radius, 1)) radius = 1.0f; diff --git a/src/quick3d/spheremesh.h b/src/quick3d/spheremesh.h index 86c7c8ecf..1f275b273 100644 --- a/src/quick3d/spheremesh.h +++ b/src/quick3d/spheremesh.h @@ -58,15 +58,15 @@ class SphereMeshPrivate; class Q_QT3D_QUICK_EXPORT SphereMesh : public QQuickMesh { Q_OBJECT - Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) Q_PROPERTY(int levelOfDetail READ levelOfDetail WRITE setLevelOfDetail NOTIFY levelOfDetailChanged) Q_PROPERTY(Qt::Axis axis READ axis WRITE setAxis NOTIFY axisChanged) public: SphereMesh(QObject *parent = 0); ~SphereMesh(); - qreal radius() const; - void setRadius(qreal radius); + float radius() const; + void setRadius(float radius); int levelOfDetail() const; void setLevelOfDetail(int lod); diff --git a/src/threed/arrays/qcolor4ub.cpp b/src/threed/arrays/qcolor4ub.cpp index 2d2f38449..b367d1310 100644 --- a/src/threed/arrays/qcolor4ub.cpp +++ b/src/threed/arrays/qcolor4ub.cpp @@ -171,7 +171,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn qreal QColor4ub::redF() const { return m_red / 255.0f; } + \fn float QColor4ub::redF() const { return m_red / 255.0f; } Returns the red component of this color as a floating-point value between 0 and 1. @@ -180,7 +180,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn qreal QColor4ub::greenF() const { return m_green / 255.0f; } + \fn float QColor4ub::greenF() const { return m_green / 255.0f; } Returns the green component of this color as a floating-point value between 0 and 1. @@ -189,7 +189,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn qreal QColor4ub::blueF() const { return m_blue / 255.0f; } + \fn float QColor4ub::blueF() const { return m_blue / 255.0f; } Returns the blue component of this color as a floating-point value between 0 and 1. @@ -198,7 +198,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn qreal QColor4ub::alphaF() const { return m_alpha / 255.0f; } + \fn float QColor4ub::alphaF() const { return m_alpha / 255.0f; } Returns the alpha component of this color as a floating-point value between 0 and 1. @@ -207,7 +207,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QColor4ub::setRedF(qreal value) + \fn void QColor4ub::setRedF(float value) Sets the red component of this color to a floating-point \a value, between 0 and 1. @@ -216,7 +216,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QColor4ub::setGreenF(qreal value) + \fn void QColor4ub::setGreenF(float value) Sets the green component of this color to a floating-point \a value, between 0 and 1. @@ -225,7 +225,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QColor4ub::setBlueF(qreal value) + \fn void QColor4ub::setBlueF(float value) Sets the blue component of this color to a floating-point \a value, between 0 and 1. @@ -234,7 +234,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QColor4ub::setAlphaF(qreal value) + \fn void QColor4ub::setAlphaF(float value) Sets the alpha component of this color to a floating-point \a value, between 0 and 1. @@ -252,7 +252,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QColor4ub::setRgbF(qreal red, qreal green, qreal blue, qreal alpha) + \fn void QColor4ub::setRgbF(float red, float green, float blue, float alpha) Sets the components of this color to \a red, \a green, \a blue, and \a alpha. Each component is a floating-point value between 0 and 1. @@ -270,7 +270,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QColor4ub QColor4ub::fromRgbF(qreal red, qreal green, qreal blue, qreal alpha) + \fn QColor4ub QColor4ub::fromRgbF(float red, float green, float blue, float alpha) Returns a QColor4ub with the components \a red, \a green, \a blue, and \a alpha. Each component is a floating-point value between 0 and 1. diff --git a/src/threed/arrays/qcolor4ub.h b/src/threed/arrays/qcolor4ub.h index 98c281c72..4d40f40ac 100644 --- a/src/threed/arrays/qcolor4ub.h +++ b/src/threed/arrays/qcolor4ub.h @@ -74,22 +74,22 @@ public: void setBlue(int value) { m_blue = uchar(value); } void setAlpha(int value) { m_alpha = uchar(value); } - qreal redF() const { return m_red / 255.0f; } - qreal greenF() const { return m_green / 255.0f; } - qreal blueF() const { return m_blue / 255.0f; } - qreal alphaF() const { return m_alpha / 255.0f; } + float redF() const { return m_red / 255.0f; } + float greenF() const { return m_green / 255.0f; } + float blueF() const { return m_blue / 255.0f; } + float alphaF() const { return m_alpha / 255.0f; } - void setRedF(qreal value) { m_red = uchar(qRound(value * 255.0f)); } - void setGreenF(qreal value) { m_green = uchar(qRound(value * 255.0f)); } - void setBlueF(qreal value) { m_blue = uchar(qRound(value * 255.0f)); } - void setAlphaF(qreal value) { m_alpha = uchar(qRound(value * 255.0f)); } + void setRedF(float value) { m_red = uchar(qRound(value * 255.0f)); } + void setGreenF(float value) { m_green = uchar(qRound(value * 255.0f)); } + void setBlueF(float value) { m_blue = uchar(qRound(value * 255.0f)); } + void setAlphaF(float value) { m_alpha = uchar(qRound(value * 255.0f)); } void setRgb(int red, int green, int blue, int alpha = 255); - void setRgbF(qreal red, qreal green, qreal blue, qreal alpha = 1.0f); + void setRgbF(float red, float green, float blue, float alpha = 1.0f); static QColor4ub fromRgb(int red, int green, int blue, int alpha = 255); static QColor4ub fromRgbF - (qreal red, qreal green, qreal blue, qreal alpha = 1.0f); + (float red, float green, float blue, float alpha = 1.0f); static QColor4ub fromRaw(const uchar *data); QColor toColor() const; @@ -159,7 +159,7 @@ inline void QColor4ub::setRgb(int red, int green, int blue, int alpha) m_alpha = uchar(alpha); } -inline void QColor4ub::setRgbF(qreal red, qreal green, qreal blue, qreal alpha) +inline void QColor4ub::setRgbF(float red, float green, float blue, float alpha) { m_red = uchar(qRound(red * 255.0f)); m_green = uchar(qRound(green * 255.0f)); @@ -173,7 +173,7 @@ inline QColor4ub QColor4ub::fromRgb(int red, int green, int blue, int alpha) } inline QColor4ub QColor4ub::fromRgbF - (qreal red, qreal green, qreal blue, qreal alpha) + (float red, float green, float blue, float alpha) { return QColor4ub(qRound(red * 255.0f), qRound(green * 255.0f), qRound(blue * 255.0f), qRound(alpha * 255.0f)); diff --git a/src/threed/arrays/qcustomdataarray.cpp b/src/threed/arrays/qcustomdataarray.cpp index d48327d6a..63a040345 100644 --- a/src/threed/arrays/qcustomdataarray.cpp +++ b/src/threed/arrays/qcustomdataarray.cpp @@ -487,7 +487,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) } /*! - \fn void QCustomDataArray::setAt(int index, qreal x) + \fn void QCustomDataArray::setAt(int index, float x) \overload Sets the floating-point element at \a index in this custom data @@ -497,7 +497,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) */ /*! - \fn void QCustomDataArray::setAt(int index, qreal x, qreal y) + \fn void QCustomDataArray::setAt(int index, float x, float y) \overload Sets the 2D vector element at \a index in this custom @@ -508,7 +508,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) */ /*! - \fn void QCustomDataArray::setAt(int index, qreal x, qreal y, qreal z) + \fn void QCustomDataArray::setAt(int index, float x, float y, float z) \overload Sets the 3D vector element at \a index in this custom @@ -519,7 +519,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) */ /*! - \fn void QCustomDataArray::setAt(int index, qreal x, qreal y, qreal z, qreal w) + \fn void QCustomDataArray::setAt(int index, float x, float y, float z, float w) \overload Sets the 4D vector element at \a index in this custom @@ -583,7 +583,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) */ /*! - \fn qreal QCustomDataArray::floatAt(int index) const + \fn float QCustomDataArray::floatAt(int index) const Returns the floating-point element at \a index in this custom data array. The elementType() must be QCustomDataArray::Float. @@ -628,7 +628,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) */ /*! - \fn void QCustomDataArray::append(qreal x) + \fn void QCustomDataArray::append(float x) \overload Appends the floating-point value \a x to this custom data array. @@ -638,7 +638,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) */ /*! - \fn void QCustomDataArray::append(qreal x, qreal y) + \fn void QCustomDataArray::append(float x, float y) \overload Appends the 2D vector value (\a x, \a y) to this custom data array. @@ -648,7 +648,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) */ /*! - \fn void QCustomDataArray::append(qreal x, qreal y, qreal z) + \fn void QCustomDataArray::append(float x, float y, float z) \overload Appends the 3D vector value (\a x, \a y, \a z) to this custom @@ -658,7 +658,7 @@ void QCustomDataArray::setAt(int index, const QVariant& value) */ /*! - \fn void QCustomDataArray::append(qreal x, qreal y, qreal z, qreal w) + \fn void QCustomDataArray::append(float x, float y, float z, float w) \overload Appends the 4D vector value (\a x, \a y, \a z, \a w) to this custom diff --git a/src/threed/arrays/qcustomdataarray.h b/src/threed/arrays/qcustomdataarray.h index e63fe28ad..8e2081185 100644 --- a/src/threed/arrays/qcustomdataarray.h +++ b/src/threed/arrays/qcustomdataarray.h @@ -102,26 +102,26 @@ public: QVariant at(int index) const; void setAt(int index, const QVariant& value); - void setAt(int index, qreal x); - void setAt(int index, qreal x, qreal y); - void setAt(int index, qreal x, qreal y, qreal z); - void setAt(int index, qreal x, qreal y, qreal z, qreal w); + void setAt(int index, float x); + void setAt(int index, float x, float y); + void setAt(int index, float x, float y, float z); + void setAt(int index, float x, float y, float z, float w); void setAt(int index, const QVector2D& value); void setAt(int index, const QVector3D& value); void setAt(int index, const QVector4D& value); void setAt(int index, const QColor4ub& value); void setAt(int index, Qt::GlobalColor value); - qreal floatAt(int index) const; + float floatAt(int index) const; QVector2D vector2DAt(int index) const; QVector3D vector3DAt(int index) const; QVector4D vector4DAt(int index) const; QColor4ub colorAt(int index) const; - void append(qreal x); - void append(qreal x, qreal y); - void append(qreal x, qreal y, qreal z); - void append(qreal x, qreal y, qreal z, qreal w); + void append(float x); + void append(float x, float y); + void append(float x, float y, float z); + void append(float x, float y, float z, float w); void append(const QVector2D& value); void append(const QVector3D& value); void append(const QVector4D& value); @@ -222,41 +222,41 @@ inline void QCustomDataArray::squeeze() m_array.squeeze(); } -inline void QCustomDataArray::setAt(int index, qreal x) +inline void QCustomDataArray::setAt(int index, float x) { Q_ASSERT(m_elementType == QCustomDataArray::Float); Q_ASSERT(index >= 0 && index < size()); - m_array[index] = float(x); + m_array[index] = x; } -inline void QCustomDataArray::setAt(int index, qreal x, qreal y) +inline void QCustomDataArray::setAt(int index, float x, float y) { Q_ASSERT(m_elementType == QCustomDataArray::Vector2D); Q_ASSERT(index >= 0 && index < size()); float *data = m_array.data() + index * 2; - data[0] = float(x); - data[1] = float(y); + data[0] = x; + data[1] = y; } -inline void QCustomDataArray::setAt(int index, qreal x, qreal y, qreal z) +inline void QCustomDataArray::setAt(int index, float x, float y, float z) { Q_ASSERT(m_elementType == QCustomDataArray::Vector3D); Q_ASSERT(index >= 0 && index < size()); float *data = m_array.data() + index * 3; - data[0] = float(x); - data[1] = float(y); - data[2] = float(z); + data[0] = x; + data[1] = y; + data[2] = z; } -inline void QCustomDataArray::setAt(int index, qreal x, qreal y, qreal z, qreal w) +inline void QCustomDataArray::setAt(int index, float x, float y, float z, float w) { Q_ASSERT(m_elementType == QCustomDataArray::Vector4D); Q_ASSERT(index >= 0 && index < size()); float *data = m_array.data() + index * 4; - data[0] = float(x); - data[1] = float(y); - data[2] = float(z); - data[3] = float(w); + data[0] = x; + data[1] = y; + data[2] = z; + data[3] = w; } inline void QCustomDataArray::setAt(int index, const QVector2D& value) @@ -264,8 +264,8 @@ inline void QCustomDataArray::setAt(int index, const QVector2D& value) Q_ASSERT(m_elementType == QCustomDataArray::Vector2D); Q_ASSERT(index >= 0 && index < size()); float *data = m_array.data() + index * 2; - data[0] = float(value.x()); - data[1] = float(value.y()); + data[0] = value.x(); + data[1] = value.y(); } inline void QCustomDataArray::setAt(int index, const QVector3D& value) @@ -273,9 +273,9 @@ inline void QCustomDataArray::setAt(int index, const QVector3D& value) Q_ASSERT(m_elementType == QCustomDataArray::Vector3D); Q_ASSERT(index >= 0 && index < size()); float *data = m_array.data() + index * 3; - data[0] = float(value.x()); - data[1] = float(value.y()); - data[2] = float(value.z()); + data[0] = value.x(); + data[1] = value.y(); + data[2] = value.z(); } inline void QCustomDataArray::setAt(int index, const QVector4D& value) @@ -283,10 +283,10 @@ inline void QCustomDataArray::setAt(int index, const QVector4D& value) Q_ASSERT(m_elementType == QCustomDataArray::Vector4D); Q_ASSERT(index >= 0 && index < size()); float *data = m_array.data() + index * 4; - data[0] = float(value.x()); - data[1] = float(value.y()); - data[2] = float(value.z()); - data[3] = float(value.w()); + data[0] = value.x(); + data[1] = value.y(); + data[2] = value.z(); + data[3] = value.w(); } inline void QCustomDataArray::setAt(int index, const QColor4ub& value) @@ -303,7 +303,7 @@ inline void QCustomDataArray::setAt(int index, Qt::GlobalColor value) *(reinterpret_cast<QColor4ub *>(m_array.data() + index)) = QColor4ub(value); } -inline qreal QCustomDataArray::floatAt(int index) const +inline float QCustomDataArray::floatAt(int index) const { Q_ASSERT(m_elementType == QCustomDataArray::Float); Q_ASSERT(index >= 0 && index < size()); @@ -341,47 +341,47 @@ inline QColor4ub QCustomDataArray::colorAt(int index) const return *(reinterpret_cast<const QColor4ub *>(m_array.constData() + index)); } -inline void QCustomDataArray::append(qreal x) +inline void QCustomDataArray::append(float x) { Q_ASSERT(m_elementType == QCustomDataArray::Float); - m_array.append(float(x)); + m_array.append(x); } -inline void QCustomDataArray::append(qreal x, qreal y) +inline void QCustomDataArray::append(float x, float y) { Q_ASSERT(m_elementType == QCustomDataArray::Vector2D); - m_array.append(float(x), float(y)); + m_array.append(x, y); } -inline void QCustomDataArray::append(qreal x, qreal y, qreal z) +inline void QCustomDataArray::append(float x, float y, float z) { Q_ASSERT(m_elementType == QCustomDataArray::Vector3D); - m_array.append(float(x), float(y), float(z)); + m_array.append(x, y, z); } -inline void QCustomDataArray::append(qreal x, qreal y, qreal z, qreal w) +inline void QCustomDataArray::append(float x, float y, float z, float w) { Q_ASSERT(m_elementType == QCustomDataArray::Vector4D); - m_array.append(float(x), float(y), float(z), float(w)); + m_array.append(x, y, z, w); } inline void QCustomDataArray::append(const QVector2D& value) { Q_ASSERT(m_elementType == QCustomDataArray::Vector2D); - m_array.append(float(value.x()), float(value.y())); + m_array.append(value.x(), value.y()); } inline void QCustomDataArray::append(const QVector3D& value) { Q_ASSERT(m_elementType == QCustomDataArray::Vector3D); - m_array.append(float(value.x()), float(value.y()), float(value.z())); + m_array.append(value.x(), value.y(), value.z()); } inline void QCustomDataArray::append(const QVector4D& value) { Q_ASSERT(m_elementType == QCustomDataArray::Vector4D); - m_array.append(float(value.x()), float(value.y()), - float(value.z()), float(value.w())); + m_array.append(value.x(), value.y(), + value.z(), value.w()); } inline void QCustomDataArray::append(const QColor4ub& value) diff --git a/src/threed/arrays/qvector2darray.cpp b/src/threed/arrays/qvector2darray.cpp index f05cee287..d961a1207 100644 --- a/src/threed/arrays/qvector2darray.cpp +++ b/src/threed/arrays/qvector2darray.cpp @@ -98,7 +98,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QVector2DArray::append(qreal x, qreal y) + \fn void QVector2DArray::append(float x, float y) \overload Appends (\a x, \a y) to this array of QVector2D values. @@ -124,7 +124,7 @@ QT_BEGIN_NAMESPACE \sa scaled() */ -void QVector2DArray::scale(qreal scale) +void QVector2DArray::scale(float scale) { if (isDetached()) { // Modify the array in-place. @@ -150,9 +150,9 @@ void QVector2DArray::scale(qreal scale) \sa scale() */ -QVector2DArray QVector2DArray::scaled(qreal scale) const +QVector2DArray QVector2DArray::scaled(float scale) const { - const qreal identity = 1.0; + const float identity = 1.0f; if (qFuzzyCompare(scale, identity)) return *this; QArray<QVector2D> result; @@ -191,7 +191,7 @@ void QVector2DArray::translate(const QVector2D& value) } /*! - \fn void QVector2DArray::translate(qreal x, qreal y) + \fn void QVector2DArray::translate(float x, float y) \overload Translates the elements in this array of QVector2D values @@ -218,7 +218,7 @@ QArray<QVector2D> QVector2DArray::translated(const QVector2D& value) const } /*! - \fn QArray<QVector2D> QVector2DArray::translated(qreal x, qreal y) const + \fn QArray<QVector2D> QVector2DArray::translated(float x, float y) const \overload Returns a copy of this array of QVector2D values, translated diff --git a/src/threed/arrays/qvector2darray.h b/src/threed/arrays/qvector2darray.h index 1529a556a..57919d73c 100644 --- a/src/threed/arrays/qvector2darray.h +++ b/src/threed/arrays/qvector2darray.h @@ -60,18 +60,18 @@ public: QVector2DArray(int size, const QVector2D& value = QVector2D()); QVector2DArray(const QArray<QVector2D>& other); - void append(qreal x, qreal y); + void append(float x, float y); void append(const QPointF& point); void append(const QPoint& point); - void scale(qreal scale); - QVector2DArray scaled(qreal scale) const; + void scale(float scale); + QVector2DArray scaled(float scale) const; void translate(const QVector2D& value); - void translate(qreal x, qreal y); + void translate(float x, float y); QArray<QVector2D> translated(const QVector2D& value) const; - QArray<QVector2D> translated(qreal x, qreal y) const; + QArray<QVector2D> translated(float x, float y) const; void transform(const QMatrix4x4& matrix); QArray<QVector2D> transformed(const QMatrix4x4& matrix) const; @@ -102,7 +102,7 @@ inline QVector2DArray::QVector2DArray(int size, const QVector2D& value) inline QVector2DArray::QVector2DArray(const QArray<QVector2D>& other) : QArray<QVector2D>(other) {} -inline void QVector2DArray::append(qreal x, qreal y) +inline void QVector2DArray::append(float x, float y) { QArray<QVector2D>::append(QVector2D(x, y)); } inline void QVector2DArray::append(const QPointF& point) @@ -111,10 +111,10 @@ inline void QVector2DArray::append(const QPointF& point) inline void QVector2DArray::append(const QPoint& point) { QArray<QVector2D>::append(QVector2D(point)); } -inline void QVector2DArray::translate(qreal x, qreal y) +inline void QVector2DArray::translate(float x, float y) { translate(QVector2D(x, y)); } -inline QArray<QVector2D> QVector2DArray::translated(qreal x, qreal y) const +inline QArray<QVector2D> QVector2DArray::translated(float x, float y) const { return translated(QVector2D(x, y)); } QT_END_NAMESPACE diff --git a/src/threed/arrays/qvector3darray.cpp b/src/threed/arrays/qvector3darray.cpp index 1f7830e89..dbe5dd189 100644 --- a/src/threed/arrays/qvector3darray.cpp +++ b/src/threed/arrays/qvector3darray.cpp @@ -98,7 +98,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QVector3DArray::append(qreal x, qreal y, qreal z) + \fn void QVector3DArray::append(float x, float y, float z) Appends (\a x, \a y, \a z) to this array of QVector3D values. */ @@ -109,7 +109,7 @@ QT_BEGIN_NAMESPACE \sa scaled() */ -void QVector3DArray::scale(qreal scale) +void QVector3DArray::scale(float scale) { if (isDetached()) { // Modify the array in-place. @@ -135,7 +135,7 @@ void QVector3DArray::scale(qreal scale) \sa scale() */ -QVector3DArray QVector3DArray::scaled(qreal scale) const +QVector3DArray QVector3DArray::scaled(float scale) const { QArray<QVector3D> result; int size = count(); @@ -173,7 +173,7 @@ void QVector3DArray::translate(const QVector3D& value) } /*! - \fn void QVector3DArray::translate(qreal x, qreal y, qreal z) + \fn void QVector3DArray::translate(float x, float y, float z) \overload Translates the elements in this array of QVector3D values @@ -200,7 +200,7 @@ QArray<QVector3D> QVector3DArray::translated(const QVector3D& value) const } /*! - \fn QArray<QVector3D> QVector3DArray::translated(qreal x, qreal y, qreal z) const + \fn QArray<QVector3D> QVector3DArray::translated(float x, float y, float z) const \overload Returns a copy of this array of QVector3D values, translated diff --git a/src/threed/arrays/qvector3darray.h b/src/threed/arrays/qvector3darray.h index 8d8d02be3..e51191563 100644 --- a/src/threed/arrays/qvector3darray.h +++ b/src/threed/arrays/qvector3darray.h @@ -60,16 +60,16 @@ public: QVector3DArray(int size, const QVector3D& value = QVector3D()); QVector3DArray(const QArray<QVector3D>& other); - void append(qreal x, qreal y, qreal z); + void append(float x, float y, float z); - void scale(qreal scale); - QVector3DArray scaled(qreal scale) const; + void scale(float scale); + QVector3DArray scaled(float scale) const; void translate(const QVector3D& value); - void translate(qreal x, qreal y, qreal z); + void translate(float x, float y, float z); QArray<QVector3D> translated(const QVector3D& value) const; - QArray<QVector3D> translated(qreal x, qreal y, qreal z) const; + QArray<QVector3D> translated(float x, float y, float z) const; void transform(const QMatrix4x4& matrix); QArray<QVector3D> transformed(const QMatrix4x4& matrix) const; @@ -100,13 +100,13 @@ inline QVector3DArray::QVector3DArray(int size, const QVector3D& value) inline QVector3DArray::QVector3DArray(const QArray<QVector3D>& other) : QArray<QVector3D>(other) {} -inline void QVector3DArray::append(qreal x, qreal y, qreal z) +inline void QVector3DArray::append(float x, float y, float z) { QArray<QVector3D>::append(QVector3D(x, y, z)); } -inline void QVector3DArray::translate(qreal x, qreal y, qreal z) +inline void QVector3DArray::translate(float x, float y, float z) { translate(QVector3D(x, y, z)); } -inline QArray<QVector3D> QVector3DArray::translated(qreal x, qreal y, qreal z) const +inline QArray<QVector3D> QVector3DArray::translated(float x, float y, float z) const { return translated(QVector3D(x, y, z)); } QT_END_NAMESPACE diff --git a/src/threed/arrays/qvector4darray.cpp b/src/threed/arrays/qvector4darray.cpp index 3efba08aa..8a3b473a3 100644 --- a/src/threed/arrays/qvector4darray.cpp +++ b/src/threed/arrays/qvector4darray.cpp @@ -98,7 +98,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QVector4DArray::append(qreal x, qreal y, qreal z, qreal w) + \fn void QVector4DArray::append(float x, float y, float z, float w) Appends (\a x, \a y, \a z, \a w) to this array of QVector4D values. */ @@ -109,7 +109,7 @@ QT_BEGIN_NAMESPACE \sa scaled() */ -void QVector4DArray::scale(qreal scale) +void QVector4DArray::scale(float scale) { if (isDetached()) { // Modify the array in-place. @@ -135,7 +135,7 @@ void QVector4DArray::scale(qreal scale) \sa scale() */ -QVector4DArray QVector4DArray::scaled(qreal scale) const +QVector4DArray QVector4DArray::scaled(float scale) const { QArray<QVector4D> result; int size = count(); @@ -173,7 +173,7 @@ void QVector4DArray::translate(const QVector4D& value) } /*! - \fn void QVector4DArray::translate(qreal x, qreal y, qreal z, qreal w); + \fn void QVector4DArray::translate(float x, float y, float z, float w); \overload Translates the elements in this array of QVector4D values @@ -200,7 +200,7 @@ QArray<QVector4D> QVector4DArray::translated(const QVector4D& value) const } /*! - \fn QArray<QVector4D> QVector4DArray::translated(qreal x, qreal y, qreal z, qreal w) const + \fn QArray<QVector4D> QVector4DArray::translated(float x, float y, float z, float w) const \overload Returns a copy of this array of QVector4D values, translated diff --git a/src/threed/arrays/qvector4darray.h b/src/threed/arrays/qvector4darray.h index a62b2e742..d271cbd4d 100644 --- a/src/threed/arrays/qvector4darray.h +++ b/src/threed/arrays/qvector4darray.h @@ -60,17 +60,17 @@ public: QVector4DArray(int size, const QVector4D& value = QVector4D()); QVector4DArray(const QArray<QVector4D>& other); - void append(qreal x, qreal y, qreal z, qreal w); + void append(float x, float y, float z, float w); - void scale(qreal scale); - QVector4DArray scaled(qreal scale) const; + void scale(float scale); + QVector4DArray scaled(float scale) const; void translate(const QVector4D& value); - void translate(qreal x, qreal y, qreal z, qreal w); + void translate(float x, float y, float z, float w); QArray<QVector4D> translated(const QVector4D& value) const; QArray<QVector4D> translated - (qreal x, qreal y, qreal z, qreal w) const; + (float x, float y, float z, float w) const; void transform(const QMatrix4x4& matrix); QArray<QVector4D> transformed(const QMatrix4x4& matrix) const; @@ -101,14 +101,14 @@ inline QVector4DArray::QVector4DArray(int size, const QVector4D& value) inline QVector4DArray::QVector4DArray(const QArray<QVector4D>& other) : QArray<QVector4D>(other) {} -inline void QVector4DArray::append(qreal x, qreal y, qreal z, qreal w) +inline void QVector4DArray::append(float x, float y, float z, float w) { QArray<QVector4D>::append(QVector4D(x, y, z, w)); } -inline void QVector4DArray::translate(qreal x, qreal y, qreal z, qreal w) +inline void QVector4DArray::translate(float x, float y, float z, float w) { translate(QVector4D(x, y, z, w)); } inline QArray<QVector4D> QVector4DArray::translated - (qreal x, qreal y, qreal z, qreal w) const + (float x, float y, float z, float w) const { return translated(QVector4D(x, y, z, w)); } QT_END_NAMESPACE diff --git a/src/threed/geometry/qgeometrydata.cpp b/src/threed/geometry/qgeometrydata.cpp index d4263dc13..262c1d71d 100644 --- a/src/threed/geometry/qgeometrydata.cpp +++ b/src/threed/geometry/qgeometrydata.cpp @@ -504,15 +504,15 @@ QGeometryData QGeometryData::translated(const QVector3D &t) const */ void QGeometryData::generateTextureCoordinates(Qt::Orientation orientation, QGL::VertexAttribute field) { - QArray<qreal> extents; + QArray<float> extents; extents.append(0.0); - qreal totalExtents = 0.0; + float totalExtents = 0.0f; QArray<QVector3D> v = vertices(); for (int i = 0; i < v.count() - 1; ++i) { int n = (i + 1) % v.count(); QVector3D e = v[n] - v[i]; - qreal extent = e.length(); + float extent = e.length(); totalExtents += extent; extents.append(totalExtents); } @@ -859,7 +859,7 @@ void QGeometryData::reserve(int amount) If the geometry is a point or line, then the \a drawWidth value specified the width/size of the line/point. */ -void QGeometryData::draw(QGLPainter *painter, int start, int count, GLenum mode, qreal drawWidth) +void QGeometryData::draw(QGLPainter *painter, int start, int count, GLenum mode, float drawWidth) { if (d && d->indices.size() && d->count) { diff --git a/src/threed/geometry/qgeometrydata.h b/src/threed/geometry/qgeometrydata.h index 873a751c1..bd75310ce 100644 --- a/src/threed/geometry/qgeometrydata.h +++ b/src/threed/geometry/qgeometrydata.h @@ -95,7 +95,7 @@ public: void clear(); void clear(QGL::VertexAttribute); void reserve(int amount); - void draw(QGLPainter *painter, int start, int count, GLenum mode = QGL::Triangles, qreal drawWidth=1.0); + void draw(QGLPainter *painter, int start, int count, GLenum mode = QGL::Triangles, float drawWidth = 1.0f); bool upload(); enum BufferStrategyFlags { diff --git a/src/threed/geometry/qglbezierpatches.cpp b/src/threed/geometry/qglbezierpatches.cpp index 30de778dc..f36588165 100644 --- a/src/threed/geometry/qglbezierpatches.cpp +++ b/src/threed/geometry/qglbezierpatches.cpp @@ -104,7 +104,7 @@ public: } void subdivide(QGLBuilder *list) const; - qreal intersection + float intersection (const QRay3D &ray, bool anyIntersection, QVector2D *texCoord, int *patch) const; QVector3DArray positions; @@ -122,71 +122,71 @@ public: // Triangle mesh indices of the control points at each corner. int indices[4]; - QVector3D normal(qreal s, qreal t) const; + QVector3D normal(float s, float t) const; void convertToTriangles (QGeometryData *prim, - qreal xtex, qreal ytex, qreal wtex, qreal htex); + float xtex, float ytex, float wtex, float htex); void subDivide(QGLBezierPatch &patch1, QGLBezierPatch &patch2, QGLBezierPatch &patch3, QGLBezierPatch &patch4); void createNewCorners(QGLBezierPatch &patch1, QGLBezierPatch &patch2, QGLBezierPatch &patch3, QGLBezierPatch &patch4, QGeometryData *prim, - qreal xtex, qreal ytex, qreal wtex, qreal htex); + float xtex, float ytex, float wtex, float htex); void recursiveSubDivide (QGeometryData *prim, - int depth, qreal xtex, qreal ytex, qreal wtex, qreal htex); - qreal intersection - (qreal result, int depth, const QRay3D &ray, bool anyIntersection, - qreal xtex, qreal ytex, qreal wtex, qreal htex, QVector2D *tc); + int depth, float xtex, float ytex, float wtex, float htex); + float intersection + (float result, int depth, const QRay3D &ray, bool anyIntersection, + float xtex, float ytex, float wtex, float htex, QVector2D *tc); }; static int const cornerOffsets[] = {0, 3, 12, 15}; -static qreal const cornerS[] = {0.0f, 1.0f, 0.0f, 1.0f}; -static qreal const cornerT[] = {0.0f, 0.0f, 1.0f, 1.0f}; +static float const cornerS[] = {0.0f, 1.0f, 0.0f, 1.0f}; +static float const cornerT[] = {0.0f, 0.0f, 1.0f, 1.0f}; // Helper functions for calculating the components of the Bernstein // polynomial and its derivative that make up the surface. -static inline qreal b0(qreal v) +static inline float b0(float v) { return (1.0f - v) * (1.0f - v) * (1.0f - v); } -static inline qreal b1(qreal v) +static inline float b1(float v) { return 3.0f * v * (1.0f - v) * (1.0f - v); } -static inline qreal b2(qreal v) +static inline float b2(float v) { return 2.0f * v * v * (1.0f - v); } -static inline qreal b3(qreal v) +static inline float b3(float v) { return v * v * v; } -static inline qreal db0(qreal v) +static inline float db0(float v) { return -3.0f * (1.0f - v) * (1.0f - v); } -static inline qreal db1(qreal v) +static inline float db1(float v) { return -6.0f * v * (1.0f - v) + 3.0f * (1.0f - v) * (1.0f - v); } -static inline qreal db2(qreal v) +static inline float db2(float v) { return -3.0f * v * v + 6.0f * v * (1.0f - v); } -static inline qreal db3(qreal v) +static inline float db3(float v) { return 3.0f * v * v; } // Compute the normal at a specific point in the patch. // The s and t values vary between 0 and 1. -QVector3D QGLBezierPatch::normal(qreal s, qreal t) const +QVector3D QGLBezierPatch::normal(float s, float t) const { - qreal a[4]; - qreal b[4]; - qreal tx, ty, tz; - qreal sx, sy, sz; + float a[4]; + float b[4]; + float tx, ty, tz; + float sx, sy, sz; // Compute the derivative of the surface in t. a[0] = b0(s); @@ -259,7 +259,7 @@ QVector3D QGLBezierPatch::normal(qreal s, qreal t) const // Convert this patch into flat triangles. void QGLBezierPatch::convertToTriangles (QGeometryData *prim, - qreal xtex, qreal ytex, qreal wtex, qreal htex) + float xtex, float ytex, float wtex, float htex) { // The edges are considered ok if they have a non-zero length. // Zero-length edges can occur in triangular-shaped patches. @@ -373,11 +373,11 @@ void QGLBezierPatch::createNewCorners (QGLBezierPatch &patch1, QGLBezierPatch &patch2, QGLBezierPatch &patch3, QGLBezierPatch &patch4, QGeometryData *prim, - qreal xtex, qreal ytex, qreal wtex, qreal htex) + float xtex, float ytex, float wtex, float htex) { // Add vertices for the new patch corners we have created. - qreal hwtex = wtex / 2.0f; - qreal hhtex = htex / 2.0f; + float hwtex = wtex / 2.0f; + float hhtex = htex / 2.0f; int topPointIndex = prim->count(); int leftPointIndex = topPointIndex + 1; int midPointIndex = topPointIndex + 2; @@ -426,7 +426,7 @@ void QGLBezierPatch::createNewCorners // Recursively sub-divide a patch into triangles. void QGLBezierPatch::recursiveSubDivide (QGeometryData *prim, - int depth, qreal xtex, qreal ytex, qreal wtex, qreal htex) + int depth, float xtex, float ytex, float wtex, float htex) { if (depth <= 1) { convertToTriangles(prim, xtex, ytex, wtex, htex); @@ -435,8 +435,8 @@ void QGLBezierPatch::recursiveSubDivide subDivide(patch1, patch2, patch3, patch4); createNewCorners(patch1, patch2, patch3, patch4, prim, xtex, ytex, wtex, htex); --depth; - qreal hwtex = wtex / 2.0f; - qreal hhtex = htex / 2.0f; + float hwtex = wtex / 2.0f; + float hhtex = htex / 2.0f; patch1.recursiveSubDivide(prim, depth, xtex, ytex, hwtex, hhtex); patch2.recursiveSubDivide(prim, depth, xtex + hwtex, ytex, hwtex, hhtex); patch3.recursiveSubDivide(prim, depth, xtex, ytex + hhtex, hwtex, hhtex); @@ -461,10 +461,10 @@ void QGLBezierPatchesPrivate::subdivide(QGLBuilder *list) const tex1 = QVector2D(0.0f, 0.0f); tex2 = QVector2D(1.0f, 1.0f); } - qreal xtex = tex1.x(); - qreal ytex = tex1.y(); - qreal wtex = tex2.x() - xtex; - qreal htex = tex2.y() - ytex; + float xtex = tex1.x(); + float ytex = tex1.y(); + float wtex = tex2.x() - xtex; + float htex = tex2.y() - ytex; for (int corner = 0; corner < 4; ++corner) { QVector3D n = patch.normal(cornerS[corner], cornerT[corner]); patch.indices[corner] = prim.count(); @@ -482,7 +482,7 @@ void QGLBezierPatchesPrivate::subdivide(QGLBuilder *list) const list->addTriangles(prim); } -static inline qreal combineResults(qreal result, qreal t) +static inline float combineResults(float result, float t) { if (qIsNaN(result)) return t; @@ -492,9 +492,9 @@ static inline qreal combineResults(qreal result, qreal t) return result >= 0.0f ? result : qMax(result, t); } -qreal QGLBezierPatch::intersection - (qreal result, int depth, const QRay3D& ray, bool anyIntersection, - qreal xtex, qreal ytex, qreal wtex, qreal htex, QVector2D *tc) +float QGLBezierPatch::intersection + (float result, int depth, const QRay3D& ray, bool anyIntersection, + float xtex, float ytex, float wtex, float htex, QVector2D *tc) { // Check the convex hull of the patch for an intersection. // If no intersection with the convex hull, then there is @@ -509,7 +509,7 @@ qreal QGLBezierPatch::intersection if (depth <= 1) { // Divide the patch into two triangles and intersect with those. QTriangle3D triangle1(points[0], points[3], points[12]); - qreal t = triangle1.intersection(ray); + float t = triangle1.intersection(ray); if (!qIsNaN(t)) { result = combineResults(result, t); if (result == t) { @@ -521,7 +521,7 @@ qreal QGLBezierPatch::intersection } } else { QTriangle3D triangle2(points[3], points[15], points[12]); - qreal t = triangle2.intersection(ray); + float t = triangle2.intersection(ray); if (!qIsNaN(t)) { result = combineResults(result, t); if (result == t) { @@ -538,8 +538,8 @@ qreal QGLBezierPatch::intersection QGLBezierPatch patch1, patch2, patch3, patch4; subDivide(patch1, patch2, patch3, patch4); --depth; - qreal hwtex = wtex / 2.0f; - qreal hhtex = htex / 2.0f; + float hwtex = wtex / 2.0f; + float hhtex = htex / 2.0f; result = patch1.intersection (result, depth, ray, anyIntersection, xtex, ytex, hwtex, hhtex, tc); @@ -562,11 +562,11 @@ qreal QGLBezierPatch::intersection return result; } -qreal QGLBezierPatchesPrivate::intersection +float QGLBezierPatchesPrivate::intersection (const QRay3D &ray, bool anyIntersection, QVector2D *texCoord, int *bestPatch) const { int count = positions.size(); - qreal result = qSNaN(); + float result = qSNaN(); QVector2D tc; if (bestPatch) *bestPatch = -1; @@ -582,11 +582,11 @@ qreal QGLBezierPatchesPrivate::intersection tex1 = QVector2D(0.0f, 0.0f); tex2 = QVector2D(1.0f, 1.0f); } - qreal xtex = tex1.x(); - qreal ytex = tex1.y(); - qreal wtex = tex2.x() - xtex; - qreal htex = tex2.y() - ytex; - qreal prev = result; + float xtex = tex1.x(); + float ytex = tex1.y(); + float wtex = tex2.x() - xtex; + float htex = tex2.y() - ytex; + float prev = result; result = patch.intersection (result, subdivisionDepth, ray, anyIntersection, xtex, ytex, wtex, htex, &tc); @@ -764,7 +764,7 @@ bool QGLBezierPatches::intersects(const QRay3D &ray) const the actual intersection point, as shown in the following example: \code - qreal t = patches.intersection(ray); + float t = patches.intersection(ray); QVector3D pt; if (qIsNaN(t)) { qWarning("no intersection occurred"); @@ -792,7 +792,7 @@ bool QGLBezierPatches::intersects(const QRay3D &ray) const \sa intersects() */ -qreal QGLBezierPatches::intersection(const QRay3D &ray, QVector2D *texCoord, int *patch) const +float QGLBezierPatches::intersection(const QRay3D &ray, QVector2D *texCoord, int *patch) const { Q_D(const QGLBezierPatches); return d->intersection(ray, false, texCoord, patch); diff --git a/src/threed/geometry/qglbezierpatches.h b/src/threed/geometry/qglbezierpatches.h index 0eb858d78..5b7afae27 100644 --- a/src/threed/geometry/qglbezierpatches.h +++ b/src/threed/geometry/qglbezierpatches.h @@ -78,7 +78,7 @@ public: QGLBezierPatches transformed(const QMatrix4x4 &matrix) const; bool intersects(const QRay3D &ray) const; - qreal intersection(const QRay3D &ray, QVector2D *texCoord = 0, int *patch = 0) const; + float intersection(const QRay3D &ray, QVector2D *texCoord = 0, int *patch = 0) const; private: QScopedPointer<QGLBezierPatchesPrivate> d_ptr; diff --git a/src/threed/geometry/qglbuilder.cpp b/src/threed/geometry/qglbuilder.cpp index 0fd5472d2..83e3a7b2c 100644 --- a/src/threed/geometry/qglbuilder.cpp +++ b/src/threed/geometry/qglbuilder.cpp @@ -955,7 +955,7 @@ void QGLBuilder::addQuadsInterleaved(const QGeometryData &top, */ /*! - \fn void QGLBuilder::addPane(qreal size) + \fn void QGLBuilder::addPane(float size) Convenience method to add a single quad of dimensions \a size wide by \a size high in the z = 0 plane, centered on the origin. The quad has texture coordinates of (0, 0) at the bottom left and (1, 1) at the top diff --git a/src/threed/geometry/qglbuilder.h b/src/threed/geometry/qglbuilder.h index 0953f5ada..4efbbd820 100644 --- a/src/threed/geometry/qglbuilder.h +++ b/src/threed/geometry/qglbuilder.h @@ -90,7 +90,7 @@ public: void addQuadStrip(const QGeometryData &strip); void addQuadsInterleaved(const QGeometryData &top, const QGeometryData &bottom); - inline void addPane(qreal size = 1.0f); + inline void addPane(float size = 1.0f); inline void addPane(QSizeF size); protected: @@ -108,7 +108,7 @@ private: QGLBuilderPrivate *dptr; }; -inline void QGLBuilder::addPane(qreal size) +inline void QGLBuilder::addPane(float size) { addPane(QSizeF(size, size)); } diff --git a/src/threed/geometry/qglcube.cpp b/src/threed/geometry/qglcube.cpp index 196ba1ea4..422bf7eb0 100644 --- a/src/threed/geometry/qglcube.cpp +++ b/src/threed/geometry/qglcube.cpp @@ -68,14 +68,14 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QGLCube::QGLCube(qreal size) + \fn QGLCube::QGLCube(float size) Constructs the geometry for a regular cube of \a size units on a side. */ /*! - \fn qreal QGLCube::size() const + \fn float QGLCube::size() const Returns the size of this cube. @@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QGLCube::setSize(qreal size) + \fn void QGLCube::setSize(float size) Sets the \a size of this cube. diff --git a/src/threed/geometry/qglcube.h b/src/threed/geometry/qglcube.h index dc9d714a2..d2b6c054d 100644 --- a/src/threed/geometry/qglcube.h +++ b/src/threed/geometry/qglcube.h @@ -58,13 +58,13 @@ class QGLBuilder; class Q_QT3D_EXPORT QGLCube { public: - explicit QGLCube(qreal size = 1.0f) : m_size(size) {} + explicit QGLCube(float size = 1.0f) : m_size(size) {} - qreal size() const { return m_size; } - void setSize(qreal size) { m_size = size; } + float size() const { return m_size; } + void setSize(float size) { m_size = size; } private: - qreal m_size; + float m_size; }; Q_QT3D_EXPORT QGLBuilder& operator<<(QGLBuilder& builder, const QGLCube& cube); diff --git a/src/threed/geometry/qglcylinder.cpp b/src/threed/geometry/qglcylinder.cpp index aed9f7155..f27c96361 100644 --- a/src/threed/geometry/qglcylinder.cpp +++ b/src/threed/geometry/qglcylinder.cpp @@ -120,7 +120,7 @@ QT_BEGIN_NAMESPACE /*! - \fn QGLCylinder::QGLCylinder(qreal diameterTop, qreal diameterBase , qreal height, int slices, int layers, bool top, bool base) + \fn QGLCylinder::QGLCylinder(float diameterTop, float diameterBase , float height, int slices, int layers, bool top, bool base) Constructs the geometry for a cylinder with top of diameter \a diameterTop, a base of diameter \a diameterBase, and a height of \a height. @@ -137,7 +137,7 @@ QT_BEGIN_NAMESPACE /*! - \fn qreal QGLCylinder::diameterTop() const + \fn float QGLCylinder::diameterTop() const Returns the diameter of the top of the cylinder. @@ -147,7 +147,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QGLCylinder::setDiameterTop(qreal diameter) + \fn void QGLCylinder::setDiameterTop(float diameter) Sets the diameter of the top of this cylinder to \a diameter. @@ -155,7 +155,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn qreal QGLCylinder::diameterBottom() const + \fn float QGLCylinder::diameterBottom() const Returns the diameter of the bottom of the cylinder. @@ -165,7 +165,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QGLCylinder::setDiameterBottom(qreal diameter) + \fn void QGLCylinder::setDiameterBottom(float diameter) Sets the diameter of the bottom of this cylinder to \a diameter. @@ -173,7 +173,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn qreal QGLCylinder::height() const + \fn float QGLCylinder::height() const Returns the height of the cylinder. @@ -183,7 +183,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QGLCylinder::setHeight(qreal height) + \fn void QGLCylinder::setHeight(float height) Sets the height of this cylinder to \a height. @@ -283,21 +283,21 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLCylinder& cylinder) int nCaps = (cylinder.topEnabled()?1:0) + (cylinder.baseEnabled()?1:0); Q_ASSERT(cylinder.layers() >= 1 + nCaps); - qreal numSlices = qreal(cylinder.slices()); - qreal numLayers = qreal(cylinder.layers() - nCaps); // minus top and base caps - qreal topRadius = cylinder.diameterTop()/2.0; - qreal bottomRadius = cylinder.diameterBottom()/2.0; + float numSlices = float(cylinder.slices()); + float numLayers = float(cylinder.layers() - nCaps); // minus top and base caps + float topRadius = cylinder.diameterTop() / 2.0f; + float bottomRadius = cylinder.diameterBottom() / 2.0f; - qreal angle = 0; - qreal angleIncrement = (2.0 * M_PI) / numSlices; - qreal radius = topRadius; - qreal radiusIncrement = qreal(bottomRadius-topRadius)/ numLayers; - qreal height = qreal(cylinder.height()); - qreal heightDecrement = height/numLayers; - height *= 0.5; + float angle = 0.0f; + float angleIncrement = (2.0f * M_PI) / numSlices; + float radius = topRadius; + float radiusIncrement = float(bottomRadius-topRadius) / numLayers; + float height = float(cylinder.height()); + float heightDecrement = height / numLayers; + height *= 0.5f; - qreal textureHeight = 1.0; - qreal textureDecrement = 1.0/numLayers; + float textureHeight = 1.0f; + float textureDecrement = 1.0f / numLayers; QGeometryData oldLayer; @@ -306,10 +306,10 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLCylinder& cylinder) QGeometryData newLayer; //Generate a circle of vertices for this layer. for (int i=0; i<cylinder.slices(); i++) { - newLayer.appendVertex(QVector3D(radius * qCos(angle), radius * qSin(angle), height)); + newLayer.appendVertex(QVector3D(radius * cosf(angle), radius * sinf(angle), height)); angle+=angleIncrement; } - angle = 0; + angle = 0.0f; QVector3D center = newLayer.center(); // Generate texture coordinates (including an extra seam vertex for textures). newLayer.appendVertex(newLayer.vertex(0)); @@ -323,9 +323,9 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLCylinder& cylinder) top.appendVertex(center); top.appendVertexArray(newLayer.vertices()); //Generate a circle of texture vertices for this layer. - top.appendTexCoord(QVector2D(0.5,0.5)); + top.appendTexCoord(QVector2D(0.5f, 0.5f)); for (int i=1; i<top.count(); i++) { - top.appendTexCoord(QVector2D(0.5*qCos(angle)+0.5, 0.5*qSin(angle)+0.5)); + top.appendTexCoord(QVector2D(0.5f * cosf(angle) + 0.5f, 0.5f * sinf(angle) + 0.5f)); angle+=angleIncrement; } angle = 0; @@ -343,10 +343,10 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLCylinder& cylinder) QGeometryData newLayer; //Generate a circle of vertices for this layer. for (int i=0; i<cylinder.slices(); ++i) { - newLayer.appendVertex(QVector3D(radius * qCos(angle), radius * qSin(angle), height)); + newLayer.appendVertex(QVector3D(radius * cosf(angle), radius * sinf(angle), height)); angle+=angleIncrement; } - angle = 0; + angle = 0.0f; // Generate texture coordinates (including an extra seam vertex for textures). newLayer.appendVertex(newLayer.vertex(0)); newLayer.generateTextureCoordinates(); @@ -378,11 +378,11 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLCylinder& cylinder) } //Generate a circle of texture vertices for this layer. for (int i=1; i<base.count(); i++) { - base.appendTexCoord(QVector2D(0.5*qCos(angle)+0.5, 0.5*qSin(angle)+0.5)); + base.appendTexCoord(QVector2D(0.5f * cosf(angle) + 0.5f, 0.5f * sinf(angle) + 0.5f)); angle+=angleIncrement; } - base.appendTexCoord(QVector2D(0.5,0.5)); - angle = 0; + base.appendTexCoord(QVector2D(0.5f, 0.5f)); + angle = 0.0f; //we need to reverse the above to draw it properly - windings! builder.addTriangulatedFace(base.reversed()); } diff --git a/src/threed/geometry/qglcylinder.h b/src/threed/geometry/qglcylinder.h index aff5754c6..331c76b73 100644 --- a/src/threed/geometry/qglcylinder.h +++ b/src/threed/geometry/qglcylinder.h @@ -57,18 +57,18 @@ class QVector2D; class Q_QT3D_EXPORT QGLCylinder { public: - explicit QGLCylinder(qreal diameterTop = 1.0f, qreal diameterBase = 1.0f, qreal height = 1.0f, int slices = 6, int layers = 3, bool top = true, bool base = true) + explicit QGLCylinder(float diameterTop = 1.0f, float diameterBase = 1.0f, float height = 1.0f, int slices = 6, int layers = 3, bool top = true, bool base = true) : m_diameterTop(diameterTop), m_diameterBottom(diameterBase), m_height(height), m_slices(slices), m_layers(layers), m_top(top), m_base(base) {} //Cylinder dimensions - qreal diameterTop() const {return m_diameterTop;} - void setDiameterTop(qreal diameter) {m_diameterTop=diameter;} + float diameterTop() const {return m_diameterTop;} + void setDiameterTop(float diameter) {m_diameterTop=diameter;} - qreal diameterBottom() const {return m_diameterBottom;} - void setDiameterBottom(qreal diameter) {m_diameterBottom=diameter;} + float diameterBottom() const {return m_diameterBottom;} + void setDiameterBottom(float diameter) {m_diameterBottom=diameter;} - qreal height() const {return m_height;} - void setHeight(qreal height) {m_height = height;} + float height() const {return m_height;} + void setHeight(float height) {m_height = height;} //Cylinder geometrical subdivisions int slices() const {return m_slices;} @@ -85,9 +85,9 @@ public: void setBaseEnabled(bool base) {m_base = base;} protected: - qreal m_diameterTop; - qreal m_diameterBottom; - qreal m_height; + float m_diameterTop; + float m_diameterBottom; + float m_height; int m_slices; int m_layers; diff --git a/src/threed/geometry/qgldome.cpp b/src/threed/geometry/qgldome.cpp index b33b5275d..f72e481aa 100644 --- a/src/threed/geometry/qgldome.cpp +++ b/src/threed/geometry/qgldome.cpp @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QGLDome::QGLDome(qreal diameter, int depth, bool base) + \fn QGLDome::QGLDome(float diameter, int depth, bool base) Creates a dome of \a diameter across (default is 1). When the dome is recursively subdivided into triangles, it will be subdivided no more @@ -103,7 +103,7 @@ QGLDome::~QGLDome() } /*! - \fn qreal QGLDome::diameter() const + \fn float QGLDome::diameter() const Returns the diameter of this dome. The default is 1. @@ -111,7 +111,7 @@ QGLDome::~QGLDome() */ /*! - \fn void QGLDome::setDiameter(qreal diameter) + \fn void QGLDome::setDiameter(float diameter) Sets the diameter of this dome to \a diameter. @@ -168,7 +168,7 @@ QGLDome::~QGLDome() */ QGLBuilder& operator<<(QGLBuilder& builder, const QGLDome& dome) { - qreal radius = dome.diameter() / 2.0f; + float radius = dome.diameter() / 2.0f; // Determine the number of slices and stacks to generate. int divisions = dome.subdivisionDepth(); @@ -183,22 +183,22 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLDome& dome) // Precompute sin/cos values for the slices and stacks. const int maxSlices = 4 * (1 << 5) + 1; const int maxStacks = 2 * (1 << 5) + 1; - qreal sliceSin[maxSlices]; - qreal sliceCos[maxSlices]; - qreal stackSin[maxStacks]; - qreal stackCos[maxStacks]; + float sliceSin[maxSlices]; + float sliceCos[maxSlices]; + float stackSin[maxStacks]; + float stackCos[maxStacks]; for (int slice = 0; slice < slices; ++slice) { - qreal angle = 2 * M_PI * slice / slices; + float angle = 2.0f * M_PI * slice / slices; sliceSin[slice] = qFastSin(angle); sliceCos[slice] = qFastCos(angle); } sliceSin[slices] = sliceSin[0]; // Join first and last slice. sliceCos[slices] = sliceCos[0]; - const qreal halfPi=M_PI/2.0; + const float halfPi = M_PI / 2.0; for (int stack = 0; stack <= stacks; ++stack) { - qreal angle = halfPi * stack / stacks; + float angle = halfPi * stack / stacks; stackSin[stack] = qFastSin(angle); stackCos[stack] = qFastCos(angle); } @@ -210,22 +210,22 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLDome& dome) // Create the stacks for the dome part of the dome for (int stack = 0; stack < stacks; ++stack) { QGeometryData prim; - qreal z = radius * stackCos[stack]; - qreal nextz = radius * stackCos[stack + 1]; - qreal s = stackSin[stack]; - qreal nexts = stackSin[stack + 1]; - qreal c = stackCos[stack]; - qreal nextc = stackCos[stack + 1]; - qreal r = radius * s; - qreal nextr = radius * nexts; + float z = radius * stackCos[stack]; + float nextz = radius * stackCos[stack + 1]; + float s = stackSin[stack]; + float nexts = stackSin[stack + 1]; + float c = stackCos[stack]; + float nextc = stackCos[stack + 1]; + float r = radius * s; + float nextr = radius * nexts; for (int slice = 0; slice <= slices; ++slice) { prim.appendVertex(QVector3D(nextr * sliceSin[slice], nextr * sliceCos[slice], nextz)); prim.appendNormal(QVector3D(sliceSin[slice] * nexts, sliceCos[slice] * nexts, nextc)); - prim.appendTexCoord(QVector2D(1.0f - qreal(slice) / slices, 1.0f - qreal(stack + 1) / stacks)); + prim.appendTexCoord(QVector2D(1.0f - float(slice) / slices, 1.0f - float(stack + 1) / stacks)); prim.appendVertex(QVector3D(r * sliceSin[slice], r * sliceCos[slice], z)); prim.appendNormal(QVector3D(sliceSin[slice] * s, sliceCos[slice] * s, c)); - prim.appendTexCoord(QVector2D(1.0f - qreal(slice) / slices, 1.0f - qreal(stack) / stacks)); + prim.appendTexCoord(QVector2D(1.0f - float(slice) / slices, 1.0f - float(stack) / stacks)); } builder.addQuadStrip(prim); } @@ -238,12 +238,12 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLDome& dome) //Generate a circle of vertices for this layer. QGeometryData tempBase; - tempBase.appendVertex(QVector3D(0,0,0)); - tempBase.appendTexCoord(QVector2D(0.5,0.5)); + tempBase.appendVertex(QVector3D(0.0f, 0.0f, 0.0f)); + tempBase.appendTexCoord(QVector2D(0.5f, 0.5f)); for (int slice=0; slice<=slices+1; slice++) { - tempBase.appendVertex(QVector3D(radius * sliceCos[slice], radius * sliceSin[slice], 0)); - tempBase.appendTexCoord(QVector2D(0.5*sliceCos[slice]+0.5, 0.5*sliceSin[slice]+0.5)); + tempBase.appendVertex(QVector3D(radius * sliceCos[slice], radius * sliceSin[slice], 0.0f)); + tempBase.appendTexCoord(QVector2D(0.5f * sliceCos[slice] + 0.5f, 0.5f * sliceSin[slice] + 0.5f)); } //we need to reverse the above to draw it properly - windings! diff --git a/src/threed/geometry/qgldome.h b/src/threed/geometry/qgldome.h index 2fdeb8ece..df3301423 100644 --- a/src/threed/geometry/qgldome.h +++ b/src/threed/geometry/qgldome.h @@ -55,12 +55,12 @@ class QGLBuilder; class Q_QT3D_EXPORT QGLDome { public: - explicit QGLDome(qreal diameter = 1.0f, int depth = 3, bool baseEnabled = true) + explicit QGLDome(float diameter = 1.0f, int depth = 3, bool baseEnabled = true) : m_diameter(diameter), m_subdivisionDepth(depth), m_baseEnabled(baseEnabled) {} virtual ~QGLDome(); - qreal diameter() const { return m_diameter; } - void setDiameter(qreal diameter) { m_diameter = diameter; } + float diameter() const { return m_diameter; } + void setDiameter(float diameter) { m_diameter = diameter; } int subdivisionDepth() const { return m_subdivisionDepth; } void setSubdivisionDepth(int depth) { m_subdivisionDepth = depth; } @@ -69,7 +69,7 @@ public: void setBaseEnabled(bool baseEnabled) {m_baseEnabled = baseEnabled;} private: - qreal m_diameter; + float m_diameter; int m_subdivisionDepth; bool m_baseEnabled; }; diff --git a/src/threed/geometry/qglsphere.cpp b/src/threed/geometry/qglsphere.cpp index 737b8bba6..42f9f8a8a 100644 --- a/src/threed/geometry/qglsphere.cpp +++ b/src/threed/geometry/qglsphere.cpp @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QGLSphere::QGLSphere(qreal diameter, int depth) + \fn QGLSphere::QGLSphere(float diameter, int depth) Creates a sphere of \a diameter across (default is 1). When the sphere is recursively subdivided into triangles, it will be subdivided no more @@ -100,7 +100,7 @@ QGLSphere::~QGLSphere() } /*! - \fn qreal QGLSphere::diameter() const + \fn float QGLSphere::diameter() const Returns the diameter of this sphere. The default is 1. @@ -108,7 +108,7 @@ QGLSphere::~QGLSphere() */ /*! - \fn void QGLSphere::setDiameter(qreal diameter) + \fn void QGLSphere::setDiameter(float diameter) Sets the diameter of this sphere to \a diameter. @@ -157,7 +157,7 @@ QGLSphere::~QGLSphere() */ QGLBuilder& operator<<(QGLBuilder& builder, const QGLSphere& sphere) { - qreal radius = sphere.diameter() / 2.0f; + float radius = sphere.diameter() / 2.0f; // Determine the number of slices and stacks to generate. static int const slicesAndStacks[] = { @@ -183,19 +183,19 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLSphere& sphere) // Precompute sin/cos values for the slices and stacks. const int maxSlices = 128 + 1; const int maxStacks = 128 + 1; - qreal sliceSin[maxSlices]; - qreal sliceCos[maxSlices]; - qreal stackSin[maxStacks]; - qreal stackCos[maxStacks]; + float sliceSin[maxSlices]; + float sliceCos[maxSlices]; + float stackSin[maxStacks]; + float stackCos[maxStacks]; for (int slice = 0; slice < slices; ++slice) { - qreal angle = 2 * M_PI * slice / slices; + float angle = 2.0f * M_PI * slice / slices; sliceSin[slice] = qFastSin(angle); sliceCos[slice] = qFastCos(angle); } sliceSin[slices] = sliceSin[0]; // Join first and last slice. sliceCos[slices] = sliceCos[0]; for (int stack = 0; stack <= stacks; ++stack) { - qreal angle = M_PI * stack / stacks; + float angle = M_PI * stack / stacks; stackSin[stack] = qFastSin(angle); stackCos[stack] = qFastCos(angle); } @@ -205,14 +205,14 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLSphere& sphere) // Create the stacks. for (int stack = 0; stack < stacks; ++stack) { QGeometryData prim; - qreal z = radius * stackCos[stack]; - qreal nextz = radius * stackCos[stack + 1]; - qreal s = stackSin[stack]; - qreal nexts = stackSin[stack + 1]; - qreal c = stackCos[stack]; - qreal nextc = stackCos[stack + 1]; - qreal r = radius * s; - qreal nextr = radius * nexts; + float z = radius * stackCos[stack]; + float nextz = radius * stackCos[stack + 1]; + float s = stackSin[stack]; + float nexts = stackSin[stack + 1]; + float c = stackCos[stack]; + float nextc = stackCos[stack + 1]; + float r = radius * s; + float nextr = radius * nexts; for (int slice = 0; slice <= slices; ++slice) { prim.appendVertex (QVector3D(nextr * sliceSin[slice], @@ -221,8 +221,8 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLSphere& sphere) (QVector3D(sliceSin[slice] * nexts, sliceCos[slice] * nexts, nextc)); prim.appendTexCoord - (QVector2D(1.0f - qreal(slice) / slices, - 1.0f - qreal(stack + 1) / stacks)); + (QVector2D(1.0f - float(slice) / slices, + 1.0f - float(stack + 1) / stacks)); prim.appendVertex (QVector3D(r * sliceSin[slice], @@ -231,8 +231,8 @@ QGLBuilder& operator<<(QGLBuilder& builder, const QGLSphere& sphere) (QVector3D(sliceSin[slice] * s, sliceCos[slice] * s, c)); prim.appendTexCoord - (QVector2D(1.0f - qreal(slice) / slices, - 1.0f - qreal(stack) / stacks)); + (QVector2D(1.0f - float(slice) / slices, + 1.0f - float(stack) / stacks)); } builder.addQuadStrip(prim); } diff --git a/src/threed/geometry/qglsphere.h b/src/threed/geometry/qglsphere.h index 0dbc23eb6..45551e54f 100644 --- a/src/threed/geometry/qglsphere.h +++ b/src/threed/geometry/qglsphere.h @@ -55,18 +55,18 @@ class QGLBuilder; class Q_QT3D_EXPORT QGLSphere { public: - explicit QGLSphere(qreal diameter = 1.0f, int depth = 5) + explicit QGLSphere(float diameter = 1.0f, int depth = 5) : m_diameter(diameter), m_subdivisionDepth(depth) {} virtual ~QGLSphere(); - qreal diameter() const { return m_diameter; } - void setDiameter(qreal diameter) { m_diameter = diameter; } + float diameter() const { return m_diameter; } + void setDiameter(float diameter) { m_diameter = diameter; } int subdivisionDepth() const { return m_subdivisionDepth; } void setSubdivisionDepth(int depth) { m_subdivisionDepth = depth; } private: - qreal m_diameter; + float m_diameter; int m_subdivisionDepth; }; diff --git a/src/threed/graphicsview/qgraphicsrotation3d.cpp b/src/threed/graphicsview/qgraphicsrotation3d.cpp index 6fbbd8193..c3c15e14e 100644 --- a/src/threed/graphicsview/qgraphicsrotation3d.cpp +++ b/src/threed/graphicsview/qgraphicsrotation3d.cpp @@ -121,7 +121,7 @@ public: QVector3D origin; QVector3D axis; - qreal angle; + float angle; }; /*! @@ -184,13 +184,13 @@ void QGraphicsRotation3D::setOrigin(const QVector3D &value) The default value for this property is 0. */ -qreal QGraphicsRotation3D::angle() const +float QGraphicsRotation3D::angle() const { Q_D(const QGraphicsRotation3D); return d->angle; } -void QGraphicsRotation3D::setAngle(qreal value) +void QGraphicsRotation3D::setAngle(float value) { Q_D(QGraphicsRotation3D); if (d->angle != value) { diff --git a/src/threed/graphicsview/qgraphicsrotation3d.h b/src/threed/graphicsview/qgraphicsrotation3d.h index e59f775c7..aba6379c0 100644 --- a/src/threed/graphicsview/qgraphicsrotation3d.h +++ b/src/threed/graphicsview/qgraphicsrotation3d.h @@ -54,7 +54,7 @@ class Q_QT3D_EXPORT QGraphicsRotation3D : public QQuickQGraphicsTransform3D { Q_OBJECT Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged) - Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged) + Q_PROPERTY(float angle READ angle WRITE setAngle NOTIFY angleChanged) Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged) public: QGraphicsRotation3D(QObject *parent = 0); @@ -63,8 +63,8 @@ public: QVector3D origin() const; void setOrigin(const QVector3D &value); - qreal angle() const; - void setAngle(qreal value); + float angle() const; + void setAngle(float value); QVector3D axis() const; void setAxis(const QVector3D &value); diff --git a/src/threed/graphicsview/qgraphicstranslation3d.cpp b/src/threed/graphicsview/qgraphicstranslation3d.cpp index 495e72652..d331d3356 100644 --- a/src/threed/graphicsview/qgraphicstranslation3d.cpp +++ b/src/threed/graphicsview/qgraphicstranslation3d.cpp @@ -112,7 +112,7 @@ public: QGraphicsTranslation3DPrivate() : progress(1.0f) {} QVector3D translate; - qreal progress; + float progress; }; /*! @@ -182,13 +182,13 @@ void QGraphicsTranslation3D::setTranslate(const QVector3D &value) are also possible by setting the value to something outside this range. */ -qreal QGraphicsTranslation3D::progress() const +float QGraphicsTranslation3D::progress() const { Q_D(const QGraphicsTranslation3D); return d->progress; } -void QGraphicsTranslation3D::setProgress(qreal value) +void QGraphicsTranslation3D::setProgress(float value) { Q_D(QGraphicsTranslation3D); if (d->progress != value) { diff --git a/src/threed/graphicsview/qgraphicstranslation3d.h b/src/threed/graphicsview/qgraphicstranslation3d.h index 323a892d3..fe1ebfb82 100644 --- a/src/threed/graphicsview/qgraphicstranslation3d.h +++ b/src/threed/graphicsview/qgraphicstranslation3d.h @@ -55,7 +55,7 @@ class Q_QT3D_EXPORT QGraphicsTranslation3D : public QQuickQGraphicsTransform3D { Q_OBJECT Q_PROPERTY(QVector3D translate READ translate WRITE setTranslate NOTIFY translateChanged) - Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged) + Q_PROPERTY(float progress READ progress WRITE setProgress NOTIFY progressChanged) public: QGraphicsTranslation3D(QObject *parent = 0); ~QGraphicsTranslation3D(); @@ -63,8 +63,8 @@ public: QVector3D translate() const; void setTranslate(const QVector3D &value); - qreal progress() const; - void setProgress(qreal value); + float progress() const; + void setProgress(float value); void applyTo(QMatrix4x4 *matrix) const; QQuickQGraphicsTransform3D *clone(QObject *parent) const; diff --git a/src/threed/materials/qglmaterial.cpp b/src/threed/materials/qglmaterial.cpp index 3eb564d65..afce2cab4 100644 --- a/src/threed/materials/qglmaterial.cpp +++ b/src/threed/materials/qglmaterial.cpp @@ -263,13 +263,13 @@ void QGLMaterial::setColor(const QColor& value) this range will be clamped to the range when the property is set. */ -qreal QGLMaterial::shininess() const +float QGLMaterial::shininess() const { Q_D(const QGLMaterial); return d->shininess; } -void QGLMaterial::setShininess(qreal value) +void QGLMaterial::setShininess(float value) { Q_D(QGLMaterial); if (value < 0) diff --git a/src/threed/materials/qglmaterial.h b/src/threed/materials/qglmaterial.h index 22e9f777b..92b143a78 100644 --- a/src/threed/materials/qglmaterial.h +++ b/src/threed/materials/qglmaterial.h @@ -71,7 +71,7 @@ class Q_QT3D_EXPORT QGLMaterial : public QGLAbstractMaterial Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged) Q_PROPERTY(QColor specularColor READ specularColor WRITE setSpecularColor NOTIFY specularColorChanged) Q_PROPERTY(QColor emittedLight READ emittedLight WRITE setEmittedLight NOTIFY emittedLightChanged) - Q_PROPERTY(qreal shininess READ shininess WRITE setShininess NOTIFY shininessChanged) + Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged) Q_PROPERTY(QGLTexture2D *texture READ texture WRITE setTexture NOTIFY texturesChanged) Q_PROPERTY(QGLMaterial::TextureCombineMode textureCombineMode READ textureCombineMode WRITE setTextureCombineMode NOTIFY texturesChanged) Q_PROPERTY(QUrl textureUrl READ textureUrl WRITE setTextureUrl NOTIFY texturesChanged) @@ -93,8 +93,8 @@ public: void setColor(const QColor& value); - qreal shininess() const; - void setShininess(qreal value); + float shininess() const; + void setShininess(float value); QGLTexture2D *texture(int layer = 0) const; void setTexture(QGLTexture2D *value, int layer = 0); diff --git a/src/threed/painting/qgllightparameters.cpp b/src/threed/painting/qgllightparameters.cpp index 42b23a0f5..e9156b39e 100644 --- a/src/threed/painting/qgllightparameters.cpp +++ b/src/threed/painting/qgllightparameters.cpp @@ -159,12 +159,12 @@ public: QColor diffuseColor; QColor specularColor; QVector3D spotDirection; - qreal spotExponent; - qreal spotAngle; - qreal spotCosAngle; - qreal constantAttenuation; - qreal linearAttenuation; - qreal quadraticAttenuation; + float spotExponent; + float spotAngle; + float spotCosAngle; + float constantAttenuation; + float linearAttenuation; + float quadraticAttenuation; }; @@ -505,13 +505,13 @@ void QGLLightParameters::setSpotDirection(const QVector3D& vector) \sa spotAngle, position */ -qreal QGLLightParameters::spotExponent() const +float QGLLightParameters::spotExponent() const { Q_D(const QGLLightParameters); return d->spotExponent; } -void QGLLightParameters::setSpotExponent(qreal value) +void QGLLightParameters::setSpotExponent(float value) { Q_D(QGLLightParameters); if (d->spotExponent != value) { @@ -543,7 +543,7 @@ void QGLLightParameters::setSpotExponent(qreal value) This parameter has no effect on a Directional light. */ -qreal QGLLightParameters::spotAngle() const +float QGLLightParameters::spotAngle() const { Q_D(const QGLLightParameters); return d->spotAngle; @@ -553,13 +553,13 @@ qreal QGLLightParameters::spotAngle() const #define M_PI 3.14159265358979323846 #endif -void QGLLightParameters::setSpotAngle(qreal value) +void QGLLightParameters::setSpotAngle(float value) { Q_D(QGLLightParameters); if (d->spotAngle != value) { d->spotAngle = value; if (value != 180.0f) - d->spotCosAngle = qCos(value * M_PI / 180.0f); + d->spotCosAngle = cosf(value * M_PI / 180.0f); else d->spotCosAngle = -1.0f; emit spotAngleChanged(); @@ -577,7 +577,7 @@ void QGLLightParameters::setSpotAngle(qreal value) \sa spotAngle() */ -qreal QGLLightParameters::spotCosAngle() const +float QGLLightParameters::spotCosAngle() const { Q_D(const QGLLightParameters); return d->spotCosAngle; @@ -602,13 +602,13 @@ qreal QGLLightParameters::spotCosAngle() const \sa linearAttenuation, quadraticAttenuation */ -qreal QGLLightParameters::constantAttenuation() const +float QGLLightParameters::constantAttenuation() const { Q_D(const QGLLightParameters); return d->constantAttenuation; } -void QGLLightParameters::setConstantAttenuation(qreal value) +void QGLLightParameters::setConstantAttenuation(float value) { Q_D(QGLLightParameters); if (d->constantAttenuation != value) { @@ -637,13 +637,13 @@ void QGLLightParameters::setConstantAttenuation(qreal value) \sa constantAttenuation, quadraticAttenuation */ -qreal QGLLightParameters::linearAttenuation() const +float QGLLightParameters::linearAttenuation() const { Q_D(const QGLLightParameters); return d->linearAttenuation; } -void QGLLightParameters::setLinearAttenuation(qreal value) +void QGLLightParameters::setLinearAttenuation(float value) { Q_D(QGLLightParameters); if (d->linearAttenuation != value) { @@ -672,13 +672,13 @@ void QGLLightParameters::setLinearAttenuation(qreal value) \sa constantAttenuation, linearAttenuation */ -qreal QGLLightParameters::quadraticAttenuation() const +float QGLLightParameters::quadraticAttenuation() const { Q_D(const QGLLightParameters); return d->quadraticAttenuation; } -void QGLLightParameters::setQuadraticAttenuation(qreal value) +void QGLLightParameters::setQuadraticAttenuation(float value) { Q_D(QGLLightParameters); if (d->quadraticAttenuation != value) { diff --git a/src/threed/painting/qgllightparameters.h b/src/threed/painting/qgllightparameters.h index d64f7b623..ea5211f63 100644 --- a/src/threed/painting/qgllightparameters.h +++ b/src/threed/painting/qgllightparameters.h @@ -69,11 +69,11 @@ class Q_QT3D_EXPORT QGLLightParameters : public QObject Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged) Q_PROPERTY(QColor specularColor READ specularColor WRITE setSpecularColor NOTIFY specularColorChanged) Q_PROPERTY(QVector3D spotDirection READ spotDirection WRITE setSpotDirection NOTIFY spotDirectionChanged) - Q_PROPERTY(qreal spotExponent READ spotExponent WRITE setSpotExponent NOTIFY spotExponentChanged) - Q_PROPERTY(qreal spotAngle READ spotAngle WRITE setSpotAngle NOTIFY spotAngleChanged) - Q_PROPERTY(qreal constantAttenuation READ constantAttenuation WRITE setConstantAttenuation NOTIFY constantAttenuationChanged) - Q_PROPERTY(qreal linearAttenuation READ linearAttenuation WRITE setLinearAttenuation NOTIFY linearAttenuationChanged) - Q_PROPERTY(qreal quadraticAttenuation READ quadraticAttenuation WRITE setQuadraticAttenuation NOTIFY quadraticAttenuationChanged) + Q_PROPERTY(float spotExponent READ spotExponent WRITE setSpotExponent NOTIFY spotExponentChanged) + Q_PROPERTY(float spotAngle READ spotAngle WRITE setSpotAngle NOTIFY spotAngleChanged) + Q_PROPERTY(float constantAttenuation READ constantAttenuation WRITE setConstantAttenuation NOTIFY constantAttenuationChanged) + Q_PROPERTY(float linearAttenuation READ linearAttenuation WRITE setLinearAttenuation NOTIFY linearAttenuationChanged) + Q_PROPERTY(float quadraticAttenuation READ quadraticAttenuation WRITE setQuadraticAttenuation NOTIFY quadraticAttenuationChanged) public: enum LightType { Directional, @@ -103,22 +103,22 @@ public: QVector3D spotDirection() const; void setSpotDirection(const QVector3D& value); - qreal spotExponent() const; - void setSpotExponent(qreal value); + float spotExponent() const; + void setSpotExponent(float value); - qreal spotAngle() const; - void setSpotAngle(qreal value); + float spotAngle() const; + void setSpotAngle(float value); - qreal spotCosAngle() const; + float spotCosAngle() const; - qreal constantAttenuation() const; - void setConstantAttenuation(qreal value); + float constantAttenuation() const; + void setConstantAttenuation(float value); - qreal linearAttenuation() const; - void setLinearAttenuation(qreal value); + float linearAttenuation() const; + void setLinearAttenuation(float value); - qreal quadraticAttenuation() const; - void setQuadraticAttenuation(qreal value); + float quadraticAttenuation() const; + void setQuadraticAttenuation(float value); QVector4D eyePosition(const QMatrix4x4& transform) const; QVector3D eyeSpotDirection(const QMatrix4x4& transform) const; diff --git a/src/threed/painting/qglpainter.cpp b/src/threed/painting/qglpainter.cpp index f848c0b75..078334b11 100644 --- a/src/threed/painting/qglpainter.cpp +++ b/src/threed/painting/qglpainter.cpp @@ -710,7 +710,7 @@ QMatrix4x4 QGLPainter::combinedMatrix() const // Inverting the eye transformation will often result in values like // 1.5e-15 in the world matrix. Clamp these to zero to make worldMatrix() // more stable when removing the eye component of the modelViewMatrix(). -static inline qreal qt_gl_stablize_value(qreal value) +static inline float qt_gl_stablize_value(float value) { return (qAbs(value) >= 0.00001f) ? value : 0.0f; } @@ -928,7 +928,7 @@ QGLRenderSequencer *QGLPainter::renderSequencer() Returns the aspect ratio of the viewport for adjusting projection transformations. */ -qreal QGLPainter::aspectRatio() const +float QGLPainter::aspectRatio() const { return currentSurface()->aspectRatio(); } @@ -1535,30 +1535,12 @@ void QGLPainter::updateFixedFunction(QGLPainter::Updates updates) if ((updates & QGLPainter::UpdateModelViewMatrix) != 0) { const QMatrix4x4 &matrix = d->modelViewMatrix.top(); glMatrixMode(GL_MODELVIEW); - if (sizeof(qreal) == sizeof(GLfloat)) { - glLoadMatrixf(reinterpret_cast<const GLfloat *> - (matrix.constData())); - } else { - GLfloat mat[16]; - const float *m = matrix.constData(); - for (int index = 0; index < 16; ++index) - mat[index] = m[index]; - glLoadMatrixf(mat); - } + glLoadMatrixf(reinterpret_cast<const GLfloat *>(matrix.constData())); } if ((updates & QGLPainter::UpdateProjectionMatrix) != 0) { const QMatrix4x4 &matrix = d->projectionMatrix.top(); glMatrixMode(GL_PROJECTION); - if (sizeof(qreal) == sizeof(GLfloat)) { - glLoadMatrixf(reinterpret_cast<const GLfloat *> - (matrix.constData())); - } else { - GLfloat mat[16]; - const float *m = matrix.constData(); - for (int index = 0; index < 16; ++index) - mat[index] = m[index]; - glLoadMatrixf(mat); - } + glLoadMatrixf(reinterpret_cast<const GLfloat *>(matrix.constData())); } if ((updates & QGLPainter::UpdateLights) != 0) { // Save the current modelview matrix and load the identity. diff --git a/src/threed/painting/qglpainter.h b/src/threed/painting/qglpainter.h index db439312b..7259744bb 100644 --- a/src/threed/painting/qglpainter.h +++ b/src/threed/painting/qglpainter.h @@ -135,7 +135,7 @@ public: bool isCullable(const QBox3D& box) const; QGLRenderSequencer *renderSequencer(); - qreal aspectRatio() const; + float aspectRatio() const; QGLAbstractEffect *effect() const; diff --git a/src/threed/painting/qmatrix4x4stack.cpp b/src/threed/painting/qmatrix4x4stack.cpp index 1653c0351..8ab472e9a 100644 --- a/src/threed/painting/qmatrix4x4stack.cpp +++ b/src/threed/painting/qmatrix4x4stack.cpp @@ -226,7 +226,7 @@ QMatrix4x4Stack& QMatrix4x4Stack::operator*=(const QMatrix4x4& matrix) \sa scale(), rotate() */ -void QMatrix4x4Stack::translate(qreal x, qreal y, qreal z) +void QMatrix4x4Stack::translate(float x, float y, float z) { Q_D(QMatrix4x4Stack); d->matrix.translate(x, y, z); @@ -258,7 +258,7 @@ void QMatrix4x4Stack::translate(const QVector3D& vector) \sa translate(), rotate() */ -void QMatrix4x4Stack::scale(qreal x, qreal y, qreal z) +void QMatrix4x4Stack::scale(float x, float y, float z) { Q_D(QMatrix4x4Stack); d->matrix.scale(x, y, z); @@ -277,7 +277,7 @@ void QMatrix4x4Stack::scale(qreal x, qreal y, qreal z) \sa translate(), rotate() */ -void QMatrix4x4Stack::scale(qreal factor) +void QMatrix4x4Stack::scale(float factor) { Q_D(QMatrix4x4Stack); d->matrix.scale(factor); @@ -310,7 +310,7 @@ void QMatrix4x4Stack::scale(const QVector3D& vector) \sa scale(), translate() */ -void QMatrix4x4Stack::rotate(qreal angle, qreal x, qreal y, qreal z) +void QMatrix4x4Stack::rotate(float angle, float x, float y, float z) { Q_D(QMatrix4x4Stack); d->matrix.rotate(angle, x, y, z); @@ -323,7 +323,7 @@ void QMatrix4x4Stack::rotate(qreal angle, qreal x, qreal y, qreal z) \sa scale(), translate() */ -void QMatrix4x4Stack::rotate(qreal angle, const QVector3D& vector) +void QMatrix4x4Stack::rotate(float angle, const QVector3D& vector) { Q_D(QMatrix4x4Stack); d->matrix.rotate(angle, vector); diff --git a/src/threed/painting/qmatrix4x4stack.h b/src/threed/painting/qmatrix4x4stack.h index 167284277..a4019b46d 100644 --- a/src/threed/painting/qmatrix4x4stack.h +++ b/src/threed/painting/qmatrix4x4stack.h @@ -67,13 +67,13 @@ public: void setToIdentity(); - void translate(qreal x, qreal y, qreal z); + void translate(float x, float y, float z); void translate(const QVector3D& vector); - void scale(qreal x, qreal y, qreal z); - void scale(qreal factor); + void scale(float x, float y, float z); + void scale(float factor); void scale(const QVector3D& vector); - void rotate(qreal angle, qreal x, qreal y, qreal z); - void rotate(qreal angle, const QVector3D& vector); + void rotate(float angle, float x, float y, float z); + void rotate(float angle, const QVector3D& vector); void rotate(const QQuaternion &quaternion); QMatrix4x4Stack& operator=(const QMatrix4x4& matrix); diff --git a/src/threed/scene/qglscenenode.cpp b/src/threed/scene/qglscenenode.cpp index 7fdb0e445..c6d3c1df1 100644 --- a/src/threed/scene/qglscenenode.cpp +++ b/src/threed/scene/qglscenenode.cpp @@ -493,13 +493,13 @@ void QGLSceneNode::setPosition(const QVector3D &p) \sa position() */ -qreal QGLSceneNode::x() const +float QGLSceneNode::x() const { Q_D(const QGLSceneNode); return d->translate.x(); } -void QGLSceneNode::setX(qreal x) +void QGLSceneNode::setX(float x) { Q_D(QGLSceneNode); if (x != d->translate.x()) @@ -516,13 +516,13 @@ void QGLSceneNode::setX(qreal x) \sa position() */ -qreal QGLSceneNode::y() const +float QGLSceneNode::y() const { Q_D(const QGLSceneNode); return d->translate.y(); } -void QGLSceneNode::setY(qreal y) +void QGLSceneNode::setY(float y) { Q_D(QGLSceneNode); if (y != d->translate.y()) @@ -539,13 +539,13 @@ void QGLSceneNode::setY(qreal y) \sa position() */ -qreal QGLSceneNode::z() const +float QGLSceneNode::z() const { Q_D(const QGLSceneNode); return d->translate.z(); } -void QGLSceneNode::setZ(qreal z) +void QGLSceneNode::setZ(float z) { Q_D(QGLSceneNode); if (z != d->translate.z()) @@ -688,7 +688,7 @@ void QGLSceneNode::setDrawingMode(QGL::DrawingMode mode) \sa drawingMode() */ -qreal QGLSceneNode::drawingWidth() const +float QGLSceneNode::drawingWidth() const { Q_D(const QGLSceneNode); return d->drawingWidth; @@ -702,7 +702,7 @@ qreal QGLSceneNode::drawingWidth() const \sa drawingMode() */ -void QGLSceneNode::setDrawingWidth(qreal width) +void QGLSceneNode::setDrawingWidth(float width) { Q_D(QGLSceneNode); d->drawingWidth = width; diff --git a/src/threed/scene/qglscenenode.h b/src/threed/scene/qglscenenode.h index 607736acf..eacbccc3d 100644 --- a/src/threed/scene/qglscenenode.h +++ b/src/threed/scene/qglscenenode.h @@ -65,9 +65,9 @@ class Q_QT3D_EXPORT QGLSceneNode : public QObject Q_ENUMS(Option) Q_FLAGS(Options) Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY updated) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY updated) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY updated) - Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY updated) + Q_PROPERTY(float x READ x WRITE setX NOTIFY updated) + Q_PROPERTY(float y READ y WRITE setY NOTIFY updated) + Q_PROPERTY(float z READ z WRITE setZ NOTIFY updated) Q_PROPERTY(QGLMaterial *material READ material WRITE setMaterial NOTIFY updated) Q_PROPERTY(QGLMaterial *backMaterial READ backMaterial WRITE setBackMaterial NOTIFY updated) Q_PROPERTY(Options options READ options WRITE setOptions NOTIFY updated) @@ -99,12 +99,12 @@ public: void setLocalTransform(const QMatrix4x4 &); QVector3D position() const; void setPosition(const QVector3D &p); - qreal x() const; - void setX(qreal x); - qreal y() const; - void setY(qreal y); - qreal z() const; - void setZ(qreal z); + float x() const; + void setX(float x); + float y() const; + void setY(float y); + float z() const; + void setZ(float z); QList<QQuickQGraphicsTransform3D *> transforms() const; void setTransforms(const QList<QQuickQGraphicsTransform3D *> &transforms); @@ -113,8 +113,8 @@ public: QGL::DrawingMode drawingMode() const; void setDrawingMode(QGL::DrawingMode mode); - qreal drawingWidth() const; - void setDrawingWidth(qreal width); + float drawingWidth() const; + void setDrawingWidth(float width); QGL::StandardEffect effect() const; void setEffect(QGL::StandardEffect); diff --git a/src/threed/scene_bezier/qglbezierscenehandler.cpp b/src/threed/scene_bezier/qglbezierscenehandler.cpp index 3628098f1..51cba2bd5 100644 --- a/src/threed/scene_bezier/qglbezierscenehandler.cpp +++ b/src/threed/scene_bezier/qglbezierscenehandler.cpp @@ -106,7 +106,7 @@ QGLAbstractScene *QGLBezierSceneHandler::read() QVector3DArray vertices; for (int vertex = 0; vertex < vertexCount; ++vertex) { bool eoln = false; - qreal coords[3] = {0.0f, 0.0f, 0.0f}; + float coords[3] = {0.0f, 0.0f, 0.0f}; for (int index = 0; index < 3; ++index) { stream >> coords[index]; @@ -151,15 +151,15 @@ QGLAbstractScene *QGLBezierSceneHandler::read() // matrix.translate(0.0f, 0.0f, -1.5f); for (int vertex = 0; vertex < vertexCount; ++vertex) { QVector3D vec = vertices[vertex]; - qreal x = vec.x(); - qreal y = vec.y(); - qreal z = vec.z(); + float x = vec.x(); + float y = vec.y(); + float z = vec.z(); z -= 1.5f; x *= 0.5f; y *= 0.5f; z *= 0.5f; - qreal y2 = z; - qreal z2 = -y; + float y2 = z; + float z2 = -y; y = y2; z = z2; vertices[vertex] = QVector3D(x, y, z); diff --git a/src/threed/surfaces/qglabstractsurface.cpp b/src/threed/surfaces/qglabstractsurface.cpp index 9d70e61d4..8e4f4e320 100644 --- a/src/threed/surfaces/qglabstractsurface.cpp +++ b/src/threed/surfaces/qglabstractsurface.cpp @@ -344,7 +344,7 @@ QRect QGLAbstractSurface::viewportRect() const if the DPI in the horizontal vs vertical direction is not the same, that is, the pixels are not square. */ -qreal QGLAbstractSurface::aspectRatio() const +float QGLAbstractSurface::aspectRatio() const { Q_ASSERT(isValid()); @@ -354,7 +354,7 @@ qreal QGLAbstractSurface::aspectRatio() const return 1.0f; // Return the final aspect ratio based on viewport. - return (qreal)size.width() / (qreal)size.height(); + return float(size.width()) / float(size.height()); } /*! diff --git a/src/threed/surfaces/qglabstractsurface.h b/src/threed/surfaces/qglabstractsurface.h index 5f7905634..7187719b1 100644 --- a/src/threed/surfaces/qglabstractsurface.h +++ b/src/threed/surfaces/qglabstractsurface.h @@ -84,7 +84,7 @@ public: virtual void deactivate(QGLAbstractSurface *nextSurface = 0) = 0; virtual QRect viewportGL() const = 0; QRect viewportRect() const; - virtual qreal aspectRatio() const; + virtual float aspectRatio() const; bool switchTo(QGLAbstractSurface *nextSurface); virtual bool isValid() const; diff --git a/src/threed/viewing/qglcamera.cpp b/src/threed/viewing/qglcamera.cpp index a078b4bf9..b87b7532f 100644 --- a/src/threed/viewing/qglcamera.cpp +++ b/src/threed/viewing/qglcamera.cpp @@ -387,9 +387,9 @@ public: QGLCameraPrivate(); QGLCamera::ProjectionType projectionType; - qreal fieldOfView; - qreal nearPlane; - qreal farPlane; + float fieldOfView; + float nearPlane; + float farPlane; QSizeF viewSize; QSizeF minViewSize; int screenRotation; @@ -397,7 +397,7 @@ public: QVector3D upVector; QVector3D center; QVector3D viewVector; - qreal eyeSeparation; + float eyeSeparation; QVector3D motionAdjustment; QQuaternion motionQuaternion; bool adjustForAspectRatio; @@ -502,13 +502,13 @@ void QGLCamera::setProjectionType(QGLCamera::ProjectionType value) \sa projectionType */ -qreal QGLCamera::fieldOfView() const +float QGLCamera::fieldOfView() const { Q_D(const QGLCamera); return d->fieldOfView; } -void QGLCamera::setFieldOfView(qreal angle) +void QGLCamera::setFieldOfView(float angle) { Q_D(QGLCamera); if (d->fieldOfView != angle) { @@ -533,13 +533,13 @@ void QGLCamera::setFieldOfView(qreal angle) \sa farPlane */ -qreal QGLCamera::nearPlane() const +float QGLCamera::nearPlane() const { Q_D(const QGLCamera); return d->nearPlane; } -void QGLCamera::setNearPlane(qreal value) +void QGLCamera::setNearPlane(float value) { Q_D(QGLCamera); if (d->nearPlane != value) { @@ -564,13 +564,13 @@ void QGLCamera::setNearPlane(qreal value) \sa nearPlane */ -qreal QGLCamera::farPlane() const +float QGLCamera::farPlane() const { Q_D(const QGLCamera); return d->farPlane; } -void QGLCamera::setFarPlane(qreal value) +void QGLCamera::setFarPlane(float value) { Q_D(QGLCamera); if (d->farPlane != value) { @@ -727,7 +727,7 @@ void QGLCamera::setEye(const QVector3D& vertex) \sa eye(), setEye(), translateCenter() */ -void QGLCamera::translateEye(qreal x, qreal y, qreal z) +void QGLCamera::translateEye(float x, float y, float z) { Q_D(QGLCamera); d->eye += translation(x, y, z); @@ -805,7 +805,7 @@ void QGLCamera::setCenter(const QVector3D& vertex) \sa center(), setCenter(), translateEye() */ -void QGLCamera::translateCenter(qreal x, qreal y, qreal z) +void QGLCamera::translateCenter(float x, float y, float z) { Q_D(QGLCamera); d->center += translation(x, y, z); @@ -831,13 +831,13 @@ void QGLCamera::translateCenter(qreal x, qreal y, qreal z) \sa eye */ -qreal QGLCamera::eyeSeparation() const +float QGLCamera::eyeSeparation() const { Q_D(const QGLCamera); return d->eyeSeparation; } -void QGLCamera::setEyeSeparation(qreal value) +void QGLCamera::setEyeSeparation(float value) { Q_D(QGLCamera); if (d->eyeSeparation != value) { @@ -893,8 +893,8 @@ void QGLCamera::setMotionAdjustment(const QVector3D& vector) QVector3D view = -vector.normalized(); if (view.z() < 0.0f) view = -view; - qreal xangle = asin(view.x()) * 180.0f / M_PI; - qreal yangle = asin(-view.y()) * 180.0f / M_PI; + float xangle = asinf(view.x()) * 180.0f / M_PI; + float yangle = asinf(-view.y()) * 180.0f / M_PI; // Construct the pan and tilt quaternions. if (qFuzzyIsNull(xangle)) @@ -957,7 +957,7 @@ void QGLCamera::setAdjustForAspectRatio(bool value) \sa pan(), roll(), rotateEye(), rotateCenter() */ -QQuaternion QGLCamera::tilt(qreal angle) const +QQuaternion QGLCamera::tilt(float angle) const { Q_D(const QGLCamera); QVector3D side = QVector3D::crossProduct(d->viewVector, d->upVector); @@ -972,7 +972,7 @@ QQuaternion QGLCamera::tilt(qreal angle) const \sa tilt(), roll(), rotateEye(), rotateCenter() */ -QQuaternion QGLCamera::pan(qreal angle) const +QQuaternion QGLCamera::pan(float angle) const { Q_D(const QGLCamera); return QQuaternion::fromAxisAndAngle(d->upVector, angle); @@ -986,7 +986,7 @@ QQuaternion QGLCamera::pan(qreal angle) const \sa tilt(), pan(), rotateEye(), rotateCenter() */ -QQuaternion QGLCamera::roll(qreal angle) const +QQuaternion QGLCamera::roll(float angle) const { Q_D(const QGLCamera); return QQuaternion::fromAxisAndAngle(d->viewVector, angle); @@ -1044,7 +1044,7 @@ void QGLCamera::rotateCenter(const QQuaternion& q) \sa translateEye(), translateCenter() */ -QVector3D QGLCamera::translation(qreal x, qreal y, qreal z) const +QVector3D QGLCamera::translation(float x, float y, float z) const { Q_D(const QGLCamera); QVector3D vector(0.0f, 0.0f, 0.0f); @@ -1069,14 +1069,14 @@ QVector3D QGLCamera::translation(qreal x, qreal y, qreal z) const \sa modelViewMatrix() */ -QMatrix4x4 QGLCamera::projectionMatrix(qreal aspectRatio) const +QMatrix4x4 QGLCamera::projectionMatrix(float aspectRatio) const { Q_D(const QGLCamera); QMatrix4x4 m; if (!d->adjustForAspectRatio) aspectRatio = 1.0f; if (d->screenRotation != 0) { - m.rotate((qreal)(d->screenRotation), 0.0f, 0.0f, 1.0f); + m.rotate(float(d->screenRotation), 0.0f, 0.0f, 1.0f); if (d->screenRotation == 90 || d->screenRotation == 270) { if (aspectRatio != 0.0f) aspectRatio = 1.0f / aspectRatio; @@ -1086,8 +1086,8 @@ QMatrix4x4 QGLCamera::projectionMatrix(qreal aspectRatio) const m.perspective(d->fieldOfView, aspectRatio, d->nearPlane, d->farPlane); } else { - qreal halfWidth = d->viewSize.width() / 2.0f; - qreal halfHeight = d->viewSize.height() / 2.0f; + float halfWidth = d->viewSize.width() / 2.0f; + float halfHeight = d->viewSize.height() / 2.0f; if (aspectRatio > 1.0f) { halfWidth *= aspectRatio; } else if (aspectRatio > 0.0f && aspectRatio < 1.0f) { @@ -1146,7 +1146,7 @@ QMatrix4x4 QGLCamera::modelViewMatrix(QGL::Eye eye) const into eye co-ordinates within the current camera view. */ QVector3D QGLCamera::mapPoint - (const QPoint& point, qreal aspectRatio, const QSize& viewportSize) const + (const QPoint& point, float aspectRatio, const QSize& viewportSize) const { Q_D(const QGLCamera); @@ -1178,13 +1178,13 @@ QVector3D QGLCamera::mapPoint // (unless the point was outside the viewport). The yrel is // flipped upside down to account for the incoming co-ordinate // being left-handed, but the world being right-handed. - qreal xrel, yrel; + float xrel, yrel; if (width) - xrel = (((qreal)(x * 2)) - (qreal)width) / (qreal)width; + xrel = ((float(x * 2)) - float(width)) / float(width); else xrel = 0.0f; if (height) - yrel = -(((qreal)(y * 2)) - (qreal)height) / (qreal)height; + yrel = -((float(y * 2)) - float(height)) / float(height); else yrel = 0.0f; @@ -1243,7 +1243,7 @@ QVector3D QGLCamera::mapPoint \sa tiltPanRollEye() */ void QGLCamera::tiltPanRollCenter - (qreal tiltAngle, qreal panAngle, qreal rollAngle, + (float tiltAngle, float panAngle, float rollAngle, QGLCamera::RotateOrder order) { switch (order) { @@ -1283,7 +1283,7 @@ void QGLCamera::tiltPanRollCenter \sa tiltPanRollCenter() */ void QGLCamera::tiltPanRollEye - (qreal tiltAngle, qreal panAngle, qreal rollAngle, + (float tiltAngle, float panAngle, float rollAngle, QGLCamera::RotateOrder order) { switch (order) { diff --git a/src/threed/viewing/qglcamera.h b/src/threed/viewing/qglcamera.h index 2f7b0e3a5..a916afc09 100644 --- a/src/threed/viewing/qglcamera.h +++ b/src/threed/viewing/qglcamera.h @@ -64,16 +64,16 @@ class Q_QT3D_EXPORT QGLCamera : public QObject Q_OBJECT Q_ENUMS(ProjectionType RotateOrder) Q_PROPERTY(ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionChanged) - Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY projectionChanged) - Q_PROPERTY(qreal nearPlane READ nearPlane WRITE setNearPlane NOTIFY projectionChanged) - Q_PROPERTY(qreal farPlane READ farPlane WRITE setFarPlane NOTIFY projectionChanged) + Q_PROPERTY(float fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY projectionChanged) + Q_PROPERTY(float nearPlane READ nearPlane WRITE setNearPlane NOTIFY projectionChanged) + Q_PROPERTY(float farPlane READ farPlane WRITE setFarPlane NOTIFY projectionChanged) Q_PROPERTY(QSizeF viewSize READ viewSize WRITE setViewSize NOTIFY projectionChanged SCRIPTABLE false) Q_PROPERTY(QSizeF minViewSize READ minViewSize WRITE setMinViewSize NOTIFY projectionChanged SCRIPTABLE false) Q_PROPERTY(int screenRotation READ screenRotation WRITE setScreenRotation NOTIFY projectionChanged SCRIPTABLE false) Q_PROPERTY(QVector3D eye READ eye WRITE setEye NOTIFY viewChanged) Q_PROPERTY(QVector3D upVector READ upVector WRITE setUpVector NOTIFY viewChanged) Q_PROPERTY(QVector3D center READ center WRITE setCenter NOTIFY viewChanged) - Q_PROPERTY(qreal eyeSeparation READ eyeSeparation WRITE setEyeSeparation NOTIFY viewChanged) + Q_PROPERTY(float eyeSeparation READ eyeSeparation WRITE setEyeSeparation NOTIFY viewChanged) Q_PROPERTY(QVector3D motionAdjustment READ motionAdjustment WRITE setMotionAdjustment DESIGNABLE false NOTIFY viewChanged SCRIPTABLE false) Q_PROPERTY(bool adjustForAspectRatio READ adjustForAspectRatio WRITE setAdjustForAspectRatio NOTIFY viewChanged) public: @@ -89,14 +89,14 @@ public: QGLCamera::ProjectionType projectionType() const; void setProjectionType(QGLCamera::ProjectionType value); - qreal fieldOfView() const; - void setFieldOfView(qreal angle); + float fieldOfView() const; + void setFieldOfView(float angle); - qreal nearPlane() const; - void setNearPlane(qreal value); + float nearPlane() const; + void setNearPlane(float value); - qreal farPlane() const; - void setFarPlane(qreal value); + float farPlane() const; + void setFarPlane(float value); QSizeF viewSize() const; void setViewSize(const QSizeF& size); @@ -116,8 +116,8 @@ public: QVector3D center() const; void setCenter(const QVector3D& vertex); - qreal eyeSeparation() const; - void setEyeSeparation(qreal value); + float eyeSeparation() const; + void setEyeSeparation(float value); QVector3D motionAdjustment() const; void setMotionAdjustment(const QVector3D& vector); @@ -125,20 +125,20 @@ public: bool adjustForAspectRatio() const; void setAdjustForAspectRatio(bool value); - QQuaternion tilt(qreal angle) const; - QQuaternion pan(qreal angle) const; - QQuaternion roll(qreal angle) const; + QQuaternion tilt(float angle) const; + QQuaternion pan(float angle) const; + QQuaternion roll(float angle) const; void rotateEye(const QQuaternion& q); void rotateCenter(const QQuaternion& q); - QVector3D translation(qreal x, qreal y, qreal z) const; + QVector3D translation(float x, float y, float z) const; - QMatrix4x4 projectionMatrix(qreal aspectRatio) const; + QMatrix4x4 projectionMatrix(float aspectRatio) const; QMatrix4x4 modelViewMatrix(QGL::Eye eye = QGL::NoEye) const; QVector3D mapPoint - (const QPoint& point, qreal aspectRatio, + (const QPoint& point, float aspectRatio, const QSize& viewportSize) const; enum RotateOrder @@ -154,12 +154,12 @@ public: QGLCamera *clone(QObject *parent = 0) const; public Q_SLOTS: - void translateEye(qreal x, qreal y, qreal z); - void translateCenter(qreal x, qreal y, qreal z); + void translateEye(float x, float y, float z); + void translateCenter(float x, float y, float z); - void tiltPanRollCenter(qreal tiltAngle, qreal panAngle, qreal rollAngle, + void tiltPanRollCenter(float tiltAngle, float panAngle, float rollAngle, QGLCamera::RotateOrder order = TiltPanRoll); - void tiltPanRollEye(qreal tiltAngle, qreal panAngle, qreal rollAngle, + void tiltPanRollEye(float tiltAngle, float panAngle, float rollAngle, QGLCamera::RotateOrder order = TiltPanRoll); Q_SIGNALS: diff --git a/src/threed/viewing/qglcameraanimation.cpp b/src/threed/viewing/qglcameraanimation.cpp index cf20a1eca..be7d7ea1d 100644 --- a/src/threed/viewing/qglcameraanimation.cpp +++ b/src/threed/viewing/qglcameraanimation.cpp @@ -105,17 +105,17 @@ public: // Derived values for use during the animation. PointOfRotation pointOfRotation; QVector3D upVectorAxis; - qreal upVectorAngle; + float upVectorAngle; QVector3D pointAxis; - qreal pointAngle; + float pointAngle; QVector3D centerTranslate; QVector3D eyeTranslate; - qreal lengthStart; - qreal lengthEnd; + float lengthStart; + float lengthEnd; static void rotateBetween(const QVector3D &start, const QVector3D &end, const QVector3D &defaultAxis, - QVector3D *rotationAxis, qreal *rotationAngle); + QVector3D *rotationAxis, float *rotationAngle); void deriveRotations(); }; @@ -131,7 +131,7 @@ static inline bool fuzzyCompareVectors(const QVector3D &v1, const QVector3D &v2) // or "defaultAxis" if the cross-product is zero (180 degree rotation). void QGLCameraAnimationPrivate::rotateBetween (const QVector3D &start, const QVector3D &end, const QVector3D &defaultAxis, - QVector3D *rotationAxis, qreal *rotationAngle) + QVector3D *rotationAxis, float *rotationAngle) { QVector3D nstart = start.normalized(); QVector3D nend = end.normalized(); @@ -448,8 +448,8 @@ void QGLCameraAnimation::updateCurrentTime(int currentTime) } // Calculate the progress and modify it with the easing curve. - qreal progress = d->easingCurve.valueForProgress - (qreal(currentTime) / qreal(d->duration)); + float progress = d->easingCurve.valueForProgress + (float(currentTime) / float(d->duration)); // Calculate the new eye and center locations. QVector3D eye = d->startEye; @@ -460,7 +460,7 @@ void QGLCameraAnimation::updateCurrentTime(int currentTime) (d->pointAxis, d->pointAngle * progress); eye = q.rotatedVector(eye - d->startCenter); if (d->lengthStart != d->lengthEnd) { - qreal length = (1.0f - progress) * d->lengthStart + + float length = (1.0f - progress) * d->lengthStart + progress * d->lengthEnd; eye = eye.normalized() * length; } @@ -472,7 +472,7 @@ void QGLCameraAnimation::updateCurrentTime(int currentTime) (d->pointAxis, d->pointAngle * progress * 2.0f); eye = q.rotatedVector(eye - d->startCenter); if (d->lengthStart != d->lengthEnd) { - qreal length = (1.0f - progress) * d->lengthStart + + float length = (1.0f - progress) * d->lengthStart + progress * d->lengthEnd; eye = eye.normalized() * length; } @@ -493,7 +493,7 @@ void QGLCameraAnimation::updateCurrentTime(int currentTime) (d->pointAxis, d->pointAngle * progress); center = q.rotatedVector(center - d->startEye); if (d->lengthStart != d->lengthEnd) { - qreal length = (1.0f - progress) * d->lengthStart + + float length = (1.0f - progress) * d->lengthStart + progress * d->lengthEnd; center = center.normalized() * length; } @@ -505,7 +505,7 @@ void QGLCameraAnimation::updateCurrentTime(int currentTime) (d->pointAxis, d->pointAngle * progress * 2.0f); center = q.rotatedVector(center - d->startEye); if (d->lengthStart != d->lengthEnd) { - qreal length = (1.0f - progress) * d->lengthStart + + float length = (1.0f - progress) * d->lengthStart + progress * d->lengthEnd; center = center.normalized() * length; } diff --git a/src/threed/viewing/qglview.cpp b/src/threed/viewing/qglview.cpp index 4af11adc3..39274b057 100644 --- a/src/threed/viewing/qglview.cpp +++ b/src/threed/viewing/qglview.cpp @@ -412,16 +412,16 @@ class QGLViewSubsurface : public QGLSubsurface { public: QGLViewSubsurface(QGLAbstractSurface *surface, const QRect ®ion, - qreal adjust) + float adjust) : QGLSubsurface(surface, region), m_adjust(adjust) {} - qreal aspectRatio() const; + float aspectRatio() const; private: - qreal m_adjust; + float m_adjust; }; -qreal QGLViewSubsurface::aspectRatio() const +float QGLViewSubsurface::aspectRatio() const { return QGLSubsurface::aspectRatio() * m_adjust; } @@ -430,7 +430,7 @@ qreal QGLViewSubsurface::aspectRatio() const QGLAbstractSurface *QGLViewPrivate::leftEyeSurface(const QSize &size) { QRect viewport; - qreal adjust = 1.0f; + float adjust = 1.0f; switch (stereoType) { case QGLView::Hardware: #if defined(GL_BACK_LEFT) && defined(GL_BACK_RIGHT) @@ -494,7 +494,7 @@ QGLAbstractSurface *QGLViewPrivate::leftEyeSurface(const QSize &size) QGLAbstractSurface *QGLViewPrivate::rightEyeSurface(const QSize &size) { QRect viewport; - qreal adjust = 1.0f; + float adjust = 1.0f; switch (stereoType) { case QGLView::Hardware: #if defined(GL_BACK_LEFT) && defined(GL_BACK_RIGHT) @@ -789,7 +789,7 @@ void QGLView::setCamera(QGLCamera *value) QVector3D QGLView::mapPoint(const QPoint &point) const { QSize viewportSize(size()); - qreal aspectRatio; + float aspectRatio; // Get the size of the underlying paint device. int width = viewportSize.width(); @@ -801,7 +801,7 @@ QVector3D QGLView::mapPoint(const QPoint &point) const if (width <= 0 || height <= 0) aspectRatio = 1.0f; else - aspectRatio = (qreal)width / (qreal)height; + aspectRatio = float(width) / float(height); // Map the point into eye co-ordinates. return d->camera->mapPoint(point, aspectRatio, viewportSize); @@ -1223,7 +1223,7 @@ void QGLView::wheelEvent(QWheelEvent *e) void QGLView::keyPressEvent(QKeyEvent *e) { QGLCamera *camera; - qreal sep; + float sep; // process the key only if we're doing camera navigation, or we // have received a Quit action @@ -1467,14 +1467,14 @@ void QGLView::wheel(int delta) { if (d->options & QGLView::FOVZoom) { //Use field-of view as zoom (much like a traditional camera) - qreal scale = qAbs(viewDelta(delta, delta).x()); + float scale = qAbs(viewDelta(delta, delta).x()); if (delta < 0) scale = -scale; if (scale >= 0.0f) scale += 1.0f; else scale = 1.0f / (1.0f - scale); - qreal fov = d->camera->fieldOfView(); + float fov = d->camera->fieldOfView(); if (fov != 0.0f) d->camera->setFieldOfView(d->camera->fieldOfView() / scale); else @@ -1483,8 +1483,8 @@ void QGLView::wheel(int delta) // enable this to get wheel navigation that actually zooms by moving the // camera back, as opposed to making the angle of view wider. QVector3D viewVector= camera()->eye() - camera()->center(); - qreal zoomMag = viewVector.length(); - qreal zoomIncrement = -float(delta) / 100.0f; + float zoomMag = viewVector.length(); + float zoomIncrement = -float(delta) / 100.0f; if (!qFuzzyIsNull(zoomIncrement)) { zoomMag += zoomIncrement; @@ -1526,8 +1526,8 @@ void QGLView::rotate(int deltax, int deltay) if (rotation == 180 || rotation == 270) { deltay = -deltay; } - qreal anglex = deltax * 90.0f / width(); - qreal angley = deltay * 90.0f / height(); + float anglex = deltax * 90.0f / width(); + float angley = deltay * 90.0f / height(); QQuaternion q = d->camera->pan(-anglex); q *= d->camera->tilt(-angley); d->camera->rotateCenter(q); @@ -1550,7 +1550,7 @@ QPointF QGLView::viewDelta(int deltax, int deltay) const int w = width(); int h = height(); bool scaleToWidth; - qreal scaleFactor, scaleX, scaleY; + float scaleFactor, scaleX, scaleY; QSizeF viewSize = d->camera->viewSize(); if (w >= h) { if (viewSize.width() >= viewSize.height()) @@ -1576,12 +1576,12 @@ QPointF QGLView::viewDelta(int deltax, int deltay) const } if (scaleToWidth) { scaleFactor = 2.0f / viewSize.width(); - scaleX = scaleFactor * ((qreal)h) / ((qreal)w); + scaleX = scaleFactor * float(h) / float(w); scaleY = scaleFactor; } else { scaleFactor = 2.0f / viewSize.height(); scaleX = scaleFactor; - scaleY = scaleFactor * ((qreal)w) / ((qreal)h); + scaleY = scaleFactor * float(w) / float(h); } return QPointF(deltax * scaleX / w, deltay * scaleY / h); } diff --git a/tests/auto/imports/qcapsulemesh/tst_qcapsulemesh.cpp b/tests/auto/imports/qcapsulemesh/tst_qcapsulemesh.cpp index 03e98a19c..a66741c4b 100644 --- a/tests/auto/imports/qcapsulemesh/tst_qcapsulemesh.cpp +++ b/tests/auto/imports/qcapsulemesh/tst_qcapsulemesh.cpp @@ -159,7 +159,7 @@ void tst_QCapsuleMesh::testGeometry() unsigned int ii0 = ib.at(i); QVERIFY(ii0<(unsigned int)verts.size()); QVector3D vv0 = verts.at(ii0); - qreal vv0sq = (vv0-QVector3D(0,0,vv0.z())).lengthSquared(); + float vv0sq = (vv0-QVector3D(0,0,vv0.z())).lengthSquared(); QVERIFY(fabs(vv0sq-0.25)<0.0001); // vertex is on cylinder QVector3D nn0 = norms.at(ii0); QVERIFY((fabs(QVector3D::dotProduct(nn0,(vv0-QVector3D(0,0,vv0.z()))))-1.0) < 0.0001); // vertex normal points to the same direction as vertex @@ -167,7 +167,7 @@ void tst_QCapsuleMesh::testGeometry() unsigned int ii1 = ib.at(i+1); QVERIFY(ii1<(unsigned int)verts.size()); QVector3D vv1 = verts.at(ii1); - qreal vv1sq = (vv1-QVector3D(0,0,vv1.z())).lengthSquared(); + float vv1sq = (vv1-QVector3D(0,0,vv1.z())).lengthSquared(); QVERIFY(fabs(vv1sq-0.25)<0.0001); // vertex is on cylinder QVector3D nn1 = norms.at(ii1); QVERIFY((fabs(QVector3D::dotProduct(nn1,(vv1-QVector3D(0,0,vv1.z()))))-1.0) < 0.0001); // vertex normal points to the same direction as vertex @@ -175,15 +175,16 @@ void tst_QCapsuleMesh::testGeometry() unsigned int ii2 = ib.at(i+2); QVERIFY(ii2<(unsigned int)verts.size()); QVector3D vv2 = verts.at(ii2); - qreal vv2sq = (vv2-QVector3D(0,0,vv2.z())).lengthSquared(); + float vv2sq = (vv2-QVector3D(0,0,vv2.z())).lengthSquared(); QVERIFY(fabs(vv2sq-0.25)<0.0001); // vertex is on cylinder QVector3D nn2 = norms.at(ii2); QVERIFY((fabs(QVector3D::dotProduct(nn2,(vv2-QVector3D(0,0,vv2.z()))))-1.0) < 0.0001); // vertex normal points to the same direction as vertex QVector3D triangleNormal = QVector3D::crossProduct(vv1-vv0,vv2-vv0); triangleNormal.normalize(); - qreal dp = QVector3D::dotProduct(triangleNormal,nn0); - QVERIFY(dp>0.9238 && dp<=1.0); // triangle normal points in approx the same dir as one of vertex normals. Max deviation is 22.5 degrees. + float dp = QVector3D::dotProduct(triangleNormal,nn0); + const float epsilon = 1.0e-5f; + QVERIFY(dp - 0.9238f > -epsilon && dp - 1.0f <= epsilon); // triangle normal points in approx the same dir as one of vertex normals. Max deviation is 22.5 degrees. } } { @@ -211,30 +212,30 @@ void tst_QCapsuleMesh::testGeometry() unsigned int ii0 = ib.at(i); QVERIFY(ii0<(unsigned int)verts.size()); QVector3D vv0 = verts.at(ii0); - qreal vv0sq = vv0.lengthSquared(); + float vv0sq = vv0.lengthSquared(); QVERIFY(fabs(vv0sq-0.25)<0.0001); // vertex is on dome QVector3D nn0 = norms.at(ii0); - qreal nn0sq = nn0.lengthSquared(); + float nn0sq = nn0.lengthSquared(); QVERIFY(fabs(nn0sq-1.0)<0.0001); // normal has unit length QVERIFY(fabs(QVector3D::dotProduct(nn0,vv0)-0.5) < 0.0001); // vertex normal points to the same direction as vertex unsigned int ii1 = ib.at(i+1); QVERIFY(ii1<(unsigned int)verts.size()); QVector3D vv1 = verts.at(ii1); - qreal vv1sq = vv1.lengthSquared(); + float vv1sq = vv1.lengthSquared(); QVERIFY(fabs(vv1sq-0.25)<0.0001); // vertex is on dome QVector3D nn1 = norms.at(ii1); - qreal nn1sq = nn1.lengthSquared(); + float nn1sq = nn1.lengthSquared(); QVERIFY(fabs(nn1sq-1.0)<0.0001); // normal has unit length QVERIFY(fabs(QVector3D::dotProduct(nn1,vv1)-0.5) < 0.0001); // vertex normal points to the same direction as vertex unsigned int ii2 = ib.at(i+2); QVERIFY(ii2<(unsigned int)verts.size()); QVector3D vv2 = verts.at(ii2); - qreal vv2sq = vv2.lengthSquared(); + float vv2sq = vv2.lengthSquared(); QVERIFY(fabs(vv2sq-0.25)<0.0001); // vertex is on cylinder QVector3D nn2 = norms.at(ii2); - qreal nn2sq = nn2.lengthSquared(); + float nn2sq = nn2.lengthSquared(); QVERIFY(fabs(nn2sq-1.0)<0.0001); // normal has unit length QVERIFY(fabs(QVector3D::dotProduct(nn2,vv2)-0.5) < 0.0001); // vertex normal points to the same direction as vertex @@ -247,7 +248,7 @@ void tst_QCapsuleMesh::testGeometry() QVector3D triangleNormal = QVector3D::crossProduct(vvv0,vvv1); if (triangleNormal.lengthSquared()>0.001) { triangleNormal.normalize(); - qreal dp = QVector3D::dotProduct(triangleNormal,nn0); + float dp = QVector3D::dotProduct(triangleNormal,nn0); QVERIFY(dp<-0.8628); } } @@ -279,30 +280,30 @@ void tst_QCapsuleMesh::testGeometry() unsigned int ii0 = ib.at(i); QVERIFY(ii0<(unsigned int)verts.size()); QVector3D vv0 = verts.at(ii0); - qreal vv0sq = vv0.lengthSquared(); + float vv0sq = vv0.lengthSquared(); QVERIFY(fabs(vv0sq-0.25)<0.0001); // vertex is on dome QVector3D nn0 = norms.at(ii0); - qreal nn0sq = nn0.lengthSquared(); + float nn0sq = nn0.lengthSquared(); QVERIFY(fabs(nn0sq-1.0)<0.0001); // normal has unit length QVERIFY(fabs(QVector3D::dotProduct(nn0,vv0)-0.5) < 0.0001); // vertex normal points to the same direction as vertex unsigned int ii1 = ib.at(i+1); QVERIFY(ii1<(unsigned int)verts.size()); QVector3D vv1 = verts.at(ii1); - qreal vv1sq = vv1.lengthSquared(); + float vv1sq = vv1.lengthSquared(); QVERIFY(fabs(vv1sq-0.25)<0.0001); // vertex is on dome QVector3D nn1 = norms.at(ii1); - qreal nn1sq = nn1.lengthSquared(); + float nn1sq = nn1.lengthSquared(); QVERIFY(fabs(nn1sq-1.0)<0.0001); // normal has unit length QVERIFY(fabs(QVector3D::dotProduct(nn1,vv1)-0.5) < 0.0001); // vertex normal points to the same direction as vertex unsigned int ii2 = ib.at(i+2); QVERIFY(ii2<(unsigned int)verts.size()); QVector3D vv2 = verts.at(ii2); - qreal vv2sq = vv2.lengthSquared(); + float vv2sq = vv2.lengthSquared(); QVERIFY(fabs(vv2sq-0.25)<0.0001); // vertex is on cylinder QVector3D nn2 = norms.at(ii2); - qreal nn2sq = nn2.lengthSquared(); + float nn2sq = nn2.lengthSquared(); QVERIFY(fabs(nn2sq-1.0)<0.0001); // normal has unit length QVERIFY(fabs(QVector3D::dotProduct(nn2,vv2)-0.5) < 0.0001); // vertex normal points to the same direction as vertex @@ -315,7 +316,7 @@ void tst_QCapsuleMesh::testGeometry() QVector3D triangleNormal = QVector3D::crossProduct(vvv0,vvv1); if (triangleNormal.lengthSquared()>0.001) { triangleNormal.normalize(); - qreal dp = QVector3D::dotProduct(triangleNormal,nn0); + float dp = QVector3D::dotProduct(triangleNormal,nn0); QVERIFY(dp<-0.8628); } } diff --git a/tests/auto/imports/qcylindermesh/tst_qcylindermesh.cpp b/tests/auto/imports/qcylindermesh/tst_qcylindermesh.cpp index 61211b6e8..28c97b864 100644 --- a/tests/auto/imports/qcylindermesh/tst_qcylindermesh.cpp +++ b/tests/auto/imports/qcylindermesh/tst_qcylindermesh.cpp @@ -135,7 +135,7 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii0 = ib.at(i); QVERIFY(ii0<(unsigned int)verts.size()); QVector3D vv0 = verts.at(ii0); - qreal vv0sq = (vv0-QVector3D(0,0,0.5)).lengthSquared(); + float vv0sq = (vv0-QVector3D(0,0,0.5)).lengthSquared(); QVERIFY(fabs(vv0sq)<0.0001 || fabs(vv0sq-1.0)<0.0001); // vertex is either in center or on circle QVector3D nn0 = norms.at(ii0); QVERIFY((fabs(QVector3D::dotProduct(nn0,QVector3D(0,0,1)))-1.0) < 0.0001); // vertex normal == {0,0,1} @@ -143,7 +143,7 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii1 = ib.at(i+1); QVERIFY(ii1<(unsigned int)verts.size()); QVector3D vv1 = verts.at(ii1); - qreal vv1sq = (vv1-QVector3D(0,0,0.5)).lengthSquared(); + float vv1sq = (vv1-QVector3D(0,0,0.5)).lengthSquared(); QVERIFY(fabs(vv1sq)<0.0001 || fabs(vv1sq-1.0)<0.0001); // vertex is either in center or on circle QVector3D nn1 = norms.at(ii1); QVERIFY((fabs(QVector3D::dotProduct(nn1,QVector3D(0,0,1)))-1.0) < 0.0001); // vertex normal == {0,0,1} @@ -151,7 +151,7 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii2 = ib.at(i+2); QVERIFY(ii2<(unsigned int)verts.size()); QVector3D vv2 = verts.at(ii2); - qreal vv2sq = (vv2-QVector3D(0,0,0.5)).lengthSquared(); + float vv2sq = (vv2-QVector3D(0,0,0.5)).lengthSquared(); QVERIFY(fabs(vv2sq)<0.0001 || fabs(vv2sq-1.0)<0.0001); // vertex is either in center or on circle QVector3D nn2 = norms.at(ii2); QVERIFY((fabs(QVector3D::dotProduct(nn2,QVector3D(0,0,1)))-1.0) < 0.0001); // vertex normal == {0,0,1} @@ -175,7 +175,7 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii0 = ib.at(i); QVERIFY(ii0<(unsigned int)verts.size()); QVector3D vv0 = verts.at(ii0); - qreal vv0sq = (vv0-QVector3D(0,0,vv0.z())).lengthSquared(); + float vv0sq = (vv0-QVector3D(0,0,vv0.z())).lengthSquared(); QVERIFY(fabs(vv0sq-1.0)<0.0001); // vertex is on cylinder QVector3D nn0 = norms.at(ii0); QVERIFY((fabs(QVector3D::dotProduct(nn0,(vv0-QVector3D(0,0,vv0.z()))))-1.0) < 0.0001); // vertex normal points to the same direction as vertex @@ -183,7 +183,7 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii1 = ib.at(i+1); QVERIFY(ii1<(unsigned int)verts.size()); QVector3D vv1 = verts.at(ii1); - qreal vv1sq = (vv1-QVector3D(0,0,vv1.z())).lengthSquared(); + float vv1sq = (vv1-QVector3D(0,0,vv1.z())).lengthSquared(); QVERIFY(fabs(vv1sq-1.0)<0.0001); // vertex is on cylinder QVector3D nn1 = norms.at(ii1); QVERIFY((fabs(QVector3D::dotProduct(nn1,(vv1-QVector3D(0,0,vv1.z()))))-1.0) < 0.0001); // vertex normal points to the same direction as vertex @@ -191,15 +191,16 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii2 = ib.at(i+2); QVERIFY(ii2<(unsigned int)verts.size()); QVector3D vv2 = verts.at(ii2); - qreal vv2sq = (vv2-QVector3D(0,0,vv2.z())).lengthSquared(); + float vv2sq = (vv2-QVector3D(0,0,vv2.z())).lengthSquared(); QVERIFY(fabs(vv2sq-1.0)<0.0001); // vertex is on cylinder QVector3D nn2 = norms.at(ii2); QVERIFY((fabs(QVector3D::dotProduct(nn2,(vv2-QVector3D(0,0,vv2.z()))))-1.0) < 0.0001); // vertex normal points to the same direction as vertex QVector3D triangleNormal = QVector3D::crossProduct(vv1-vv0,vv2-vv0); triangleNormal.normalize(); - qreal dp = QVector3D::dotProduct(triangleNormal,nn0); - QVERIFY(dp>0.9238 && dp<=1.0); // triangle normal points in approx the same dir as one of vertex normals. Max deviation is 22.5 degrees. + float dp = QVector3D::dotProduct(triangleNormal,nn0); + const float epsilon = 1.0e-5f; + QVERIFY(dp - 0.9238f > -epsilon && dp - 1.0f <= epsilon); // triangle normal points in approx the same dir as one of vertex normals. Max deviation is 22.5 degrees. } } { @@ -216,7 +217,7 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii0 = ib.at(i); QVERIFY(ii0<(unsigned int)verts.size()); QVector3D vv0 = verts.at(ii0); - qreal vv0sq = (vv0-QVector3D(0,0,-0.5)).lengthSquared(); + float vv0sq = (vv0-QVector3D(0,0,-0.5)).lengthSquared(); QVERIFY(fabs(vv0sq)<0.0001 || fabs(vv0sq-1.0)<0.0001); // vertex is either in center or on circle QVector3D nn0 = norms.at(ii0); QVERIFY((fabs(QVector3D::dotProduct(nn0,QVector3D(0,0,-1)))-1.0) < 0.0001); // vertex normal == {0,0,-1} @@ -224,7 +225,7 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii1 = ib.at(i+1); QVERIFY(ii1<(unsigned int)verts.size()); QVector3D vv1 = verts.at(ii1); - qreal vv1sq = (vv1-QVector3D(0,0,-0.5)).lengthSquared(); + float vv1sq = (vv1-QVector3D(0,0,-0.5)).lengthSquared(); QVERIFY(fabs(vv1sq)<0.0001 || fabs(vv1sq-1.0)<0.0001); // vertex is either in center or on circle QVector3D nn1 = norms.at(ii1); QVERIFY((fabs(QVector3D::dotProduct(nn1,QVector3D(0,0,-1)))-1.0) < 0.0001); // vertex normal == {0,0,-1} @@ -232,7 +233,7 @@ void tst_QCylinderMesh::testGeometry() unsigned int ii2 = ib.at(i+2); QVERIFY(ii2<(unsigned int)verts.size()); QVector3D vv2 = verts.at(ii2); - qreal vv2sq = (vv2-QVector3D(0,0,-0.5)).lengthSquared(); + float vv2sq = (vv2-QVector3D(0,0,-0.5)).lengthSquared(); QVERIFY(fabs(vv2sq)<0.0001 || fabs(vv2sq-1.0)<0.0001); // vertex is either in center or on circle QVector3D nn2 = norms.at(ii2); QVERIFY((fabs(QVector3D::dotProduct(nn2,QVector3D(0,0,-1)))-1.0) < 0.0001); // vertex normal == {0,0,-1} diff --git a/tests/auto/imports/qline/tst_qline.cpp b/tests/auto/imports/qline/tst_qline.cpp index 2f389bf28..54da4852a 100644 --- a/tests/auto/imports/qline/tst_qline.cpp +++ b/tests/auto/imports/qline/tst_qline.cpp @@ -74,9 +74,9 @@ void tst_QLine::test() { QSignalSpy spyVertices(&line,SIGNAL(verticesChanged())); QVariantList vertices; - vertices.append(QVariant(qreal(1.0))); - vertices.append(QVariant(qreal(2.0))); - vertices.append(QVariant(qreal(3.0))); + vertices.append(QVariant(1.0f)); + vertices.append(QVariant(2.0f)); + vertices.append(QVariant(3.0f)); line.setVertices(vertices); QCOMPARE(spyVertices.size(), 1); diff --git a/tests/auto/imports/qpoint/tst_qpoint.cpp b/tests/auto/imports/qpoint/tst_qpoint.cpp index affb32921..44b3ba28d 100644 --- a/tests/auto/imports/qpoint/tst_qpoint.cpp +++ b/tests/auto/imports/qpoint/tst_qpoint.cpp @@ -74,9 +74,9 @@ void tst_QPoint::test() { QSignalSpy spyVertices(&point,SIGNAL(verticesChanged())); QVariantList vertices; - vertices.append(QVariant(qreal(1.0))); - vertices.append(QVariant(qreal(2.0))); - vertices.append(QVariant(qreal(3.0))); + vertices.append(QVariant(1.0f)); + vertices.append(QVariant(2.0f)); + vertices.append(QVariant(3.0f)); point.setVertices(vertices); QCOMPARE(spyVertices.size(), 1); diff --git a/tests/auto/imports/qspheremesh/tst_qspheremesh.cpp b/tests/auto/imports/qspheremesh/tst_qspheremesh.cpp index 7da925c0e..b1b3a76a9 100644 --- a/tests/auto/imports/qspheremesh/tst_qspheremesh.cpp +++ b/tests/auto/imports/qspheremesh/tst_qspheremesh.cpp @@ -133,21 +133,21 @@ void tst_QSphereMesh::testGeometry() unsigned int ii0 = ib.at(i); QVERIFY(ii0<(unsigned int)verts.size()); QVector3D vv0 = verts.at(ii0); - qreal vv0sq = vv0.lengthSquared(); + float vv0sq = vv0.lengthSquared(); QVERIFY(fabs(vv0sq-1.0)<0.0001); // vertex is on sphere QVector3D nn0 = norms.at(ii0); QVERIFY((fabs(QVector3D::dotProduct(vv0,nn0))-1.0) < 0.0001); // vertex normal == vertex itself unsigned int ii1 = ib.at(i+1); QVERIFY(ii1<(unsigned int)verts.size()); QVector3D vv1 = verts.at(ii1); - qreal vv1sq = vv1.lengthSquared(); + float vv1sq = vv1.lengthSquared(); QVERIFY(fabs(vv1sq-1.0)<0.0001); // vertex is on sphere QVector3D nn1 = norms.at(ii1); QVERIFY((fabs(QVector3D::dotProduct(vv1,nn1))-1.0) < 0.0001); // vertex normal == vertex itself unsigned int ii2 = ib.at(i+2); QVERIFY(ii2<(unsigned int)verts.size()); QVector3D vv2 = verts.at(ii2); - qreal vv2sq = vv2.lengthSquared(); + float vv2sq = vv2.lengthSquared(); QVERIFY(fabs(vv2sq-1.0)<0.0001); // vertex is on sphere QVector3D nn2 = norms.at(ii2); QVERIFY((fabs(QVector3D::dotProduct(vv2,nn2))-1.0) < 0.0001); // vertex normal == vertex itself @@ -161,7 +161,7 @@ void tst_QSphereMesh::testGeometry() QVector3D triangleNormal = QVector3D::crossProduct(vvv0,vvv1); if (triangleNormal.lengthSquared()>0.001) { triangleNormal.normalize(); - qreal dp = QVector3D::dotProduct(triangleNormal,nn0); + float dp = QVector3D::dotProduct(triangleNormal,nn0); QVERIFY(dp<-0.8628); } } diff --git a/tests/auto/threed/qcolor4ub/tst_qcolor4ub.cpp b/tests/auto/threed/qcolor4ub/tst_qcolor4ub.cpp index 31c074983..f9aec3de5 100644 --- a/tests/auto/threed/qcolor4ub/tst_qcolor4ub.cpp +++ b/tests/auto/threed/qcolor4ub/tst_qcolor4ub.cpp @@ -68,30 +68,30 @@ void tst_QColor4ub::create() QCOMPARE(c1.green(), 0); QCOMPARE(c1.blue(), 0); QCOMPARE(c1.alpha(), 255); - QCOMPARE(c1.redF(), qreal(0.0)); - QCOMPARE(c1.greenF(), qreal(0.0)); - QCOMPARE(c1.blueF(), qreal(0.0)); - QCOMPARE(c1.alphaF(), qreal(1.0)); + QCOMPARE(c1.redF(), 0.0f); + QCOMPARE(c1.greenF(), 0.0f); + QCOMPARE(c1.blueF(), 0.0f); + QCOMPARE(c1.alphaF(), 1.0f); QColor4ub c2(162, 54, 39); QCOMPARE(c2.red(), 162); QCOMPARE(c2.green(), 54); QCOMPARE(c2.blue(), 39); QCOMPARE(c2.alpha(), 255); - QVERIFY(fuzzyCompare(c2.redF(), qreal(162 / 255.0f))); - QVERIFY(fuzzyCompare(c2.greenF(), qreal(54 / 255.0f))); - QVERIFY(fuzzyCompare(c2.blueF(), qreal(39 / 255.0f))); - QVERIFY(fuzzyCompare(c2.alphaF(), qreal(1.0))); + QVERIFY(fuzzyCompare(c2.redF(), 162 / 255.0f)); + QVERIFY(fuzzyCompare(c2.greenF(), 54 / 255.0f)); + QVERIFY(fuzzyCompare(c2.blueF(), 39 / 255.0f)); + QVERIFY(fuzzyCompare(c2.alphaF(), 1.0)); QColor4ub c3(162, 54, 39, 41); QCOMPARE(c3.red(), 162); QCOMPARE(c3.green(), 54); QCOMPARE(c3.blue(), 39); QCOMPARE(c3.alpha(), 41); - QVERIFY(fuzzyCompare(c3.redF(), qreal(162 / 255.0f))); - QVERIFY(fuzzyCompare(c3.greenF(), qreal(54 / 255.0f))); - QVERIFY(fuzzyCompare(c3.blueF(), qreal(39 / 255.0f))); - QVERIFY(fuzzyCompare(c3.alphaF(), qreal(41 / 255.0f))); + QVERIFY(fuzzyCompare(c3.redF(), 162 / 255.0f)); + QVERIFY(fuzzyCompare(c3.greenF(), 54 / 255.0f)); + QVERIFY(fuzzyCompare(c3.blueF(), 39 / 255.0f)); + QVERIFY(fuzzyCompare(c3.alphaF(), 41 / 255.0f)); QColor4ub c4(QColor(162, 54, 39, 41)); QCOMPARE(c4.red(), 162); @@ -164,10 +164,10 @@ void tst_QColor4ub::modify() QCOMPARE(c1.green(), 163); QCOMPARE(c1.blue(), 2); QCOMPARE(c1.alpha(), 200); - QVERIFY(fuzzyCompare(c1.redF(), qreal(34 / 255.0f))); - QVERIFY(fuzzyCompare(c1.greenF(), qreal(163 / 255.0f))); - QVERIFY(fuzzyCompare(c1.blueF(), qreal(2 / 255.0f))); - QVERIFY(fuzzyCompare(c1.alphaF(), qreal(200 / 255.0f))); + QVERIFY(fuzzyCompare(c1.redF(), 34 / 255.0f)); + QVERIFY(fuzzyCompare(c1.greenF(), 163 / 255.0f)); + QVERIFY(fuzzyCompare(c1.blueF(), 2 / 255.0f)); + QVERIFY(fuzzyCompare(c1.alphaF(), 200 / 255.0f)); QColor4ub c2; c2.setRedF(1.0f); @@ -178,10 +178,10 @@ void tst_QColor4ub::modify() QCOMPARE(c2.green(), 128); QCOMPARE(c2.blue(), 64); QCOMPARE(c2.alpha(), 191); - QVERIFY(fuzzyCompare(c2.redF(), qreal(1.0))); - QVERIFY(fuzzyCompare(c2.greenF(), qreal(128 / 255.0f))); - QVERIFY(fuzzyCompare(c2.blueF(), qreal(64 / 255.0f))); - QVERIFY(fuzzyCompare(c2.alphaF(), qreal(191 / 255.0f))); + QVERIFY(fuzzyCompare(c2.redF(), 1.0f)); + QVERIFY(fuzzyCompare(c2.greenF(), 128 / 255.0f)); + QVERIFY(fuzzyCompare(c2.blueF(), 64 / 255.0f)); + QVERIFY(fuzzyCompare(c2.alphaF(), 191 / 255.0f)); QColor4ub c3; c3.setRgb(162, 54, 39); diff --git a/tests/auto/threed/qglbuilder/tst_qglbuilder.cpp b/tests/auto/threed/qglbuilder/tst_qglbuilder.cpp index 43bd95fe0..498828525 100644 --- a/tests/auto/threed/qglbuilder/tst_qglbuilder.cpp +++ b/tests/auto/threed/qglbuilder/tst_qglbuilder.cpp @@ -557,7 +557,7 @@ void tst_QGLBuilder::addTriangleFan() QVector3D b(1.0f, -1.0f, 0.0f); QVector3D c(1.0f, 1.0f, 0.0f); QVector3D d(-1.0f, 1.0f, 0.0f); - qreal one_on_root2 = 1.0f / sqrt(2.0f); + float one_on_root2 = 1.0f / sqrtf(2.0f); QVector3D n1(0.0f, -one_on_root2, one_on_root2); QVector3D n2(one_on_root2, 0.0f, one_on_root2); QVector3D n3(0.0f, one_on_root2, one_on_root2); @@ -701,7 +701,7 @@ void tst_QGLBuilder::extrude() p.appendVertex(a); q = p.translated(-n); - qreal one_on_root2 = 1.0f / sqrt(2.0f); + float one_on_root2 = 1.0f / sqrtf(2.0f); QVector3D n1(-one_on_root2, -one_on_root2, 0.0f); QVector3D n2(one_on_root2, -one_on_root2, 0.0f); QVector3D n3(one_on_root2, one_on_root2, 0.0f); @@ -797,7 +797,7 @@ void tst_QGLBuilder::finalize() p.appendVertex(center); p.appendVertex(a, b, c, d); - qreal one_on_root2 = 1.0f / sqrt(2.0f); + float one_on_root2 = 1.0f / sqrtf(2.0f); QVector3D n0(0.0f, 0.0f, 1.0f); QVector3D n1(-one_on_root2, -one_on_root2, 0.0f); QVector3D n2(one_on_root2, -one_on_root2, 0.0f); diff --git a/tests/auto/threed/qglcamera/tst_qglcamera.cpp b/tests/auto/threed/qglcamera/tst_qglcamera.cpp index 139af6317..2fc192a6e 100644 --- a/tests/auto/threed/qglcamera/tst_qglcamera.cpp +++ b/tests/auto/threed/qglcamera/tst_qglcamera.cpp @@ -64,16 +64,16 @@ void tst_QGLCamera::create() // Test that a newly created object has the correct defaults. QGLCamera camera; QVERIFY(camera.projectionType() == QGLCamera::Perspective); - QCOMPARE(camera.fieldOfView(), (qreal)0.0f); - QCOMPARE(camera.nearPlane(), (qreal)5.0f); - QCOMPARE(camera.farPlane(), (qreal)1000.0f); + QCOMPARE(camera.fieldOfView(), 0.0f); + QCOMPARE(camera.nearPlane(), 5.0f); + QCOMPARE(camera.farPlane(), 1000.0f); QCOMPARE(camera.viewSize(), QSizeF(2.0f, 2.0f)); QCOMPARE(camera.minViewSize(), QSizeF(0.0001f, 0.0001f)); QCOMPARE(camera.screenRotation(), 0); QVERIFY(camera.eye() == QVector3D(0, 0, 10)); QVERIFY(camera.upVector() == QVector3D(0, 1, 0)); QVERIFY(camera.center() == QVector3D(0, 0, 0)); - QCOMPARE(camera.eyeSeparation(), (qreal)0.0f); + QCOMPARE(camera.eyeSeparation(), 0.0f); QVERIFY(camera.motionAdjustment() == QVector3D(0, 0, 1)); QVERIFY(camera.adjustForAspectRatio()); } @@ -88,13 +88,13 @@ void tst_QGLCamera::modify() QVERIFY(camera.projectionType() == QGLCamera::Orthographic); QCOMPARE(spy1.size(), 1); camera.setFieldOfView(60.0f); - QCOMPARE(camera.fieldOfView(), (qreal)60.0f); + QCOMPARE(camera.fieldOfView(), 60.0f); QCOMPARE(spy1.size(), 2); camera.setNearPlane(-3.0f); - QCOMPARE(camera.nearPlane(), (qreal)-3.0f); + QCOMPARE(camera.nearPlane(), -3.0f); QCOMPARE(spy1.size(), 3); camera.setFarPlane(3000.0f); - QCOMPARE(camera.farPlane(), (qreal)3000.0f); + QCOMPARE(camera.farPlane(), 3000.0f); QCOMPARE(spy1.size(), 4); camera.setViewSize(QSizeF(45.0f, 25.5f)); QCOMPARE(camera.viewSize(), QSizeF(45.0f, 25.5f)); @@ -115,7 +115,7 @@ void tst_QGLCamera::modify() QVERIFY(camera.center() == QVector3D(7.0f, 8.0f, 9.0f)); QCOMPARE(spy2.size(), 3); camera.setEyeSeparation(3.0f); - QCOMPARE(camera.eyeSeparation(), (qreal)3.0f); + QCOMPARE(camera.eyeSeparation(), 3.0f); QCOMPARE(spy2.size(), 4); camera.setMotionAdjustment(QVector3D(10.0f, 11.0f, 12.0f)); QVERIFY(camera.motionAdjustment() == QVector3D(10.0f, 11.0f, 12.0f)); @@ -126,16 +126,16 @@ void tst_QGLCamera::modify() // Test that we don't get any side effects between properties. QVERIFY(camera.projectionType() == QGLCamera::Orthographic); - QCOMPARE(camera.fieldOfView(), (qreal)60.0f); - QCOMPARE(camera.nearPlane(), (qreal)-3.0f); - QCOMPARE(camera.farPlane(), (qreal)3000.0f); + QCOMPARE(camera.fieldOfView(), 60.0f); + QCOMPARE(camera.nearPlane(), -3.0f); + QCOMPARE(camera.farPlane(), 3000.0f); QCOMPARE(camera.viewSize(), QSizeF(45.0f, 25.5f)); QCOMPARE(camera.minViewSize(), QSizeF(0.05f, 0.025f)); QCOMPARE(camera.screenRotation(), 270); QVERIFY(camera.eye() == QVector3D(1.0f, 2.0f, 3.0f)); QVERIFY(camera.upVector() == QVector3D(4.0f, 5.0f, 6.0f)); QVERIFY(camera.center() == QVector3D(7.0f, 8.0f, 9.0f)); - QCOMPARE(camera.eyeSeparation(), (qreal)3.0f); + QCOMPARE(camera.eyeSeparation(), 3.0f); QVERIFY(camera.motionAdjustment() == QVector3D(10.0f, 11.0f, 12.0f)); QVERIFY(!camera.adjustForAspectRatio()); diff --git a/tests/auto/threed/qglcube/tst_qglcube.cpp b/tests/auto/threed/qglcube/tst_qglcube.cpp index f6aea5e8f..37915bbe4 100644 --- a/tests/auto/threed/qglcube/tst_qglcube.cpp +++ b/tests/auto/threed/qglcube/tst_qglcube.cpp @@ -139,8 +139,8 @@ void tst_QGLCube::create() void tst_QGLCube::size() { - qreal size0 = 3.2f; - qreal size1 = 5.2f; + float size0 = 3.2f; + float size1 = 5.2f; QGLCube cube(size0); QCOMPARE(cube.size(), size0); { diff --git a/tests/auto/threed/qglcylinder/tst_qglcylinder.cpp b/tests/auto/threed/qglcylinder/tst_qglcylinder.cpp index 1adfe9d52..775469250 100644 --- a/tests/auto/threed/qglcylinder/tst_qglcylinder.cpp +++ b/tests/auto/threed/qglcylinder/tst_qglcylinder.cpp @@ -57,7 +57,7 @@ private slots: void build(); private: - bool validateCylinder(QGLSceneNode *node, qreal topDiameter, qreal baseDiameter, qreal height, bool top, bool base); + bool validateCylinder(QGLSceneNode *node, float topDiameter, float baseDiameter, float height, bool top, bool base); }; void tst_QGLCylinder::create() @@ -67,9 +67,9 @@ void tst_QGLCylinder::create() //Defaults QGLCylinder cylinder1; - QCOMPARE(cylinder1.diameterTop(), qreal(1.0f)); - QCOMPARE(cylinder1.diameterBottom(), qreal(1.0f)); - QCOMPARE(cylinder1.height(), qreal(1.0f)); + QCOMPARE(cylinder1.diameterTop(), 1.0f); + QCOMPARE(cylinder1.diameterBottom(), 1.0f); + QCOMPARE(cylinder1.height(), 1.0f); QCOMPARE(cylinder1.slices(), 6); QCOMPARE(cylinder1.layers(), 3); QCOMPARE(cylinder1.topEnabled(), true); @@ -77,9 +77,9 @@ void tst_QGLCylinder::create() //Top diameter QGLCylinder cylinder2(0.5f); - QCOMPARE(cylinder2.diameterTop(), qreal(0.5f)); - QCOMPARE(cylinder2.diameterBottom(), qreal(1.0f)); - QCOMPARE(cylinder2.height(), qreal(1.0f)); + QCOMPARE(cylinder2.diameterTop(), 0.5f); + QCOMPARE(cylinder2.diameterBottom(), 1.0f); + QCOMPARE(cylinder2.height(), 1.0f); QCOMPARE(cylinder2.slices(), 6); QCOMPARE(cylinder2.layers(), 3); QCOMPARE(cylinder2.topEnabled(), true); @@ -87,9 +87,9 @@ void tst_QGLCylinder::create() //Top and Bottom diameter QGLCylinder cylinder3(0.5f, 1.5f); - QCOMPARE(cylinder3.diameterTop(), qreal(0.5f)); - QCOMPARE(cylinder3.diameterBottom(), qreal(1.5f)); - QCOMPARE(cylinder3.height(), qreal(1.0f)); + QCOMPARE(cylinder3.diameterTop(), 0.5f); + QCOMPARE(cylinder3.diameterBottom(), 1.5f); + QCOMPARE(cylinder3.height(), 1.0f); QCOMPARE(cylinder3.slices(), 6); QCOMPARE(cylinder3.layers(), 3); QCOMPARE(cylinder3.topEnabled(), true); @@ -97,9 +97,9 @@ void tst_QGLCylinder::create() //Top & Bottom diameter, Height QGLCylinder cylinder4(0.5f, 1.5f, 3.0f); - QCOMPARE(cylinder4.diameterTop(), qreal(0.5f)); - QCOMPARE(cylinder4.diameterBottom(), qreal(1.5f)); - QCOMPARE(cylinder4.height(), qreal(3.0f)); + QCOMPARE(cylinder4.diameterTop(), 0.5f); + QCOMPARE(cylinder4.diameterBottom(), 1.5f); + QCOMPARE(cylinder4.height(), 3.0f); QCOMPARE(cylinder4.slices(), 6); QCOMPARE(cylinder4.layers(), 3); QCOMPARE(cylinder4.topEnabled(), true); @@ -107,9 +107,9 @@ void tst_QGLCylinder::create() //Top & Bottom diameter, Height, Slices QGLCylinder cylinder5(0.5f, 1.5f, 3.0f, 10); - QCOMPARE(cylinder5.diameterTop(), qreal(0.5f)); - QCOMPARE(cylinder5.diameterBottom(), qreal(1.5f)); - QCOMPARE(cylinder5.height(), qreal(3.0f)); + QCOMPARE(cylinder5.diameterTop(), 0.5f); + QCOMPARE(cylinder5.diameterBottom(), 1.5f); + QCOMPARE(cylinder5.height(), 3.0f); QCOMPARE(cylinder5.slices(), 10); QCOMPARE(cylinder5.layers(), 3); QCOMPARE(cylinder5.topEnabled(), true); @@ -117,9 +117,9 @@ void tst_QGLCylinder::create() //Top & Bottom diameter, Height, Slices, Layers QGLCylinder cylinder6(0.5f, 1.5f, 3.0f, 10, 5); - QCOMPARE(cylinder6.diameterTop(), qreal(0.5f)); - QCOMPARE(cylinder6.diameterBottom(), qreal(1.5f)); - QCOMPARE(cylinder6.height(), qreal(3.0f)); + QCOMPARE(cylinder6.diameterTop(), 0.5f); + QCOMPARE(cylinder6.diameterBottom(), 1.5f); + QCOMPARE(cylinder6.height(), 3.0f); QCOMPARE(cylinder6.slices(), 10); QCOMPARE(cylinder6.layers(), 5); QCOMPARE(cylinder6.topEnabled(), true); @@ -127,9 +127,9 @@ void tst_QGLCylinder::create() //Top & Bottom diameter, Height, Slices, Layers, Top disabled QGLCylinder cylinder7(0.5f, 1.5f, 3.0f, 10, 5, false); - QCOMPARE(cylinder7.diameterTop(), qreal(0.5f)); - QCOMPARE(cylinder7.diameterBottom(), qreal(1.5f)); - QCOMPARE(cylinder7.height(), qreal(3.0f)); + QCOMPARE(cylinder7.diameterTop(), 0.5f); + QCOMPARE(cylinder7.diameterBottom(), 1.5f); + QCOMPARE(cylinder7.height(), 3.0f); QCOMPARE(cylinder7.slices(), 10); QCOMPARE(cylinder7.layers(), 5); QCOMPARE(cylinder7.topEnabled(), false); @@ -137,9 +137,9 @@ void tst_QGLCylinder::create() //Top & Bottom diameter, Height, Slices, Layers, Top disabled, Bottom disabled. QGLCylinder cylinder8(0.5f, 1.5f, 3.0f, 10, 5, false, false); - QCOMPARE(cylinder8.diameterTop(), qreal(0.5f)); - QCOMPARE(cylinder8.diameterBottom(), qreal(1.5f)); - QCOMPARE(cylinder8.height(), qreal(3.0f)); + QCOMPARE(cylinder8.diameterTop(), 0.5f); + QCOMPARE(cylinder8.diameterBottom(), 1.5f); + QCOMPARE(cylinder8.height(), 3.0f); QCOMPARE(cylinder8.slices(), 10); QCOMPARE(cylinder8.layers(), 5); QCOMPARE(cylinder8.topEnabled(), false); @@ -152,13 +152,13 @@ void tst_QGLCylinder::modify() QGLCylinder cylinder1; cylinder1.setDiameterTop(0.5f); - QCOMPARE(cylinder1.diameterTop(), qreal(0.5f)); + QCOMPARE(cylinder1.diameterTop(), 0.5f); cylinder1.setDiameterBottom(1.5f); - QCOMPARE(cylinder1.diameterBottom(), qreal(1.5f)); + QCOMPARE(cylinder1.diameterBottom(), 1.5f); cylinder1.setHeight(3.0f); - QCOMPARE(cylinder1.height(), qreal(3.0f)); + QCOMPARE(cylinder1.height(), 3.0f); cylinder1.setSlices(10); QCOMPARE(cylinder1.slices(), 10); @@ -177,7 +177,7 @@ void tst_QGLCylinder::modify() // on the top and bottom are at the correct height, and that all normals // are of length 1. It also ensures that all points are within the defined // top and bottom diameters for the cylinder. -bool tst_QGLCylinder::validateCylinder(QGLSceneNode *node, qreal topDiameter, qreal baseDiameter, qreal height, bool topAttached, bool baseAttached) +bool tst_QGLCylinder::validateCylinder(QGLSceneNode *node, float topDiameter, float baseDiameter, float height, bool topAttached, bool baseAttached) { QGLSceneNode *top = node->findChild<QGLSceneNode *>("Cylinder Top"); QGLSceneNode *sides = node->findChild<QGLSceneNode *>("Cylinder Sides"); diff --git a/tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp b/tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp index 3e297362e..c4e9f887d 100644 --- a/tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp +++ b/tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp @@ -68,12 +68,12 @@ void tst_QGLLightParameters::create() QVERIFY(params.diffuseColor() == QColor(255, 255, 255, 255)); QVERIFY(params.specularColor() == QColor(255, 255, 255, 255)); QVERIFY(params.spotDirection() == QVector3D(0, 0, -1)); - QCOMPARE(params.spotExponent(), (qreal)0.0f); - QCOMPARE(params.spotAngle(), (qreal)180.0f); - QCOMPARE(params.spotCosAngle(), (qreal)-1.0f); - QCOMPARE(params.constantAttenuation(), (qreal)1.0f); - QCOMPARE(params.linearAttenuation(), (qreal)0.0f); - QCOMPARE(params.quadraticAttenuation(), (qreal)0.0f); + QCOMPARE(params.spotExponent(), 0.0f); + QCOMPARE(params.spotAngle(), 180.0f); + QCOMPARE(params.spotCosAngle(), -1.0f); + QCOMPARE(params.constantAttenuation(), 1.0f); + QCOMPARE(params.linearAttenuation(), 0.0f); + QCOMPARE(params.quadraticAttenuation(), 0.0f); } void tst_QGLLightParameters::modify() @@ -139,33 +139,33 @@ void tst_QGLLightParameters::modify() QCOMPARE(lightSpy.size(), 6); params.setSpotExponent(23.5f); - QCOMPARE(params.spotExponent(), (qreal)23.5f); + QCOMPARE(params.spotExponent(), 23.5f); QCOMPARE(spotExponentSpy.size(), 1); QCOMPARE(lightSpy.size(), 7); params.setSpotAngle(90.0f); - QCOMPARE(params.spotAngle(), (qreal)90.0f); + QCOMPARE(params.spotAngle(), 90.0f); QVERIFY(params.spotCosAngle() <= 0.000001f); // Fuzzy compare is not fuzzy enough! QCOMPARE(spotAngleSpy.size(), 1); QCOMPARE(lightSpy.size(), 8); params.setSpotAngle(180.0f); - QCOMPARE(params.spotCosAngle(), (qreal)-1.0f); + QCOMPARE(params.spotCosAngle(), -1.0f); QCOMPARE(spotAngleSpy.size(), 2); QCOMPARE(lightSpy.size(), 9); params.setConstantAttenuation(16.0f); - QCOMPARE(params.constantAttenuation(), (qreal)16.0f); + QCOMPARE(params.constantAttenuation(), 16.0f); QCOMPARE(constSpy.size(), 1); QCOMPARE(lightSpy.size(), 10); params.setLinearAttenuation(-3.5f); - QCOMPARE(params.linearAttenuation(), (qreal)-3.5f); + QCOMPARE(params.linearAttenuation(), -3.5f); QCOMPARE(linearSpy.size(), 1); QCOMPARE(lightSpy.size(), 11); params.setQuadraticAttenuation(4.0f); - QCOMPARE(params.quadraticAttenuation(), (qreal)4.0f); + QCOMPARE(params.quadraticAttenuation(), 4.0f); QCOMPARE(quadSpy.size(), 1); QCOMPARE(lightSpy.size(), 12); @@ -186,12 +186,12 @@ void tst_QGLLightParameters::modify() QCOMPARE(params.specularColor().blue(), 0); QCOMPARE(params.specularColor().alpha(), 255); QVERIFY(params.spotDirection() == QVector3D(0.0f, 1.0f, 0.0f)); - QCOMPARE(params.spotExponent(), (qreal)23.5f); - QCOMPARE(params.spotAngle(), (qreal)180.0f); - QCOMPARE(params.spotCosAngle(), (qreal)-1.0f); - QCOMPARE(params.constantAttenuation(), (qreal)16.0f); - QCOMPARE(params.linearAttenuation(), (qreal)-3.5f); - QCOMPARE(params.quadraticAttenuation(), (qreal)4.0f); + QCOMPARE(params.spotExponent(), 23.5f); + QCOMPARE(params.spotAngle(), 180.0f); + QCOMPARE(params.spotCosAngle(), -1.0f); + QCOMPARE(params.constantAttenuation(), 16.0f); + QCOMPARE(params.linearAttenuation(), -3.5f); + QCOMPARE(params.quadraticAttenuation(), 4.0f); // Set the properties to same values and check for no further signals. params.setDirection(QVector3D(-1, -2, 3)); diff --git a/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp b/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp index e13767b6d..b53a96579 100644 --- a/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp +++ b/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp @@ -254,23 +254,29 @@ void tst_QGLMaterial::cleanupTestCase() delete widget; } -static inline bool fuzzyCompare(qreal x, qreal y) +// Fix the problem where a compared value happens to be zero (and +// you cannot always predict this, and should not predict it +// since then you produce self-fulling prophecies instead of tests). +// In that case qFuzzyCompare has a completely strict criterion since +// it finds the "fudge factor" by multiplying by zero... +static inline bool fuzzyCompare(float p1, float p2) { - return qAbs(x - y) <= 0.00001; + float fac = qMin(qAbs(p1), qAbs(p2)); + return (qAbs(p1 - p2) <= (qIsNull(fac) ? 0.00001f : 0.00001f * fac)); } void tst_QGLMaterial::standardMaterial() { // Test that a newly created object has the correct defaults. QGLMaterial mat1; - QVERIFY(fuzzyCompare(mat1.ambientColor().redF(), qreal(0.2f))); - QVERIFY(fuzzyCompare(mat1.ambientColor().greenF(), qreal(0.2f))); - QVERIFY(fuzzyCompare(mat1.ambientColor().blueF(), qreal(0.2f))); - QVERIFY(fuzzyCompare(mat1.ambientColor().alphaF(), qreal(1.0f))); - QVERIFY(fuzzyCompare(mat1.diffuseColor().redF(), qreal(0.8f))); - QVERIFY(fuzzyCompare(mat1.diffuseColor().greenF(), qreal(0.8f))); - QVERIFY(fuzzyCompare(mat1.diffuseColor().blueF(), qreal(0.8f))); - QVERIFY(fuzzyCompare(mat1.diffuseColor().alphaF(), qreal(1.0f))); + QVERIFY(fuzzyCompare(mat1.ambientColor().redF(), 0.2f)); + QVERIFY(fuzzyCompare(mat1.ambientColor().greenF(), 0.2f)); + QVERIFY(fuzzyCompare(mat1.ambientColor().blueF(), 0.2f)); + QVERIFY(fuzzyCompare(mat1.ambientColor().alphaF(), 1.0f)); + QVERIFY(fuzzyCompare(mat1.diffuseColor().redF(), 0.8f)); + QVERIFY(fuzzyCompare(mat1.diffuseColor().greenF(), 0.8f)); + QVERIFY(fuzzyCompare(mat1.diffuseColor().blueF(), 0.8f)); + QVERIFY(fuzzyCompare(mat1.diffuseColor().alphaF(), 1.0f)); QCOMPARE(mat1.specularColor().red(), 0); QCOMPARE(mat1.specularColor().green(), 0); QCOMPARE(mat1.specularColor().blue(), 0); @@ -279,7 +285,7 @@ void tst_QGLMaterial::standardMaterial() QCOMPARE(mat1.emittedLight().green(), 0); QCOMPARE(mat1.emittedLight().blue(), 0); QCOMPARE(mat1.emittedLight().alpha(), 255); - QCOMPARE(mat1.shininess(), qreal(0)); + QCOMPARE(mat1.shininess(), 0.0f); QVERIFY(!mat1.isTransparent()); // Test modifying each field individually, including expected signals. @@ -340,7 +346,7 @@ void tst_QGLMaterial::standardMaterial() QCOMPARE(texturesSpy.count(), 0); QCOMPARE(materialSpy.count(), 4); mat2.setShininess(128); - QCOMPARE(mat2.shininess(), qreal(128)); + QCOMPARE(mat2.shininess(), 128.0f); QCOMPARE(ambientSpy.count(), 1); QCOMPARE(diffuseSpy.count(), 1); QCOMPARE(specularSpy.count(), 1); @@ -365,9 +371,9 @@ void tst_QGLMaterial::standardMaterial() // Check clamping of shininess to the range 0..128. mat1.setShininess(-0.5f); - QCOMPARE(mat1.shininess(), qreal(0.0f)); + QCOMPARE(mat1.shininess(), 0.0f); mat1.setShininess(128.5f); - QCOMPARE(mat1.shininess(), qreal(128.0f)); + QCOMPARE(mat1.shininess(), 128.0f); // Test that we don't get any side effects between properties. QCOMPARE(mat2.ambientColor().red(), 0); @@ -386,7 +392,7 @@ void tst_QGLMaterial::standardMaterial() QCOMPARE(mat2.emittedLight().green(), 255); QCOMPARE(mat2.emittedLight().blue(), 255); QCOMPARE(mat2.emittedLight().alpha(), 255); - QCOMPARE(mat2.shininess(), qreal(128)); + QCOMPARE(mat2.shininess(), 128.0f); // Test the material fetch functions from QGLAbstractMaterial. QVERIFY(mat1.front() == &mat1); @@ -396,14 +402,14 @@ void tst_QGLMaterial::standardMaterial() // Test setting a pseudo-flat color via QGLMaterial::setColor(). mat2.setColor(QColor::fromRgbF(0.2f, 0.8f, 0.5f, 0.7f)); - QVERIFY(fuzzyCompare(mat2.ambientColor().redF(), qreal(0.2f * 0.2f))); - QVERIFY(fuzzyCompare(mat2.ambientColor().greenF(), qreal(0.2f * 0.8f))); - QVERIFY(fuzzyCompare(mat2.ambientColor().blueF(), qreal(0.2f * 0.5f))); - QVERIFY(fuzzyCompare(mat2.ambientColor().alphaF(), qreal(0.7f))); - QVERIFY(fuzzyCompare(mat2.diffuseColor().redF(), qreal(0.8f * 0.2f))); - QVERIFY(fuzzyCompare(mat2.diffuseColor().greenF(), qreal(0.8f * 0.8f))); - QVERIFY(fuzzyCompare(mat2.diffuseColor().blueF(), qreal(0.8f * 0.5f))); - QVERIFY(fuzzyCompare(mat2.diffuseColor().alphaF(), qreal(0.7f))); + QVERIFY(fuzzyCompare(mat2.ambientColor().redF(), 0.2f * 0.2f)); + QVERIFY(fuzzyCompare(mat2.ambientColor().greenF(), 0.2f * 0.8f)); + QVERIFY(fuzzyCompare(mat2.ambientColor().blueF(), 0.2f * 0.5f)); + QVERIFY(fuzzyCompare(mat2.ambientColor().alphaF(), 0.7f)); + QVERIFY(fuzzyCompare(mat2.diffuseColor().redF(), 0.8f * 0.2f)); + QVERIFY(fuzzyCompare(mat2.diffuseColor().greenF(), 0.8f * 0.8f)); + QVERIFY(fuzzyCompare(mat2.diffuseColor().blueF(), 0.8f * 0.5f)); + QVERIFY(fuzzyCompare(mat2.diffuseColor().alphaF(), 0.7f)); QCOMPARE(ambientSpy.count(), 2); QCOMPARE(diffuseSpy.count(), 2); QCOMPARE(specularSpy.count(), 1); @@ -613,7 +619,7 @@ static inline QVector4D colorToVector4D(const QColor &color) color.blueF(), color.alphaF()); } -static inline qreal clampRange(qreal value) +static inline float clampRange(float value) { if (value < 0.0f) return 0.0f; @@ -623,7 +629,7 @@ static inline qreal clampRange(qreal value) return value; } -static inline QColor vector4DToColor(const QVector4D &value, qreal alpha) +static inline QColor vector4DToColor(const QVector4D &value, float alpha) { return QColor::fromRgbF(clampRange(value.x()), clampRange(value.y()), @@ -683,11 +689,11 @@ static QColor litColor(const QGLMaterial &material) } if (light.spotAngle() != 180.0f) { - qreal spot = qMax(QVector3D::dotProduct + float spot = qMax(QVector3D::dotProduct (vertex - pli.toVector3D(), light.spotDirection()), 0.0f); if (spot < light.spotCosAngle()) { - adcomponent = QVector4D(0, 0, 0, 0); - scomponent = QVector4D(0, 0, 0, 0); + adcomponent = QVector4D(0.0f, 0.0f, 0.0f, 0.0f); + scomponent = QVector4D(0.0f, 0.0f, 0.0f, 0.0f); } else { spot = qPow(spot, light.spotExponent()); adcomponent *= spot; @@ -696,8 +702,8 @@ static QColor litColor(const QGLMaterial &material) } if (pli.w() != 0.0f) { - qreal attenuation = light.constantAttenuation(); - qreal len = (pli.toVector3D() - vertex).length(); + float attenuation = light.constantAttenuation(); + float len = (pli.toVector3D() - vertex).length(); attenuation += light.linearAttenuation() * len; attenuation += light.quadraticAttenuation() * len * len; color += adcomponent / attenuation; diff --git a/tests/auto/threed/qglpainter/qglsimulator.cpp b/tests/auto/threed/qglpainter/qglsimulator.cpp index 5e5a4032b..963b866d0 100644 --- a/tests/auto/threed/qglpainter/qglsimulator.cpp +++ b/tests/auto/threed/qglpainter/qglsimulator.cpp @@ -122,8 +122,8 @@ void QGLSimulator::drawTriangles(const QVector3DArray& array) QPointF QGLSimulator::project(const QVector3D& vector) const { QVector3D pt = (m_projectionMatrix * m_modelViewMatrix) * vector; - qreal x = (pt.x() + 1.0f) * m_viewport.width() * 0.5f + m_viewport.x(); - qreal y = (pt.y() + 1.0f) * m_viewport.height() * 0.5f + m_viewport.y(); + float x = (pt.x() + 1.0f) * m_viewport.width() * 0.5f + m_viewport.x(); + float y = (pt.y() + 1.0f) * m_viewport.height() * 0.5f + m_viewport.y(); y = (m_viewport.height() - 1) - y; return QPointF(x, y); } diff --git a/tests/auto/threed/qglscenenode/tst_qglscenenode.cpp b/tests/auto/threed/qglscenenode/tst_qglscenenode.cpp index 539b14cff..2a8d09b58 100644 --- a/tests/auto/threed/qglscenenode/tst_qglscenenode.cpp +++ b/tests/auto/threed/qglscenenode/tst_qglscenenode.cpp @@ -82,9 +82,9 @@ void tst_QGLSceneNode::defaultValues() QVERIFY(node.localTransform().isIdentity()); QVERIFY(node.position() == QVector3D(0, 0, 0)); - QCOMPARE(node.x(), qreal(0.0f)); - QCOMPARE(node.y(), qreal(0.0f)); - QCOMPARE(node.z(), qreal(0.0f)); + QCOMPARE(node.x(), 0.0f); + QCOMPARE(node.y(), 0.0f); + QCOMPARE(node.z(), 0.0f); QVERIFY(node.transforms().isEmpty()); diff --git a/tests/auto/threed/qglsection/tst_qglsection.cpp b/tests/auto/threed/qglsection/tst_qglsection.cpp index d713216c5..1ce3d408d 100644 --- a/tests/auto/threed/qglsection/tst_qglsection.cpp +++ b/tests/auto/threed/qglsection/tst_qglsection.cpp @@ -437,9 +437,9 @@ void tst_QGLSection::accumNormals() void tst_QGLSection::normalizedNormals() { - const qreal qRadius = 1.0f; - const qreal qHeight = 0.6f; - const qreal qThickness = 0.4f; + const float qRadius = 1.0f; + const float qHeight = 0.6f; + const float qThickness = 0.4f; const int qNumSlices = 16; TestBuilder builder; @@ -456,10 +456,10 @@ void tst_QGLSection::normalizedNormals() QVector3D anc(qRadius * 2.0f, qRadius *2.0f, qHeight); for (int slice = 1; slice < qNumSlices; ++slice) { - const qreal pi2 = 2.0 * M_PI; - qreal angle = (slice * pi2) / (4 * qNumSlices); - qreal cs = qCos(angle); - qreal sn = qSin(angle); + const float pi2 = 2.0f * M_PI; + float angle = (slice * pi2) / (4 * qNumSlices); + float cs = cosf(angle); + float sn = sinf(angle); QVector3D a(cs * qRadius, sn * qRadius, 0.0f); QVector3D b(cs * (qRadius + qThickness), sn * (qRadius + qThickness), qHeight); QGeometryData quad; diff --git a/tests/auto/threed/qglsphere/tst_qglsphere.cpp b/tests/auto/threed/qglsphere/tst_qglsphere.cpp index cd0bd7ea4..6450632db 100644 --- a/tests/auto/threed/qglsphere/tst_qglsphere.cpp +++ b/tests/auto/threed/qglsphere/tst_qglsphere.cpp @@ -57,21 +57,21 @@ private slots: void build(); private: - bool validateSphere(QGLSceneNode *node, qreal size); + bool validateSphere(QGLSceneNode *node, float size); }; void tst_QGLSphere::create() { QGLSphere sphere1; - QCOMPARE(sphere1.diameter(), qreal(1.0f)); + QCOMPARE(sphere1.diameter(), 1.0f); QCOMPARE(sphere1.subdivisionDepth(), 5); QGLSphere sphere2(27.5f); - QCOMPARE(sphere2.diameter(), qreal(27.5f)); + QCOMPARE(sphere2.diameter(), 27.5f); QCOMPARE(sphere2.subdivisionDepth(), 5); QGLSphere sphere3(20.5f, 4); - QCOMPARE(sphere3.diameter(), qreal(20.5f)); + QCOMPARE(sphere3.diameter(), 20.5f); QCOMPARE(sphere3.subdivisionDepth(), 4); } @@ -80,14 +80,14 @@ void tst_QGLSphere::modify() QGLSphere sphere1; sphere1.setDiameter(5.0f); sphere1.setSubdivisionDepth(4); - QCOMPARE(sphere1.diameter(), qreal(5.0f)); + QCOMPARE(sphere1.diameter(), 5.0f); QCOMPARE(sphere1.subdivisionDepth(), 4); } // Validates the geometry in a sphere node to check that all vertices // are on the surface of a sphere of diameter "size" and all normals // are of length 1 and point directly out from the center. -bool tst_QGLSphere::validateSphere(QGLSceneNode *node, qreal size) +bool tst_QGLSphere::validateSphere(QGLSceneNode *node, float size) { QGeometryData data = node->geometry(); int start = node->start(); diff --git a/tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp b/tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp index 30016f69d..991634412 100644 --- a/tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp +++ b/tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp @@ -75,7 +75,7 @@ void tst_QGraphicsTransform3D::rotation3D() QGraphicsRotation3D rot1; QVERIFY(rot1.origin() == QVector3D(0, 0, 0)); QVERIFY(rot1.axis() == QVector3D(0, 0, 1)); - QCOMPARE(rot1.angle(), qreal(0.0f)); + QCOMPARE(rot1.angle(), 0.0f); QSignalSpy spy1(&rot1, SIGNAL(originChanged())); QSignalSpy spy2(&rot1, SIGNAL(axisChanged())); @@ -87,7 +87,7 @@ void tst_QGraphicsTransform3D::rotation3D() rot1.setAngle(45.0f); QVERIFY(rot1.origin() == QVector3D(1, 2, 3)); QVERIFY(rot1.axis() == QVector3D(4, -5, 6)); - QCOMPARE(rot1.angle(), qreal(45.0f)); + QCOMPARE(rot1.angle(), 45.0f); QCOMPARE(spy1.size(), 1); QCOMPARE(spy2.size(), 1); @@ -181,7 +181,7 @@ void tst_QGraphicsTransform3D::translation3D() { QGraphicsTranslation3D translate1; QVERIFY(translate1.translate() == QVector3D(0, 0, 0)); - QCOMPARE(translate1.progress(), qreal(1.0f)); + QCOMPARE(translate1.progress(), 1.0f); QSignalSpy spy1(&translate1, SIGNAL(translateChanged())); QSignalSpy spy2(&translate1, SIGNAL(progressChanged())); @@ -190,7 +190,7 @@ void tst_QGraphicsTransform3D::translation3D() translate1.setTranslate(QVector3D(4, -6, 0.5f)); translate1.setProgress(2.0f); QVERIFY(translate1.translate() == QVector3D(4, -6, 0.5f)); - QCOMPARE(translate1.progress(), qreal(2.0f)); + QCOMPARE(translate1.progress(), 2.0f); QCOMPARE(spy1.size(), 1); QCOMPARE(spy2.size(), 1); diff --git a/tests/auto/threed/qvectorarray/tst_qvectorarray.cpp b/tests/auto/threed/qvectorarray/tst_qvectorarray.cpp index e82704391..86325ec14 100644 --- a/tests/auto/threed/qvectorarray/tst_qvectorarray.cpp +++ b/tests/auto/threed/qvectorarray/tst_qvectorarray.cpp @@ -191,19 +191,19 @@ void tst_QVectorArray::create4DArray() void tst_QVectorArray::scale_data() { - QTest::addColumn<qreal>("scale"); - - QTest::newRow("zero") << qreal(0.0f); - QTest::newRow("one") << qreal(1.0f); - QTest::newRow("neg-one") << qreal(-1.0f); - QTest::newRow("two") << qreal(2.0f); - QTest::newRow("neg-two-point-five") << qreal(-2.5f); - QTest::newRow("half") << qreal(0.5f); + QTest::addColumn<float>("scale"); + + QTest::newRow("zero") << 0.0f; + QTest::newRow("one") << 1.0f; + QTest::newRow("neg-one") << -1.0f; + QTest::newRow("two") << 2.0f; + QTest::newRow("neg-two-point-five") << -2.5f; + QTest::newRow("half") << 0.5f; } void tst_QVectorArray::scale() { - QFETCH(qreal, scale); + QFETCH(float, scale); QVector2DArray v2array; QVector3DArray v3array; diff --git a/tests/benchmarks/matrix_properties/tst_matrix_properties.cpp b/tests/benchmarks/matrix_properties/tst_matrix_properties.cpp index 559ac80a0..ae1d4e022 100644 --- a/tests/benchmarks/matrix_properties/tst_matrix_properties.cpp +++ b/tests/benchmarks/matrix_properties/tst_matrix_properties.cpp @@ -163,10 +163,10 @@ void tst_matrix_properties::boundVariableChange() QVERIFY(item != 0); QByteArray propertyNameByteArray = propertyName.toUtf8().constData(); - qreal value = 1.0; + float value = 1.0f; QBENCHMARK { - item->setProperty(propertyNameByteArray.constData(), (value += 0.1)); + item->setProperty(propertyNameByteArray.constData(), (value += 0.1f)); } delete item; diff --git a/tests/benchmarks/qglbuilder_perf/tst_qglbuilder_perf.cpp b/tests/benchmarks/qglbuilder_perf/tst_qglbuilder_perf.cpp index 1ea8740b1..463eac98f 100644 --- a/tests/benchmarks/qglbuilder_perf/tst_qglbuilder_perf.cpp +++ b/tests/benchmarks/qglbuilder_perf/tst_qglbuilder_perf.cpp @@ -102,9 +102,9 @@ void tst_QGLBuilder::addQuadRandom_data() } } -static inline qreal randCoord() +static inline float randCoord() { - return (200.0f * ((qreal)qrand() / (qreal)RAND_MAX)) - 100.0f; + return (200.0f * (float(qrand()) / float(RAND_MAX))) - 100.0f; } QVector3D randVector() diff --git a/tools/qt3d/qglinfo/fpswidget.cpp b/tools/qt3d/qglinfo/fpswidget.cpp index 8d8bff4c0..ac4dd232c 100644 --- a/tools/qt3d/qglinfo/fpswidget.cpp +++ b/tools/qt3d/qglinfo/fpswidget.cpp @@ -198,8 +198,8 @@ void FPSWidget::resizeGL(int w, int h) glLoadIdentity(); #endif int side = qMin(w, h); - qreal ws = (qreal)w / (qreal)side; - qreal hs = (qreal)h / (qreal)side; + float ws = float(w) / float(side); + float hs = float(h) / float(side); #if defined(QT_OPENGL_ES_2) projection.setToIdentity(); projection.ortho(-ws, ws, -hs, hs, -10.0f, 10.0f); @@ -253,7 +253,7 @@ void FPSWidget::paintGL() program.disableAttributeArray(vertexAttr); program.disableAttributeArray(normalAttr); #endif - QString framesPerSecond = QString::fromLatin1("%1 fps").arg(1000.0f / ((qreal)totalFrameTime / (qreal)frameCount)); + QString framesPerSecond = QString::fromLatin1("%1 fps").arg(1000.0f / (float(totalFrameTime) / float(frameCount))); } void FPSWidget::animate() @@ -268,7 +268,7 @@ void FPSWidget::animate() { frameCount += 1; totalFrameTime += frameElapsed; - emit fps(1000.0f / ((qreal)frameTime->elapsed() / (qreal)frameCount)); + emit fps(1000.0f / (float(frameTime->elapsed()) / float(frameCount))); xrot = (xrot + adv) % 360; yrot = (xrot + adv) % 360; zrot = (xrot + adv) % 360; |