Skip to content

Commit

Permalink
Fix 3d renderer does not work with multipoint layers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 9, 2017
1 parent 4c78526 commit df7a1d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/3d/qgs3dutils.cpp
Expand Up @@ -172,14 +172,15 @@ QList<QVector3D> Qgs3DUtils::positions( const Qgs3DMapSettings &map, QgsVectorLa
continue;

const QgsAbstractGeometry *g = f.geometry().constGet();
if ( const QgsPoint *pt = qgsgeometry_cast< const QgsPoint *>( g ) )
for ( auto it = g->vertices_begin(); it != g->vertices_end(); ++it )
{
QgsPoint pt = *it;
float geomZ = 0;
if ( pt->is3D() )
if ( pt.is3D() )
{
geomZ = pt->z();
geomZ = pt.z();
}
float terrainZ = map.terrainGenerator()->heightAt( pt->x(), pt->y(), map ) * map.terrainVerticalScale();
float terrainZ = map.terrainGenerator()->heightAt( pt.x(), pt.y(), map ) * map.terrainVerticalScale();
float h;
switch ( altClamp )
{
Expand All @@ -193,11 +194,9 @@ QList<QVector3D> Qgs3DUtils::positions( const Qgs3DMapSettings &map, QgsVectorLa
h = terrainZ + geomZ;
break;
}
positions.append( QVector3D( pt->x() - map.originX(), h, -( pt->y() - map.originY() ) ) );
positions.append( QVector3D( pt.x() - map.originX(), h, -( pt.y() - map.originY() ) ) );
//qDebug() << positions.last();
}
else
qDebug() << "not a point";
}

return positions;
Expand Down
2 changes: 1 addition & 1 deletion src/3d/qgs3dutils.h
Expand Up @@ -75,7 +75,7 @@ class _3D_EXPORT Qgs3DUtils
static QMatrix4x4 stringToMatrix4x4( const QString &str );

/**
* Calculates (x,y,z) position of point in the Point vector layers
* Calculates (x,y,z) positions of a (multi)point in the Point vector layers
*/
static QList<QVector3D> positions( const Qgs3DMapSettings &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, AltitudeClamping altClamp );

Expand Down

0 comments on commit df7a1d0

Please sign in to comment.