Skip to content
Permalink
Browse files

Move initialization to header, erase parent_name from export object

  • Loading branch information
NEDJIMAbelgacem committed Jul 27, 2020
1 parent db1ab71 commit daa532794bb38cb8ad572030fbcd41e6fa1ce438
Showing with 8 additions and 18 deletions.
  1. +0 −8 src/3d/qgs3dexportobject.cpp
  2. +2 −4 src/3d/qgs3dexportobject.h
  3. +6 −6 src/3d/qgs3dsceneexporter.cpp
@@ -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 )
@@ -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; }
@@ -117,7 +115,7 @@ class Qgs3DExportObject : public QObject

QImage mTextureImage;

bool mSmoothEdges;
bool mSmoothEdges = false;
};

#endif // Qgs3DExportObject_H
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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 );

@@ -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 );
@@ -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;

0 comments on commit daa5327

Please sign in to comment.
You can’t perform that action at this time.