mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-14 19:36:40 +02:00
Merge pull request #6833 from PhilipRosedale/searchChoice
Choice of hand ray pick or head pick
This commit is contained in:
commit
d8dceade2e
1 changed files with 22 additions and 33 deletions
|
@ -33,6 +33,8 @@ var BUMPER_ON_VALUE = 0.5;
|
||||||
|
|
||||||
var HAND_HEAD_MIX_RATIO = 0.0; // 0 = only use hands for search/move. 1 = only use head for search/move.
|
var HAND_HEAD_MIX_RATIO = 0.0; // 0 = only use hands for search/move. 1 = only use head for search/move.
|
||||||
|
|
||||||
|
var PICK_WITH_HAND_RAY = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// distant manipulation
|
// distant manipulation
|
||||||
//
|
//
|
||||||
|
@ -302,8 +304,10 @@ function MyController(hand) {
|
||||||
this.searchSphere = null;
|
this.searchSphere = null;
|
||||||
|
|
||||||
// how far from camera to search intersection?
|
// how far from camera to search intersection?
|
||||||
|
var DEFAULT_SEARCH_SPHERE_DISTANCE = 1000;
|
||||||
this.intersectionDistance = 0.0;
|
this.intersectionDistance = 0.0;
|
||||||
this.searchSphereDistance = 0.0;
|
this.searchSphereDistance = DEFAULT_SEARCH_SPHERE_DISTANCE;
|
||||||
|
|
||||||
|
|
||||||
this.ignoreIK = false;
|
this.ignoreIK = false;
|
||||||
this.offsetPosition = Vec3.ZERO;
|
this.offsetPosition = Vec3.ZERO;
|
||||||
|
@ -456,7 +460,6 @@ function MyController(hand) {
|
||||||
visible: true,
|
visible: true,
|
||||||
alpha: 1
|
alpha: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
this.overlayLine = Overlays.addOverlay("line3d", lineProperties);
|
this.overlayLine = Overlays.addOverlay("line3d", lineProperties);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -699,10 +702,9 @@ function MyController(hand) {
|
||||||
|
|
||||||
this.searchSphereOff = function() {
|
this.searchSphereOff = function() {
|
||||||
if (this.searchSphere !== null) {
|
if (this.searchSphere !== null) {
|
||||||
//Overlays.editOverlay(this.searchSphere, { visible: false });
|
|
||||||
Overlays.deleteOverlay(this.searchSphere);
|
Overlays.deleteOverlay(this.searchSphere);
|
||||||
this.searchSphere = null;
|
this.searchSphere = null;
|
||||||
this.searchSphereDistance = 0.0;
|
this.searchSphereDistance = DEFAULT_SEARCH_SPHERE_DISTANCE;
|
||||||
this.intersectionDistance = 0.0;
|
this.intersectionDistance = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,8 +813,9 @@ function MyController(hand) {
|
||||||
var handDeltaRotation = Quat.multiply(currentHandRotation, Quat.inverse(this.startingHandRotation));
|
var handDeltaRotation = Quat.multiply(currentHandRotation, Quat.inverse(this.startingHandRotation));
|
||||||
|
|
||||||
var distantPickRay = {
|
var distantPickRay = {
|
||||||
origin: Camera.position,
|
origin: PICK_WITH_HAND_RAY ? handPosition : Camera.position,
|
||||||
direction: Vec3.mix(Quat.getUp(this.getHandRotation()), Quat.getFront(Camera.orientation), HAND_HEAD_MIX_RATIO),
|
direction: PICK_WITH_HAND_RAY ? Quat.getUp(this.getHandRotation()) :
|
||||||
|
Vec3.mix(Quat.getUp(this.getHandRotation()), Quat.getFront(Camera.orientation), HAND_HEAD_MIX_RATIO),
|
||||||
length: PICK_MAX_DISTANCE
|
length: PICK_MAX_DISTANCE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -897,8 +900,8 @@ function MyController(hand) {
|
||||||
grabbableData = grabbableDataForCandidate;
|
grabbableData = grabbableDataForCandidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.grabbedEntity !== null) {
|
if ((this.grabbedEntity !== null) && (this.triggerSmoothedGrab() || this.bumperSqueezed())) {
|
||||||
// We've found an entity that we'll do something with.
|
// We are squeezing enough to grab, and we've found an entity that we'll try to do something with.
|
||||||
var near = (nearPickedCandidateEntities.indexOf(this.grabbedEntity) >= 0);
|
var near = (nearPickedCandidateEntities.indexOf(this.grabbedEntity) >= 0);
|
||||||
var isPhysical = this.propsArePhysical(props);
|
var isPhysical = this.propsArePhysical(props);
|
||||||
|
|
||||||
|
@ -942,32 +945,18 @@ function MyController(hand) {
|
||||||
this.handleParticleBeam(distantPickRay.origin, this.getHandRotation(), NO_INTERSECT_COLOR);
|
this.handleParticleBeam(distantPickRay.origin, this.getHandRotation(), NO_INTERSECT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (USE_OVERLAY_LINES_FOR_SEARCHING === true) {
|
var SEARCH_SPHERE_SIZE = 0.011;
|
||||||
// this.overlayLineOn(searchVisualizationPickRay.origin,
|
var SEARCH_SPHERE_FOLLOW_RATE = 0.50;
|
||||||
// Vec3.sum(searchVisualizationPickRay.origin,
|
|
||||||
// Vec3.multiply(searchVisualizationPickRay.direction,
|
|
||||||
// LINE_LENGTH)),
|
|
||||||
// NO_INTERSECT_COLOR);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (this.intersectionDistance > 0) {
|
if (this.intersectionDistance > 0) {
|
||||||
var SPHERE_INTERSECTION_SIZE = 0.011;
|
// If we hit something with our pick ray, move the search sphere toward that distance
|
||||||
var SEARCH_SPHERE_FOLLOW_RATE = 0.50;
|
this.searchSphereDistance = this.searchSphereDistance * SEARCH_SPHERE_FOLLOW_RATE + this.intersectionDistance * (1.0 - SEARCH_SPHERE_FOLLOW_RATE);
|
||||||
var SEARCH_SPHERE_CHASE_DROP = 0.2;
|
}
|
||||||
this.searchSphereDistance = this.searchSphereDistance * SEARCH_SPHERE_FOLLOW_RATE +
|
|
||||||
this.intersectionDistance * (1.0 - SEARCH_SPHERE_FOLLOW_RATE);
|
var searchSphereLocation = Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
||||||
var searchSphereLocation = Vec3.sum(distantPickRay.origin,
|
this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance, (this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
||||||
Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) {
|
||||||
searchSphereLocation.y -= ((this.intersectionDistance - this.searchSphereDistance) /
|
this.overlayLineOn(handPosition, searchSphereLocation, (this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
||||||
this.intersectionDistance) * SEARCH_SPHERE_CHASE_DROP;
|
|
||||||
this.searchSphereOn(searchSphereLocation,
|
|
||||||
SPHERE_INTERSECTION_SIZE * this.intersectionDistance,
|
|
||||||
this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
|
||||||
if (USE_OVERLAY_LINES_FOR_SEARCHING === true) {
|
|
||||||
this.overlayLineOn(handPosition,
|
|
||||||
searchSphereLocation,
|
|
||||||
this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue