Fix 3D build on windows

This commit is contained in:
Juergen E. Fischer 2017-10-14 23:41:23 +02:00
parent 949d216744
commit d6a12e0ba0
5 changed files with 30 additions and 21 deletions

View File

@ -165,6 +165,7 @@ cmake -G Ninja ^
-D WITH_SERVER=TRUE ^ -D WITH_SERVER=TRUE ^
-D SERVER_SKIP_ECW=TRUE ^ -D SERVER_SKIP_ECW=TRUE ^
-D WITH_GRASS=TRUE ^ -D WITH_GRASS=TRUE ^
-D WITH_3D=TRUE ^
-D WITH_GRASS7=TRUE ^ -D WITH_GRASS7=TRUE ^
-D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^ -D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^
-D WITH_GLOBE=FALSE ^ -D WITH_GLOBE=FALSE ^
@ -324,6 +325,7 @@ exit /b 1
:error :error
echo BUILD ERROR %ERRORLEVEL%: %DATE% %TIME% echo BUILD ERROR %ERRORLEVEL%: %DATE% %TIME%
if exist %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 del %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 if exist %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 del %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2
exit /b 1
:end :end
echo FINISHED: %DATE% %TIME% echo FINISHED: %DATE% %TIME%

View File

@ -203,8 +203,8 @@ void Qgs3DMapScene::onCameraChanged()
{ {
Qt3DRender::QCamera *camera = cameraController()->camera(); Qt3DRender::QCamera *camera = cameraController()->camera();
QMatrix4x4 viewMatrix = camera->viewMatrix(); QMatrix4x4 viewMatrix = camera->viewMatrix();
float near = 1e9; float fnear = 1e9;
float far = 0; float ffar = 0;
QList<QgsChunkNode *> activeNodes = mTerrain->activeNodes(); QList<QgsChunkNode *> activeNodes = mTerrain->activeNodes();
@ -227,27 +227,27 @@ void Qgs3DMapScene::onCameraChanged()
QVector4D pc = viewMatrix * p; QVector4D pc = viewMatrix * p;
float dst = -pc.z(); // in camera coordinates, x grows right, y grows down, z grows to the back float dst = -pc.z(); // in camera coordinates, x grows right, y grows down, z grows to the back
if ( dst < near ) if ( dst < fnear )
near = dst; fnear = dst;
if ( dst > far ) if ( dst > ffar )
far = dst; ffar = dst;
} }
} }
if ( near < 1 ) if ( fnear < 1 )
near = 1; // does not really make sense to use negative far plane (behind camera) 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 // the update didn't work out... this should not happen
// well at least temprarily use some conservative starting values // 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"; qDebug() << "oops... this should not happen! couldn't determine near/far plane. defaulting to 1...1e9";
near = 1; fnear = 1;
far = 1e9; ffar = 1e9;
} }
// set near/far plane - with some tolerance in front/behind expected near/far planes // set near/far plane - with some tolerance in front/behind expected near/far planes
camera->setFarPlane( far * 2 ); camera->setFarPlane( ffar * 2 );
camera->setNearPlane( near / 2 ); camera->setNearPlane( fnear / 2 );
} }
else else
qDebug() << "no terrain - not setting near/far plane"; qDebug() << "no terrain - not setting near/far plane";

View File

@ -20,6 +20,7 @@
#include "qgs3drendererregistry.h" #include "qgs3drendererregistry.h"
#include "qgsabstract3drenderer.h" #include "qgsabstract3drenderer.h"
#include "qgsabstract3dsymbol.h"
#include "qgsphongmaterialsettings.h" #include "qgsphongmaterialsettings.h"
#include "qgs3dutils.h" #include "qgs3dutils.h"
@ -30,8 +31,6 @@
class QgsVectorLayer; class QgsVectorLayer;
class QgsAbstract3DSymbol;
/** /**
* \ingroup core * \ingroup core

View File

@ -26,6 +26,11 @@ QgsDemTerrainGenerator::QgsDemTerrainGenerator()
{ {
} }
QgsDemTerrainGenerator::~QgsDemTerrainGenerator()
{
delete mHeightMapGenerator;
}
void QgsDemTerrainGenerator::setLayer( QgsRasterLayer *layer ) void QgsDemTerrainGenerator::setLayer( QgsRasterLayer *layer )
{ {
mLayer = QgsMapLayerRef( layer ); mLayer = QgsMapLayerRef( layer );
@ -91,11 +96,13 @@ void QgsDemTerrainGenerator::updateGenerator()
if ( dem ) if ( dem )
{ {
mTerrainTilingScheme = QgsTilingScheme( dem->extent(), dem->crs() ); mTerrainTilingScheme = QgsTilingScheme( dem->extent(), dem->crs() );
mHeightMapGenerator.reset( new QgsDemHeightMapGenerator( dem, mTerrainTilingScheme, mResolution ) ); delete mHeightMapGenerator;
mHeightMapGenerator = new QgsDemHeightMapGenerator( dem, mTerrainTilingScheme, mResolution );
} }
else else
{ {
mTerrainTilingScheme = QgsTilingScheme(); mTerrainTilingScheme = QgsTilingScheme();
mHeightMapGenerator.reset(); delete mHeightMapGenerator;
mHeightMapGenerator = nullptr;
} }
} }

View File

@ -20,11 +20,11 @@
#include "qgsterraingenerator.h" #include "qgsterraingenerator.h"
#include <memory> #include <memory>
class QgsDemHeightMapGenerator;
class QgsRasterLayer; class QgsRasterLayer;
class QgsDemHeightMapGenerator;
#include "qgsmaplayerref.h" #include "qgsmaplayerref.h"
@ -37,6 +37,7 @@ class _3D_EXPORT QgsDemTerrainGenerator : public QgsTerrainGenerator
{ {
public: public:
QgsDemTerrainGenerator(); QgsDemTerrainGenerator();
~QgsDemTerrainGenerator();
//! Sets raster layer with elevation model to be used for terrain generation //! Sets raster layer with elevation model to be used for terrain generation
void setLayer( QgsRasterLayer *layer ); void setLayer( QgsRasterLayer *layer );
@ -49,7 +50,7 @@ class _3D_EXPORT QgsDemTerrainGenerator : public QgsTerrainGenerator
int resolution() const { return mResolution; } int resolution() const { return mResolution; }
//! Returns height map generator object - takes care of extraction of elevations from the layer) //! 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; virtual QgsTerrainGenerator *clone() const override SIP_FACTORY;
Type type() const override; Type type() const override;
@ -64,7 +65,7 @@ class _3D_EXPORT QgsDemTerrainGenerator : public QgsTerrainGenerator
private: private:
void updateGenerator(); void updateGenerator();
std::unique_ptr<QgsDemHeightMapGenerator> mHeightMapGenerator; QgsDemHeightMapGenerator *mHeightMapGenerator = nullptr;
//! source layer for heights //! source layer for heights
QgsMapLayerRef mLayer; QgsMapLayerRef mLayer;