forked from qt-creator/qt-creator
Update MouseArea3D::getCameraToNodeDir() to not rely on cameraNode()
The cameraNode() function has been removed from QtQuick3D and it only existed because of the weird way we we're creating the camera node. Now, instead of the round-trip, just request the spatial node directly. See: b74fde27@qtquick3d Change-Id: Icc8584aebee4952356769a134756074cba8d1b0e Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io>
This commit is contained in:
@@ -1021,12 +1021,17 @@ QVector3D MouseArea3D::getNormal() const
|
||||
QVector3D MouseArea3D::getCameraToNodeDir(QQuick3DNode *node) const
|
||||
{
|
||||
QVector3D dir;
|
||||
if (qobject_cast<QQuick3DOrthographicCamera *>(m_view3D->camera())) {
|
||||
dir = -m_view3D->camera()->cameraNode()->getDirection();
|
||||
} else {
|
||||
QVector3D camPos = m_view3D->camera()->scenePosition();
|
||||
QVector3D nodePos = pivotScenePosition(node);
|
||||
dir = (nodePos - camPos).normalized();
|
||||
if (m_view3D->camera()) {
|
||||
// We need to do a cast here to be compatible with Qt 5.x.
|
||||
// From Qt 6.2 the type can be read from the node directly.
|
||||
if (qobject_cast<QQuick3DOrthographicCamera *>(m_view3D->camera())) {
|
||||
if (auto renderCamera = QQuick3DObjectPrivate::get(m_view3D->camera())->spatialNode)
|
||||
dir -= static_cast<QSSGRenderCamera *>(renderCamera)->getDirection();
|
||||
} else {
|
||||
QVector3D camPos = m_view3D->camera()->scenePosition();
|
||||
QVector3D nodePos = pivotScenePosition(node);
|
||||
dir = (nodePos - camPos).normalized();
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user