mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Make teleport.js normal rejection more lenient
This commit is contained in:
parent
16d535c495
commit
53623f7583
2 changed files with 28 additions and 3 deletions
|
@ -142,6 +142,7 @@ function ifAvatarMovedGoActive() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MAIN CONTROL
|
// MAIN CONTROL
|
||||||
|
var isEnabled = true;
|
||||||
var wasMuted, isAway;
|
var wasMuted, isAway;
|
||||||
var wasOverlaysVisible = Menu.isOptionChecked("Overlays");
|
var wasOverlaysVisible = Menu.isOptionChecked("Overlays");
|
||||||
var eventMappingName = "io.highfidelity.away"; // goActive on hand controller button events, too.
|
var eventMappingName = "io.highfidelity.away"; // goActive on hand controller button events, too.
|
||||||
|
@ -159,7 +160,7 @@ function safeGetHMDMounted() {
|
||||||
var wasHmdMounted = safeGetHMDMounted();
|
var wasHmdMounted = safeGetHMDMounted();
|
||||||
|
|
||||||
function goAway() {
|
function goAway() {
|
||||||
if (isAway) {
|
if (!isEnabled || isAway) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +275,24 @@ function maybeGoAway() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setEnabled(value) {
|
||||||
|
print("setting away enabled: ", value);
|
||||||
|
if (!value) {
|
||||||
|
goActive();
|
||||||
|
}
|
||||||
|
isEnabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable";
|
||||||
|
var handleMessage = function(channel, message, sender) {
|
||||||
|
print("Got away message");
|
||||||
|
if (channel == CHANNEL_AWAY_ENABLE) {
|
||||||
|
setEnabled(message == 'enable');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Messages.subscribe(CHANNEL_AWAY_ENABLE);
|
||||||
|
Messages.messageReceived.connect(handleMessage);
|
||||||
|
|
||||||
Script.update.connect(maybeMoveOverlay);
|
Script.update.connect(maybeMoveOverlay);
|
||||||
|
|
||||||
Script.update.connect(maybeGoAway);
|
Script.update.connect(maybeGoAway);
|
||||||
|
|
|
@ -627,11 +627,17 @@ function isMoving() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// When determininig whether you can teleport to a location, the normal of the
|
||||||
|
// point that is being intersected with is looked at. If this normal is more
|
||||||
|
// than MAX_ANGLE_FROM_UP_TO_TELEPORT degrees from <0, 1, 0> (straight up), then
|
||||||
|
// you can't teleport there.
|
||||||
|
var MAX_ANGLE_FROM_UP_TO_TELEPORT = 70;
|
||||||
function isTooCloseToTeleport(position, surfaceNormal) {
|
function isTooCloseToTeleport(position, surfaceNormal) {
|
||||||
var adj = Math.sqrt(surfaceNormal.x * surfaceNormal.x + surfaceNormal.z * surfaceNormal.z);
|
var adj = Math.sqrt(surfaceNormal.x * surfaceNormal.x + surfaceNormal.z * surfaceNormal.z);
|
||||||
var angleUp = Math.atan2(surfaceNormal.y, adj) * (180 / Math.PI);
|
var angleUp = Math.atan2(surfaceNormal.y, adj) * (180 / Math.PI);
|
||||||
//print(angleUp);
|
return angleUp < (90 - MAX_ANGLE_FROM_UP_TO_TELEPORT) ||
|
||||||
return angleUp < 80 || angleUp > 110 || Vec3.distance(MyAvatar.position, position) <= TELEPORT_CANCEL_RANGE;
|
angleUp > (90 + MAX_ANGLE_FROM_UP_TO_TELEPORT) ||
|
||||||
|
Vec3.distance(MyAvatar.position, position) <= TELEPORT_CANCEL_RANGE;
|
||||||
};
|
};
|
||||||
|
|
||||||
function registerMappings() {
|
function registerMappings() {
|
||||||
|
|
Loading…
Reference in a new issue