mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 03:19:24 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into mouse_pick_in_oculus
This commit is contained in:
commit
b197558b87
5 changed files with 110 additions and 112 deletions
|
@ -29,11 +29,11 @@
|
||||||
elPosY.value = origin.y.toFixed(2);
|
elPosY.value = origin.y.toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.minorGridSpacing) {
|
if (data.minorGridSpacing !== undefined) {
|
||||||
elMinorSpacing.value = data.minorGridSpacing;
|
elMinorSpacing.value = data.minorGridSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.majorGridEvery) {
|
if (data.majorGridEvery !== undefined) {
|
||||||
elMajorSpacing.value = data.majorGridEvery;
|
elMajorSpacing.value = data.majorGridEvery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
gridColor = data.gridColor;
|
gridColor = data.gridColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.elSnapToGrid !== undefined) {
|
if (data.snapToGrid !== undefined) {
|
||||||
elSnapToGrid.checked = data.snapToGrid == true;
|
elSnapToGrid.checked = data.snapToGrid == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1749,13 +1749,6 @@ SelectionDisplay = (function () {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
var debug = Menu.isOptionChecked("Debug Ryans Rotation Problems");
|
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
print("rotateYaw()...");
|
|
||||||
print(" event.x,y:" + event.x + "," + event.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
Overlays.editOverlay(selectionBox, { ignoreRayIntersection: true, visible: false});
|
Overlays.editOverlay(selectionBox, { ignoreRayIntersection: true, visible: false});
|
||||||
Overlays.editOverlay(baseOfEntityProjectionOverlay, { ignoreRayIntersection: true, visible: false });
|
Overlays.editOverlay(baseOfEntityProjectionOverlay, { ignoreRayIntersection: true, visible: false });
|
||||||
|
@ -1763,10 +1756,6 @@ SelectionDisplay = (function () {
|
||||||
|
|
||||||
var result = Overlays.findRayIntersection(pickRay);
|
var result = Overlays.findRayIntersection(pickRay);
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
print(" findRayIntersection() .... result.intersects:" + result.intersects);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.intersects) {
|
if (result.intersects) {
|
||||||
var center = yawCenter;
|
var center = yawCenter;
|
||||||
var zero = yawZero;
|
var zero = yawZero;
|
||||||
|
@ -1776,26 +1765,7 @@ SelectionDisplay = (function () {
|
||||||
var distanceFromCenter = Vec3.distance(center, result.intersection);
|
var distanceFromCenter = Vec3.distance(center, result.intersection);
|
||||||
var snapToInner = distanceFromCenter < innerRadius;
|
var snapToInner = distanceFromCenter < innerRadius;
|
||||||
var snapAngle = snapToInner ? innerSnapAngle : 1.0;
|
var snapAngle = snapToInner ? innerSnapAngle : 1.0;
|
||||||
|
|
||||||
// for debugging
|
|
||||||
if (debug) {
|
|
||||||
Vec3.print(" result.intersection:",result.intersection);
|
|
||||||
Overlays.editOverlay(rotateCurrentOverlay, { visible: true, start: center, end: result.intersection });
|
|
||||||
Vec3.print(" centerToZero:", centerToZero);
|
|
||||||
Vec3.print(" centerToIntersect:", centerToIntersect);
|
|
||||||
Vec3.print(" rotationNormal:", rotationNormal);
|
|
||||||
print(" angleFromZero:" + angleFromZero);
|
|
||||||
print(" distanceFromCenter:" + distanceFromCenter);
|
|
||||||
print(" snapAngle:" + snapAngle);
|
|
||||||
}
|
|
||||||
|
|
||||||
angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle;
|
angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle;
|
||||||
|
|
||||||
// for debugging
|
|
||||||
if (debug) {
|
|
||||||
print(" angleFromZero:" + angleFromZero + " --- after snap");
|
|
||||||
}
|
|
||||||
|
|
||||||
var yawChange = Quat.fromVec3Degrees({ x: 0, y: angleFromZero, z: 0 });
|
var yawChange = Quat.fromVec3Degrees({ x: 0, y: angleFromZero, z: 0 });
|
||||||
|
|
||||||
// Entities should only reposition if we are rotating multiple selections around
|
// Entities should only reposition if we are rotating multiple selections around
|
||||||
|
@ -1906,23 +1876,12 @@ SelectionDisplay = (function () {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
var debug = Menu.isOptionChecked("Debug Ryans Rotation Problems");
|
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
print("rotatePitch()...");
|
|
||||||
print(" event.x,y:" + event.x + "," + event.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
Overlays.editOverlay(selectionBox, { ignoreRayIntersection: true, visible: false});
|
Overlays.editOverlay(selectionBox, { ignoreRayIntersection: true, visible: false});
|
||||||
Overlays.editOverlay(baseOfEntityProjectionOverlay, { ignoreRayIntersection: true, visible: false });
|
Overlays.editOverlay(baseOfEntityProjectionOverlay, { ignoreRayIntersection: true, visible: false });
|
||||||
Overlays.editOverlay(rotateOverlayTarget, { ignoreRayIntersection: false });
|
Overlays.editOverlay(rotateOverlayTarget, { ignoreRayIntersection: false });
|
||||||
var result = Overlays.findRayIntersection(pickRay);
|
var result = Overlays.findRayIntersection(pickRay);
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
print(" findRayIntersection() .... result.intersects:" + result.intersects);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.intersects) {
|
if (result.intersects) {
|
||||||
var properties = Entities.getEntityProperties(selectionManager.selections[0]);
|
var properties = Entities.getEntityProperties(selectionManager.selections[0]);
|
||||||
var center = pitchCenter;
|
var center = pitchCenter;
|
||||||
|
@ -1936,13 +1895,6 @@ SelectionDisplay = (function () {
|
||||||
var snapAngle = snapToInner ? innerSnapAngle : 1.0;
|
var snapAngle = snapToInner ? innerSnapAngle : 1.0;
|
||||||
angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle;
|
angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle;
|
||||||
|
|
||||||
// for debugging
|
|
||||||
if (debug) {
|
|
||||||
Vec3.print(" result.intersection:",result.intersection);
|
|
||||||
Overlays.editOverlay(rotateCurrentOverlay, { visible: true, start: center, end: result.intersection });
|
|
||||||
print(" angleFromZero:" + angleFromZero);
|
|
||||||
}
|
|
||||||
|
|
||||||
var pitchChange = Quat.fromVec3Degrees({ x: angleFromZero, y: 0, z: 0 });
|
var pitchChange = Quat.fromVec3Degrees({ x: angleFromZero, y: 0, z: 0 });
|
||||||
|
|
||||||
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
||||||
|
@ -2043,23 +1995,12 @@ SelectionDisplay = (function () {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
var debug = Menu.isOptionChecked("Debug Ryans Rotation Problems");
|
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
print("rotateRoll()...");
|
|
||||||
print(" event.x,y:" + event.x + "," + event.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
Overlays.editOverlay(selectionBox, { ignoreRayIntersection: true, visible: false});
|
Overlays.editOverlay(selectionBox, { ignoreRayIntersection: true, visible: false});
|
||||||
Overlays.editOverlay(baseOfEntityProjectionOverlay, { ignoreRayIntersection: true, visible: false });
|
Overlays.editOverlay(baseOfEntityProjectionOverlay, { ignoreRayIntersection: true, visible: false });
|
||||||
Overlays.editOverlay(rotateOverlayTarget, { ignoreRayIntersection: false });
|
Overlays.editOverlay(rotateOverlayTarget, { ignoreRayIntersection: false });
|
||||||
var result = Overlays.findRayIntersection(pickRay);
|
var result = Overlays.findRayIntersection(pickRay);
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
print(" findRayIntersection() .... result.intersects:" + result.intersects);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.intersects) {
|
if (result.intersects) {
|
||||||
var properties = Entities.getEntityProperties(selectionManager.selections[0]);
|
var properties = Entities.getEntityProperties(selectionManager.selections[0]);
|
||||||
var center = rollCenter;
|
var center = rollCenter;
|
||||||
|
@ -2073,13 +2014,6 @@ SelectionDisplay = (function () {
|
||||||
var snapAngle = snapToInner ? innerSnapAngle : 1.0;
|
var snapAngle = snapToInner ? innerSnapAngle : 1.0;
|
||||||
angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle;
|
angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle;
|
||||||
|
|
||||||
// for debugging
|
|
||||||
if (debug) {
|
|
||||||
Vec3.print(" result.intersection:",result.intersection);
|
|
||||||
Overlays.editOverlay(rotateCurrentOverlay, { visible: true, start: center, end: result.intersection });
|
|
||||||
print(" angleFromZero:" + angleFromZero);
|
|
||||||
}
|
|
||||||
|
|
||||||
var rollChange = Quat.fromVec3Degrees({ x: 0, y: 0, z: angleFromZero });
|
var rollChange = Quat.fromVec3Degrees({ x: 0, y: 0, z: angleFromZero });
|
||||||
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
||||||
var entityID = SelectionManager.selections[i];
|
var entityID = SelectionManager.selections[i];
|
||||||
|
@ -2310,14 +2244,6 @@ SelectionDisplay = (function () {
|
||||||
Overlays.editOverlay(rotateOverlayInner, { visible: true, rotation: overlayOrientation, position: overlayCenter });
|
Overlays.editOverlay(rotateOverlayInner, { visible: true, rotation: overlayOrientation, position: overlayCenter });
|
||||||
Overlays.editOverlay(rotateOverlayOuter, { visible: true, rotation: overlayOrientation, position: overlayCenter, startAt: 0, endAt: 360 });
|
Overlays.editOverlay(rotateOverlayOuter, { visible: true, rotation: overlayOrientation, position: overlayCenter, startAt: 0, endAt: 360 });
|
||||||
Overlays.editOverlay(rotateOverlayCurrent, { visible: true, rotation: overlayOrientation, position: overlayCenter, startAt: 0, endAt: 0 });
|
Overlays.editOverlay(rotateOverlayCurrent, { visible: true, rotation: overlayOrientation, position: overlayCenter, startAt: 0, endAt: 0 });
|
||||||
|
|
||||||
// for debugging
|
|
||||||
var debug = Menu.isOptionChecked("Debug Ryans Rotation Problems");
|
|
||||||
if (debug) {
|
|
||||||
Overlays.editOverlay(rotateZeroOverlay, { visible: true, start: overlayCenter, end: result.intersection });
|
|
||||||
Overlays.editOverlay(rotateCurrentOverlay, { visible: true, start: overlayCenter, end: result.intersection });
|
|
||||||
}
|
|
||||||
|
|
||||||
Overlays.editOverlay(yawHandle, { visible: false });
|
Overlays.editOverlay(yawHandle, { visible: false });
|
||||||
Overlays.editOverlay(pitchHandle, { visible: false });
|
Overlays.editOverlay(pitchHandle, { visible: false });
|
||||||
Overlays.editOverlay(rollHandle, { visible: false });
|
Overlays.editOverlay(rollHandle, { visible: false });
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
var SETTING_GRID_VISIBLE = 'gridVisible';
|
||||||
|
var SETTING_GRID_SNAP_TO_GRID = 'gridSnapToGrid';
|
||||||
|
var SETTING_GRID_MINOR_WIDTH= 'gridMinorWidth';
|
||||||
|
var SETTING_GRID_MAJOR_EVERY = 'gridMajorEvery';
|
||||||
|
var SETTING_GRID_COLOR = 'gridColor';
|
||||||
|
|
||||||
Grid = function(opts) {
|
Grid = function(opts) {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
@ -12,9 +18,6 @@ Grid = function(opts) {
|
||||||
|
|
||||||
var worldSize = 16384;
|
var worldSize = 16384;
|
||||||
|
|
||||||
var minorGridWidth = 0.5;
|
|
||||||
var majorGridWidth = 1.5;
|
|
||||||
|
|
||||||
var snapToGrid = false;
|
var snapToGrid = false;
|
||||||
|
|
||||||
var gridOverlay = Overlays.addOverlay("grid", {
|
var gridOverlay = Overlays.addOverlay("grid", {
|
||||||
|
@ -23,7 +26,7 @@ Grid = function(opts) {
|
||||||
color: { red: 0, green: 0, blue: 128 },
|
color: { red: 0, green: 0, blue: 128 },
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
||||||
minorGridWidth: 0.1,
|
minorGridSpacing: 0.1,
|
||||||
majorGridEvery: 2,
|
majorGridEvery: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -40,16 +43,37 @@ Grid = function(opts) {
|
||||||
that.getSnapToGrid = function() { return snapToGrid; };
|
that.getSnapToGrid = function() { return snapToGrid; };
|
||||||
|
|
||||||
that.setEnabled = function(enabled) {
|
that.setEnabled = function(enabled) {
|
||||||
that.enabled = enabled;
|
if (that.enabled != enabled) {
|
||||||
updateGrid();
|
that.enabled = enabled;
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
if (selectionManager.hasSelection()) {
|
||||||
|
that.setPosition(selectionManager.getBottomPosition());
|
||||||
|
} else {
|
||||||
|
that.setPosition(MyAvatar.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGrid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
that.setVisible = function(visible, noUpdate) {
|
that.setVisible = function(visible, noUpdate) {
|
||||||
that.visible = visible;
|
if (visible != that.visible) {
|
||||||
updateGrid();
|
that.visible = visible;
|
||||||
|
updateGrid();
|
||||||
|
|
||||||
if (!noUpdate) {
|
if (visible) {
|
||||||
that.emitUpdate();
|
if (selectionManager.hasSelection()) {
|
||||||
|
that.setPosition(selectionManager.getBottomPosition());
|
||||||
|
} else {
|
||||||
|
that.setPosition(MyAvatar.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!noUpdate) {
|
||||||
|
that.emitUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +195,7 @@ Grid = function(opts) {
|
||||||
Overlays.editOverlay(gridOverlay, {
|
Overlays.editOverlay(gridOverlay, {
|
||||||
position: { x: origin.y, y: origin.y, z: -origin.y },
|
position: { x: origin.y, y: origin.y, z: -origin.y },
|
||||||
visible: that.visible && that.enabled,
|
visible: that.visible && that.enabled,
|
||||||
minorGridWidth: minorGridSpacing,
|
minorGridSpacing: minorGridSpacing,
|
||||||
majorGridEvery: majorGridEvery,
|
majorGridEvery: majorGridEvery,
|
||||||
color: gridColor,
|
color: gridColor,
|
||||||
alpha: gridAlpha,
|
alpha: gridAlpha,
|
||||||
|
@ -181,15 +205,43 @@ Grid = function(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
|
saveSettings();
|
||||||
|
|
||||||
Overlays.deleteOverlay(gridOverlay);
|
Overlays.deleteOverlay(gridOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadSettings() {
|
||||||
|
that.setVisible(Settings.getValue(SETTING_GRID_VISIBLE) == "true", true);
|
||||||
|
snapToGrid = Settings.getValue(SETTING_GRID_SNAP_TO_GRID) == "true";
|
||||||
|
minorGridSpacing = parseFloat(Settings.getValue(SETTING_GRID_MINOR_WIDTH), 10);
|
||||||
|
majorGridEvery = parseInt(Settings.getValue(SETTING_GRID_MAJOR_EVERY), 10);
|
||||||
|
try {
|
||||||
|
var newColor = JSON.parse(Settings.getValue(SETTING_GRID_COLOR));
|
||||||
|
if (newColor.red !== undefined && newColor.green !== undefined && newColor.blue !== undefined) {
|
||||||
|
gridColor.red = newColor.red;
|
||||||
|
gridColor.green = newColor.green;
|
||||||
|
gridColor.blue = newColor.blue;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
updateGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveSettings() {
|
||||||
|
Settings.setValue(SETTING_GRID_VISIBLE, that.visible);
|
||||||
|
Settings.setValue(SETTING_GRID_SNAP_TO_GRID, snapToGrid);
|
||||||
|
Settings.setValue(SETTING_GRID_MINOR_WIDTH, minorGridSpacing);
|
||||||
|
Settings.setValue(SETTING_GRID_MAJOR_EVERY, majorGridEvery);
|
||||||
|
Settings.setValue(SETTING_GRID_COLOR, JSON.stringify(gridColor));
|
||||||
|
}
|
||||||
|
|
||||||
that.addListener = function(callback) {
|
that.addListener = function(callback) {
|
||||||
that.onUpdate = callback;
|
that.onUpdate = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
updateGrid();
|
|
||||||
|
loadSettings();
|
||||||
|
|
||||||
that.onUpdate = null;
|
that.onUpdate = null;
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,28 @@ var toolBar = (function () {
|
||||||
Overlays.editOverlay(loadFileMenuItem, { visible: active });
|
Overlays.editOverlay(loadFileMenuItem, { visible: active });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
that.setActive = function(active) {
|
||||||
|
if (active != isActive) {
|
||||||
|
isActive = active;
|
||||||
|
if (!isActive) {
|
||||||
|
entityListTool.setVisible(false);
|
||||||
|
gridTool.setVisible(false);
|
||||||
|
grid.setEnabled(false);
|
||||||
|
propertiesTool.setVisible(false);
|
||||||
|
selectionManager.clearSelections();
|
||||||
|
cameraManager.disable();
|
||||||
|
} else {
|
||||||
|
cameraManager.enable();
|
||||||
|
entityListTool.setVisible(true);
|
||||||
|
gridTool.setVisible(true);
|
||||||
|
propertiesTool.setVisible(true);
|
||||||
|
grid.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toolBar.selectTool(activeButton, active);
|
||||||
|
};
|
||||||
|
|
||||||
var RESIZE_INTERVAL = 50;
|
var RESIZE_INTERVAL = 50;
|
||||||
var RESIZE_TIMEOUT = 20000;
|
var RESIZE_TIMEOUT = 20000;
|
||||||
var RESIZE_MAX_CHECKS = RESIZE_TIMEOUT / RESIZE_INTERVAL;
|
var RESIZE_MAX_CHECKS = RESIZE_TIMEOUT / RESIZE_INTERVAL;
|
||||||
|
@ -288,21 +310,7 @@ var toolBar = (function () {
|
||||||
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||||
|
|
||||||
if (activeButton === toolBar.clicked(clickedOverlay)) {
|
if (activeButton === toolBar.clicked(clickedOverlay)) {
|
||||||
isActive = !isActive;
|
that.setActive(!isActive);
|
||||||
if (!isActive) {
|
|
||||||
entityListTool.setVisible(false);
|
|
||||||
gridTool.setVisible(false);
|
|
||||||
grid.setEnabled(false);
|
|
||||||
propertiesTool.setVisible(false);
|
|
||||||
selectionManager.clearSelections();
|
|
||||||
cameraManager.disable();
|
|
||||||
} else {
|
|
||||||
cameraManager.enable();
|
|
||||||
entityListTool.setVisible(true);
|
|
||||||
gridTool.setVisible(true);
|
|
||||||
grid.setEnabled(true);
|
|
||||||
propertiesTool.setVisible(true);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +674,6 @@ function setupModelMenus() {
|
||||||
Menu.addMenuItem({ menuName: "File", menuItemName: "Models", isSeparator: true, beforeItem: "Settings" });
|
Menu.addMenuItem({ menuName: "File", menuItemName: "Models", isSeparator: true, beforeItem: "Settings" });
|
||||||
Menu.addMenuItem({ menuName: "File", menuItemName: "Export Models", shortcutKey: "CTRL+META+E", afterItem: "Models" });
|
Menu.addMenuItem({ menuName: "File", menuItemName: "Export Models", shortcutKey: "CTRL+META+E", afterItem: "Models" });
|
||||||
Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" });
|
Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" });
|
||||||
Menu.addMenuItem({ menuName: "Developer", menuItemName: "Debug Ryans Rotation Problems", isCheckable: true });
|
|
||||||
|
|
||||||
Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_INSPECT_TOOL_ENABLED,
|
Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_INSPECT_TOOL_ENABLED,
|
||||||
isCheckable: true, isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) == "true" });
|
isCheckable: true, isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) == "true" });
|
||||||
|
@ -693,7 +700,6 @@ function cleanupModelMenus() {
|
||||||
Menu.removeSeparator("File", "Models");
|
Menu.removeSeparator("File", "Models");
|
||||||
Menu.removeMenuItem("File", "Export Models");
|
Menu.removeMenuItem("File", "Export Models");
|
||||||
Menu.removeMenuItem("File", "Import Models");
|
Menu.removeMenuItem("File", "Import Models");
|
||||||
Menu.removeMenuItem("Developer", "Debug Ryans Rotation Problems");
|
|
||||||
|
|
||||||
Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED);
|
Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED);
|
||||||
Menu.removeMenuItem("View", MENU_EASE_ON_FOCUS);
|
Menu.removeMenuItem("View", MENU_EASE_ON_FOCUS);
|
||||||
|
@ -815,6 +821,13 @@ function handeMenuEvent(menuItem) {
|
||||||
|
|
||||||
Menu.menuItemEvent.connect(handeMenuEvent);
|
Menu.menuItemEvent.connect(handeMenuEvent);
|
||||||
|
|
||||||
|
Controller.keyPressEvent.connect(function(event) {
|
||||||
|
if (event.text == 'w' || event.text == 'a' || event.text == 's' || event.text == 'd'
|
||||||
|
|| event.text == 'UP' || event.text == 'DOWN' || event.text == 'LEFT' || event.text == 'RIGHT') {
|
||||||
|
toolBar.setActive(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Controller.keyReleaseEvent.connect(function (event) {
|
Controller.keyReleaseEvent.connect(function (event) {
|
||||||
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
|
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
|
||||||
if (event.text == "`") {
|
if (event.text == "`") {
|
||||||
|
|
|
@ -151,12 +151,19 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity) {
|
||||||
return QScriptValue(); // no entity...
|
return QScriptValue(); // no entity...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: we keep local variables for the entityID and the script because
|
||||||
|
// below in loadScriptContents() it's possible for us to execute the
|
||||||
|
// application event loop, which may cause our entity to be deleted on
|
||||||
|
// us. We don't really need access the entity after this point, can
|
||||||
|
// can accomplish all we need to here with just the script "text" and the ID.
|
||||||
EntityItemID entityID = entity->getEntityItemID();
|
EntityItemID entityID = entity->getEntityItemID();
|
||||||
|
QString entityScript = entity->getScript();
|
||||||
|
|
||||||
if (_entityScripts.contains(entityID)) {
|
if (_entityScripts.contains(entityID)) {
|
||||||
EntityScriptDetails details = _entityScripts[entityID];
|
EntityScriptDetails details = _entityScripts[entityID];
|
||||||
|
|
||||||
// check to make sure our script text hasn't changed on us since we last loaded it
|
// check to make sure our script text hasn't changed on us since we last loaded it
|
||||||
if (details.scriptText == entity->getScript()) {
|
if (details.scriptText == entityScript) {
|
||||||
return details.scriptObject; // previously loaded
|
return details.scriptObject; // previously loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,18 +171,18 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity) {
|
||||||
// has changed and so we need to reload it.
|
// has changed and so we need to reload it.
|
||||||
_entityScripts.remove(entityID);
|
_entityScripts.remove(entityID);
|
||||||
}
|
}
|
||||||
if (entity->getScript().isEmpty()) {
|
if (entityScript.isEmpty()) {
|
||||||
return QScriptValue(); // no script
|
return QScriptValue(); // no script
|
||||||
}
|
}
|
||||||
|
|
||||||
QString scriptContents = loadScriptContents(entity->getScript());
|
QString scriptContents = loadScriptContents(entityScript);
|
||||||
|
|
||||||
QScriptSyntaxCheckResult syntaxCheck = QScriptEngine::checkSyntax(scriptContents);
|
QScriptSyntaxCheckResult syntaxCheck = QScriptEngine::checkSyntax(scriptContents);
|
||||||
if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) {
|
if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) {
|
||||||
qDebug() << "EntityTreeRenderer::loadEntityScript() entity:" << entityID;
|
qDebug() << "EntityTreeRenderer::loadEntityScript() entity:" << entityID;
|
||||||
qDebug() << " " << syntaxCheck.errorMessage() << ":"
|
qDebug() << " " << syntaxCheck.errorMessage() << ":"
|
||||||
<< syntaxCheck.errorLineNumber() << syntaxCheck.errorColumnNumber();
|
<< syntaxCheck.errorLineNumber() << syntaxCheck.errorColumnNumber();
|
||||||
qDebug() << " SCRIPT:" << entity->getScript();
|
qDebug() << " SCRIPT:" << entityScript;
|
||||||
return QScriptValue(); // invalid script
|
return QScriptValue(); // invalid script
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,12 +191,12 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity) {
|
||||||
if (!entityScriptConstructor.isFunction()) {
|
if (!entityScriptConstructor.isFunction()) {
|
||||||
qDebug() << "EntityTreeRenderer::loadEntityScript() entity:" << entityID;
|
qDebug() << "EntityTreeRenderer::loadEntityScript() entity:" << entityID;
|
||||||
qDebug() << " NOT CONSTRUCTOR";
|
qDebug() << " NOT CONSTRUCTOR";
|
||||||
qDebug() << " SCRIPT:" << entity->getScript();
|
qDebug() << " SCRIPT:" << entityScript;
|
||||||
return QScriptValue(); // invalid script
|
return QScriptValue(); // invalid script
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue entityScriptObject = entityScriptConstructor.construct();
|
QScriptValue entityScriptObject = entityScriptConstructor.construct();
|
||||||
EntityScriptDetails newDetails = { entity->getScript(), entityScriptObject };
|
EntityScriptDetails newDetails = { entityScript, entityScriptObject };
|
||||||
_entityScripts[entityID] = newDetails;
|
_entityScripts[entityID] = newDetails;
|
||||||
|
|
||||||
return entityScriptObject; // newly constructed
|
return entityScriptObject; // newly constructed
|
||||||
|
|
Loading…
Reference in a new issue