Scenery3d.cpp   Scenery3d.cpp 
skipping to change at line 98 skipping to change at line 98
core(NULL), landscapeMgr(NULL), heightmap(NULL), heightmapLoad(NULL) , core(NULL), landscapeMgr(NULL), heightmap(NULL), heightmapLoad(NULL) ,
mainViewUp(0.0, 0.0, 1.0), mainViewDir(1.0, 0.0, 0.0), viewPos(0.0, 0 .0, 0.0), mainViewUp(0.0, 0.0, 1.0), mainViewDir(1.0, 0.0, 0.0), viewPos(0.0, 0 .0, 0.0),
drawnTriangles(0), drawnModels(0), materialSwitches(0), shaderSwitche s(0), drawnTriangles(0), drawnModels(0), materialSwitches(0), shaderSwitche s(0),
requiresCubemap(false), cubemappingUsedLastFrame(false), requiresCubemap(false), cubemappingUsedLastFrame(false),
lazyDrawing(false), updateOnlyDominantOnMoving(true), updateSecondDom inantOnMoving(true), needsMovementEndUpdate(false), lazyDrawing(false), updateOnlyDominantOnMoving(true), updateSecondDom inantOnMoving(true), needsMovementEndUpdate(false),
needsCubemapUpdate(true), needsMovementUpdate(false), lazyInterval(2. 0), lastCubemapUpdate(0.0), lastCubemapUpdateRealTime(0), lastMovementEndRe alTime(0), needsCubemapUpdate(true), needsMovementUpdate(false), lazyInterval(2. 0), lastCubemapUpdate(0.0), lastCubemapUpdateRealTime(0), lastMovementEndRe alTime(0),
cubeMapCubeTex(0), cubeMapCubeDepth(0), cubeMapTex(), cubeRB(0), domi nantFace(0), secondDominantFace(1), cubeFBO(0), cubeSideFBO(), cubeMappingC reated(false), cubeMapCubeTex(0), cubeMapCubeDepth(0), cubeMapTex(), cubeRB(0), domi nantFace(0), secondDominantFace(1), cubeFBO(0), cubeSideFBO(), cubeMappingC reated(false),
cubeVertexBuffer(QOpenGLBuffer::VertexBuffer), cubeIndexBuffer(QOpenG LBuffer::IndexBuffer), cubeIndexCount(0), cubeVertexBuffer(QOpenGLBuffer::VertexBuffer), cubeIndexBuffer(QOpenG LBuffer::IndexBuffer), cubeIndexCount(0),
lightOrthoNear(0.1f), lightOrthoFar(1000.0f), parallaxScale(0.015f) lightOrthoNear(0.1f), lightOrthoFar(1000.0f), parallaxScale(0.015f)
{ {
#ifndef NDEBUG
qDebug()<<"Scenery3d constructor..."; qDebug()<<"Scenery3d constructor...";
#endif
//the arrays should all contain only zeroes //the arrays should all contain only zeroes
Q_ASSERT(cubeMapTex[0]==0); Q_ASSERT(cubeMapTex[0]==0);
Q_ASSERT(cubeSideFBO[0]==0); Q_ASSERT(cubeSideFBO[0]==0);
shaderParameters.openglES = false; shaderParameters.openglES = false;
shaderParameters.shadowTransform = false; shaderParameters.shadowTransform = false;
shaderParameters.pixelLighting = false; shaderParameters.pixelLighting = false;
shaderParameters.bump = false; shaderParameters.bump = false;
shaderParameters.shadows = false; shaderParameters.shadows = false;
shaderParameters.shadowFilterQuality = S3DEnum::SFQ_LOW; shaderParameters.shadowFilterQuality = S3DEnum::SFQ_LOW;
shaderParameters.pcss = false; shaderParameters.pcss = false;
shaderParameters.geometryShader = false; shaderParameters.geometryShader = false;
shaderParameters.torchLight = false; shaderParameters.torchLight = false;
shaderParameters.frustumSplits = 0; shaderParameters.frustumSplits = 0;
sceneBoundingBox = AABB(Vec3f(0.0f), Vec3f(0.0f)); sceneBoundingBox = AABB(Vec3f(0.0f), Vec3f(0.0f));
debugTextFont.setFamily("Courier"); debugTextFont.setFamily("Courier");
debugTextFont.setPixelSize(16); debugTextFont.setPixelSize(16);
#ifndef NDEBUG
qDebug()<<"Scenery3d constructor...done"; qDebug()<<"Scenery3d constructor...done";
#endif
} }
Scenery3d::~Scenery3d() Scenery3d::~Scenery3d()
{ {
if (heightmap) { if (heightmap) {
delete heightmap; delete heightmap;
heightmap = NULL; heightmap = NULL;
} }
if(heightmapLoad) if(heightmapLoad)
skipping to change at line 324 skipping to change at line 327
} }
//reset the cubemap time so that is ensured it is immediately rerend ered //reset the cubemap time so that is ensured it is immediately rerend ered
invalidateCubemap(); invalidateCubemap();
} }
void Scenery3d::handleKeys(QKeyEvent* e) void Scenery3d::handleKeys(QKeyEvent* e)
{ {
//TODO FS maybe move this to Mgr, so that input is separate from ren dering and scene management? //TODO FS maybe move this to Mgr, so that input is separate from ren dering and scene management?
if ((e->type() == QKeyEvent::KeyPress) && (e->modifiers() & Qt::Cont static const Qt::KeyboardModifier S3D_SPEEDBASE_MODIFIER = Qt::Shift
rolModifier)) Modifier;
//on OSX, there is a still-unfixed bug which prevents the command ke
y (=Qt's Control key) to be used here
//see https://bugreports.qt.io/browse/QTBUG-36839
//we have to use the option/ALT key instead to activate walking arou
nd, and CMD is used as multiplier.
#ifdef Q_OS_OSX
static const Qt::KeyboardModifier S3D_CTRL_MODIFIER = Qt::AltModifie
r;
static const Qt::KeyboardModifier S3D_SPEEDMUL_MODIFIER = Qt::Contro
lModifier;
#else
static const Qt::KeyboardModifier S3D_CTRL_MODIFIER = Qt::ControlMod
ifier;
static const Qt::KeyboardModifier S3D_SPEEDMUL_MODIFIER = Qt::AltMod
ifier;
#endif
if ((e->type() == QKeyEvent::KeyPress) && (e->modifiers() & S3D_CTRL
_MODIFIER))
{ {
// Pressing CTRL+ALT: 5x, CTRL+SHIFT: 10x speedup; CTRL+SHIF T+ALT: 50x! // Pressing CTRL+ALT: 5x, CTRL+SHIFT: 10x speedup; CTRL+SHIF T+ALT: 50x!
float speedup=((e->modifiers() & Qt::ShiftModifier)? 10.0f : float speedup=((e->modifiers() & S3D_SPEEDBASE_MODIFIER)? 10
1.0f); .0f : 1.0f);
speedup *= ((e->modifiers() & Qt::AltModifier)? 5.0f : 1.0f) speedup *= ((e->modifiers() & S3D_SPEEDMUL_MODIFIER)? 5.0f :
; 1.0f);
switch (e->key()) switch (e->key())
{ {
case Qt::Key_PageUp: movement[2] = -1.0f * speedu p; e->accept(); break; case Qt::Key_PageUp: movement[2] = -1.0f * speedu p; e->accept(); break;
case Qt::Key_PageDown: movement[2] = 1.0f * speedu p; e->accept(); break; case Qt::Key_PageDown: movement[2] = 1.0f * speedu p; e->accept(); break;
case Qt::Key_Up: movement[1] = -1.0f * speedu p; e->accept(); break; case Qt::Key_Up: movement[1] = -1.0f * speedu p; e->accept(); break;
case Qt::Key_Down: movement[1] = 1.0f * speedu p; e->accept(); break; case Qt::Key_Down: movement[1] = 1.0f * speedu p; e->accept(); break;
case Qt::Key_Right: movement[0] = 1.0f * speedu p; e->accept(); break; case Qt::Key_Right: movement[0] = 1.0f * speedu p; e->accept(); break;
case Qt::Key_Left: movement[0] = -1.0f * speedu p; e->accept(); break; case Qt::Key_Left: movement[0] = -1.0f * speedu p; e->accept(); break;
#ifdef QT_DEBUG #ifdef QT_DEBUG
//leave this out on non-debug builds to redu ce conflict chance //leave this out on non-debug builds to reduce confl ict chance
case Qt::Key_P: saveFrusts(); e->accept(); b reak; case Qt::Key_P: saveFrusts(); e->accept(); b reak;
#endif #endif
} }
} }
else if ((e->type() == QKeyEvent::KeyRelease) && (e->modifiers() & Q // FS: No modifier here!? GZ: I want the lock feature. If this does
t::ControlModifier)) not work for MacOS, it is not there, but only on that platform...
#ifdef Q_OS_OSX
else if ((e->type() == QKeyEvent::KeyRelease) )
#else
else if ((e->type() == QKeyEvent::KeyRelease) && (e->modifiers() & S
3D_CTRL_MODIFIER))
#endif
{ {
if (e->key() == Qt::Key_PageUp || e->key() == Qt::Key_PageDo //if a movement key is released, stop moving in that directi
wn || on
e->key() == Qt::Key_Up || e->key() == Qt //we do not accept the event on MacOS to allow further handl
::Key_Down || ing the event in other modules. (Else the regular view motion stop does not
e->key() == Qt::Key_Left || e->key() == Qt work!)
::Key_Right ) switch (e->key())
{ {
movement[0] = movement[1] = movement[2] = 0.0f; case Qt::Key_PageUp:
e->accept(); case Qt::Key_PageDown:
movement[2] = 0.0f;
#ifndef Q_OS_OSX
e->accept();
#endif
break;
case Qt::Key_Up:
case Qt::Key_Down:
movement[1] = 0.0f;
#ifndef Q_OS_OSX
e->accept();
#endif
break;
case Qt::Key_Right:
case Qt::Key_Left:
movement[0] = 0.0f;
#ifndef Q_OS_OSX
e->accept();
#endif
break;
} }
} }
} }
void Scenery3d::saveFrusts() void Scenery3d::saveFrusts()
{ {
fixShadowData = !fixShadowData; fixShadowData = !fixShadowData;
camFrustShadow.saveDrawingCorners(); camFrustShadow.saveDrawingCorners();
skipping to change at line 387 skipping to change at line 428
StelMovementMgr *stelMovementMgr = GETSTELMODULE(StelMovemen tMgr); StelMovementMgr *stelMovementMgr = GETSTELMODULE(StelMovemen tMgr);
Vec3d viewDirection = core->getMovementMgr()->getViewDirecti onJ2000(); Vec3d viewDirection = core->getMovementMgr()->getViewDirecti onJ2000();
Vec3d viewDirectionAltAz=core->j2000ToAltAz(viewDirection); Vec3d viewDirectionAltAz=core->j2000ToAltAz(viewDirection);
double alt, az; double alt, az;
StelUtils::rectToSphe(&az, &alt, viewDirectionAltAz); StelUtils::rectToSphe(&az, &alt, viewDirectionAltAz);
//if we were moving in the last update //if we were moving in the last update
bool wasMoving = moveVector.lengthSquared()>0.0; bool wasMoving = moveVector.lengthSquared()>0.0;
moveVector = Vec3d(( movement[0] * std::cos(az) + movement[1 //moveVector = Vec3d(( movement[0] * std::cos(az) + movement
] * std::sin(az)), [1] * std::sin(az)),
( movement[0] * std::sin(az) - movement[1] * // ( movement[0] * std::sin(az) - movement[1] *
std::cos(az)), std::cos(az)),
// movement[2]);
//Bring move into world-grid space
//currentScene.zRotateMatrix.transfo(moveVector);
// GZ DON'T!: Rotating by zRotateMatrix will make a case of
convergence_angle=180 (i.e. misconfigured model) very silly (inverted!). --
>Just swap x/y.
// moveVector.set(-moveVector.v[1], moveVector.v[0], moveVec
tor.v[2]);
// Better yet: immediately make it right.
moveVector.set( movement[1] * std::cos(az) - movement[0] * s
td::sin(az),
movement[0] * std::cos(az) + movement[1] * s
td::sin(az),
movement[2]); movement[2]);
//get current time //get current time
double curTime = core->getJD(); double curTime = core->getJD();
if(lazyDrawing) if(lazyDrawing)
{ {
needsMovementUpdate = false; needsMovementUpdate = false;
//check if cubemap requires redraw //check if cubemap requires redraw
skipping to change at line 440 skipping to change at line 490
needsCubemapUpdate = false; needsCubemapUpdate = false;
} }
} }
else else
{ {
needsCubemapUpdate = true; needsCubemapUpdate = true;
} }
moveVector *= deltaTime * 0.01 * qMax(5.0, stelMovementMgr-> getCurrentFov()); moveVector *= deltaTime * 0.01 * qMax(5.0, stelMovementMgr-> getCurrentFov());
//Bring move into world-grid space
currentScene.zRotateMatrix.transfo(moveVector);
absolutePosition.v[0] += moveVector.v[0]; absolutePosition.v[0] += moveVector.v[0];
absolutePosition.v[1] += moveVector.v[1]; absolutePosition.v[1] += moveVector.v[1];
eye_height -= moveVector.v[2]; eye_height -= moveVector.v[2];
absolutePosition.v[2] = -groundHeight()-eye_height; absolutePosition.v[2] = -groundHeight()-eye_height;
//View Up in our case always pointing positive up //View Up in our case always pointing positive up
mainViewUp.v[0] = 0; mainViewUp.v[0] = 0;
mainViewUp.v[1] = 0; mainViewUp.v[1] = 0;
mainViewUp.v[2] = 1; mainViewUp.v[2] = 1;
skipping to change at line 1824 skipping to change at line 1871
} }
else else
{ {
qWarning()<<"[Scenery3d] Cannot use debug shader, pr obably on OpenGL ES context"; qWarning()<<"[Scenery3d] Cannot use debug shader, pr obably on OpenGL ES context";
} }
} }
#endif #endif
StelPainter painter(altAzProjector); StelPainter painter(altAzProjector);
painter.setFont(debugTextFont); painter.setFont(debugTextFont);
painter.setColor(1,0,1,1); painter.setColor(1.f,0.f,1.f,1.f);
// For now, these messages print light mixture values. // For now, these messages print light mixture values.
painter.drawText(20, 160, lightMessage); painter.drawText(20, 160, lightMessage);
painter.drawText(20, 145, lightMessage2); painter.drawText(20, 145, lightMessage2);
painter.drawText(20, 130, lightMessage3); painter.drawText(20, 130, lightMessage3);
painter.drawText(20, 115, QString("Torch range %1, brightness %2/%3/%4" ).arg(torchRange).arg(lightInfo.torchDiffuse[0]).arg(lightInfo.torchDiffuse [1]).arg(lightInfo.torchDiffuse[2])); painter.drawText(20, 115, QString("Torch range %1, brightness %2/%3/%4" ).arg(torchRange).arg(lightInfo.torchDiffuse[0]).arg(lightInfo.torchDiffuse [1]).arg(lightInfo.torchDiffuse[2]));
QString str = QString("BB: %1/%2/%3 %4/%5/%6").arg(sceneBoundingBox.min .v[0], 7, 'f', 2).arg(sceneBoundingBox.min.v[1], 7, 'f', 2).arg(sceneBoundi ngBox.min.v[2], 7, 'f', 2) QString str = QString("BB: %1/%2/%3 %4/%5/%6").arg(sceneBoundingBox.min .v[0], 7, 'f', 2).arg(sceneBoundingBox.min.v[1], 7, 'f', 2).arg(sceneBoundi ngBox.min.v[2], 7, 'f', 2)
.arg(sceneBoundingBox.max.v[0], 7, 'f', 2).arg(sceneBoun dingBox.max.v[1], 7, 'f', 2).arg(sceneBoundingBox.max.v[2], 7, 'f', 2); .arg(sceneBoundingBox.max.v[0], 7, 'f', 2).arg(sceneBoun dingBox.max.v[1], 7, 'f', 2).arg(sceneBoundingBox.max.v[2], 7, 'f', 2);
painter.drawText(10, 100, str); painter.drawText(10, 100, str);
// PRINT OTHER MESSAGES HERE: // PRINT OTHER MESSAGES HERE:
 End of changes. 13 change blocks. 
26 lines changed or deleted 86 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/