mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into autoTesterUpdate
This commit is contained in:
commit
cfd7e86a0f
3 changed files with 72 additions and 27 deletions
|
@ -307,7 +307,6 @@ void Avatar::updateAvatarEntities() {
|
|||
// NOTE: if this avatar entity is not attached to us, strip its entity script completely...
|
||||
auto attachedScript = properties.getScript();
|
||||
if (!isMyAvatar() && !attachedScript.isEmpty()) {
|
||||
qCDebug(avatars_renderer) << "removing entity script from avatar attached entity:" << entityID << "old script:" << attachedScript;
|
||||
QString noScript;
|
||||
properties.setScript(noScript);
|
||||
}
|
||||
|
|
|
@ -18,10 +18,16 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
Script.include("/~/system/libraries/utils.js");
|
||||
|
||||
(function () {
|
||||
var MARGIN = 25;
|
||||
|
||||
function InEditMode(hand) {
|
||||
this.hand = hand;
|
||||
this.triggerClicked = false;
|
||||
this.selectedTarget = null;
|
||||
this.reticleMinX = MARGIN;
|
||||
this.reticleMaxX;
|
||||
this.reticleMinY = MARGIN;
|
||||
this.reticleMaxY;
|
||||
|
||||
this.parameters = makeDispatcherModuleParameters(
|
||||
160,
|
||||
|
@ -47,6 +53,16 @@ Script.include("/~/system/libraries/utils.js");
|
|||
return (HMD.tabletScreenID && objectID === HMD.tabletScreenID)
|
||||
|| (HMD.homeButtonID && objectID === HMD.homeButtonID);
|
||||
};
|
||||
|
||||
this.calculateNewReticlePosition = function(intersection) {
|
||||
var dims = Controller.getViewportDimensions();
|
||||
this.reticleMaxX = dims.x - MARGIN;
|
||||
this.reticleMaxY = dims.y - MARGIN;
|
||||
var point2d = HMD.overlayFromWorldPoint(intersection);
|
||||
point2d.x = Math.max(this.reticleMinX, Math.min(point2d.x, this.reticleMaxX));
|
||||
point2d.y = Math.max(this.reticleMinY, Math.min(point2d.y, this.reticleMaxY));
|
||||
return point2d;
|
||||
};
|
||||
|
||||
this.sendPickData = function(controllerData) {
|
||||
if (controllerData.triggerClicks[this.hand]) {
|
||||
|
@ -72,6 +88,23 @@ Script.include("/~/system/libraries/utils.js");
|
|||
|
||||
this.triggerClicked = true;
|
||||
}
|
||||
|
||||
this.sendPointingAtData(controllerData);
|
||||
};
|
||||
|
||||
this.sendPointingAtData = function(controllerData) {
|
||||
var rayPick = controllerData.rayPicks[this.hand];
|
||||
var hudRayPick = controllerData.hudRayPicks[this.hand];
|
||||
var point2d = this.calculateNewReticlePosition(hudRayPick.intersection);
|
||||
var desktopWindow = Window.isPointOnDesktopWindow(point2d);
|
||||
var tablet = this.pointingAtTablet(rayPick.objectID);
|
||||
var rightHand = this.hand === RIGHT_HAND;
|
||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||
method: "pointingAt",
|
||||
desktopWindow: desktopWindow,
|
||||
tablet: tablet,
|
||||
rightHand: rightHand
|
||||
}));
|
||||
};
|
||||
|
||||
this.exitModule = function() {
|
||||
|
@ -104,6 +137,7 @@ Script.include("/~/system/libraries/utils.js");
|
|||
if (overlayLaser) {
|
||||
var overlayLaserReady = overlayLaser.isReady(controllerData);
|
||||
var target = controllerData.rayPicks[this.hand].objectID;
|
||||
this.sendPointingAtData(controllerData);
|
||||
if (overlayLaserReady.active && this.pointingAtTablet(target)) {
|
||||
return this.exitModule();
|
||||
}
|
||||
|
|
|
@ -58,6 +58,14 @@ SelectionManager = (function() {
|
|||
that.setSelections([messageParsed.entityID]);
|
||||
} else if (messageParsed.method === "clearSelection") {
|
||||
that.clearSelections();
|
||||
} else if (messageParsed.method === "pointingAt") {
|
||||
if (messageParsed.rightHand) {
|
||||
that.pointingAtDesktopWindowRight = messageParsed.desktopWindow;
|
||||
that.pointingAtTabletRight = messageParsed.tablet;
|
||||
} else {
|
||||
that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow;
|
||||
that.pointingAtTabletLeft = messageParsed.tablet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,6 +101,11 @@ SelectionManager = (function() {
|
|||
that.worldDimensions = Vec3.ZERO;
|
||||
that.worldRegistrationPoint = Vec3.HALF;
|
||||
that.centerPosition = Vec3.ZERO;
|
||||
|
||||
that.pointingAtDesktopWindowLeft = false;
|
||||
that.pointingAtDesktopWindowRight = false;
|
||||
that.pointingAtTabletLeft = false;
|
||||
that.pointingAtTabletRight = false;
|
||||
|
||||
that.saveProperties = function() {
|
||||
that.savedProperties = {};
|
||||
|
@ -313,8 +326,6 @@ SelectionDisplay = (function() {
|
|||
|
||||
var CTRL_KEY_CODE = 16777249;
|
||||
|
||||
var AVATAR_COLLISIONS_OPTION = "Enable Avatar Collisions";
|
||||
|
||||
var TRANSLATE_DIRECTION = {
|
||||
X : 0,
|
||||
Y : 1,
|
||||
|
@ -368,7 +379,7 @@ SelectionDisplay = (function() {
|
|||
|
||||
var ctrlPressed = false;
|
||||
|
||||
var handleStretchCollisionOverride = false;
|
||||
var replaceCollisionsAfterStretch = false;
|
||||
|
||||
var handlePropertiesTranslateArrowCones = {
|
||||
shape: "Cone",
|
||||
|
@ -644,11 +655,6 @@ SelectionDisplay = (function() {
|
|||
var activeTool = null;
|
||||
var handleTools = {};
|
||||
|
||||
that.shutdown = function() {
|
||||
that.restoreAvatarCollisionsFromStretch();
|
||||
}
|
||||
Script.scriptEnding.connect(that.shutdown);
|
||||
|
||||
// We get mouseMoveEvents from the handControllers, via handControllerPointer.
|
||||
// But we dont' get mousePressEvents.
|
||||
that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
||||
|
@ -667,7 +673,13 @@ SelectionDisplay = (function() {
|
|||
activeHand = (activeHand === Controller.Standard.RightHand) ?
|
||||
Controller.Standard.LeftHand : Controller.Standard.RightHand;
|
||||
}
|
||||
if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) {
|
||||
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
||||
SelectionManager.pointingAtDesktopWindowRight) ||
|
||||
(hand === Controller.Standard.LeftHand &&
|
||||
SelectionManager.pointingAtDesktopWindowLeft);
|
||||
var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) ||
|
||||
(hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft);
|
||||
if (pointingAtDesktopWindow || pointingAtTablet) {
|
||||
return;
|
||||
}
|
||||
that.mousePressEvent({});
|
||||
|
@ -1832,13 +1844,6 @@ SelectionDisplay = (function() {
|
|||
};
|
||||
};
|
||||
|
||||
that.restoreAvatarCollisionsFromStretch = function() {
|
||||
if (handleStretchCollisionOverride) {
|
||||
Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, true);
|
||||
handleStretchCollisionOverride = false;
|
||||
}
|
||||
}
|
||||
|
||||
// TOOL DEFINITION: HANDLE STRETCH TOOL
|
||||
function makeStretchTool(stretchMode, directionEnum, directionVec, pivot, offset, stretchPanel, scaleHandle) {
|
||||
var directionFor3DStretch = directionVec;
|
||||
|
@ -2041,9 +2046,12 @@ SelectionDisplay = (function() {
|
|||
if (scaleHandle != null) {
|
||||
Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE_SELECTED });
|
||||
}
|
||||
if (Menu.isOptionChecked(AVATAR_COLLISIONS_OPTION)) {
|
||||
Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, false);
|
||||
handleStretchCollisionOverride = true;
|
||||
|
||||
var collisionToRemove = "myAvatar";
|
||||
if (properties.collidesWith.indexOf(collisionToRemove) > -1) {
|
||||
var newCollidesWith = properties.collidesWith.replace(collisionToRemove, "");
|
||||
Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith});
|
||||
that.replaceCollisionsAfterStretch = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2054,7 +2062,13 @@ SelectionDisplay = (function() {
|
|||
if (scaleHandle != null) {
|
||||
Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE });
|
||||
}
|
||||
that.restoreAvatarCollisionsFromStretch();
|
||||
|
||||
if (that.replaceCollisionsAfterStretch) {
|
||||
var newCollidesWith = SelectionManager.savedProperties[SelectionManager.selections[0]].collidesWith;
|
||||
Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith});
|
||||
that.replaceCollisionsAfterStretch = false;
|
||||
}
|
||||
|
||||
pushCommandForSelections();
|
||||
};
|
||||
|
||||
|
@ -2140,12 +2154,10 @@ SelectionDisplay = (function() {
|
|||
}
|
||||
var newPosition = Vec3.sum(initialPosition, changeInPosition);
|
||||
|
||||
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
||||
Entities.editEntity(SelectionManager.selections[i], {
|
||||
position: newPosition,
|
||||
dimensions: newDimensions
|
||||
});
|
||||
}
|
||||
Entities.editEntity(SelectionManager.selections[0], {
|
||||
position: newPosition,
|
||||
dimensions: newDimensions
|
||||
});
|
||||
|
||||
var wantDebug = false;
|
||||
if (wantDebug) {
|
||||
|
|
Loading…
Reference in a new issue