Merge pull request #5817 from sethalves/hand-controller-adjustment

if the intersection distance is small, use grab-mode rather than distant-grab-mode
This commit is contained in:
Philip Rosedale 2015-09-15 18:41:42 -07:00
commit 2846381396

View file

@ -97,8 +97,8 @@ function controller(side, triggerAction, pullAction, hand) {
controller.prototype.updateLine = function() {
if (this.pointer != null) {
if (Entities.getEntityProperties(this.pointer).id != this.poitner) {
this.pointer == null;
if (Entities.getEntityProperties(this.pointer).id != this.pointer) {
this.pointer = null;
}
}
@ -118,7 +118,6 @@ controller.prototype.updateLine = function() {
});
}
var handPosition = this.getHandPosition();
var direction = Quat.getUp(this.getHandRotation());
@ -172,14 +171,26 @@ controller.prototype.checkForIntersections = function(origin, direction) {
if (intersection.intersects && intersection.properties.collisionsWillMove === 1) {
var handPosition = Controller.getSpatialControlPosition(this.palm);
this.distanceToEntity = Vec3.distance(handPosition, intersection.properties.position);
Entities.editEntity(this.pointer, {
linePoints: [
ZERO_VEC,
Vec3.multiply(direction, this.distanceToEntity)
]
});
this.grabbedEntity = intersection.entityID;
return true;
var intersectionDistance = Vec3.distance(handPosition, intersection.intersection);
if (intersectionDistance < 0.6) {
//We are grabbing an entity, so let it know we've grabbed it
this.grabbedEntity = intersection.entityID;
this.activateEntity(this.grabbedEntity);
this.hidePointer();
this.shouldDisplayLine = false;
this.grabEntity();
return true;
} else {
Entities.editEntity(this.pointer, {
linePoints: [
ZERO_VEC,
Vec3.multiply(direction, this.distanceToEntity)
]
});
this.grabbedEntity = intersection.entityID;
return true;
}
}
return false;
}