[Case 6569] Add protection for dynamic vs static collision type (details below).

When creating a model, it was possible to elect Exact collision with the dynamic
property even though this combination is prohibited.  This combination would silently
fail rather than notifying the user of the error.

This commit implements safeguards against the invalid combination:
    * If the user elects the Exact collision type and the dynamic field is unchecked, then dynamic field is disabled.
    * If the user elects a different collision type and the dynamic filed is unchecked, then the dynamic field is enabled.
    * If the user has checked the dynamic field and subsequently elects the Exact collision type, then the selection is
      void and the previous collision selection is retained; however, an error dialog is presented informing the user of the error.

Changes Committed:
    modified:   interface/resources/qml/hifi/tablet/NewModelDialog.qml
This commit is contained in:
LaShonda Hopper 2017-11-08 12:24:16 -05:00
parent 114a45a089
commit dac2ae19a4

View file

@ -11,8 +11,11 @@
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2 as OriginalDialogs
import "../../styles-uit" import "../../styles-uit"
import "../../controls-uit" import "../../controls-uit"
import "../dialogs"
Rectangle { Rectangle {
id: newModelDialog id: newModelDialog
@ -25,6 +28,15 @@ Rectangle {
property bool punctuationMode: false property bool punctuationMode: false
property bool keyboardRasied: false property bool keyboardRasied: false
function errorMessageBox(message) {
return desktop.messageBox({
icon: hifi.icons.warning,
defaultButton: OriginalDialogs.StandardButton.Ok,
title: "Error",
text: message
});
}
Item { Item {
id: column1 id: column1
anchors.rightMargin: 10 anchors.rightMargin: 10
@ -98,7 +110,6 @@ Rectangle {
CheckBox { CheckBox {
id: dynamic id: dynamic
text: qsTr("Dynamic") text: qsTr("Dynamic")
} }
Row { Row {
@ -139,15 +150,39 @@ Rectangle {
ComboBox { ComboBox {
id: collisionType id: collisionType
property int priorIndex: 0
property string staticMeshCollisionText: "Exact - All polygons"
property var collisionArray: ["No Collision",
"Basic - Whole model",
"Good - Sub-meshes",
staticMeshCollisionText,
"Box",
"Sphere"]
width: 200 width: 200
z: 100 z: 100
transformOrigin: Item.Center transformOrigin: Item.Center
model: ["No Collision", model: collisionArray
"Basic - Whole model",
"Good - Sub-meshes", onCurrentIndexChanged: {
"Exact - All polygons", if (collisionArray[currentIndex] === staticMeshCollisionText) {
"Box",
"Sphere"] if (dynamic.checked) {
currentIndex = priorIndex;
errorMessageBox("Models with Automatic Collisions set to \"" + staticMeshCollisionText + "\" cannot be dynamic.");
//--EARLY EXIT--( Can't have a static mesh model that's dynamic )
return;
}
dynamic.enabled = false;
} else {
dynamic.enabled = true;
}
priorIndex = currentIndex;
}
} }
Row { Row {