Skip to content
Permalink
Browse files

Qgs-ify axis aligned bounding box. Qgs-ification finished!

  • Loading branch information
wonder-sk committed Sep 26, 2017
1 parent 894db92 commit e9d0dc1a17539023b1b888adeffaca3e2cceab9f
@@ -2,7 +2,7 @@
# sources

SET(QGIS_3D_SRCS

qgsaabb.cpp
qgs3dmapscene.cpp
qgs3dmapsettings.cpp
qgs3dutils.cpp
@@ -73,8 +73,7 @@ QT5_ADD_RESOURCES(QGIS_3D_RCC_SRCS shaders.qrc)
# install headers

SET(QGIS_3D_HDRS
aabb.h

qgsaabb.h
qgs3dmapscene.h
qgs3dmapsettings.h
qgs3dutils.h
@@ -213,14 +212,3 @@ IF (APPLE AND QGIS_MACAPP_INSTALL_DEV)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -id \"${QGIS_MACAPP_DEV_PREFIX}/qgis_3d.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_3d\" \"$ENV{DESTDIR}${QGIS_MACAPP_DEV_PREFIX}/qgis_3d.framework/qgis_3d\")")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -change \"${CMAKE_INSTALL_NAME_DIR}/qgis_core.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_core\" \"${QGIS_MACAPP_DEV_PREFIX}/qgis_core.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_core\" \"$ENV{DESTDIR}${QGIS_MACAPP_DEV_PREFIX}/qgis_3d.framework/qgis_3d\")")
ENDIF (APPLE AND QGIS_MACAPP_INSTALL_DEV)


#############################################################
# qgis 3d test executable (temporary)

add_executable(qgis3d
testapp/main.cpp
testapp/sidepanel.cpp
testapp/window3d.cpp
)
target_link_libraries(qgis3d qgis_3d)

This file was deleted.

@@ -6,7 +6,7 @@
#include <Qt3DRender/QGeometryRenderer>
#include <Qt3DExtras/QPhongMaterial>

#include "aabb.h"
#include "qgsaabb.h"


///@cond PRIVATE
@@ -77,7 +77,7 @@ class AABBMesh : public Qt3DRender::QGeometryRenderer
public:
AABBMesh( Qt3DCore::QNode *parent = nullptr );

void setBoxes( const QList<AABB> &bboxes );
void setBoxes( const QList<QgsAABB> &bboxes );

private:
LineMeshGeometry *_lineMeshGeo;
@@ -97,10 +97,10 @@ AABBMesh::AABBMesh( Qt3DCore::QNode *parent )
setGeometry( _lineMeshGeo );
}

void AABBMesh::setBoxes( const QList<AABB> &bboxes )
void AABBMesh::setBoxes( const QList<QgsAABB> &bboxes )
{
QList<QVector3D> vertices;
Q_FOREACH ( const AABB &bbox, bboxes )
Q_FOREACH ( const QgsAABB &bbox, bboxes )
vertices << bbox.verticesForLines();
_lineMeshGeo->setVertices( vertices );
setVertexCount( _lineMeshGeo->vertexCount() );
@@ -121,7 +121,7 @@ QgsChunkBoundsEntity::QgsChunkBoundsEntity( Qt3DCore::QNode *parent )
addComponent( bboxesMaterial );
}

void QgsChunkBoundsEntity::setBoxes( const QList<AABB> &bboxes )
void QgsChunkBoundsEntity::setBoxes( const QList<QgsAABB> &bboxes )
{
aabbMesh->setBoxes( bboxes );
}
@@ -14,7 +14,7 @@

#include <Qt3DCore/QEntity>

class AABB;
class QgsAABB;
class AABBMesh;


@@ -29,7 +29,7 @@ class QgsChunkBoundsEntity : public Qt3DCore::QEntity
QgsChunkBoundsEntity( Qt3DCore::QNode *parent = nullptr );

//! Sets a list of bounding boxes to be rendered by the entity
void setBoxes( const QList<AABB> &bboxes );
void setBoxes( const QList<QgsAABB> &bboxes );

private:
AABBMesh *aabbMesh;
@@ -44,7 +44,7 @@ static float screenSpaceError( QgsChunkNode *node, const SceneState &state )
return sse;
}

QgsChunkedEntity::QgsChunkedEntity( const AABB &rootBbox, float rootError, float tau, int maxLevel, QgsChunkLoaderFactory *loaderFactory, Qt3DCore::QNode *parent )
QgsChunkedEntity::QgsChunkedEntity( const QgsAABB &rootBbox, float rootError, float tau, int maxLevel, QgsChunkLoaderFactory *loaderFactory, Qt3DCore::QNode *parent )
: Qt3DCore::QEntity( parent )
, needsUpdate( false )
, tau( tau )
@@ -142,7 +142,7 @@ void QgsChunkedEntity::update( const SceneState &state )

