mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Update teleport to sit in invisible seats
This commit is contained in:
parent
8c232b5abb
commit
aa94106229
1 changed files with 26 additions and 11 deletions
|
@ -94,6 +94,7 @@ var TELEPORTER_STATES = {
|
||||||
|
|
||||||
var TARGET = {
|
var TARGET = {
|
||||||
NONE: 'none', // Not currently targetting anything
|
NONE: 'none', // Not currently targetting anything
|
||||||
|
INVISIBLE: 'invisible', // The current target is an invvsible surface
|
||||||
INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.)
|
INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.)
|
||||||
SURFACE: 'surface', // The current target is a valid surface
|
SURFACE: 'surface', // The current target is a valid surface
|
||||||
SEAT: 'seat', // The current target is a seat
|
SEAT: 'seat', // The current target is a seat
|
||||||
|
@ -229,10 +230,22 @@ function Teleporter() {
|
||||||
direction: Quat.getUp(handRotation),
|
direction: Quat.getUp(handRotation),
|
||||||
};
|
};
|
||||||
|
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true, [], [this.targetEntity], true, true);
|
// We do up to 2 ray picks to find a teleport location.
|
||||||
|
// There are 2 types of teleport locations we are interested in:
|
||||||
|
// 1. A visible floor. This can be any entity surface that points within some degree of "up"
|
||||||
|
// 2. A seat. The seat can be visible or invisible.
|
||||||
|
//
|
||||||
|
// * In the first pass we pick against visible and invisible entities so that we can find invisible seats.
|
||||||
|
// We might hit an invisible entity that is not a seat, so we need to do a second pass.
|
||||||
|
// * In the second pass we pick against visible entities only.
|
||||||
|
//
|
||||||
|
var intersection = Entities.findRayIntersection(pickRay, true, [], [this.targetEntity], false, true);
|
||||||
|
|
||||||
var teleportLocationType = getTeleportTargetType(intersection);
|
var teleportLocationType = getTeleportTargetType(intersection);
|
||||||
//print("Teleport location type: ", teleportLocationType);
|
if (teleportLocationType === TARGET.INVISIBLE) {
|
||||||
|
intersection = Entities.findRayIntersection(pickRay, true, [], [this.targetEntity], true, true);
|
||||||
|
teleportLocationType = getTeleportTargetType(intersection);
|
||||||
|
}
|
||||||
|
|
||||||
if (teleportLocationType === TARGET.NONE) {
|
if (teleportLocationType === TARGET.NONE) {
|
||||||
this.hideTargetOverlay();
|
this.hideTargetOverlay();
|
||||||
|
@ -241,7 +254,7 @@ function Teleporter() {
|
||||||
|
|
||||||
var farPosition = Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, 50));
|
var farPosition = Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, 50));
|
||||||
this.updateLineOverlay(_this.activeHand, pickRay.origin, farPosition, COLORS_TELEPORT_CANNOT_TELEPORT);
|
this.updateLineOverlay(_this.activeHand, pickRay.origin, farPosition, COLORS_TELEPORT_CANNOT_TELEPORT);
|
||||||
} else if (teleportLocationType === TARGET.INVALID) {
|
} else if (teleportLocationType === TARGET.INVALID || teleportLocationType === TARGET.INVISIBLE) {
|
||||||
this.hideTargetOverlay();
|
this.hideTargetOverlay();
|
||||||
this.hideSeatOverlay();
|
this.hideSeatOverlay();
|
||||||
|
|
||||||
|
@ -424,18 +437,20 @@ function getTeleportTargetType(intersection) {
|
||||||
return TARGET.NONE;
|
return TARGET.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
var userData = Entities.getEntityProperties(intersection.entityID, 'userData').userData;
|
var props = Entities.getEntityProperties(intersection.entityID, ['userData', 'visible']);
|
||||||
var data = parseJSON(userData);
|
var data = parseJSON(props.userData);
|
||||||
if (data !== undefined && data.seat !== undefined) {
|
if (data !== undefined && data.seat !== undefined) {
|
||||||
return TARGET.SEAT;
|
return TARGET.SEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!props.visible) {
|
||||||
|
return TARGET.INVISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
var surfaceNormal = intersection.surfaceNormal;
|
var surfaceNormal = intersection.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("distacne is: ", Vec3.distance(MyAvatar.position, intersection.intersection));
|
|
||||||
|
|
||||||
if (angleUp < (90 - MAX_ANGLE_FROM_UP_TO_TELEPORT) ||
|
if (angleUp < (90 - MAX_ANGLE_FROM_UP_TO_TELEPORT) ||
|
||||||
angleUp > (90 + MAX_ANGLE_FROM_UP_TO_TELEPORT) ||
|
angleUp > (90 + MAX_ANGLE_FROM_UP_TO_TELEPORT) ||
|
||||||
Vec3.distance(MyAvatar.position, intersection.intersection) <= TELEPORT_CANCEL_RANGE) {
|
Vec3.distance(MyAvatar.position, intersection.intersection) <= TELEPORT_CANCEL_RANGE) {
|
||||||
|
|
Loading…
Reference in a new issue