Improved outline debugging script for easier test plan

This commit is contained in:
Olivier Prat 2017-10-20 11:32:43 +02:00
parent 8229c41622
commit 732fe3b8db
4 changed files with 90 additions and 33 deletions

View file

@ -71,6 +71,12 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis
return false;
}
bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) {
_selectedItemsListMap.insert(listName, GameplayObjects());
emit selectedItemsListChanged(listName);
return true;
}
template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) {
GameplayObjects currentList = _selectedItemsListMap.value(listName);
currentList.addToGameplayObjects(idToAdd);

View file

@ -61,6 +61,7 @@ public:
Q_INVOKABLE bool addToSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id);
Q_INVOKABLE bool removeFromSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id);
Q_INVOKABLE bool clearSelectedItemsList(const QString& listName);
signals:
void selectedItemsListChanged(const QString& listName);

View file

@ -55,14 +55,7 @@ var end2 = {
}
var outlineGroupIndex = 0
function setOutlineGroupIndex(index) {
print("Switching to outline group "+index)
outlineGroupIndex = index
}
window.fromQml.connect(setOutlineGroupIndex);
var isSelectionAddEnabled = false
var renderStates = [{name: "test", end: end}];
var defaultRenderStates = [{name: "test", distance: 20.0, end: end2}];
@ -71,33 +64,64 @@ var ray = LaserPointers.createLaserPointer({
filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_AVATARS | RayPick.PICK_INVISIBLE | RayPick.PICK_NONCOLLIDABLE,
renderStates: renderStates,
defaultRenderStates: defaultRenderStates,
enabled: true
enabled: false
});
function getSelectionName() {
var selectionName = "contextOverlayHighlightList"
if (outlineGroupIndex>0) {
selectionName += outlineGroupIndex
}
return selectionName
}
function fromQml(message) {
tokens = message.split(' ')
print("Received '"+message+"' from outline.qml")
if (tokens[0]=="outline") {
outlineGroupIndex = parseInt(tokens[1])
print("Switching to outline group "+outlineGroupIndex)
} else if (tokens[0]=="pick") {
var isPickingEnabled = tokens[1]=='true'
print("Ray picking set to "+isPickingEnabled.toString())
if (isPickingEnabled) {
LaserPointers.enableLaserPointer(ray)
} else {
LaserPointers.disableLaserPointer(ray)
}
} else if (tokens[0]=="add") {
isSelectionAddEnabled = tokens[1]=='true'
print("Add to selection set to "+isSelectionAddEnabled.toString())
if (!isSelectionAddEnabled) {
Selection.clearSelectedItemsList(getSelectionName())
}
}
}
window.fromQml.connect(fromQml);
function cleanup() {
LaserPointers.removeLaserPointer(ray);
}
Script.scriptEnding.connect(cleanup);
var prevID = 0;
var prevType = "";
function update() {
var prevID = 0
var prevType = ""
var selectedID = 0
var selectedType = ""
var time = 0
function update(deltaTime) {
// you have to do this repeatedly because there's a bug but I'll fix it
LaserPointers.setRenderState(ray, "test");
var result = LaserPointers.getPrevRayPickResult(ray);
var selectionName = "contextOverlayHighlightList"
if (outlineGroupIndex>0) {
selectionName += outlineGroupIndex
}
var selectionName = getSelectionName()
if (result.type != RayPick.INTERSECTED_NONE) {
time += deltaTime
if (result.objectID != prevID) {
if (prevID != 0) {
Selection.removeFromSelectedItemsList(selectionName, prevType, prevID)
}
var typeName = ""
if (result.type == RayPick.INTERSECTED_ENTITY) {
typeName = "entity"
@ -107,19 +131,28 @@ function update() {
typeName = "avatar"
}
Selection.addToSelectedItemsList(selectionName, typeName, result.objectID)
//print("OUTLINE " + outlineGroupIndex + " picked type: " + result.type + ", id: " + result.objectID);
prevID = result.objectID;
prevType = typeName;
time = 0
} else if (time>1.0 && prevID!=selectedID) {
if (prevID != 0 && !isSelectionAddEnabled) {
Selection.removeFromSelectedItemsList(selectionName, selectedType, selectedID)
}
selectedID = prevID
selectedType = prevType
Selection.addToSelectedItemsList(selectionName, selectedType, selectedID)
//print("OUTLINE " + outlineGroupIndex + " picked type: " + result.type + ", id: " + result.objectID);
}
} else {
if (prevID != 0) {
if (prevID != 0 && !isSelectionAddEnabled) {
Selection.removeFromSelectedItemsList(selectionName, prevType, prevID)
}
prevID = 0;
prevID = 0
selectedID = 0
time = 0
}
}
Script.update.connect(update);
}()); // END LOCAL_SCOPE

View file

@ -21,12 +21,29 @@ Item {
spacing: 8
anchors.fill: parent
CheckBox {
id: debug
text: "View Mask"
checked: root.debugConfig["viewMask"]
onCheckedChanged: {
root.debugConfig["viewMask"] = checked;
Row {
spacing: 8
CheckBox {
id: debug
text: "View Mask"
checked: root.debugConfig["viewMask"]
onCheckedChanged: {
root.debugConfig["viewMask"] = checked;
}
}
CheckBox {
text: "Hover select"
checked: false
onCheckedChanged: {
sendToScript("pick "+checked.toString())
}
}
CheckBox {
text: "Add to selection"
checked: false
onCheckedChanged: {
sendToScript("add "+checked.toString())
}
}
}
@ -36,7 +53,7 @@ Item {
height: 400
onCurrentIndexChanged: {
sendToScript(currentIndex)
sendToScript("outline "+currentIndex)
}
Tab {