fixing grabbing and tablet bugs

This commit is contained in:
druiz17 2017-09-28 11:18:40 -07:00
parent 287f4f1d71
commit 3b05317db6
3 changed files with 31 additions and 6 deletions

View file

@ -255,6 +255,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
this.messageGrabEntity = false;
this.grabEntityProps = null;
this.shouldSendStart = false;
this.equipedWithSecondary = false;
this.parameters = makeDispatcherModuleParameters(
300,
@ -370,6 +371,10 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
return this.rawSecondaryValue < BUMPER_ON_VALUE;
};
this.secondarySmoothedSqueezed = function() {
return this.rawSecondaryValue > BUMPER_ON_VALUE;
};
this.chooseNearEquipHotspots = function(candidateEntityProps, controllerData) {
var _this = this;
var collectedHotspots = flatten(candidateEntityProps.map(function(props) {
@ -592,11 +597,13 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
// if the potentialHotspot os not cloneable and locked return null
if (potentialEquipHotspot &&
((this.triggerSmoothedSqueezed() && !this.waitForTriggerRelease) || this.messageGrabEntity)) {
(((this.triggerSmoothedSqueezed() || this.secondarySmoothedSqueezed()) && !this.waitForTriggerRelease) ||
this.messageGrabEntity)) {
this.grabbedHotspot = potentialEquipHotspot;
this.targetEntityID = this.grabbedHotspot.entityID;
this.startEquipEntity(controllerData);
this.messageGrabEnity = false;
this.equipedWithSecondary = this.secondarySmoothedSqueezed();
return makeRunningValues(true, [potentialEquipHotspot.entityID], []);
} else {
return makeRunningValues(false, [], []);
@ -627,7 +634,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
return this.checkNearbyHotspots(controllerData, deltaTime, timestamp);
}
if (controllerData.secondaryValues[this.hand]) {
if (controllerData.secondaryValues[this.hand] && !this.equipedWithSecondary) {
// 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
@ -644,7 +651,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
var dropDetected = this.dropGestureProcess(deltaTime);
if (this.triggerSmoothedReleased()) {
if (this.triggerSmoothedReleased() || this.secondaryReleased()) {
if (this.shouldSendStart) {
// we don't want to send startEquip message until the trigger is released. otherwise,
// guns etc will fire right as they are equipped.
@ -653,6 +660,9 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
this.shouldSendStart = false;
}
this.waitForTriggerRelease = false;
if (this.secondaryReleased() && this.equipedWithSecondary) {
this.equipedWithSecondary = false;
}
}
if (dropDetected && this.prevDropDetected !== dropDetected) {

View file

@ -132,7 +132,7 @@ Script.include("/~/system/libraries/controllers.js");
this.updateLaserPointer = function(controllerData) {
var SEARCH_SPHERE_SIZE = 0.011;
var MIN_SPHERE_SIZE = 0.0005;
var radius = Math.max(1.2 * SEARCH_SPHERE_SIZE * this.intersectionDistance, MIN_SPHERE_SIZE);
var radius = Math.max(1.2 * SEARCH_SPHERE_SIZE * this.intersectionDistance, MIN_SPHERE_SIZE) * MyAvatar.sensorToWorldScale;
var dim = {x: radius, y: radius, z: radius};
var mode = "hold";
if (!this.distanceHolding && !this.distanceRotating) {
@ -424,7 +424,7 @@ Script.include("/~/system/libraries/controllers.js");
this.laserPointerOff();
return makeRunningValues(false, [], []);
}
this.intersectionDistance = controllerData.rayPicks[this.hand].distance;
this.updateLaserPointer(controllerData);
var otherModuleName =this.hand === RIGHT_HAND ? "LeftFarActionGrabEntity" : "RightFarActionGrabEntity";

View file

@ -152,6 +152,20 @@ Script.include("/~/system/libraries/controllers.js");
}
};
this.updateStylus = function() {
if (this.stylus) {
var X_ROT_NEG_90 = { x: -0.70710678, y: 0, z: 0, w: 0.70710678 };
var modelOrientation = Quat.multiply(this.stylusTip.orientation, X_ROT_NEG_90);
var modelPositionOffset = Vec3.multiplyQbyV(modelOrientation, { x: 0, y: 0, z: MyAvatar.sensorToWorldScale * -WEB_STYLUS_LENGTH / 2 });
var stylusProps = {
position: Vec3.sum(this.stylusTip.position, modelPositionOffset),
rotation: modelOrientation
};
Overlays.editOverlay(this.stylus, stylusProps);
}
};
this.showStylus = function() {
if (this.stylus) {
return;
@ -320,6 +334,7 @@ Script.include("/~/system/libraries/controllers.js");
if (this.isNearStylusTarget) {
if (!this.useFingerInsteadOfStylus) {
this.showStylus();
this.updateStylus();
} else {
this.pointFinger(true);
}
@ -335,7 +350,7 @@ Script.include("/~/system/libraries/controllers.js");
var SCALED_TABLET_MAX_HOVER_DISTANCE = TABLET_MAX_HOVER_DISTANCE * sensorScaleFactor;
if (nearestStylusTarget && nearestStylusTarget.distance > SCALED_TABLET_MIN_TOUCH_DISTANCE &&
nearestStylusTarget.distance < SCALED_TABLET_MAX_HOVER_DISTANCE) {
nearestStylusTarget.distance < SCALED_TABLET_MAX_HOVER_DISTANCE && !this.getOtherHandController().stylusTouchingTarget) {
this.requestTouchFocus(nearestStylusTarget);