mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #9246 from birarda/touch-equip
add Oculus Touch friendly grab and equip
This commit is contained in:
commit
9ee1c64573
2 changed files with 39 additions and 24 deletions
|
@ -823,7 +823,7 @@ function MyController(hand) {
|
|||
if (this.hand === RIGHT_HAND && this.state === STATE_SEARCHING && this.getOtherHandController().state === STATE_SEARCHING) {
|
||||
this.maybeScaleMyAvatar();
|
||||
}
|
||||
|
||||
|
||||
if (this.ignoreInput()) {
|
||||
this.turnOffVisualizations();
|
||||
return;
|
||||
|
@ -1062,12 +1062,6 @@ function MyController(hand) {
|
|||
|
||||
this.secondaryPress = function(value) {
|
||||
_this.rawSecondaryValue = value;
|
||||
|
||||
// The value to check if we will allow the release function to be called
|
||||
var allowReleaseValue = 0.1;
|
||||
if (value > 0 && _this.state == STATE_HOLD) {
|
||||
_this.release();
|
||||
}
|
||||
};
|
||||
|
||||
this.updateSmoothedTrigger = function() {
|
||||
|
@ -1118,19 +1112,18 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.off = function(deltaTime, timestamp) {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
|
||||
if (this.triggerSmoothedReleased() && this.secondaryReleased()) {
|
||||
this.waitForTriggerRelease = false;
|
||||
}
|
||||
if (!this.waitForTriggerRelease && this.triggerSmoothedSqueezed()) {
|
||||
if (!this.waitForTriggerRelease && (this.triggerSmoothedSqueezed() || this.secondarySqueezed())) {
|
||||
this.lastPickTime = 0;
|
||||
this.startingHandRotation = getControllerWorldLocation(this.handToController(), true).orientation;
|
||||
if (this.triggerSmoothedSqueezed()) {
|
||||
this.setState(STATE_SEARCHING, "trigger squeeze detected");
|
||||
return;
|
||||
}
|
||||
this.searchStartTime = Date.now();
|
||||
this.setState(STATE_SEARCHING, "trigger squeeze detected");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var controllerLocation = getControllerWorldLocation(this.handToController(), true);
|
||||
var worldHandPosition = controllerLocation.position;
|
||||
|
||||
|
@ -1469,15 +1462,19 @@ function MyController(hand) {
|
|||
this.search = function(deltaTime, timestamp) {
|
||||
var _this = this;
|
||||
var name;
|
||||
var FAR_SEARCH_DELAY = 0; // msecs before search beam appears
|
||||
|
||||
var farSearching = this.triggerSmoothedSqueezed() && (Date.now() - this.searchStartTime > FAR_SEARCH_DELAY);
|
||||
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedOverlay = null;
|
||||
this.isInitialGrab = false;
|
||||
this.shouldResetParentOnRelease = false;
|
||||
this.preparingHoldRelease = false;
|
||||
|
||||
this.checkForStrayChildren();
|
||||
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
if ((this.triggerSmoothedReleased() && this.secondaryReleased())) {
|
||||
this.setState(STATE_OFF, "trigger released");
|
||||
return;
|
||||
}
|
||||
|
@ -1496,10 +1493,11 @@ function MyController(hand) {
|
|||
|
||||
var potentialEquipHotspot = this.chooseBestEquipHotspot(candidateHotSpotEntities);
|
||||
if (potentialEquipHotspot) {
|
||||
if (this.triggerSmoothedGrab() && holdEnabled) {
|
||||
if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && holdEnabled) {
|
||||
this.grabbedHotspot = potentialEquipHotspot;
|
||||
this.grabbedEntity = potentialEquipHotspot.entityID;
|
||||
this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1539,7 +1537,8 @@ function MyController(hand) {
|
|||
// potentialNearTriggerEntity = entity;
|
||||
}
|
||||
} else {
|
||||
if (this.triggerSmoothedGrab() && nearGrabEnabled) {
|
||||
// If near something grabbable, grab it!
|
||||
if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) {
|
||||
var props = entityPropertiesCache.getProps(entity);
|
||||
var grabProps = entityPropertiesCache.getGrabProps(entity);
|
||||
var refCount = grabProps.refCount ? grabProps.refCount : 0;
|
||||
|
@ -1629,7 +1628,7 @@ function MyController(hand) {
|
|||
// potentialFarTriggerEntity = entity;
|
||||
}
|
||||
} else if (this.entityIsDistanceGrabbable(rayPickInfo.entityID, handPosition)) {
|
||||
if (this.triggerSmoothedGrab() && !isEditing() && farGrabEnabled) {
|
||||
if (this.triggerSmoothedGrab() && !isEditing() && farGrabEnabled && farSearching) {
|
||||
this.grabbedEntity = entity;
|
||||
this.setState(STATE_DISTANCE_HOLDING, "distance hold '" + name + "'");
|
||||
return;
|
||||
|
@ -1706,7 +1705,7 @@ function MyController(hand) {
|
|||
equipHotspotBuddy.highlightHotspot(potentialEquipHotspot);
|
||||
}
|
||||
|
||||
if (farGrabEnabled) {
|
||||
if (farGrabEnabled && farSearching) {
|
||||
this.searchIndicatorOn(rayPickInfo.searchRay);
|
||||
}
|
||||
Reticle.setVisible(false);
|
||||
|
@ -2145,7 +2144,7 @@ function MyController(hand) {
|
|||
|
||||
this.grabPointSphereOff();
|
||||
|
||||
if (this.state == STATE_NEAR_GRABBING && !this.triggerClicked) {
|
||||
if (this.state == STATE_NEAR_GRABBING && (!this.triggerClicked && this.secondaryReleased())) {
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
this.setState(STATE_OFF, "trigger released");
|
||||
return;
|
||||
|
@ -2153,6 +2152,22 @@ function MyController(hand) {
|
|||
|
||||
if (this.state == STATE_HOLD) {
|
||||
|
||||
if (this.secondarySqueezed()) {
|
||||
// this.secondaryReleased() will always be true when not depressed
|
||||
// so we cannot simply rely on that for release - ensure that the
|
||||
// trigger was first "prepared" by being pushed in before the release
|
||||
this.preparingHoldRelease = true;
|
||||
}
|
||||
|
||||
if (this.preparingHoldRelease && this.secondaryReleased()) {
|
||||
// we have an equipped object and the secondary trigger was released
|
||||
// short-circuit the other checks and release it
|
||||
this.preparingHoldRelease = false;
|
||||
|
||||
this.release();
|
||||
return;
|
||||
}
|
||||
|
||||
var dropDetected = this.dropGestureProcess(deltaTime);
|
||||
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
|
@ -2648,7 +2663,7 @@ function MyController(hand) {
|
|||
this.grabbedOverlay = null;
|
||||
this.grabbedHotspot = null;
|
||||
|
||||
if (this.triggerSmoothedGrab()) {
|
||||
if (this.triggerSmoothedGrab() || this.secondarySqueezed()) {
|
||||
this.waitForTriggerRelease = true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -53,9 +53,9 @@ function animStateHandler(props) {
|
|||
}
|
||||
|
||||
function update(dt) {
|
||||
var leftTrigger = normalizeControllerValue(Controller.getValue(Controller.Standard.LT));
|
||||
var rightTrigger = normalizeControllerValue(Controller.getValue(Controller.Standard.RT));
|
||||
|
||||
var leftTrigger = clamp(Controller.getValue(Controller.Standard.LT) + Controller.getValue(Controller.Standard.LeftGrip), 0, 1);
|
||||
var rightTrigger = clamp(Controller.getValue(Controller.Standard.RT) + Controller.getValue(Controller.Standard.RightGrip), 0, 1);
|
||||
|
||||
// Average last few trigger values together for a bit of smoothing
|
||||
var tau = clamp(dt / TRIGGER_SMOOTH_TIMESCALE, 0, 1);
|
||||
lastLeftTrigger = lerp(leftTrigger, lastLeftTrigger, tau);
|
||||
|
|
Loading…
Reference in a new issue