if ( bboxesEntity )
{
QList<AABB> bboxes;
QList<QgsAABB> bboxes;
Q_FOREACH ( QgsChunkNode *n, activeNodes )
bboxes << n->bbox;
bboxesEntity->setBoxes( bboxes );
@@ -14,7 +14,7 @@

#include <Qt3DCore/QEntity>

class AABB;
class QgsAABB;
class QgsChunkNode;
class QgsChunkList;
class QgsChunkQueueJob;
@@ -51,7 +51,7 @@ class QgsChunkedEntity : public Qt3DCore::QEntity
Q_OBJECT
public:
//! Constructs a chunked entity
QgsChunkedEntity( const AABB &rootBbox, float rootError, float tau, int maxLevel, QgsChunkLoaderFactory *loaderFactory, Qt3DCore::QNode *parent = nullptr );
QgsChunkedEntity( const QgsAABB &rootBbox, float rootError, float tau, int maxLevel, QgsChunkLoaderFactory *loaderFactory, Qt3DCore::QNode *parent = nullptr );
~QgsChunkedEntity();

//! Called when e.g. camera changes and entity may need updated
@@ -7,7 +7,7 @@

///@cond PRIVATE

QgsChunkNode::QgsChunkNode( int x, int y, int z, const AABB &bbox, float error, QgsChunkNode *parent )
QgsChunkNode::QgsChunkNode( int x, int y, int z, const QgsAABB &bbox, float error, QgsChunkNode *parent )
: bbox( bbox )
, error( error )
, x( x )
@@ -62,16 +62,16 @@ void QgsChunkNode::ensureAllChildrenExist()
float ymax = bbox.yMax;

if ( !children[0] )
children[0] = new QgsChunkNode( x * 2 + 0, y * 2 + 1, z + 1, AABB( bbox.xMin, ymin, bbox.zMin, xc, ymax, zc ), childError, this );
children[0] = new QgsChunkNode( x * 2 + 0, y * 2 + 1, z + 1, QgsAABB( bbox.xMin, ymin, bbox.zMin, xc, ymax, zc ), childError, this );

if ( !children[1] )
children[1] = new QgsChunkNode( x * 2 + 0, y * 2 + 0, z + 1, AABB( bbox.xMin, ymin, zc, xc, ymax, bbox.zMax ), childError, this );
children[1] = new QgsChunkNode( x * 2 + 0, y * 2 + 0, z + 1, QgsAABB( bbox.xMin, ymin, zc, xc, ymax, bbox.zMax ), childError, this );

if ( !children[2] )
children[2] = new QgsChunkNode( x * 2 + 1, y * 2 + 1, z + 1, AABB( xc, ymin, bbox.zMin, bbox.xMax, ymax, zc ), childError, this );
children[2] = new QgsChunkNode( x * 2 + 1, y * 2 + 1, z + 1, QgsAABB( xc, ymin, bbox.zMin, bbox.xMax, ymax, zc ), childError, this );

if ( !children[3] )
children[3] = new QgsChunkNode( x * 2 + 1, y * 2 + 0, z + 1, AABB( xc, ymin, zc, bbox.xMax, ymax, bbox.zMax ), childError, this );
children[3] = new QgsChunkNode( x * 2 + 1, y * 2 + 0, z + 1, QgsAABB( xc, ymin, zc, bbox.xMax, ymax, bbox.zMax ), childError, this );
}

int QgsChunkNode::level() const
@@ -241,7 +241,7 @@ void QgsChunkNode::setUpdated()
state = QgsChunkNode::Loaded;
}

void QgsChunkNode::setExactBbox( const AABB &box )
void QgsChunkNode::setExactBbox( const QgsAABB &box )
{
bbox = box;

@@ -12,7 +12,7 @@
// version without notice, or even be removed.
//

#include "aabb.h"
#include "qgsaabb.h"

#include <QTime>

@@ -44,7 +44,7 @@ class QgsChunkNode
{
public:
//! constructs a skeleton chunk
QgsChunkNode( int x, int y, int z, const AABB &bbox, float error, QgsChunkNode *parent = nullptr );
QgsChunkNode( int x, int y, int z, const QgsAABB &bbox, float error, QgsChunkNode *parent = nullptr );

~QgsChunkNode();

@@ -98,9 +98,9 @@ class QgsChunkNode
void setUpdated();

//! called when bounding box
void setExactBbox( const AABB &box );
void setExactBbox( const QgsAABB &box );

AABB bbox; //!< Bounding box in world coordinates
QgsAABB bbox; //!< Bounding box in world coordinates
float error; //!< Error of the node in world coordinates

int x, y, z; //!< Chunk coordinates (for use with a tiling scheme)
@@ -12,7 +12,7 @@

#include <QTimer>

#include "aabb.h"
#include "qgsaabb.h"
#include "qgs3dmapsettings.h"
#include "qgs3dutils.h"
#include "qgsabstract3drenderer.h"
@@ -203,7 +203,7 @@ void Qgs3DMapScene::onCameraChanged()
{
// project each corner of bbox to camera coordinates
// and determine closest and farthest point.
AABB bbox = node->bbox;
QgsAABB bbox = node->bbox;
for ( int i = 0; i < 8; ++i )
{
QVector4D p( ( ( i >> 0 ) & 1 ) ? bbox.xMin : bbox.xMax,
@@ -203,7 +203,7 @@ static inline uint outcode( const QVector4D &v )
//! should be equivalent to https://searchcode.com/codesearch/view/35195518/
//! qt3d /src/threed/painting/qglpainter.cpp
//! bool QGLPainter::isCullable(const QBox3D& box) const
bool Qgs3DUtils::isCullable( const AABB &bbox, const QMatrix4x4 &viewProjectionMatrix )
bool Qgs3DUtils::isCullable( const QgsAABB &bbox, const QMatrix4x4 &viewProjectionMatrix )
{
uint out = 0xff;

@@ -5,7 +5,7 @@ class QgsLineString;
class QgsPolygonV2;

#include "qgs3dmapsettings.h"
#include "aabb.h"
#include "qgsaabb.h"

//! how to handle altitude of vector features
enum AltitudeClamping
@@ -67,7 +67,7 @@ class _3D_EXPORT Qgs3DUtils
Returns true if bbox is completely outside the current viewing volume.
This is used to perform object culling checks.
*/
static bool isCullable( const AABB &bbox, const QMatrix4x4 &viewProjectionMatrix );
static bool isCullable( const QgsAABB &bbox, const QMatrix4x4 &viewProjectionMatrix );
};

#endif // QGS3DUTILS_H

0 comments on commit e9d0dc1

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