summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2015-12-03 14:49:40 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-12-10 17:44:50 +0000
commit5bab5d2f9023ecda899a2eb5b074e1e91cfb8045 (patch)
treee08d81fe1ef3a58c16714e3fd3f7be1a9c7230fc /src/render
parent04da7188665ce6f9550807e5cd9c52e3fa717745 (diff)
Move all raycasting code as private in Qt3DRender
Change-Id: I871cbc57166493f30ea307305d8664e2f8a8873f Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render')
-rw-r--r--src/render/backend/triangleboundingvolume.cpp8
-rw-r--r--src/render/backend/triangleboundingvolume_p.h4
-rw-r--r--src/render/backend/trianglesextractor.cpp94
-rw-r--r--src/render/backend/trianglesextractor_p.h8
-rw-r--r--src/render/frontend/sphere.cpp2
-rw-r--r--src/render/frontend/sphere_p.h4
-rw-r--r--src/render/geometry/geometryrenderer.cpp2
-rw-r--r--src/render/geometry/geometryrenderer_p.h12
-rw-r--r--src/render/jobs/pickboundingvolumejob.cpp49
-rw-r--r--src/render/jobs/pickboundingvolumejob_p.h11
-rw-r--r--src/render/raycasting/qabstractcollisionqueryservice.cpp67
-rw-r--r--src/render/raycasting/qabstractcollisionqueryservice_p.h107
-rw-r--r--src/render/raycasting/qboundingsphere.cpp53
-rw-r--r--src/render/raycasting/qboundingsphere_p.h72
-rw-r--r--src/render/raycasting/qboundingvolume.cpp53
-rw-r--r--src/render/raycasting/qboundingvolume_p.h (renamed from src/render/services/qraycastingservice.h)47
-rw-r--r--src/render/raycasting/qboundingvolumeprovider.cpp52
-rw-r--r--src/render/raycasting/qboundingvolumeprovider_p.h70
-rw-r--r--src/render/raycasting/qcollisionqueryresult.cpp115
-rw-r--r--src/render/raycasting/qcollisionqueryresult_p.h119
-rw-r--r--src/render/raycasting/qraycastingservice.cpp (renamed from src/render/services/qraycastingservice.cpp)17
-rw-r--r--src/render/raycasting/qraycastingservice_p.h (renamed from src/render/services/qraycastingservice_p.h)42
-rw-r--r--src/render/raycasting/raycasting.pri17
-rw-r--r--src/render/render.pro1
-rw-r--r--src/render/services/services.pri3
25 files changed, 886 insertions, 143 deletions
diff --git a/src/render/backend/triangleboundingvolume.cpp b/src/render/backend/triangleboundingvolume.cpp
index 75b87dc75..8353e0cef 100644
--- a/src/render/backend/triangleboundingvolume.cpp
+++ b/src/render/backend/triangleboundingvolume.cpp
@@ -89,7 +89,7 @@ bool intersectsSegmentTriangle(const Qt3DCore::QRay3D &ray,
}
TriangleBoundingVolume::TriangleBoundingVolume()
- : Qt3DCore::QBoundingVolume()
+ : QBoundingVolume()
{
}
@@ -97,7 +97,7 @@ TriangleBoundingVolume::TriangleBoundingVolume()
The vertices a, b, c are assumed to be in counter clockwise order.
*/
TriangleBoundingVolume::TriangleBoundingVolume(const Qt3DCore::QNodeId &id, const QVector3D &a, const QVector3D &b, const QVector3D &c)
- : Qt3DCore::QBoundingVolume()
+ : QBoundingVolume()
, m_id(id)
, m_a(a)
, m_b(b)
@@ -121,9 +121,9 @@ bool TriangleBoundingVolume::intersects(const Qt3DCore::QRay3D &ray, QVector3D *
return intersected;
}
-Qt3DCore::QBoundingVolume::Type TriangleBoundingVolume::type() const
+QBoundingVolume::Type TriangleBoundingVolume::type() const
{
- return Qt3DCore::QBoundingVolume::Triangle;
+ return QBoundingVolume::Triangle;
}
QVector3D TriangleBoundingVolume::a() const
diff --git a/src/render/backend/triangleboundingvolume_p.h b/src/render/backend/triangleboundingvolume_p.h
index 5cdbbd9f2..849a3abe1 100644
--- a/src/render/backend/triangleboundingvolume_p.h
+++ b/src/render/backend/triangleboundingvolume_p.h
@@ -48,7 +48,7 @@
// We mean it.
//
-#include <Qt3DCore/qboundingvolume.h>
+#include <Qt3DRender/private/qboundingvolume_p.h>
#include <Qt3DCore/qnodeid.h>
#include <QVector3D>
@@ -65,7 +65,7 @@ Q_AUTOTEST_EXPORT bool intersectsSegmentTriangle(const Qt3DCore::QRay3D &ray,
QVector3D &uvw,
float &t);
-class Q_AUTOTEST_EXPORT TriangleBoundingVolume : public Qt3DCore::QBoundingVolume
+class Q_AUTOTEST_EXPORT TriangleBoundingVolume : public QBoundingVolume
{
public:
TriangleBoundingVolume();
diff --git a/src/render/backend/trianglesextractor.cpp b/src/render/backend/trianglesextractor.cpp
index 7a5ecf180..85eba29df 100644
--- a/src/render/backend/trianglesextractor.cpp
+++ b/src/render/backend/trianglesextractor.cpp
@@ -90,13 +90,13 @@ struct BufferInfo
// indices, vertices are already offset
template<typename index, typename vertex>
-QVector<Qt3DCore::QBoundingVolume *> traverseTrianglesIndexed(index *indices,
- vertex *vertices,
- const BufferInfo &indexInfo,
- const BufferInfo &vertexInfo,
- const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> traverseTrianglesIndexed(index *indices,
+ vertex *vertices,
+ const BufferInfo &indexInfo,
+ const BufferInfo &vertexInfo,
+ const Qt3DCore::QNodeId id)
{
- QVector<Qt3DCore::QBoundingVolume *> tris;
+ QVector<QBoundingVolume *> tris;
uint i = 0;
const uint verticesStride = vertexInfo.byteStride / sizeof(vertex);
const uint maxVerticesDataSize = qMin(vertexInfo.dataSize, 3U);
@@ -118,11 +118,11 @@ QVector<Qt3DCore::QBoundingVolume *> traverseTrianglesIndexed(index *indices,
// vertices are already offset
template<typename vertex>
-QVector<Qt3DCore::QBoundingVolume *> traverseTriangles(vertex *vertices,
- const BufferInfo &vertexInfo,
- const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> traverseTriangles(vertex *vertices,
+ const BufferInfo &vertexInfo,
+ const Qt3DCore::QNodeId id)
{
- QVector<Qt3DCore::QBoundingVolume *> tris;
+ QVector<QBoundingVolume *> tris;
uint i = 0;
const uint verticesStride = vertexInfo.byteStride / sizeof(vertex);
@@ -144,13 +144,13 @@ QVector<Qt3DCore::QBoundingVolume *> traverseTriangles(vertex *vertices,
// indices, vertices are already offset
template<typename index, typename vertex>
-QVector<Qt3DCore::QBoundingVolume *> traverseTriangleStripIndexed(index *indices,
- vertex *vertices,
- const BufferInfo &indexInfo,
- const BufferInfo &vertexInfo,
- const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> traverseTriangleStripIndexed(index *indices,
+ vertex *vertices,
+ const BufferInfo &indexInfo,
+ const BufferInfo &vertexInfo,
+ const Qt3DCore::QNodeId id)
{
- QVector<Qt3DCore::QBoundingVolume *> tris;
+ QVector<QBoundingVolume *> tris;
uint i = 0;
const uint verticesStride = vertexInfo.byteStride / sizeof(vertex);
const uint maxVerticesDataSize = qMin(vertexInfo.dataSize, 3U);
@@ -172,11 +172,11 @@ QVector<Qt3DCore::QBoundingVolume *> traverseTriangleStripIndexed(index *indices
// vertices are already offset
template<typename vertex>
-QVector<Qt3DCore::QBoundingVolume *> traverseTriangleStrip(vertex *vertices,
- const BufferInfo &vertexInfo,
- const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> traverseTriangleStrip(vertex *vertices,
+ const BufferInfo &vertexInfo,
+ const Qt3DCore::QNodeId id)
{
- QVector<Qt3DCore::QBoundingVolume *> tris;
+ QVector<QBoundingVolume *> tris;
uint i = 0;
const uint verticesStride = vertexInfo.byteStride / sizeof(vertex);
@@ -198,13 +198,13 @@ QVector<Qt3DCore::QBoundingVolume *> traverseTriangleStrip(vertex *vertices,
// indices, vertices are already offset
template<typename index, typename vertex>
-QVector<Qt3DCore::QBoundingVolume *> traverseTriangleFanIndexed(index *indices,
- vertex *vertices,
- const BufferInfo &indexInfo,
- const BufferInfo &vertexInfo,
- const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> traverseTriangleFanIndexed(index *indices,
+ vertex *vertices,
+ const BufferInfo &indexInfo,
+ const BufferInfo &vertexInfo,
+ const Qt3DCore::QNodeId id)
{
- QVector<Qt3DCore::QBoundingVolume *> tris;
+ QVector<QBoundingVolume *> tris;
const uint verticesStride = vertexInfo.byteStride / sizeof(vertex);
const uint maxVerticesDataSize = qMin(vertexInfo.dataSize, 3U);
@@ -231,11 +231,11 @@ QVector<Qt3DCore::QBoundingVolume *> traverseTriangleFanIndexed(index *indices,
// vertices are already offset
template<typename vertex>
-QVector<Qt3DCore::QBoundingVolume *> traverseTriangleFan(vertex *vertices,
- const BufferInfo &vertexInfo,
- const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> traverseTriangleFan(vertex *vertices,
+ const BufferInfo &vertexInfo,
+ const Qt3DCore::QNodeId id)
{
- QVector<Qt3DCore::QBoundingVolume *> tris;
+ QVector<QBoundingVolume *> tris;
const uint verticesStride = vertexInfo.byteStride / sizeof(vertex);
const uint maxVerticesDataSize = qMin(vertexInfo.dataSize, 3U);
@@ -262,13 +262,13 @@ QVector<Qt3DCore::QBoundingVolume *> traverseTriangleFan(vertex *vertices,
// indices, vertices are already offset
template<typename index, typename vertex>
-QVector<Qt3DCore::QBoundingVolume *> traverseTriangleAdjacencyIndexed(index *indices,
- vertex *vertices,
- const BufferInfo &indexInfo,
- const BufferInfo &vertexInfo,
- const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> traverseTriangleAdjacencyIndexed(index *indices,
+ vertex *vertices,
+ const BufferInfo &indexInfo,
+ const BufferInfo &vertexInfo,
+ const Qt3DCore::QNodeId id)
{
- QVector<Qt3DCore::QBoundingVolume *> tris;
+ QVector<QBoundingVolume *> tris;
uint i = 0;
const uint verticesStride = vertexInfo.byteStride / sizeof(vertex);
const uint maxVerticesDataSize = qMin(vertexInfo.dataSize, 3U);
@@ -290,11 +290,11 @@ QVector<Qt3DCore::QBoundingVolume *> traverseTriangleAdjacencyIndexed(index *ind
// vertices are already offset
template<typename vertex>
-QVector<Qt3DCore::QBoundingVolume *> traverseTriangleAdjacency(vertex *vertices,
- const BufferInfo &vertexInfo,
- const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> traverseTriangleAdjacency(vertex *vertices,
+ const BufferInfo &vertexInfo,
+ const Qt3DCore::QNodeId id)
{
- QVector<Qt3DCore::QBoundingVolume *> tris;
+ QVector<QBoundingVolume *> tris;
uint i = 0;
const uint verticesStride = vertexInfo.byteStride / sizeof(vertex);
@@ -332,7 +332,7 @@ typename EnumToType<v>::type *castToType(const QByteArray &u, uint byteOffset)
}
template<typename ReturnType, typename Func>
-QVector<Qt3DCore::QBoundingVolume *> processBuffer(const BufferInfo &info, Func &f)
+QVector<QBoundingVolume *> processBuffer(const BufferInfo &info, Func &f)
{
switch (info.type) {
case QAttribute::Byte: return f(info, castToType<QAttribute::Byte>(info.data, info.byteOffset));
@@ -428,7 +428,7 @@ TrianglesExtractor::TrianglesExtractor(GeometryRenderer *renderer, NodeManagers
{
}
-QVector<Qt3DCore::QBoundingVolume *> TrianglesExtractor::extract(const Qt3DCore::QNodeId id)
+QVector<QBoundingVolume *> TrianglesExtractor::extract(const Qt3DCore::QNodeId id)
{
if (m_renderer && m_renderer->instanceCount() == 1 && isTriangleBased(m_renderer->primitiveType())) {
Attribute *positionAttribute = Q_NULLPTR;
@@ -473,26 +473,26 @@ QVector<Qt3DCore::QBoundingVolume *> TrianglesExtractor::extract(const Qt3DCore:
indexBufferInfo.byteStride = indexAttribute->byteStride();
indexBufferInfo.count = indexAttribute->count();
- IndexExecutor<QVector<Qt3DCore::QBoundingVolume *> > executor;
+ IndexExecutor<QVector<QBoundingVolume *> > executor;
executor.vertexBufferInfo = vertexBufferInfo;
executor.primitiveType = m_renderer->primitiveType();
executor.id = id;
- return processBuffer<QVector<Qt3DCore::QBoundingVolume *> >(indexBufferInfo, executor);
+ return processBuffer<QVector<QBoundingVolume *> >(indexBufferInfo, executor);
} else { // Non Indexed
// Check into which type the buffer needs to be casted
- VertexExecutor<QVector<Qt3DCore::QBoundingVolume *> > executor;
+ VertexExecutor<QVector<QBoundingVolume *> > executor;
executor.primitiveType = m_renderer->primitiveType();
executor.id = id;
- return processBuffer<QVector<Qt3DCore::QBoundingVolume *> >(vertexBufferInfo, executor);
+ return processBuffer<QVector<QBoundingVolume *> >(vertexBufferInfo, executor);
}
}
}
}
- return QVector<Qt3DCore::QBoundingVolume *>();
+ return QVector<QBoundingVolume *>();
}
} // namespace Render
diff --git a/src/render/backend/trianglesextractor_p.h b/src/render/backend/trianglesextractor_p.h
index d324cd183..7353278fe 100644
--- a/src/render/backend/trianglesextractor_p.h
+++ b/src/render/backend/trianglesextractor_p.h
@@ -52,12 +52,10 @@
QT_BEGIN_NAMESPACE
-namespace Qt3DCore {
-class QBoundingVolume;
-}
-
namespace Qt3DRender {
+class QBoundingVolume;
+
namespace Render {
class GeometryRenderer;
@@ -69,7 +67,7 @@ public:
explicit TrianglesExtractor(GeometryRenderer *renderer,
NodeManagers *manager);
- QVector<Qt3DCore::QBoundingVolume *> extract(const Qt3DCore::QNodeId id);
+ QVector<QBoundingVolume *> extract(const Qt3DCore::QNodeId id);
private:
GeometryRenderer *m_renderer;
diff --git a/src/render/frontend/sphere.cpp b/src/render/frontend/sphere.cpp
index 97b39cf51..f87be42d3 100644
--- a/src/render/frontend/sphere.cpp
+++ b/src/render/frontend/sphere.cpp
@@ -224,7 +224,7 @@ bool Sphere::intersects(const Qt3DCore::QRay3D &ray, QVector3D *q) const
return intersectRaySphere(ray, *this, q);
}
-Qt3DCore::QBoundingVolume::Type Sphere::type() const
+QBoundingVolume::Type Sphere::type() const
{
return QBoundingVolume::Sphere;
}
diff --git a/src/render/frontend/sphere_p.h b/src/render/frontend/sphere_p.h
index be86b172d..37a30ce74 100644
--- a/src/render/frontend/sphere_p.h
+++ b/src/render/frontend/sphere_p.h
@@ -50,7 +50,7 @@
#include <Qt3DRender/private/qt3drender_global_p.h>
#include <Qt3DCore/qnodeid.h>
-#include <Qt3DCore/qboundingsphere.h>
+#include <Qt3DRender/private/qboundingsphere_p.h>
#include <QMatrix4x4>
#include <QVector3D>
@@ -61,7 +61,7 @@ namespace Qt3DRender {
namespace Render {
-class QT3DRENDERSHARED_PRIVATE_EXPORT Sphere : public Qt3DCore::QBoundingSphere
+class QT3DRENDERSHARED_PRIVATE_EXPORT Sphere : public QBoundingSphere
{
public:
inline Sphere(const Qt3DCore::QNodeId &i = Qt3DCore::QNodeId())
diff --git a/src/render/geometry/geometryrenderer.cpp b/src/render/geometry/geometryrenderer.cpp
index 9a9cab227..bbe30e5fe 100644
--- a/src/render/geometry/geometryrenderer.cpp
+++ b/src/render/geometry/geometryrenderer.cpp
@@ -39,7 +39,7 @@
#include <Qt3DCore/qscenepropertychange.h>
#include <Qt3DRender/private/geometryrenderermanager_p.h>
#include <Qt3DCore/qbackendscenepropertychange.h>
-#include <Qt3DCore/qboundingvolume.h>
+#include <Qt3DRender/private/qboundingvolume_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/render/geometry/geometryrenderer_p.h b/src/render/geometry/geometryrenderer_p.h
index bbcd3397b..8e68ab1f8 100644
--- a/src/render/geometry/geometryrenderer_p.h
+++ b/src/render/geometry/geometryrenderer_p.h
@@ -54,12 +54,10 @@
QT_BEGIN_NAMESPACE
-namespace Qt3DCore {
-class QBoundingVolume;
-}
-
namespace Qt3DRender {
+class QBoundingVolume;
+
namespace Render {
class GeometryRendererManager;
@@ -90,9 +88,9 @@ public:
void unsetDirty();
// Build triangle data Job thread
- void setTriangleVolumes(const QVector<Qt3DCore::QBoundingVolume *> &volumes);
+ void setTriangleVolumes(const QVector<QBoundingVolume *> &volumes);
// Pick volumes job
- QVector<Qt3DCore::QBoundingVolume *> triangleData() const;
+ QVector<QBoundingVolume *> triangleData() const;
private:
Qt3DCore::QNodeId m_geometryId;
@@ -107,7 +105,7 @@ private:
bool m_enabled;
QGeometryFunctorPtr m_functor;
GeometryRendererManager *m_manager;
- QVector<Qt3DCore::QBoundingVolume *> m_triangleVolumes;
+ QVector<QBoundingVolume *> m_triangleVolumes;
};
class GeometryRendererFunctor : public Qt3DCore::QBackendNodeFunctor
diff --git a/src/render/jobs/pickboundingvolumejob.cpp b/src/render/jobs/pickboundingvolumejob.cpp
index 1dc0b2575..768277ad4 100644
--- a/src/render/jobs/pickboundingvolumejob.cpp
+++ b/src/render/jobs/pickboundingvolumejob.cpp
@@ -48,11 +48,10 @@
#include <Qt3DRender/private/geometryrenderer_p.h>
#include <Qt3DRender/private/trianglesextractor_p.h>
#include <Qt3DRender/private/triangleboundingvolume_p.h>
-#include <Qt3DRender/qraycastingservice.h>
+#include <Qt3DRender/private/qraycastingservice_p.h>
#include <Qt3DRender/qgeometryrenderer.h>
#include <Qt3DCore/qservicelocator.h>
#include <Qt3DCore/qray3d.h>
-#include <Qt3DCore/qabstractcollisionqueryservice.h>
#include <QSurface>
QT_BEGIN_NAMESPACE
@@ -124,9 +123,9 @@ public:
};
-QVector<Qt3DCore::QBoundingVolume *> gatherBoundingVolumes(Entity *entity)
+QVector<QBoundingVolume *> gatherBoundingVolumes(Entity *entity)
{
- QVector<Qt3DCore::QBoundingVolume *> volumes;
+ QVector<QBoundingVolume *> volumes;
if (entity != Q_NULLPTR) {
volumes.push_back(entity->worldBoundingVolume());
@@ -137,17 +136,17 @@ QVector<Qt3DCore::QBoundingVolume *> gatherBoundingVolumes(Entity *entity)
return volumes;
}
-class SphereBoundingVolumesGatherer : public Qt3DCore::QBoundingVolumeProvider
+class SphereBoundingVolumesGatherer : public QBoundingVolumeProvider
{
public:
explicit SphereBoundingVolumesGatherer(Entity *root)
- : Qt3DCore::QBoundingVolumeProvider()
+ : QBoundingVolumeProvider()
, m_root(root)
, m_needsRefresh(true)
{
}
- QVector<Qt3DCore::QBoundingVolume *> boundingVolumes() const Q_DECL_FINAL
+ QVector<QBoundingVolume *> boundingVolumes() const Q_DECL_FINAL
{
if (m_needsRefresh) {
m_volumes = gatherBoundingVolumes(m_root);
@@ -158,16 +157,16 @@ public:
private:
Entity *m_root;
- mutable QVector<Qt3DCore::QBoundingVolume *> m_volumes;
+ mutable QVector<QBoundingVolume *> m_volumes;
mutable bool m_needsRefresh;
};
-class TriangleVolumeGatherer : public Qt3DCore::QBoundingVolumeProvider
+class TriangleVolumeGatherer : public QBoundingVolumeProvider
{
public:
explicit TriangleVolumeGatherer(Entity *root, NodeManagers *manager)
- : Qt3DCore::QBoundingVolumeProvider()
+ : QBoundingVolumeProvider()
, m_root(root)
, m_manager(manager)
{
@@ -179,21 +178,21 @@ public:
qDeleteAll(m_volumes);
}
- QVector<Qt3DCore::QBoundingVolume *> boundingVolumes() const Q_DECL_FINAL
+ QVector<QBoundingVolume *> boundingVolumes() const Q_DECL_FINAL
{
return m_volumes;
}
private:
- QVector<Qt3DCore::QBoundingVolume *> buildTriangleBoundingVolumes()
+ QVector<QBoundingVolume *> buildTriangleBoundingVolumes()
{
- QVector<Qt3DCore::QBoundingVolume *> volumes;
+ QVector<QBoundingVolume *> volumes;
if (m_root) {
GeometryRenderer *gRenderer = m_root->renderComponent<GeometryRenderer>();
if (gRenderer) {
- const QVector<Qt3DCore::QBoundingVolume *> localVolumes = gRenderer->triangleData();
+ const QVector<QBoundingVolume *> localVolumes = gRenderer->triangleData();
volumes.reserve(localVolumes.size());
- Q_FOREACH (const Qt3DCore::QBoundingVolume *v, localVolumes) {
+ Q_FOREACH (const QBoundingVolume *v, localVolumes) {
TriangleBoundingVolume *worldVolume = new TriangleBoundingVolume();
*worldVolume = static_cast<const TriangleBoundingVolume *>(v)->transformed(*m_root->worldTransform());
volumes.push_back(worldVolume);
@@ -205,7 +204,7 @@ private:
Entity *m_root;
NodeManagers *m_manager;
- QVector<Qt3DCore::QBoundingVolume *> m_volumes;
+ QVector<QBoundingVolume *> m_volumes;
};
} // anonymous
@@ -240,7 +239,7 @@ void PickBoundingVolumeJob::run()
if (m_mouseEvents.empty())
return;
- Qt3DCore::QAbstractCollisionQueryService *rayCasting = m_renderer->renderAspect()->services()->service<Qt3DCore::QAbstractCollisionQueryService>
+ QAbstractCollisionQueryService *rayCasting = m_renderer->renderAspect()->services()->service<QAbstractCollisionQueryService>
(Qt3DCore::QServiceLocator::CollisionService);
if (rayCasting == Q_NULLPTR) {
@@ -411,8 +410,8 @@ QRect PickBoundingVolumeJob::windowViewport(const QRectF &relativeViewport) cons
QVector<Qt3DCore::QNodeId> PickBoundingVolumeJob::sphereHitsForViewportAndCamera(const QPoint &pos,
const QRectF &relativeViewport,
const Qt3DCore::QNodeId &cameraId,
- Qt3DCore::QAbstractCollisionQueryService *rayCasting,
- Qt3DCore::QBoundingVolumeProvider *volumeProvider) const
+ QAbstractCollisionQueryService *rayCasting,
+ QBoundingVolumeProvider *volumeProvider) const
{
QMatrix4x4 viewMatrix;
QMatrix4x4 projectionMatrix;
@@ -424,8 +423,8 @@ QVector<Qt3DCore::QNodeId> PickBoundingVolumeJob::sphereHitsForViewportAndCamera
// In GL the y is inverted compared to Qt
const QPoint glCorrectPos = s ? QPoint(pos.x(), s->size().height() - pos.y()) : pos;
const Qt3DCore::QRay3D ray = intersectionRay(glCorrectPos, viewMatrix, projectionMatrix, viewport);
- const Qt3DCore::QQueryHandle rayCastingHandle = rayCasting->query(ray, Qt3DCore::QAbstractCollisionQueryService::AllHits, volumeProvider);
- const Qt3DCore::QCollisionQueryResult queryResult = rayCasting->fetchResult(rayCastingHandle);
+ const QQueryHandle rayCastingHandle = rayCasting->query(ray, QAbstractCollisionQueryService::AllHits, volumeProvider);
+ const QCollisionQueryResult queryResult = rayCasting->fetchResult(rayCastingHandle);
return queryResult.entitiesHit();
}
@@ -433,7 +432,7 @@ QVector<Qt3DCore::QNodeId> PickBoundingVolumeJob::triangleHitsForViewportAndCame
const QRectF &relativeViewport,
const Qt3DCore::QNodeId &cameraId,
const Qt3DCore::QNodeId &entityId,
- Qt3DCore::QAbstractCollisionQueryService *rayCasting) const
+ QAbstractCollisionQueryService *rayCasting) const
{
QMatrix4x4 viewMatrix;
QMatrix4x4 projectionMatrix;
@@ -450,10 +449,10 @@ QVector<Qt3DCore::QNodeId> PickBoundingVolumeJob::triangleHitsForViewportAndCame
TriangleVolumeGatherer boundingVolumeProvider(m_manager->lookupResource<Entity, EntityManager>(entityId),
m_manager);
- const Qt3DCore::QQueryHandle rayCastingHandle = rayCasting->query(ray,
- Qt3DCore::QAbstractCollisionQueryService::AllHits,
+ const QQueryHandle rayCastingHandle = rayCasting->query(ray,
+ QAbstractCollisionQueryService::AllHits,
&boundingVolumeProvider);
- const Qt3DCore::QCollisionQueryResult queryResult = rayCasting->fetchResult(rayCastingHandle);
+ const QCollisionQueryResult queryResult = rayCasting->fetchResult(rayCastingHandle);
return queryResult.entitiesHit();
}
diff --git a/src/render/jobs/pickboundingvolumejob_p.h b/src/render/jobs/pickboundingvolumejob_p.h
index 685638a58..11a7a1596 100644
--- a/src/render/jobs/pickboundingvolumejob_p.h
+++ b/src/render/jobs/pickboundingvolumejob_p.h
@@ -49,7 +49,7 @@
//
#include <Qt3DCore/qaspectjob.h>
-#include <Qt3DCore/qboundingvolumeprovider.h>
+#include <Qt3DRender/private/qboundingvolumeprovider_p.h>
#include <Qt3DRender/private/handle_types_p.h>
#include <Qt3DCore/qray3d.h>
#include <QSharedPointer>
@@ -59,11 +59,12 @@ QT_BEGIN_NAMESPACE
namespace Qt3DCore {
class QNodeId;
-class QAbstractCollisionQueryService;
}
namespace Qt3DRender {
+class QAbstractCollisionQueryService;
+
namespace Render {
class Entity;
@@ -97,13 +98,13 @@ private:
QVector<Qt3DCore::QNodeId> sphereHitsForViewportAndCamera(const QPoint &pos,
const QRectF &relativeViewport,
const Qt3DCore::QNodeId &cameraId,
- Qt3DCore::QAbstractCollisionQueryService *rayCasting,
- Qt3DCore::QBoundingVolumeProvider *volumeProvider) const;
+ Qt3DRender::QAbstractCollisionQueryService *rayCasting,
+ Qt3DRender::QBoundingVolumeProvider *volumeProvider) const;
QVector<Qt3DCore::QNodeId> triangleHitsForViewportAndCamera(const QPoint &pos,
const QRectF &relativeViewport,
const Qt3DCore::QNodeId &cameraId,
const Qt3DCore::QNodeId &entityId,
- Qt3DCore::QAbstractCollisionQueryService *rayCasting) const;
+ Qt3DRender::QAbstractCollisionQueryService *rayCasting) const;
void clearPreviouslyHoveredPickers();
HObjectPicker m_currentPicker;
QVector<HObjectPicker> m_hoveredPickers;
diff --git a/src/render/raycasting/qabstractcollisionqueryservice.cpp b/src/render/raycasting/qabstractcollisionqueryservice.cpp
new file mode 100644
index 000000000..e28b3a7ea
--- /dev/null
+++ b/src/render/raycasting/qabstractcollisionqueryservice.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qabstractcollisionqueryservice_p.h"
+
+#include "qcollisionqueryresult_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QAbstractCollisionQueryService::QAbstractCollisionQueryService(const QString &description)
+ : QAbstractServiceProvider(*new QAbstractCollisionQueryServicePrivate(description))
+{
+}
+
+QAbstractCollisionQueryService::QAbstractCollisionQueryService(QAbstractCollisionQueryServicePrivate &dd)
+ : QAbstractServiceProvider(dd)
+{
+}
+
+void QAbstractCollisionQueryService::setResultHandle(QCollisionQueryResult &result, const QQueryHandle &handle)
+{
+ result.d_func()->setHandle(handle);
+}
+
+void QAbstractCollisionQueryService::addEntityHit(QCollisionQueryResult &result, const Qt3DCore::QNodeId &entity)
+{
+ result.d_func()->addEntityHit(entity);
+}
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/raycasting/qabstractcollisionqueryservice_p.h b/src/render/raycasting/qabstractcollisionqueryservice_p.h
new file mode 100644
index 000000000..286f4f932
--- /dev/null
+++ b/src/render/raycasting/qabstractcollisionqueryservice_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QABSTRACTCOLLISIONQUERYSERVICE_P_H
+#define QT3DRENDER_QABSTRACTCOLLISIONQUERYSERVICE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QVector>
+
+#include <Qt3DRender/qt3drender_global.h>
+#include <Qt3DCore/qservicelocator.h>
+#include <Qt3DCore/qnodeid.h>
+#include <Qt3DCore/private/qabstractserviceprovider_p.h>
+#include <Qt3DRender/private/qcollisionqueryresult_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+class QRay3D;
+}
+
+namespace Qt3DRender {
+
+class QBoundingVolumeProvider;
+
+class QAbstractCollisionQueryServicePrivate : public Qt3DCore::QAbstractServiceProviderPrivate
+{
+public:
+ QAbstractCollisionQueryServicePrivate(const QString &description)
+ : QAbstractServiceProviderPrivate(Qt3DCore::QServiceLocator::CollisionService, description)
+ {}
+};
+
+class QT3DRENDERSHARED_EXPORT QAbstractCollisionQueryService : public Qt3DCore::QAbstractServiceProvider
+{
+public:
+ enum QueryMode {
+ FirstHit,
+ AllHits
+ };
+
+ virtual QQueryHandle query(const Qt3DCore::QRay3D &ray, QueryMode mode, QBoundingVolumeProvider *provider) = 0;
+
+ virtual QCollisionQueryResult fetchResult(const QQueryHandle &handle) = 0;
+ virtual QVector<QCollisionQueryResult> fetchAllResults() const = 0;
+
+protected:
+ QAbstractCollisionQueryService(const QString &description = QString());
+ QAbstractCollisionQueryService(QAbstractCollisionQueryServicePrivate &dd);
+
+ void setResultHandle(QCollisionQueryResult &result, const QQueryHandle &handle);
+ void addEntityHit(QCollisionQueryResult &result, const Qt3DCore::QNodeId &entity);
+
+private:
+ Q_DECLARE_PRIVATE(QAbstractCollisionQueryService)
+};
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Qt3DRender::QAbstractCollisionQueryService::QueryMode)
+
+#endif // QT3DRENDER_QABSTRACTCOLLISIONQUERYSERVICE_P_H
diff --git a/src/render/raycasting/qboundingsphere.cpp b/src/render/raycasting/qboundingsphere.cpp
new file mode 100644
index 000000000..1c6915cf4
--- /dev/null
+++ b/src/render/raycasting/qboundingsphere.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qboundingsphere_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QBoundingSphere::QBoundingSphere()
+{
+}
+
+QBoundingSphere::~QBoundingSphere()
+{
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/raycasting/qboundingsphere_p.h b/src/render/raycasting/qboundingsphere_p.h
new file mode 100644
index 000000000..c05fb7613
--- /dev/null
+++ b/src/render/raycasting/qboundingsphere_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QBOUNDINGSPHERE_P_H
+#define QT3DRENDER_QBOUNDINGSPHERE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/qt3drender_global.h>
+#include <Qt3DRender/private/qboundingvolume_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QT3DRENDERSHARED_EXPORT QBoundingSphere : public QBoundingVolume
+{
+public:
+ QBoundingSphere();
+ ~QBoundingSphere();
+
+ virtual QVector3D center() const = 0;
+ virtual float radius() const = 0;
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QBOUNDINGSPHERE_P_H
diff --git a/src/render/raycasting/qboundingvolume.cpp b/src/render/raycasting/qboundingvolume.cpp
new file mode 100644
index 000000000..414f4f278
--- /dev/null
+++ b/src/render/raycasting/qboundingvolume.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qboundingvolume_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QBoundingVolume::QBoundingVolume()
+{
+}
+
+QBoundingVolume::~QBoundingVolume()
+{
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/services/qraycastingservice.h b/src/render/raycasting/qboundingvolume_p.h
index 2982c161c..b426870a2 100644
--- a/src/render/services/qraycastingservice.h
+++ b/src/render/raycasting/qboundingvolume_p.h
@@ -34,43 +34,52 @@
**
****************************************************************************/
-#ifndef QT3DRENDER_RENDER_QRAYCASTINGSERVICE_H
-#define QT3DRENDER_RENDER_QRAYCASTINGSERVICE_H
+#ifndef QT3DRENDER_QBOUNDINGVOLUME_P_H
+#define QT3DRENDER_QBOUNDINGVOLUME_P_H
-#include <Qt3DRender/qt3drender_global.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
-#include <Qt3DCore/qabstractcollisionqueryservice.h>
+#include <Qt3DRender/qt3drender_global.h>
+#include <Qt3DCore/qnodeid.h>
QT_BEGIN_NAMESPACE
namespace Qt3DCore {
-class QBoundingVolumeProvider;
+class QRay3D;
}
namespace Qt3DRender {
-class QRayCastingServicePrivate;
-
-class QT3DRENDERSHARED_EXPORT QRayCastingService : public Qt3DCore::QAbstractCollisionQueryService
+class QT3DRENDERSHARED_EXPORT QBoundingVolume
{
public:
- QRayCastingService();
+ QBoundingVolume();
+ virtual ~QBoundingVolume();
- Qt3DCore::QQueryHandle query(const Qt3DCore::QRay3D &ray, QueryMode mode, Qt3DCore::QBoundingVolumeProvider *provider) Q_DECL_OVERRIDE;
+ enum Type {
+ Sphere = 0,
+ Triangle
+ };
- Qt3DCore::QCollisionQueryResult fetchResult(const Qt3DCore::QQueryHandle &handle) Q_DECL_OVERRIDE;
- QVector<Qt3DCore::QCollisionQueryResult> fetchAllResults() const Q_DECL_OVERRIDE;
+ virtual Qt3DCore::QNodeId id() const = 0;
+ virtual bool intersects(const Qt3DCore::QRay3D &ray, QVector3D *q = Q_NULLPTR) const = 0;
-protected:
- QRayCastingService(QRayCastingServicePrivate &dd);
-
-private:
- Q_DISABLE_COPY(QRayCastingService)
- Q_DECLARE_PRIVATE(QRayCastingService)
+ virtual Type type() const = 0;
};
} // namespace Qt3DRender
QT_END_NAMESPACE
-#endif // QT3DRENDER_RENDER_QRAYCASTINGSERVICE_H
+Q_DECLARE_METATYPE(Qt3DRender::QBoundingVolume*)
+
+#endif // QT3DRENDER_QBOUNDINGVOLUME_P_H
diff --git a/src/render/raycasting/qboundingvolumeprovider.cpp b/src/render/raycasting/qboundingvolumeprovider.cpp
new file mode 100644
index 000000000..cff36e906
--- /dev/null
+++ b/src/render/raycasting/qboundingvolumeprovider.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qboundingvolumeprovider_p.h"
+
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QBoundingVolumeProvider::~QBoundingVolumeProvider()
+{
+
+}
+
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/raycasting/qboundingvolumeprovider_p.h b/src/render/raycasting/qboundingvolumeprovider_p.h
new file mode 100644
index 000000000..3f38a6f6c
--- /dev/null
+++ b/src/render/raycasting/qboundingvolumeprovider_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QBOUNDINGVOLUMEPROVIDER_P_H
+#define QT3DRENDER_QBOUNDINGVOLUMEPROVIDER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/qt3drender_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QBoundingVolume;
+
+class QT3DRENDERSHARED_EXPORT QBoundingVolumeProvider
+{
+public:
+ virtual ~QBoundingVolumeProvider();
+ virtual QVector<QBoundingVolume *> boundingVolumes() const = 0;
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QBOUNDINGVOLUMEPROVIDER_P_H
diff --git a/src/render/raycasting/qcollisionqueryresult.cpp b/src/render/raycasting/qcollisionqueryresult.cpp
new file mode 100644
index 000000000..cf2ea0a9a
--- /dev/null
+++ b/src/render/raycasting/qcollisionqueryresult.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcollisionqueryresult_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QCollisionQueryResultPrivate::QCollisionQueryResultPrivate()
+ : QSharedData()
+{
+}
+
+QCollisionQueryResultPrivate::QCollisionQueryResultPrivate(const QCollisionQueryResultPrivate &copy)
+ : QSharedData(copy)
+ , m_handle(copy.m_handle)
+ , m_entitiesHit(copy.m_entitiesHit)
+{
+}
+
+void QCollisionQueryResultPrivate::addEntityHit(const Qt3DCore::QNodeId &entity)
+{
+ m_entitiesHit.append(entity);
+}
+
+void QCollisionQueryResultPrivate::setHandle(const QQueryHandle &handle)
+{
+ m_handle = handle;
+}
+
+QCollisionQueryResult::QCollisionQueryResult()
+ : d_ptr(new QCollisionQueryResultPrivate())
+{
+}
+
+QCollisionQueryResult::QCollisionQueryResult(const QCollisionQueryResult &result)
+ : d_ptr(result.d_ptr)
+{
+}
+
+QCollisionQueryResult::~QCollisionQueryResult()
+{
+}
+
+QCollisionQueryResult &QCollisionQueryResult::operator=(const QCollisionQueryResult &result)
+{
+ d_ptr = result.d_ptr;
+ return *this;
+}
+
+QVector<Qt3DCore::QNodeId> QCollisionQueryResult::entitiesHit() const
+{
+ Q_D(const QCollisionQueryResult);
+ return d->m_entitiesHit;
+}
+
+/*!
+ \internal
+*/
+QCollisionQueryResult::QCollisionQueryResult(QCollisionQueryResultPrivate &p)
+ : d_ptr(&p)
+{
+}
+
+/*!
+ \internal
+*/
+QCollisionQueryResultPrivate *QCollisionQueryResult::d_func()
+{
+ return d_ptr.data();
+}
+
+QQueryHandle QCollisionQueryResult::handle() const
+{
+ Q_D(const QCollisionQueryResult);
+ return d->m_handle;
+}
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/raycasting/qcollisionqueryresult_p.h b/src/render/raycasting/qcollisionqueryresult_p.h
new file mode 100644
index 000000000..c4eb164ff
--- /dev/null
+++ b/src/render/raycasting/qcollisionqueryresult_p.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QCOLLISIONQUERYRESULT_P_H
+#define QT3DRENDER_QCOLLISIONQUERYRESULT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/qt3drender_global.h>
+#include <Qt3DCore/qnodeid.h>
+#include <QVector>
+#include <QSharedData>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+typedef int QQueryHandle;
+
+class QCollisionQueryResultPrivate : public QSharedData
+{
+public:
+ explicit QCollisionQueryResultPrivate();
+ explicit QCollisionQueryResultPrivate(const QCollisionQueryResultPrivate &copy);
+
+ void setHandle(const QQueryHandle &handle);
+ void addEntityHit(const Qt3DCore::QNodeId &entity);
+
+ QQueryHandle m_handle;
+ QVector<Qt3DCore::QNodeId> m_entitiesHit;
+};
+
+class QT3DRENDERSHARED_EXPORT QCollisionQueryResult
+{
+public:
+ QCollisionQueryResult();
+ QCollisionQueryResult(const QCollisionQueryResult &);
+ ~QCollisionQueryResult();
+
+ QCollisionQueryResult &operator=(const QCollisionQueryResult &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QCollisionQueryResult &operator=(QCollisionQueryResult &&other) Q_DECL_NOTHROW
+ {
+ swap(other);
+ return *this;
+ }
+#endif
+
+ void swap(QCollisionQueryResult &other) Q_DECL_NOTHROW
+ {
+ qSwap(d_ptr, other.d_ptr);
+ }
+
+ QQueryHandle handle() const;
+ QVector<Qt3DCore::QNodeId> entitiesHit() const;
+
+private:
+ friend class QAbstractCollisionQueryService;
+
+ explicit QCollisionQueryResult(QCollisionQueryResultPrivate &p);
+
+ QSharedDataPointer<QCollisionQueryResultPrivate> d_ptr;
+ // Q_DECLARE_PRIVATE equivalent for shared data pointers
+ QCollisionQueryResultPrivate *d_func();
+ inline const QCollisionQueryResultPrivate *d_func() const
+ {
+ return d_ptr.constData();
+ }
+};
+
+} // Qt3DRender
+
+Q_DECLARE_SHARED(Qt3DRender::QCollisionQueryResult)
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QCOLLISIONQUERYRESULT_P_H
diff --git a/src/render/services/qraycastingservice.cpp b/src/render/raycasting/qraycastingservice.cpp
index af06b06d7..8e897ec14 100644
--- a/src/render/services/qraycastingservice.cpp
+++ b/src/render/raycasting/qraycastingservice.cpp
@@ -34,12 +34,11 @@
**
****************************************************************************/
-#include "qraycastingservice.h"
#include "qraycastingservice_p.h"
#include <Qt3DCore/qray3d.h>
#include <Qt3DRender/private/sphere_p.h>
-#include <Qt3DCore/qboundingvolumeprovider.h>
+#include <Qt3DRender/private/qboundingvolumeprovider_p.h>
#include <QMap>
#include <QtConcurrent>
@@ -116,8 +115,8 @@ struct CollisionGathererFunctor
} // anonymous
-QCollisionQueryResult QRayCastingServicePrivate::collides(const Qt3DCore::QRay3D &ray, Qt3DCore::QBoundingVolumeProvider *provider,
- Qt3DCore::QAbstractCollisionQueryService::QueryMode mode, const Qt3DCore::QQueryHandle &handle)
+QCollisionQueryResult QRayCastingServicePrivate::collides(const Qt3DCore::QRay3D &ray, QBoundingVolumeProvider *provider,
+ QAbstractCollisionQueryService::QueryMode mode, const QQueryHandle &handle)
{
Q_Q(QRayCastingService);
@@ -153,9 +152,9 @@ QRayCastingService::QRayCastingService()
{
}
-Qt3DCore::QQueryHandle QRayCastingService::query(const Qt3DCore::QRay3D &ray,
- QAbstractCollisionQueryService::QueryMode mode,
- Qt3DCore::QBoundingVolumeProvider *provider)
+QQueryHandle QRayCastingService::query(const Qt3DCore::QRay3D &ray,
+ QAbstractCollisionQueryService::QueryMode mode,
+ QBoundingVolumeProvider *provider)
{
Q_D(QRayCastingService);
@@ -171,14 +170,14 @@ Qt3DCore::QQueryHandle QRayCastingService::query(const Qt3DCore::QRay3D &ray,
return handle;
}
-Qt3DCore::QCollisionQueryResult QRayCastingService::fetchResult(const Qt3DCore::QQueryHandle &handle)
+QCollisionQueryResult QRayCastingService::fetchResult(const QQueryHandle &handle)
{
Q_D(QRayCastingService);
return d->m_results.value(handle).result();
}
-QVector<Qt3DCore::QCollisionQueryResult> QRayCastingService::fetchAllResults() const
+QVector<QCollisionQueryResult> QRayCastingService::fetchAllResults() const
{
Q_D(const QRayCastingService);
diff --git a/src/render/services/qraycastingservice_p.h b/src/render/raycasting/qraycastingservice_p.h
index 252c50bfd..b4fdc1549 100644
--- a/src/render/services/qraycastingservice_p.h
+++ b/src/render/raycasting/qraycastingservice_p.h
@@ -49,8 +49,7 @@
//
#include <Qt3DCore/qt3dcore_global.h>
-#include <Qt3DCore/qabstractcollisionqueryservice.h>
-#include <Qt3DCore/private/qabstractcollisionqueryservice_p.h>
+#include <Qt3DRender/private/qabstractcollisionqueryservice_p.h>
#include <Qt3DCore/qray3d.h>
#include <QHash>
@@ -59,35 +58,52 @@
QT_BEGIN_NAMESPACE
-namespace Qt3DCore {
+namespace Qt3DRender {
+
class QBoundingVolume;
class QBoundingVolumeProvider;
-}
+class QRayCastingServicePrivate;
-namespace Qt3DRender {
+typedef QFuture<QCollisionQueryResult> FutureQueryResult;
+
+class QT3DRENDERSHARED_EXPORT QRayCastingService : public QAbstractCollisionQueryService
+{
+public:
+ QRayCastingService();
+
+ QQueryHandle query(const Qt3DCore::QRay3D &ray, QueryMode mode, QBoundingVolumeProvider *provider) Q_DECL_OVERRIDE;
+
+ QCollisionQueryResult fetchResult(const QQueryHandle &handle) Q_DECL_OVERRIDE;
+ QVector<QCollisionQueryResult> fetchAllResults() const Q_DECL_OVERRIDE;
-typedef QFuture<Qt3DCore::QCollisionQueryResult> FutureQueryResult;
+protected:
+ QRayCastingService(QRayCastingServicePrivate &dd);
+
+private:
+ Q_DISABLE_COPY(QRayCastingService)
+ Q_DECLARE_PRIVATE(QRayCastingService)
+};
-class QRayCastingServicePrivate : public Qt3DCore::QAbstractCollisionQueryServicePrivate
+class QRayCastingServicePrivate : public QAbstractCollisionQueryServicePrivate
{
public:
QRayCastingServicePrivate(const QString &description);
- Qt3DCore::QCollisionQueryResult collides(const Qt3DCore::QRay3D &ray,
- Qt3DCore::QBoundingVolumeProvider *provider,
- Qt3DCore::QAbstractCollisionQueryService::QueryMode mode,
- const Qt3DCore::QQueryHandle &handle);
+ QCollisionQueryResult collides(const Qt3DCore::QRay3D &ray,
+ QBoundingVolumeProvider *provider,
+ QAbstractCollisionQueryService::QueryMode mode,
+ const QQueryHandle &handle);
Q_DECLARE_PUBLIC(QRayCastingService)
struct Query
{
- Qt3DCore::QQueryHandle handle;
+ QQueryHandle handle;
Qt3DCore::QRay3D ray;
QRayCastingService::QueryMode mode;
};
- QHash<Qt3DCore::QQueryHandle, FutureQueryResult> m_results;
+ QHash<QQueryHandle, FutureQueryResult> m_results;
QAtomicInt m_handlesCount;
};
diff --git a/src/render/raycasting/raycasting.pri b/src/render/raycasting/raycasting.pri
new file mode 100644
index 000000000..fdd4be17f
--- /dev/null
+++ b/src/render/raycasting/raycasting.pri
@@ -0,0 +1,17 @@
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/qabstractcollisionqueryservice_p.h \
+ $$PWD/qboundingsphere_p.h \
+ $$PWD/qboundingvolume_p.h \
+ $$PWD/qboundingvolumeprovider_p.h \
+ $$PWD/qcollisionqueryresult_p.h \
+ $$PWD/qraycastingservice_p.h
+
+SOURCES += \
+ $$PWD/qabstractcollisionqueryservice.cpp \
+ $$PWD/qboundingsphere.cpp \
+ $$PWD/qboundingvolume.cpp \
+ $$PWD/qboundingvolumeprovider.cpp \
+ $$PWD/qcollisionqueryresult.cpp \
+ $$PWD/qraycastingservice.cpp
diff --git a/src/render/render.pro b/src/render/render.pro
index d96c8e0ca..b7a74e48e 100644
--- a/src/render/render.pro
+++ b/src/render/render.pro
@@ -23,6 +23,7 @@ include (renderstates/renderstates.pri)
include (io/io.pri)
include (defaults/defaults.pri)
include (picking/picking.pri)
+include (raycasting/raycasting.pri)
include (services/services.pri)
include (texture/texture.pri)
diff --git a/src/render/services/services.pri b/src/render/services/services.pri
index dbfe9db31..93483a2b0 100644
--- a/src/render/services/services.pri
+++ b/src/render/services/services.pri
@@ -1,10 +1,7 @@
INCLUDEPATH += $$PWD
HEADERS += \
- $$PWD/qraycastingservice.h \
- $$PWD/qraycastingservice_p.h \
$$PWD/vsyncframeadvanceservice_p.h \
SOURCES += \
- $$PWD/qraycastingservice.cpp \
$$PWD/vsyncframeadvanceservice.cpp