Skip to content

Commit

Permalink
Fix 3D build on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Oct 14, 2017
1 parent 949d216 commit d6a12e0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
2 changes: 2 additions & 0 deletions ms-windows/osgeo4w/package-nightly.cmd
Expand Up @@ -165,6 +165,7 @@ cmake -G Ninja ^
-D WITH_SERVER=TRUE ^
-D SERVER_SKIP_ECW=TRUE ^
-D WITH_GRASS=TRUE ^
-D WITH_3D=TRUE ^
-D WITH_GRASS7=TRUE ^
-D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^
-D WITH_GLOBE=FALSE ^
Expand Down Expand Up @@ -324,6 +325,7 @@ exit /b 1
:error
echo BUILD ERROR %ERRORLEVEL%: %DATE% %TIME%
if exist %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 del %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2
exit /b 1

:end
echo FINISHED: %DATE% %TIME%
Expand Down
26 changes: 13 additions & 13 deletions src/3d/qgs3dmapscene.cpp
Expand Up @@ -203,8 +203,8 @@ void Qgs3DMapScene::onCameraChanged()
{
Qt3DRender::QCamera *camera = cameraController()->camera();
QMatrix4x4 viewMatrix = camera->viewMatrix();
float near = 1e9;
float far = 0;
float fnear = 1e9;
float ffar = 0;

QList<QgsChunkNode *> activeNodes = mTerrain->activeNodes();

Expand All @@ -227,27 +227,27 @@ void Qgs3DMapScene::onCameraChanged()
QVector4D pc = viewMatrix * p;

float dst = -pc.z(); // in camera coordinates, x grows right, y grows down, z grows to the back
if ( dst < near )
near = dst;
if ( dst > far )
far = dst;
if ( dst < fnear )
fnear = dst;
if ( dst > ffar )
ffar = dst;
}
}
if ( near < 1 )
near = 1; // does not really make sense to use negative far plane (behind camera)
if ( fnear < 1 )
fnear = 1; // does not really make sense to use negative far plane (behind camera)

if ( near == 1e9 && far == 0 )
if ( fnear == 1e9 && ffar == 0 )
{
// the update didn't work out... this should not happen
// well at least temprarily use some conservative starting values
qDebug() << "oops... this should not happen! couldn't determine near/far plane. defaulting to 1...1e9";
near = 1;
far = 1e9;
fnear = 1;
ffar = 1e9;
}

// set near/far plane - with some tolerance in front/behind expected near/far planes
camera->setFarPlane( far * 2 );
camera->setNearPlane( near / 2 );
camera->setFarPlane( ffar * 2 );
camera->setNearPlane( fnear / 2 );
}
else
qDebug() << "no terrain - not setting near/far plane";
Expand Down
3 changes: 1 addition & 2 deletions src/3d/qgsvectorlayer3drenderer.h
Expand Up @@ -20,6 +20,7 @@

#include "qgs3drendererregistry.h"
#include "qgsabstract3drenderer.h"
#include "qgsabstract3dsymbol.h"

#include "qgsphongmaterialsettings.h"
#include "qgs3dutils.h"
Expand All @@ -30,8 +31,6 @@

class QgsVectorLayer;

class QgsAbstract3DSymbol;


/**
* \ingroup core
Expand Down
11 changes: 9 additions & 2 deletions src/3d/terrain/qgsdemterraingenerator.cpp
Expand Up @@ -26,6 +26,11 @@ QgsDemTerrainGenerator::QgsDemTerrainGenerator()
{
}

QgsDemTerrainGenerator::~QgsDemTerrainGenerator()
{
delete mHeightMapGenerator;
}

void QgsDemTerrainGenerator::setLayer( QgsRasterLayer *layer )
{
mLayer = QgsMapLayerRef( layer );
Expand Down Expand Up @@ -91,11 +96,13 @@ void QgsDemTerrainGenerator::updateGenerator()
if ( dem )
{
mTerrainTilingScheme = QgsTilingScheme( dem->extent(), dem->crs() );
mHeightMapGenerator.reset( new QgsDemHeightMapGenerator( dem, mTerrainTilingScheme, mResolution ) );
delete mHeightMapGenerator;
mHeightMapGenerator = new QgsDemHeightMapGenerator( dem, mTerrainTilingScheme, mResolution );
}
else
{
mTerrainTilingScheme = QgsTilingScheme();
mHeightMapGenerator.reset();
delete mHeightMapGenerator;
mHeightMapGenerator = nullptr;
}
}
9 changes: 5 additions & 4 deletions src/3d/terrain/qgsdemterraingenerator.h
Expand Up @@ -20,11 +20,11 @@

#include "qgsterraingenerator.h"

#include <memory>

class QgsDemHeightMapGenerator;
#include <memory>

class QgsRasterLayer;
class QgsDemHeightMapGenerator;

#include "qgsmaplayerref.h"

Expand All @@ -37,6 +37,7 @@ class _3D_EXPORT QgsDemTerrainGenerator : public QgsTerrainGenerator
{
public:
QgsDemTerrainGenerator();
~QgsDemTerrainGenerator();

//! Sets raster layer with elevation model to be used for terrain generation
void setLayer( QgsRasterLayer *layer );
Expand All @@ -49,7 +50,7 @@ class _3D_EXPORT QgsDemTerrainGenerator : public QgsTerrainGenerator
int resolution() const { return mResolution; }

//! Returns height map generator object - takes care of extraction of elevations from the layer)
QgsDemHeightMapGenerator *heightMapGenerator() { return mHeightMapGenerator.get(); }
QgsDemHeightMapGenerator *heightMapGenerator() { return mHeightMapGenerator; }

virtual QgsTerrainGenerator *clone() const override SIP_FACTORY;
Type type() const override;
Expand All @@ -64,7 +65,7 @@ class _3D_EXPORT QgsDemTerrainGenerator : public QgsTerrainGenerator
private:
void updateGenerator();

std::unique_ptr<QgsDemHeightMapGenerator> mHeightMapGenerator;
QgsDemHeightMapGenerator *mHeightMapGenerator = nullptr;

//! source layer for heights
QgsMapLayerRef mLayer;
Expand Down

0 comments on commit d6a12e0

Please sign in to comment.