Martin Lambers

Access device->_internals only if it is available.

......@@ -836,10 +836,12 @@ int QVRDevice::modelNodeCount() const
{
int ret = 0;
#ifdef HAVE_OPENVR
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelPositions[0].size();
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelPositions[1].size();
if (_internals) {
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelPositions[0].size();
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelPositions[1].size();
}
#endif
return ret;
}
......@@ -849,10 +851,12 @@ QVector3D QVRDevice::modelNodePosition(int nodeIndex) const
Q_UNUSED(nodeIndex);
QVector3D ret;
#ifdef HAVE_OPENVR
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelPositions[0].at(nodeIndex);
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelPositions[1].at(nodeIndex);
if (_internals) {
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelPositions[0].at(nodeIndex);
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelPositions[1].at(nodeIndex);
}
#endif
return ret;
}
......@@ -862,10 +866,12 @@ QQuaternion QVRDevice::modelNodeOrientation(int nodeIndex) const
Q_UNUSED(nodeIndex);
QQuaternion ret;
#ifdef HAVE_OPENVR
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelOrientations[0].at(nodeIndex);
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelOrientations[1].at(nodeIndex);
if (_internals) {
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelOrientations[0].at(nodeIndex);
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelOrientations[1].at(nodeIndex);
}
#endif
return ret;
}
......@@ -875,10 +881,12 @@ int QVRDevice::modelNodeVertexDataIndex(int nodeIndex) const
Q_UNUSED(nodeIndex);
int ret = -1;
#ifdef HAVE_OPENVR
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelVertexDataIndices[0].at(nodeIndex);
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelVertexDataIndices[1].at(nodeIndex);
if (_internals) {
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelVertexDataIndices[0].at(nodeIndex);
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelVertexDataIndices[1].at(nodeIndex);
}
#endif
return ret;
}
......@@ -888,10 +896,12 @@ int QVRDevice::modelNodeTextureIndex(int nodeIndex) const
Q_UNUSED(nodeIndex);
int ret = -1;
#ifdef HAVE_OPENVR
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelTextureIndices[0].at(nodeIndex);
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelTextureIndices[1].at(nodeIndex);
if (_internals) {
if (_internals->openVrTrackedEntity == 3)
ret = QVROpenVRControllerModelTextureIndices[0].at(nodeIndex);
else if (_internals->openVrTrackedEntity == 4)
ret = QVROpenVRControllerModelTextureIndices[1].at(nodeIndex);
}
#endif
return ret;
}
......@@ -901,12 +911,12 @@ bool QVRDevice::supportsHapticPulse() const
int ret = false;
#ifdef HAVE_OCULUS
# if (OVR_PRODUCT_VERSION >= 1)
if (_internals->oculusTrackedEntity == 3 || _internals->oculusTrackedEntity == 4)
if (_internals && (_internals->oculusTrackedEntity == 3 || _internals->oculusTrackedEntity == 4))
ret = true;
# endif
#endif
#ifdef HAVE_OPENVR
if (_internals->openVrTrackedEntity == 3 || _internals->openVrTrackedEntity == 4)
if (_internals && (_internals->openVrTrackedEntity == 3 || _internals->openVrTrackedEntity == 4))
ret = true;
#endif
return ret;
......@@ -917,7 +927,7 @@ void QVRDevice::triggerHapticPulse(int microseconds) const
Q_UNUSED(microseconds);
#ifdef HAVE_OCULUS
# if (OVR_PRODUCT_VERSION >= 1)
if (_internals->oculusTrackedEntity == 3 || _internals->oculusTrackedEntity == 4) {
if (_internals && (_internals->oculusTrackedEntity == 3 || _internals->oculusTrackedEntity == 4)) {
ovrControllerType ct = (_internals->oculusTrackedEntity == 3 ?
ovrControllerType_LTouch : ovrControllerType_RTouch);
ovr_SetControllerVibration(QVROculus, ct, 0.5f, 1.0f);
......@@ -926,7 +936,7 @@ void QVRDevice::triggerHapticPulse(int microseconds) const
# endif
#endif
#ifdef HAVE_OPENVR
if (_internals->openVrTrackedEntity == 3 || _internals->openVrTrackedEntity == 4) {
if (_internals && (_internals->openVrTrackedEntity == 3 || _internals->openVrTrackedEntity == 4)) {
int deviceIndex = QVROpenVRControllerIndices[_internals->openVrTrackedEntity - 3];
QVROpenVRSystem->TriggerHapticPulse(deviceIndex, 0, microseconds);
}
......