35class Q_QUICK3DPHYSICS_EXPORT
QRaycaster :
public QQuick3DNode
38 Q_PROPERTY(
bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged
39 FINAL REVISION(6, 13))
40 Q_PROPERTY(QVector3D direction READ direction WRITE setDirection NOTIFY directionChanged
41 FINAL REVISION(6, 13))
42 Q_PROPERTY(
float maxDistance READ maxDistance WRITE setMaxDistance NOTIFY maxDistanceChanged
43 FINAL REVISION(6, 13))
44 Q_PROPERTY(
bool excludeParentBody READ excludeParentBody WRITE setExcludeParentBody NOTIFY
45 excludeParentBodyChanged FINAL REVISION(6, 13))
46 Q_PROPERTY(QQmlListProperty<QAbstractPhysicsNode> excludedBodies READ excludedBodies CONSTANT
47 FINAL REVISION(6, 13))
48 Q_PROPERTY(
bool includeStatic READ includeStatic WRITE setIncludeStatic NOTIFY
49 includeStaticChanged FINAL REVISION(6, 13))
50 Q_PROPERTY(
bool includeDynamic READ includeDynamic WRITE setIncludeDynamic NOTIFY
51 includeDynamicChanged FINAL REVISION(6, 13))
52 Q_PROPERTY(
bool isColliding READ isColliding NOTIFY isCollidingChanged FINAL REVISION(6, 13))
53 Q_PROPERTY(QQuick3DPhysicsLocationHit hit READ hit NOTIFY hitChanged FINAL REVISION(6, 13))
58 explicit QRaycaster(QQuick3DNode *parent =
nullptr);
59 ~QRaycaster() override;
62 void setEnabled(
bool enabled);
64 QVector3D direction()
const;
65 void setDirection(
const QVector3D &direction);
67 float maxDistance()
const;
68 void setMaxDistance(
float maxDistance);
70 bool excludeParentBody()
const;
71 void setExcludeParentBody(
bool excludeParentBody);
73 QQmlListProperty<QAbstractPhysicsNode> excludedBodies();
75 bool includeStatic()
const;
76 void setIncludeStatic(
bool includeStatic);
78 bool includeDynamic()
const;
79 void setIncludeDynamic(
bool includeDynamic);
81 bool isColliding()
const;
82 QQuick3DPhysicsLocationHit hit()
const;
85 void enabledChanged();
86 void directionChanged();
87 void maxDistanceChanged();
88 void excludeParentBodyChanged();
89 void includeStaticChanged();
90 void includeDynamicChanged();
91 void isCollidingChanged();
93 void bodyEntered(QAbstractPhysicsNode *body);
94 void bodyExited(QAbstractPhysicsNode *body);
97 void updateRaycast(QPhysicsWorld *world);
98 void updateHit(
const QQuick3DPhysicsLocationHit &hit);
100 void gatherExcludedBodies(QVarLengthArray<
const QAbstractPhysicsNode *, 4> &excluded)
const;
102 static void qmlAppendExcludedBody(QQmlListProperty<QAbstractPhysicsNode> *list,
103 QAbstractPhysicsNode *body);
104 static QAbstractPhysicsNode *qmlExcludedBodyAt(QQmlListProperty<QAbstractPhysicsNode> *list,
106 static qsizetype qmlExcludedBodyCount(QQmlListProperty<QAbstractPhysicsNode> *list);
107 static void qmlClearExcludedBodies(QQmlListProperty<QAbstractPhysicsNode> *list);
109 bool m_enabled =
true;
110 QVector3D m_direction = QVector3D(0.0f, 0.0f, -1.0f);
111 float m_maxDistance = 100.0f;
112 bool m_excludeParentBody =
true;
113 bool m_includeStatic =
true;
114 bool m_includeDynamic =
true;
117 QList<QPointer<QAbstractPhysicsNode>> m_excludedBodies;
119 bool m_isColliding =
false;
120 QQuick3DPhysicsLocationHit m_hit;
122 friend class QPhysicsWorld;
static bool raycastImpl(const physx::PxScene *scene, const QVector3D &origin, const QVector3D &direction, float maxDistance, bool includeStatic, bool includeDynamic, physx::PxRaycastCallback &hitCallback, physx::PxHitFlags hitFlags, physx::PxQueryFlags extraQueryFlags={}, physx::PxQueryFilterCallback *filterCall=nullptr)
static bool sweepImpl(const physx::PxScene *scene, QAbstractCollisionShape *shape, const QVector3D &direction, float maxDistance, bool includeStatic, bool includeDynamic, physx::PxSweepCallback &hitCallback, physx::PxHitFlags hitFlags, physx::PxQueryFlags extraQueryFlags={})
static bool overlapImpl(const physx::PxScene *scene, QAbstractCollisionShape *shape, bool includeStatic, bool includeDynamic, physx::PxOverlapCallback &hitCallback, physx::PxQueryFlags extraQueryFlags={})