mirror of
https://github.com/overte-org/overte.git
synced 2025-04-18 23:17:10 +02:00
Add hystersis between near parent grabbing and tearing away
This commit is contained in:
parent
1362e7f361
commit
f1dad3c465
2 changed files with 9 additions and 3 deletions
|
@ -12,7 +12,8 @@
|
|||
findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH,
|
||||
HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, findHandChildEntities, TEAR_AWAY_DISTANCE, MSECS_PER_SEC, TEAR_AWAY_CHECK_TIME,
|
||||
TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, print, Uuid, highlightTargetEntity, unhighlightTargetEntity,
|
||||
distanceBetweenEntityLocalPositionAndBoundingBox, getGrabbableData, getGrabPointSphereOffset, DISPATCHER_PROPERTIES
|
||||
distanceBetweenEntityLocalPositionAndBoundingBox, getGrabbableData, getGrabPointSphereOffset, DISPATCHER_PROPERTIES,
|
||||
NEAR_GRAB_DISTANCE
|
||||
*/
|
||||
|
||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||
|
@ -235,14 +236,14 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
// nearbyEntityProperties is already sorted by length from controller
|
||||
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
|
||||
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||
var tearAwayDistance = TEAR_AWAY_DISTANCE * sensorScaleFactor;
|
||||
var nearGrabDistance = NEAR_GRAB_DISTANCE * sensorScaleFactor;
|
||||
var nearGrabRadius = NEAR_GRAB_RADIUS * sensorScaleFactor;
|
||||
for (var i = 0; i < nearbyEntityProperties.length; i++) {
|
||||
var props = nearbyEntityProperties[i];
|
||||
var grabPosition = controllerData.controllerLocations[this.hand].position; // Is offset from hand position.
|
||||
var dist = distanceBetweenPointAndEntityBoundingBox(grabPosition, props);
|
||||
var distance = Vec3.distance(grabPosition, props.position);
|
||||
if ((dist > tearAwayDistance) ||
|
||||
if ((dist > nearGrabDistance) ||
|
||||
(distance > nearGrabRadius)) { // Only smallish entities can be near grabbed.
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
TEAR_AWAY_DISTANCE:true,
|
||||
TEAR_AWAY_COUNT:true,
|
||||
TEAR_AWAY_CHECK_TIME:true,
|
||||
NEAR_GRAB_DISTANCE: true,
|
||||
distanceBetweenPointAndEntityBoundingBox:true,
|
||||
entityIsEquipped:true,
|
||||
entityIsFarGrabbedByOther:true,
|
||||
|
@ -99,6 +100,10 @@ NEAR_GRAB_RADIUS = 1.0;
|
|||
TEAR_AWAY_DISTANCE = 0.15; // ungrab an entity if its bounding-box moves this far from the hand
|
||||
TEAR_AWAY_COUNT = 2; // multiply by TEAR_AWAY_CHECK_TIME to know how long the item must be away
|
||||
TEAR_AWAY_CHECK_TIME = 0.15; // seconds, duration between checks
|
||||
|
||||
NEAR_GRAB_DISTANCE = 0.14; // Grab an entity if its bounding box is within this distance.
|
||||
// Smaller than TEAR_AWAY_DISTANCE for hysteresis.
|
||||
|
||||
DISPATCHER_HOVERING_LIST = "dispactherHoveringList";
|
||||
DISPATCHER_HOVERING_STYLE = {
|
||||
isOutlineSmooth: true,
|
||||
|
|
Loading…
Reference in a new issue