From 53b5c8e6e7546a684aad34f271d253f72547b079 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 18 Jun 2015 10:19:12 -0700 Subject: [PATCH] more merge fallout --- interface/src/devices/OculusManager.cpp | 101 +++--------------------- libraries/model/src/model/Stage.cpp | 10 +-- libraries/model/src/model/Stage.h | 2 +- 3 files changed, 15 insertions(+), 98 deletions(-) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 196f74025c..0c5f780560 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -249,7 +249,7 @@ void OculusManager::connect(QOpenGLContext* shareContext) { _ovrHmd = ovrHmd_CreateDebug(ovrHmd_DK2); } #endif - + #endif if (!_ovrHmd) { @@ -486,6 +486,7 @@ void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) { break; default: break; + } } @@ -502,6 +503,7 @@ void OculusManager::abandonCalibration() { } } + bool OculusManager::isConnected() { return _isConnected; } @@ -549,7 +551,7 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const assert(oldFrameIndex == -1 || (unsigned int)oldFrameIndex == _frameIndex - 1); oldFrameIndex = _frameIndex; #endif - + #ifndef Q_OS_WIN // FIXME: we need a better way of responding to the HSW. In particular @@ -568,6 +570,7 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const } #endif + //beginFrameTiming must be called before display if (!_frameTimingActive) { printf("WARNING: Called OculusManager::display() without calling OculusManager::beginFrameTiming() first."); @@ -686,6 +689,7 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const #ifdef Q_OS_WIN auto srcFboSize = finalFbo->getSize(); + // Blit to the oculus provided texture glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo)); _swapFbo->Bound(oglplus::Framebuffer::Target::Draw, [&] { @@ -715,6 +719,7 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const GLsync syncObject = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); glFlush(); + _outputWindow->makeCurrent(); // force the compositing context to wait for the texture // rendering to complete before it starts the distortion rendering, @@ -725,104 +730,16 @@ void OculusManager::display(QGLWidget * glCanvas, RenderArgs* renderArgs, const for_each_eye([&](ovrEyeType eye) { ovrGLTexture & glEyeTexture = reinterpret_cast(_eyeTextures[eye]); glEyeTexture.OGL.TexId = textureId; + }); // restore our normal viewport ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures); glCanvas->makeCurrent(); #endif - - // No DK2, no message. - { - float latencies[5] = {}; - if (debugFrame && ovrHmd_GetFloatArray(_ovrHmd, "DK2Latency", latencies, 5) == 5) - { - bool nonZero = false; - for (int i = 0; i < 5; ++i) - { - nonZero |= (latencies[i] != 0.f); - } - - if (nonZero) - { - qCDebug(interfaceapp) - << QString().sprintf("M2P Latency: Ren: %4.2fms TWrp: %4.2fms PostPresent: %4.2fms Err: %4.2fms %4.2fms", - (double)latencies[0], (double)latencies[1], (double)latencies[2], - (double)latencies[3], (double)latencies[4]); - } - } - } - -} - -#ifdef OVR_CLIENT_DISTORTION -void OculusManager::renderDistortionMesh(ovrPosef eyeRenderPose[ovrEye_Count]) { - - glLoadIdentity(); - auto deviceSize = qApp->getDeviceSize(); - glOrtho(0, deviceSize.width(), 0, deviceSize.height(), -1.0, 1.0); - - glDisable(GL_DEPTH_TEST); - - glDisable(GL_BLEND); - _program.bind(); - _program.setUniformValue(_textureLocation, 0); - - _program.enableAttributeArray(_positionAttributeLocation); - _program.enableAttributeArray(_colorAttributeLocation); - _program.enableAttributeArray(_texCoord0AttributeLocation); - _program.enableAttributeArray(_texCoord1AttributeLocation); - _program.enableAttributeArray(_texCoord2AttributeLocation); - - //Render the distortion meshes for each eye - for (int eyeNum = 0; eyeNum < ovrEye_Count; eyeNum++) { - - ovrHmd_GetRenderScaleAndOffset(_eyeRenderDesc[eyeNum].Fov, _renderTargetSize, _eyeTextures[eyeNum].Header.RenderViewport, - _UVScaleOffset[eyeNum]); - - GLfloat uvScale[2] = { _UVScaleOffset[eyeNum][0].x, _UVScaleOffset[eyeNum][0].y }; - _program.setUniformValueArray(_eyeToSourceUVScaleLocation, uvScale, 1, 2); - GLfloat uvOffset[2] = { _UVScaleOffset[eyeNum][1].x, 1.0f - _UVScaleOffset[eyeNum][1].y }; - _program.setUniformValueArray(_eyeToSourceUVOffsetLocation, uvOffset, 1, 2); - - ovrMatrix4f timeWarpMatrices[2]; - glm::mat4 transposeMatrices[2]; - //Grabs the timewarp matrices to be used in the shader - ovrHmd_GetEyeTimewarpMatrices(_ovrHmd, (ovrEyeType)eyeNum, eyeRenderPose[eyeNum], timeWarpMatrices); - //Have to transpose the matrices before using them - transposeMatrices[0] = glm::transpose(toGlm(timeWarpMatrices[0])); - transposeMatrices[1] = glm::transpose(toGlm(timeWarpMatrices[1])); - - glUniformMatrix4fv(_eyeRotationStartLocation, 1, GL_FALSE, (GLfloat *)&transposeMatrices[0][0][0]); - glUniformMatrix4fv(_eyeRotationEndLocation, 1, GL_FALSE, (GLfloat *)&transposeMatrices[1][0][0]); - - glBindBuffer(GL_ARRAY_BUFFER, _vertices[eyeNum]); - - //Set vertex attribute pointers - glVertexAttribPointer(_positionAttributeLocation, 2, GL_FLOAT, GL_FALSE, sizeof(DistortionVertex), (void *)0); - glVertexAttribPointer(_texCoord0AttributeLocation, 2, GL_FLOAT, GL_FALSE, sizeof(DistortionVertex), (void *)8); - glVertexAttribPointer(_texCoord1AttributeLocation, 2, GL_FLOAT, GL_FALSE, sizeof(DistortionVertex), (void *)16); - glVertexAttribPointer(_texCoord2AttributeLocation, 2, GL_FLOAT, GL_FALSE, sizeof(DistortionVertex), (void *)24); - glVertexAttribPointer(_colorAttributeLocation, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(DistortionVertex), (void *)32); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indices[eyeNum]); - glDrawElements(GL_TRIANGLES, _meshSize[eyeNum], GL_UNSIGNED_SHORT, 0); - } - - _program.disableAttributeArray(_positionAttributeLocation); - _program.disableAttributeArray(_colorAttributeLocation); - _program.disableAttributeArray(_texCoord0AttributeLocation); - _program.disableAttributeArray(_texCoord1AttributeLocation); - _program.disableAttributeArray(_texCoord2AttributeLocation); - - glEnable(GL_BLEND); - glEnable(GL_DEPTH_TEST); - _program.release(); - glBindBuffer(GL_ARRAY_BUFFER, 0); -======= ->>>>>>> db56e15410520adab59d0e54348d9b32d17d808a + } //Tries to reconnect to the sensors diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index ea1be77552..4fff47e2fd 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -42,9 +42,9 @@ Mat4d EarthSunModel::evalWorldToGeoLocationMat(double longitude, double latitude void EarthSunModel::updateWorldToSurface() const { // Check if the final position is too close to the earth center ? - double absAltitude = _earthRadius + _altitude; - if ( absAltitude < 0.01) { - absAltitude = 0.01; + float absAltitude = _earthRadius + _altitude; + if ( absAltitude < 0.01f) { + absAltitude = 0.01f; } // Final world to local Frame @@ -263,8 +263,8 @@ double evalSunDeclinaison(double dayNumber) { void SunSkyStage::updateGraphicsObject() const { // Always update the sunLongitude based on the current dayTime and the current origin // The day time is supposed to be local at the origin - double signedNormalizedDayTime = (_dayTime - NUM_HOURS_PER_HALF_DAY) / NUM_HOURS_PER_HALF_DAY; - double sunLongitude = _earthSunModel.getLongitude() + (MAX_LONGITUDE * signedNormalizedDayTime); + float signedNormalizedDayTime = (_dayTime - NUM_HOURS_PER_HALF_DAY) / NUM_HOURS_PER_HALF_DAY; + float sunLongitude = _earthSunModel.getLongitude() + (MAX_LONGITUDE * signedNormalizedDayTime); _earthSunModel.setSunLongitude(sunLongitude); // And update the sunLAtitude as the declinaison depending of the time of the year diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index b4df45e024..89a8a4c049 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -72,7 +72,7 @@ public: protected: float _scale = 1000.0f; //Km - double _earthRadius = 6360.0; + float _earthRadius = 6360.0; Quat _surfaceOrientation;