don't leave search state if we intersect something that someone else is already grabbing

This commit is contained in:
Seth Alves 2015-09-30 14:19:59 -07:00
parent b417abc3de
commit dd0a16df04
2 changed files with 12 additions and 13 deletions

View file

@ -49,8 +49,8 @@ function actionArgumentsToString(actionArguments) {
function updateOverlay(entityID, actionText) {
var properties = Entities.getEntityProperties(entityID, ["position"]);
var position = Vec3.sum(properties.position, {x:0, y:1, z:0});
var properties = Entities.getEntityProperties(entityID, ["position", "dimensions"]);
var position = Vec3.sum(properties.position, {x:0, y:properties.dimensions.y, z:0});
// print("position: " + vec3toStr(position) + " " + actionText);
if (entityID in overlays) {
var overlay = overlays[entityID];

View file

@ -273,7 +273,8 @@ function MyController(hand, triggerAction) {
var intersection = Entities.findRayIntersection(pickRay, true);
if (intersection.intersects &&
intersection.properties.collisionsWillMove === 1 &&
intersection.properties.locked === 0) {
intersection.properties.locked === 0 &&
!entityIsGrabbedByOther(intersection.entityID)) {
// the ray is intersecting something we can move.
var handControllerPosition = Controller.getSpatialControlPosition(this.palm);
var intersectionDistance = Vec3.distance(handControllerPosition, intersection.intersection);
@ -342,16 +343,14 @@ function MyController(hand, triggerAction) {
this.handPreviousRotation = handRotation;
this.actionID = NULL_ACTION_ID;
if (!entityIsGrabbedByOther(this.grabbedEntity)) {
this.actionID = Entities.addAction("spring", this.grabbedEntity, {
targetPosition: this.currentObjectPosition,
linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
targetRotation: this.currentObjectRotation,
angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
tag: getTag(),
lifetime: 5
});
}
this.actionID = Entities.addAction("spring", this.grabbedEntity, {
targetPosition: this.currentObjectPosition,
linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
targetRotation: this.currentObjectRotation,
angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
tag: getTag(),
lifetime: 5
});
if (this.actionID === NULL_ACTION_ID) {
this.actionID = null;
}