aboutsummaryrefslogtreecommitdiffstats
path: root/src/runtimerender/qssgrenderray_p.h
diff options
context:
space:
mode:
authorAndy Nichols <[email protected]>2020-03-25 17:01:03 +0100
committerAndy Nichols <[email protected]>2020-04-16 12:45:27 +0200
commitbc7a4c8e7175a105f320e2d42ab5c85981ecbda4 (patch)
treee6559d9452b7b757e92189d2667a96ee659f6b45 /src/runtimerender/qssgrenderray_p.h
parent7eff78db71e33d4daea23673c8d9452fbbde753f (diff)
Perform picking with a Bounding Volume Hierarchy
Change-Id: I49c6b6b91c527784763b5337c77dc9fc8382d9a7 Reviewed-by: Christian Strømme <[email protected]>
Diffstat (limited to 'src/runtimerender/qssgrenderray_p.h')
-rw-r--r--src/runtimerender/qssgrenderray_p.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/runtimerender/qssgrenderray_p.h b/src/runtimerender/qssgrenderray_p.h
index 0b2dacbb..5528cede 100644
--- a/src/runtimerender/qssgrenderray_p.h
+++ b/src/runtimerender/qssgrenderray_p.h
@@ -51,6 +51,9 @@
#include <QtGui/QMatrix4x4>
QT_BEGIN_NAMESPACE
+struct QSSGMeshBVHNode;
+struct QSSGRenderMesh;
+struct QSSGMeshBVHTriangle;
enum class QSSGRenderBasisPlanes
{
XY,
@@ -70,6 +73,14 @@ struct Q_AUTOTEST_EXPORT QSSGRenderRay
// If we are parallel, then no intersection of course.
static QSSGOption<QVector3D> intersect(const QSSGPlane &inPlane, const QSSGRenderRay &ray);
+ // Perform an intersection aslo returning Barycentric Coordinates
+ static bool triangleIntersect(const QSSGRenderRay &ray,
+ const QVector3D &v0,
+ const QVector3D &v1,
+ const QVector3D &v2,
+ float &u,
+ float &v);
+
struct IntersectionResult
{
bool intersects = false;
@@ -124,6 +135,17 @@ struct Q_AUTOTEST_EXPORT QSSGRenderRay
const QSSGRenderRay &ray,
bool inForceIntersect = false);
+ static void intersectWithBVH(const RayData &data,
+ const QSSGMeshBVHNode *bvh,
+ const QSSGRenderMesh *mesh,
+ QVector<IntersectionResult> &intersections,
+ int depth = 0);
+
+ static QVector<IntersectionResult> intersectWithBVHTriangles(const RayData &data,
+ const QVector<QSSGMeshBVHTriangle *> &bvhTriangles,
+ int triangleOffset,
+ int triangleCount);
+
QSSGOption<QVector2D> relative(const QMatrix4x4 &inGlobalTransform,
const QSSGBounds3 &inBounds,
QSSGRenderBasisPlanes inPlane) const;