Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move initialization to header, erase parent_name from export object
  • Loading branch information
NEDJIMAbelgacem committed Jul 27, 2020
1 parent db1ab71 commit daa5327
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
8 changes: 0 additions & 8 deletions src/3d/qgs3dexportobject.cpp
Expand Up @@ -42,14 +42,6 @@ void insertIndexData( QVector<uint> &vertexIndex, const QVector<T> &faceIndex )
}
}

Qgs3DExportObject::Qgs3DExportObject( const QString &name, const QString &parentName, QObject *parent )
: QObject( parent )
, mName( name )
, mParentName( parentName )
, mSmoothEdges( false )
{
}

void Qgs3DExportObject::setupPositionCoordinates( const QVector<float> &positionsBuffer, float scale, const QVector3D translation )
{
for ( int i = 0; i < positionsBuffer.size(); i += 3 )
Expand Down
6 changes: 2 additions & 4 deletions src/3d/qgs3dexportobject.h
Expand Up @@ -47,14 +47,12 @@ class Qgs3DExportObject : public QObject
/**
* \brief Qgs3DExportObject
* Constructs an export object that will be filled with coordinates later
* \param name
* The name of the object (the user will be able to select each object individually using its name in blender)
* \param parentName
* The name of the parent (Will be useful to define scene hierarchie)
* \param parent
* The parent QObject (we use this to delete the Qgs3DExportObject instance once the exporter instance is deallocated)
*/
Qgs3DExportObject( const QString &name, const QString &parentName = QString(), QObject *parent = nullptr );
Qgs3DExportObject( const QString &name, QObject *parent = nullptr ) : QObject( parent ), mName( name ) { }

//! Returns the object name
QString name() const { return mName; }
Expand Down Expand Up @@ -117,7 +115,7 @@ class Qgs3DExportObject : public QObject

QImage mTextureImage;

bool mSmoothEdges;
bool mSmoothEdges = false;
};

#endif // Qgs3DExportObject_H
12 changes: 6 additions & 6 deletions src/3d/qgs3dsceneexporter.cpp
Expand Up @@ -440,7 +440,7 @@ void Qgs3DSceneExporter::parseFlatTile( QgsTerrainTileEntity *tileEntity, const
QString objectNamePrefix = layerName;
if ( objectNamePrefix != QString() ) objectNamePrefix += QString();

Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "Flat_tile" ) ), "", this );
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "Flat_tile" ) ), this );
mObjects.push_back( object );

object->setSmoothEdges( mSmoothEdges );
Expand Down Expand Up @@ -495,7 +495,7 @@ void Qgs3DSceneExporter::parseDemTile( QgsTerrainTileEntity *tileEntity, const Q
QString objectNamePrefix = layerName;
if ( objectNamePrefix != QString() ) objectNamePrefix += QStringLiteral( "_" );

Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( layerName + QStringLiteral( "DEM_tile" ) ), "", this );
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( layerName + QStringLiteral( "DEM_tile" ) ), this );
mObjects.push_back( object );

object->setSmoothEdges( mSmoothEdges );
Expand Down Expand Up @@ -562,7 +562,7 @@ QVector<Qgs3DExportObject *> Qgs3DSceneExporter::processInstancedPointGeometry(
QVector<float> instancePosition = getAttributeData<float>( instanceDataAttribute, instancePositionBytes );
for ( int i = 0; i < instancePosition.size(); i += 3 )
{
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "shape_geometry" ) ), "", this );
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "shape_geometry" ) ), this );
objects.push_back( object );
object->setupPositionCoordinates( positionData, 1.0f, QVector3D( instancePosition[i], instancePosition[i + 1], instancePosition[i + 2] ) );
object->setupFaces( indexData );
Expand Down Expand Up @@ -661,7 +661,7 @@ Qgs3DExportObject *Qgs3DSceneExporter::processGeometryRenderer( Qt3DRender::QGeo
return nullptr;
}

Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "mesh_geometry" ) ), "", this );
Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "mesh_geometry" ) ), this );
object->setupPositionCoordinates( positionData, scale * sceneScale, translation + sceneTranslation );
object->setupFaces( indexData );

Expand Down Expand Up @@ -713,7 +713,7 @@ QVector<Qgs3DExportObject *> Qgs3DSceneExporter::processLines( Qt3DCore::QEntity
QVector<float> positionData = getAttributeData<float>( positionAttribute, vertexBytes );
QVector<uint> indexData = getIndexData( indexAttribute, indexBytes );

Qgs3DExportObject *exportObject = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "line" ) ), QString(), this );
Qgs3DExportObject *exportObject = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "line" ) ), this );
exportObject->setType( Qgs3DExportObject::LineStrip );
exportObject->setupPositionCoordinates( positionData );
exportObject->setupLine( indexData );
Expand All @@ -739,7 +739,7 @@ Qgs3DExportObject *Qgs3DSceneExporter::processPoints( Qt3DCore::QEntity *entity,
QVector<float> positions = getAttributeData<float>( positionAttribute, positionBytes );
points << positions;
}
Qgs3DExportObject *obj = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "points" ) ), QString(), this );
Qgs3DExportObject *obj = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "points" ) ), this );
obj->setType( Qgs3DExportObject::Points );
obj->setupPositionCoordinates( points );
return obj;
Expand Down

0 comments on commit daa5327

Please sign in to comment.