Commit f979ac99 authored by Richard Gustavsen's avatar Richard Gustavsen

QQuick3DNode: add mapping functions

parent 91987426
Pipeline #5143 passed with stage
in 4 minutes and 45 seconds
......@@ -676,4 +676,24 @@ QSSGRenderGraphObject *QQuick3DNode::updateSpatialNode(QSSGRenderGraphObject *no
return spacialNode;
}
QVector3D QQuick3DNode::mapToGlobal(const QVector3D localPosition) const
{
return mat44::transform(globalTransform(), localPosition);
}
QVector3D QQuick3DNode::mapFromGlobal(const QVector3D globalPosition) const
{
return mat44::transform(globalTransform().inverted(), globalPosition);
}
QVector3D QQuick3DNode::mapToNode(const QQuick3DNode *node, const QVector3D localPosition) const
{
return node->mapFromGlobal(mapToGlobal(localPosition));
}
QVector3D QQuick3DNode::mapFromNode(const QQuick3DNode *node, const QVector3D localPosition) const
{
return mapFromGlobal(node->mapToGlobal(localPosition));
}
QT_END_NAMESPACE
......@@ -123,6 +123,11 @@ public:
QQuick3DObject::Type type() const override;
Q_INVOKABLE QVector3D mapToGlobal(const QVector3D localPosition) const;
Q_INVOKABLE QVector3D mapFromGlobal(const QVector3D globalPosition) const;
Q_INVOKABLE QVector3D mapToNode(const QQuick3DNode *node, const QVector3D localPosition) const;
Q_INVOKABLE QVector3D mapFromNode(const QQuick3DNode *node, const QVector3D localPosition) const;
protected:
void connectNotify(const QMetaMethod &signal) override;
void disconnectNotify(const QMetaMethod &signal) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment