mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 12:23:24 +02:00
actually fix requested changes
This commit is contained in:
parent
d81420542c
commit
0fa2a71d0f
2 changed files with 25 additions and 7 deletions
|
@ -11,7 +11,8 @@
|
|||
TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS,
|
||||
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
|
||||
TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, print, Uuid, highlightTargetEntity, unhighlightTargetEntity,
|
||||
distanceBetweenEntityLocalPositionAndBoundingBox
|
||||
*/
|
||||
|
||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||
|
@ -172,12 +173,9 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
|
|||
if (now - this.lastUnequipCheckTime > MSECS_PER_SEC * TEAR_AWAY_CHECK_TIME) {
|
||||
this.lastUnequipCheckTime = now;
|
||||
if (props.parentID === MyAvatar.SELF_ID) {
|
||||
var tearAwayDistance = TEAR_AWAY_DISTANCE;
|
||||
var localX = props.localPosition.x;
|
||||
var localZ = props.localPosition.z;
|
||||
var localY = props.localPosition.y;
|
||||
if ((localX > tearAwayDistance) || (localY > tearAwayDistance) ||
|
||||
(localZ > tearAwayDistance)) {
|
||||
var tearAwayDistance = TEAR_AWAY_DISTANCE * MyAvatar.sensorToWorldScale;
|
||||
var distance = distanceBetweenEntityLocalPositionAndBoundingBox(props);
|
||||
if (distance > tearAwayDistance) {
|
||||
this.autoUnequipCounter++;
|
||||
} else {
|
||||
this.autoUnequipCounter = 0;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
highlightTargetEntity:true,
|
||||
clearHighlightedEntities:true,
|
||||
unhighlightTargetEntity:true
|
||||
distanceBetweenEntityLocalPositionAndBoundingBox: true
|
||||
*/
|
||||
|
||||
MSECS_PER_SEC = 1000.0;
|
||||
|
@ -415,6 +416,25 @@ findHandChildEntities = function(hand) {
|
|||
});
|
||||
};
|
||||
|
||||
distanceBetweenEntityLocalPositionAndBoundingBox = function(entityProps) {
|
||||
var localPoint = entityProps.localPosition;
|
||||
var entityXform = new Xform(entityProps.rotation, entityProps.position);
|
||||
var minOffset = Vec3.multiplyVbyV(entityProps.registrationPoint, entityProps.dimensions);
|
||||
var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions);
|
||||
var localMin = Vec3.subtract(entityXform.trans, minOffset);
|
||||
var localMax = Vec3.sum(entityXform.trans, maxOffset);
|
||||
|
||||
var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z};
|
||||
v.x = Math.max(v.x, localMin.x);
|
||||
v.x = Math.min(v.x, localMax.x);
|
||||
v.y = Math.max(v.y, localMin.y);
|
||||
v.y = Math.min(v.y, localMax.y);
|
||||
v.z = Math.max(v.z, localMin.z);
|
||||
v.z = Math.min(v.z, localMax.z);
|
||||
|
||||
return Vec3.distance(v, localPoint);
|
||||
};
|
||||
|
||||
distanceBetweenPointAndEntityBoundingBox = function(point, entityProps) {
|
||||
var entityXform = new Xform(entityProps.rotation, entityProps.position);
|
||||
var localPoint = entityXform.inv().xformPoint(point);
|
||||
|
|
Loading…
Reference in a new issue