summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2017-11-22 13:46:51 +0200
committerJanne Kangas <janne.kangas@qt.io>2017-11-23 09:30:10 +0000
commitee168c1574c951f4f4cbd88e077ccee05e1f1241 (patch)
treeca412a67e1e84bcc5209bded94af6e4ca31057de
parent5f95c7b35fb5e2264e35987ad4b9a8f820911534 (diff)
Fix crash when camera x/y/z scale is set to zero
Resets the scale value to original if the target object is camera. Fix was done in InspectorControlModel in order to be able to also immediately update the reset value in inspector window, as opposed to silently discarding invalid value later in the stack. Change-Id: I1433c7397efb470e724593d3d85f05372bd31db0 Task-Id: QT3DS-384 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
index f3d6d304..3be1c395 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
@@ -810,6 +810,22 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV
return;
}
+ // If the user enters 0.0 to any (x, y, z) values of camera scale,
+ // we reset the value back to original, because zero scale factor will crash
+ // camera-specific inverse matrix math. (Additionally, scale of zero for a camera
+ // is generally not useful anyway.) We could silently discard zero values also deeper in the
+ // value setter code, but then the inspector panel value would not be updated as opposed
+ // to both rejecting invalid and resetting the original value here.
+ const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem();
+ EStudioObjectType theType = studio->GetClientDataModelBridge()->GetObjectType(instance);
+
+ if (theType == EStudioObjectType::OBJTYPE_CAMERA &&
+ studio->GetPropertySystem()->GetName(handle) == Q3DStudio::CString("scale")) {
+ const QVector3D theFloat3 = qt3dsdm::get<QVector3D>(v);
+ if (theFloat3.x() == 0.0f || theFloat3.y() == 0.0f || theFloat3.z() == 0.0f )
+ v = oldValue;
+ }
+
if (!commit && m_modifiedProperty.first == 0) {
m_modifiedProperty.first = instance;
m_modifiedProperty.second = handle;