Merge branch 'master' of github.com:highfidelity/hifi into fsm-arrows-dont-walk

This commit is contained in:
Seth Alves 2016-08-05 10:44:46 -07:00
commit 84ce29eb90
18 changed files with 228 additions and 176 deletions

View file

@ -113,7 +113,7 @@ int AudioMixerClientData::parseData(ReceivedMessage& message) {
avatarAudioStream->setupCodec(_codec, _selectedCodecName, AudioConstants::MONO); avatarAudioStream->setupCodec(_codec, _selectedCodecName, AudioConstants::MONO);
qDebug() << "creating new AvatarAudioStream... codec:" << _selectedCodecName; qDebug() << "creating new AvatarAudioStream... codec:" << _selectedCodecName;
connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::sendSelectAudioFormat); connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::handleMismatchAudioFormat);
auto emplaced = _audioStreams.emplace( auto emplaced = _audioStreams.emplace(
QUuid(), QUuid(),
@ -345,6 +345,11 @@ QJsonObject AudioMixerClientData::getAudioStreamStats() {
return result; return result;
} }
void AudioMixerClientData::handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec) {
qDebug() << __FUNCTION__ << "sendingNode:" << *node << "currentCodec:" << currentCodec << "recievedCodec:" << recievedCodec;
sendSelectAudioFormat(node, currentCodec);
}
void AudioMixerClientData::sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName) { void AudioMixerClientData::sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName) {
auto replyPacket = NLPacket::create(PacketType::SelectedAudioFormat); auto replyPacket = NLPacket::create(PacketType::SelectedAudioFormat);
replyPacket->writeString(selectedCodecName); replyPacket->writeString(selectedCodecName);

View file

@ -84,6 +84,7 @@ signals:
void injectorStreamFinished(const QUuid& streamIdentifier); void injectorStreamFinished(const QUuid& streamIdentifier);
public slots: public slots:
void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec);
void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName); void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName);
private: private:

View file

@ -182,7 +182,7 @@ NodePermissions DomainGatekeeper::setPermissionsForUser(bool isLocalUser, QStrin
GroupRank rank = _server->_settingsManager.getGroupRank(groupID, rankID); GroupRank rank = _server->_settingsManager.getGroupRank(groupID, rankID);
#ifdef WANT_DEBUG #ifdef WANT_DEBUG
qDebug() << "| user-permissions: user is in group:" << groupID << " rank:" qDebug() << "| user-permissions: user " << verifiedUsername << "is in group:" << groupID << " rank:"
<< rank.name << "so:" << userPerms; << rank.name << "so:" << userPerms;
#endif #endif
} }

View file

@ -356,7 +356,7 @@ void DomainServerSettingsManager::initializeGroupPermissions(NodePermissionsMap&
if (nameKey.first.toLower() != groupNameLower) { if (nameKey.first.toLower() != groupNameLower) {
continue; continue;
} }
QUuid groupID = _groupIDs[groupNameLower]; QUuid groupID = _groupIDs[groupNameLower.toLower()];
QUuid rankID = nameKey.second; QUuid rankID = nameKey.second;
GroupRank rank = _groupRanks[groupID][rankID]; GroupRank rank = _groupRanks[groupID][rankID];
if (rank.order == 0) { if (rank.order == 0) {
@ -1477,14 +1477,14 @@ void DomainServerSettingsManager::apiGetGroupRanksErrorCallback(QNetworkReply& r
void DomainServerSettingsManager::recordGroupMembership(const QString& name, const QUuid groupID, QUuid rankID) { void DomainServerSettingsManager::recordGroupMembership(const QString& name, const QUuid groupID, QUuid rankID) {
if (rankID != QUuid()) { if (rankID != QUuid()) {
_groupMembership[name][groupID] = rankID; _groupMembership[name.toLower()][groupID] = rankID;
} else { } else {
_groupMembership[name].remove(groupID); _groupMembership[name.toLower()].remove(groupID);
} }
} }
QUuid DomainServerSettingsManager::isGroupMember(const QString& name, const QUuid& groupID) { QUuid DomainServerSettingsManager::isGroupMember(const QString& name, const QUuid& groupID) {
const QHash<QUuid, QUuid>& groupsForName = _groupMembership[name]; const QHash<QUuid, QUuid>& groupsForName = _groupMembership[name.toLower()];
if (groupsForName.contains(groupID)) { if (groupsForName.contains(groupID)) {
return groupsForName[groupID]; return groupsForName[groupID];
} }
@ -1528,7 +1528,7 @@ void DomainServerSettingsManager::debugDumpGroupsState() {
qDebug() << "_groupIDs:"; qDebug() << "_groupIDs:";
foreach (QString groupName, _groupIDs.keys()) { foreach (QString groupName, _groupIDs.keys()) {
qDebug() << "| " << groupName << "==>" << _groupIDs[groupName]; qDebug() << "| " << groupName << "==>" << _groupIDs[groupName.toLower()];
} }
qDebug() << "_groupNames:"; qDebug() << "_groupNames:";
@ -1548,7 +1548,7 @@ void DomainServerSettingsManager::debugDumpGroupsState() {
qDebug() << "_groupMembership"; qDebug() << "_groupMembership";
foreach (QString userName, _groupMembership.keys()) { foreach (QString userName, _groupMembership.keys()) {
QHash<QUuid, QUuid>& groupsForUser = _groupMembership[userName]; QHash<QUuid, QUuid>& groupsForUser = _groupMembership[userName.toLower()];
QString line = ""; QString line = "";
foreach (QUuid groupID, groupsForUser.keys()) { foreach (QUuid groupID, groupsForUser.keys()) {
line += " g=" + groupID.toString() + ",r=" + groupsForUser[groupID].toString(); line += " g=" + groupID.toString() + ",r=" + groupsForUser[groupID].toString();

View file

@ -84,7 +84,7 @@ public:
QList<QUuid> getBlacklistGroupIDs(); QList<QUuid> getBlacklistGroupIDs();
// these are used to locally cache the result of calling "api/v1/groups/.../is_member/..." on metaverse's api // these are used to locally cache the result of calling "api/v1/groups/.../is_member/..." on metaverse's api
void clearGroupMemberships(const QString& name) { _groupMembership[name].clear(); } void clearGroupMemberships(const QString& name) { _groupMembership[name.toLower()].clear(); }
void recordGroupMembership(const QString& name, const QUuid groupID, QUuid rankID); void recordGroupMembership(const QString& name, const QUuid groupID, QUuid rankID);
QUuid isGroupMember(const QString& name, const QUuid& groupID); // returns rank or -1 if not a member QUuid isGroupMember(const QString& name, const QUuid& groupID); // returns rank or -1 if not a member

View file

@ -1,15 +1,26 @@
{ {
"name": "Hydra to Standard", "name": "Hydra to Standard",
"channels": [ "channels": [
{ "from": "Hydra.LY", "filters": "invert", "to": "Standard.LY" }, { "from": "Hydra.LY", "to": "Standard.LY",
{ "from": "Hydra.LX", "to": "Standard.LX" }, "filters": [
{ "type": "deadZone", "min": 0.05 },
"invert"
]
},
{ "from": "Hydra.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LX" },
{ "from": "Hydra.LT", "to": "Standard.LTClick", { "from": "Hydra.LT", "to": "Standard.LTClick",
"peek": true, "peek": true,
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
}, },
{ "from": "Hydra.LT", "to": "Standard.LT" }, { "from": "Hydra.LT", "to": "Standard.LT" },
{ "from": "Hydra.RY", "filters": "invert", "to": "Standard.RY" },
{ "from": "Hydra.RX", "to": "Standard.RX" }, { "from": "Hydra.RY", "to": "Standard.RY",
"filters": [
{ "type": "deadZone", "min": 0.05 },
"invert"
]
},
{ "from": "Hydra.RX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RX" },
{ "from": "Hydra.RT", "to": "Standard.RTClick", { "from": "Hydra.RT", "to": "Standard.RTClick",
"peek": true, "peek": true,
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
@ -28,7 +39,6 @@
{ "from": [ "Hydra.R1", "Hydra.R3" ], "to": "Standard.RightPrimaryThumb" }, { "from": [ "Hydra.R1", "Hydra.R3" ], "to": "Standard.RightPrimaryThumb" },
{ "from": [ "Hydra.R2", "Hydra.R4" ], "to": "Standard.RightSecondaryThumb" }, { "from": [ "Hydra.R2", "Hydra.R4" ], "to": "Standard.RightSecondaryThumb" },
{ "from": [ "Hydra.L2", "Hydra.L4" ], "to": "Standard.LeftSecondaryThumb" }, { "from": [ "Hydra.L2", "Hydra.L4" ], "to": "Standard.LeftSecondaryThumb" },
{ "from": "Hydra.LeftHand", "to": "Standard.LeftHand" }, { "from": "Hydra.LeftHand", "to": "Standard.LeftHand" },
{ "from": "Hydra.RightHand", "to": "Standard.RightHand" } { "from": "Hydra.RightHand", "to": "Standard.RightHand" }
] ]

View file

@ -2,12 +2,15 @@
"name": "Oculus Touch to Standard", "name": "Oculus Touch to Standard",
"channels": [ "channels": [
{ "from": "OculusTouch.A", "to": "Standard.RightPrimaryThumb" }, { "from": "OculusTouch.A", "to": "Standard.RightPrimaryThumb" },
{ "from": "OculusTouch.B", "to": "Standard.RightSecondaryThumb" },
{ "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" }, { "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" },
{ "from": "OculusTouch.Y", "to": "Standard.LeftSecondaryThumb" },
{ "from": "OculusTouch.LY", "filters": "invert", "to": "Standard.LY" }, { "from": "OculusTouch.LY", "to": "Standard.LY",
{ "from": "OculusTouch.LX", "to": "Standard.LX" }, "filters": [
{ "type": "deadZone", "min": 0.05 },
"invert"
]
},
{ "from": "OculusTouch.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LX" },
{ "from": "OculusTouch.LT", "to": "Standard.LTClick", { "from": "OculusTouch.LT", "to": "Standard.LTClick",
"peek": true, "peek": true,
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
@ -17,8 +20,13 @@
{ "from": "OculusTouch.LeftGrip", "to": "Standard.LeftGrip" }, { "from": "OculusTouch.LeftGrip", "to": "Standard.LeftGrip" },
{ "from": "OculusTouch.LeftHand", "to": "Standard.LeftHand" }, { "from": "OculusTouch.LeftHand", "to": "Standard.LeftHand" },
{ "from": "OculusTouch.RY", "filters": "invert", "to": "Standard.RY" }, { "from": "OculusTouch.RY", "to": "Standard.RY",
{ "from": "OculusTouch.RX", "to": "Standard.RX" }, "filters": [
{ "type": "deadZone", "min": 0.05 },
"invert"
]
},
{ "from": "OculusTouch.RX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RX" },
{ "from": "OculusTouch.RT", "to": "Standard.RTClick", { "from": "OculusTouch.RT", "to": "Standard.RTClick",
"peek": true, "peek": true,
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]

View file

@ -119,6 +119,9 @@ AudioClient::AudioClient() :
this, &AudioClient::processReceivedSamples, Qt::DirectConnection); this, &AudioClient::processReceivedSamples, Qt::DirectConnection);
connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) { switchOutputToAudioDevice(outputDeviceInfo); }); connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) { switchOutputToAudioDevice(outputDeviceInfo); });
connect(&_receivedAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioClient::handleMismatchAudioFormat);
_inputDevices = getDeviceNames(QAudio::AudioInput); _inputDevices = getDeviceNames(QAudio::AudioInput);
_outputDevices = getDeviceNames(QAudio::AudioOutput); _outputDevices = getDeviceNames(QAudio::AudioOutput);
@ -147,6 +150,12 @@ AudioClient::~AudioClient() {
} }
} }
void AudioClient::handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec) {
qDebug() << __FUNCTION__ << "sendingNode:" << *node << "currentCodec:" << currentCodec << "recievedCodec:" << recievedCodec;
selectAudioFormat(recievedCodec);
}
void AudioClient::reset() { void AudioClient::reset() {
_receivedAudioStream.reset(); _receivedAudioStream.reset();
_stats.reset(); _stats.reset();
@ -532,7 +541,13 @@ void AudioClient::negotiateAudioFormat() {
} }
void AudioClient::handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message) { void AudioClient::handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message) {
_selectedCodecName = message->readString(); QString selectedCodecName = message->readString();
selectAudioFormat(selectedCodecName);
}
void AudioClient::selectAudioFormat(const QString& selectedCodecName) {
_selectedCodecName = selectedCodecName;
qDebug() << "Selected Codec:" << _selectedCodecName; qDebug() << "Selected Codec:" << _selectedCodecName;

View file

@ -104,6 +104,7 @@ public:
}; };
void negotiateAudioFormat(); void negotiateAudioFormat();
void selectAudioFormat(const QString& selectedCodecName);
const MixedProcessedAudioStream& getReceivedAudioStream() const { return _receivedAudioStream; } const MixedProcessedAudioStream& getReceivedAudioStream() const { return _receivedAudioStream; }
MixedProcessedAudioStream& getReceivedAudioStream() { return _receivedAudioStream; } MixedProcessedAudioStream& getReceivedAudioStream() { return _receivedAudioStream; }
@ -153,6 +154,7 @@ public slots:
void handleNoisyMutePacket(QSharedPointer<ReceivedMessage> message); void handleNoisyMutePacket(QSharedPointer<ReceivedMessage> message);
void handleMuteEnvironmentPacket(QSharedPointer<ReceivedMessage> message); void handleMuteEnvironmentPacket(QSharedPointer<ReceivedMessage> message);
void handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message); void handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message);
void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec);
void sendDownstreamAudioStatsPacket() { _stats.sendDownstreamAudioStatsPacket(); } void sendDownstreamAudioStatsPacket() { _stats.sendDownstreamAudioStatsPacket(); }
void handleAudioInput(); void handleAudioInput();

View file

@ -147,7 +147,7 @@ int InboundAudioStream::parseData(ReceivedMessage& message) {
writeDroppableSilentSamples(networkSamples); writeDroppableSilentSamples(networkSamples);
// inform others of the mismatch // inform others of the mismatch
auto sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(message.getSourceID()); auto sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(message.getSourceID());
emit mismatchedAudioCodec(sendingNode, _selectedCodecName); emit mismatchedAudioCodec(sendingNode, _selectedCodecName, codecInPacket);
} }
} }
break; break;

View file

@ -182,7 +182,7 @@ public:
void cleanupCodec(); void cleanupCodec();
signals: signals:
void mismatchedAudioCodec(SharedNodePointer sendingNode, const QString& desiredCodec); void mismatchedAudioCodec(SharedNodePointer sendingNode, const QString& currentCodec, const QString& recievedCodec);
public slots: public slots:
/// This function should be called every second for all the stats to function properly. If dynamic jitter buffers /// This function should be called every second for all the stats to function properly. If dynamic jitter buffers

View file

@ -374,8 +374,6 @@ void AnimDebugDraw::update() {
} }
} }
} }
data._vertexBuffer->resize(sizeof(Vertex) * numVerts);
data._vertexBuffer->setSubData<Vertex>(0, vertices);
// draw markers from shared DebugDraw singleton // draw markers from shared DebugDraw singleton
for (auto& iter : markerMap) { for (auto& iter : markerMap) {
@ -403,6 +401,9 @@ void AnimDebugDraw::update() {
} }
DebugDraw::getInstance().clearRays(); DebugDraw::getInstance().clearRays();
data._vertexBuffer->resize(sizeof(Vertex) * numVerts);
data._vertexBuffer->setSubData<Vertex>(0, vertices);
assert((!numVerts && !v) || (numVerts == (v - &vertices[0]))); assert((!numVerts && !v) || (numVerts == (v - &vertices[0])));
render::Item::Bound theBound; render::Item::Bound theBound;

View file

@ -53,7 +53,7 @@ namespace Setting {
const auto& key = handle->getKey(); const auto& key = handle->getKey();
withWriteLock([&] { withWriteLock([&] {
QVariant loadedValue; QVariant loadedValue;
if (_pendingChanges.contains(key)) { if (_pendingChanges.contains(key) && _pendingChanges[key] != UNSET_VALUE) {
loadedValue = _pendingChanges[key]; loadedValue = _pendingChanges[key];
} else { } else {
loadedValue = value(key); loadedValue = value(key);

View file

@ -46,7 +46,7 @@ namespace Setting {
private: private:
QHash<QString, Interface*> _handles; QHash<QString, Interface*> _handles;
QPointer<QTimer> _saveTimer = nullptr; QPointer<QTimer> _saveTimer = nullptr;
const QVariant UNSET_VALUE { QUuid::createUuid().variant() }; const QVariant UNSET_VALUE { QUuid::createUuid() };
QHash<QString, QVariant> _pendingChanges; QHash<QString, QVariant> _pendingChanges;
friend class Interface; friend class Interface;

View file

@ -182,6 +182,12 @@ void OculusControllerManager::TouchDevice::update(float deltaTime, const control
_poseStateMap.clear(); _poseStateMap.clear();
_buttonPressedMap.clear(); _buttonPressedMap.clear();
ovrSessionStatus status;
if (!OVR_SUCCESS(ovr_GetSessionStatus(_parent._session, &status)) || (ovrFalse == status.HmdMounted)) {
// if the HMD isn't on someone's head, don't take input from the controllers
return;
}
int numTrackedControllers = 0; int numTrackedControllers = 0;
static const auto REQUIRED_HAND_STATUS = ovrStatus_OrientationTracked & ovrStatus_PositionTracked; static const auto REQUIRED_HAND_STATUS = ovrStatus_OrientationTracked & ovrStatus_PositionTracked;
auto tracking = ovr_GetTrackingState(_parent._session, 0, false); auto tracking = ovr_GetTrackingState(_parent._session, 0, false);

View file

@ -70,15 +70,15 @@ var DISTANCE_HOLDING_UNITY_DISTANCE = 6; // The distance at which the distance
var MOVE_WITH_HEAD = true; // experimental head-control of distantly held objects var MOVE_WITH_HEAD = true; // experimental head-control of distantly held objects
var COLORS_GRAB_SEARCHING_HALF_SQUEEZE = { var COLORS_GRAB_SEARCHING_HALF_SQUEEZE = {
red: 255, red: 10,
green: 97, green: 10,
blue: 129 blue: 255
}; };
var COLORS_GRAB_SEARCHING_FULL_SQUEEZE = { var COLORS_GRAB_SEARCHING_FULL_SQUEEZE = {
red: 255, red: 250,
green: 97, green: 10,
blue: 129 blue: 10
}; };
var COLORS_GRAB_DISTANCE_HOLD = { var COLORS_GRAB_DISTANCE_HOLD = {
@ -1267,7 +1267,7 @@ function MyController(hand) {
if (this.triggerSmoothedGrab()) { if (this.triggerSmoothedGrab()) {
this.grabbedHotspot = potentialEquipHotspot; this.grabbedHotspot = potentialEquipHotspot;
this.grabbedEntity = potentialEquipHotspot.entityID; this.grabbedEntity = potentialEquipHotspot.entityID;
this.setState(STATE_HOLD, "eqipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'");
return; return;
} }
} }
@ -1378,7 +1378,7 @@ function MyController(hand) {
}; };
this.distanceHoldingEnter = function() { this.distanceHoldingEnter = function() {
Messages.sendLocalMessage('Hifi-Teleport-Disabler','both');
this.clearEquipHaptics(); this.clearEquipHaptics();
// controller pose is in avatar frame // controller pose is in avatar frame
@ -1534,7 +1534,9 @@ function MyController(hand) {
// visualizations // visualizations
this.overlayLineOn(handPosition, grabbedProperties.position, COLORS_GRAB_DISTANCE_HOLD); var rayPickInfo = this.calcRayPickInfo(this.hand);
this.overlayLineOn(rayPickInfo.searchRay.origin, grabbedProperties.position, COLORS_GRAB_DISTANCE_HOLD);
var distanceToObject = Vec3.length(Vec3.subtract(MyAvatar.position, this.currentObjectPosition)); var distanceToObject = Vec3.length(Vec3.subtract(MyAvatar.position, this.currentObjectPosition));
var success = Entities.updateAction(this.grabbedEntity, this.actionID, { var success = Entities.updateAction(this.grabbedEntity, this.actionID, {
@ -1634,7 +1636,14 @@ function MyController(hand) {
}; };
this.nearGrabbingEnter = function() { this.nearGrabbingEnter = function() {
if (this.hand === 0) {
Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'left');
}
if (this.hand === 1) {
Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'right');
}
this.lineOff(); this.lineOff();
this.overlayLineOff(); this.overlayLineOff();
@ -1961,6 +1970,7 @@ function MyController(hand) {
}; };
this.release = function() { this.release = function() {
Messages.sendLocalMessage('Hifi-Teleport-Disabler','none');
this.turnOffVisualizations(); this.turnOffVisualizations();
var noVelocity = false; var noVelocity = false;
@ -2354,9 +2364,20 @@ var handleHandMessages = function(channel, message, sender) {
try { try {
data = JSON.parse(message); data = JSON.parse(message);
var selectedController = (data.hand === 'left') ? leftController : rightController; var selectedController = (data.hand === 'left') ? leftController : rightController;
var hotspotIndex = data.hotspotIndex !== undefined ? parseInt(data.hotspotIndex) : 0;
selectedController.release(); selectedController.release();
var wearableEntity = data.entityID;
entityPropertiesCache.addEntity(wearableEntity);
selectedController.grabbedEntity = wearableEntity;
var hotspots = selectedController.collectEquipHotspots(selectedController.grabbedEntity);
if (hotspots.length > 0) {
if (hotspotIndex >= hotspots.length) {
hotspotIndex = 0;
}
selectedController.grabbedHotspot = hotspots[hotspotIndex];
}
selectedController.setState(STATE_HOLD, "Hifi-Hand-Grab msg received"); selectedController.setState(STATE_HOLD, "Hifi-Hand-Grab msg received");
selectedController.grabbedEntity = data.entityID; selectedController.nearGrabbingEnter();
} catch (e) { } catch (e) {
print("WARNING: error parsing Hifi-Hand-Grab message"); print("WARNING: error parsing Hifi-Hand-Grab message");

View file

@ -508,4 +508,3 @@ Script.scriptEnding.connect(function () {
Script.clearInterval(settingsChecker); Script.clearInterval(settingsChecker);
OffscreenFlags.navigationFocusDisabled = false; OffscreenFlags.navigationFocusDisabled = false;
}); });

View file

@ -1,21 +1,13 @@
// Created by james b. pollack @imgntn on 7/2/2016 // Created by james b. pollack @imgntn on 7/2/2016
// Copyright 2016 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// //
// Creates a beam and target and then teleports you there when you let go of either activation button. // Creates a beam and target and then teleports you there.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
var inTeleportMode = false; var inTeleportMode = false;
var currentFadeSphereOpacity = 1;
var fadeSphereInterval = null;
var fadeSphereUpdateInterval = null;
//milliseconds between fading one-tenth -- so this is a half second fade total
var USE_FADE_MODE = false;
var USE_FADE_OUT = true;
var FADE_OUT_INTERVAL = 25;
// instant // instant
// var NUMBER_OF_STEPS = 0; // var NUMBER_OF_STEPS = 0;
// var SMOOTH_ARRIVAL_SPACING = 0; // var SMOOTH_ARRIVAL_SPACING = 0;
@ -36,16 +28,13 @@ var NUMBER_OF_STEPS = 6;
// var SMOOTH_ARRIVAL_SPACING = 10; // var SMOOTH_ARRIVAL_SPACING = 10;
// var NUMBER_OF_STEPS = 20; // var NUMBER_OF_STEPS = 20;
var TARGET_MODEL_URL = Script.resolvePath("../assets/models/teleport.fbx"); var TARGET_MODEL_URL = Script.resolvePath("../assets/models/teleport.fbx");
var TARGET_MODEL_DIMENSIONS = { var TARGET_MODEL_DIMENSIONS = {
x: 1.15, x: 1.15,
y: 0.5, y: 0.5,
z: 1.15 z: 1.15
}; };
var COLORS_TELEPORT_CAN_TELEPORT = { var COLORS_TELEPORT_CAN_TELEPORT = {
red: 97, red: 97,
green: 247, green: 247,
@ -58,14 +47,22 @@ var COLORS_TELEPORT_CANNOT_TELEPORT = {
blue: 141 blue: 141
}; };
var MAX_AVATAR_SPEED = 0.25;
function ThumbPad(hand) { function ThumbPad(hand) {
this.hand = hand; this.hand = hand;
var _thisPad = this; var _thisPad = this;
this.buttonPress = function(value) { this.buttonPress = function(value) {
_thisPad.buttonValue = value; _thisPad.buttonValue = value;
}; if (value === 0) {
if (activationTimeout !== null) {
Script.clearTimeout(activationTimeout);
activationTimeout = null;
}
}
};
} }
function Trigger(hand) { function Trigger(hand) {
@ -91,7 +88,6 @@ function Teleporter() {
this.targetOverlay = null; this.targetOverlay = null;
this.updateConnected = null; this.updateConnected = null;
this.smoothArrivalInterval = null; this.smoothArrivalInterval = null;
this.fadeSphere = null;
this.teleportHand = null; this.teleportHand = null;
this.initialize = function() { this.initialize = function() {
@ -128,83 +124,25 @@ function Teleporter() {
if (inTeleportMode === true) { if (inTeleportMode === true) {
return; return;
} }
if (isDisabled === 'both') {
return;
}
inTeleportMode = true; inTeleportMode = true;
if (this.smoothArrivalInterval !== null) { if (this.smoothArrivalInterval !== null) {
Script.clearInterval(this.smoothArrivalInterval); Script.clearInterval(this.smoothArrivalInterval);
} }
if (fadeSphereInterval !== null) { if (activationTimeout !== null) {
Script.clearInterval(fadeSphereInterval); Script.clearInterval(activationTimeout);
} }
this.teleportHand = hand; this.teleportHand = hand;
this.initialize(); this.initialize();
Script.update.connect(this.update); Script.update.connect(this.update);
this.updateConnected = true; this.updateConnected = true;
}; };
this.createFadeSphere = function(avatarHead) {
var sphereProps = {
position: avatarHead,
size: -1,
color: {
red: 0,
green: 0,
blue: 0,
},
alpha: 1,
solid: true,
visible: true,
ignoreRayIntersection: true,
drawInFront: false
};
currentFadeSphereOpacity = 10;
_this.fadeSphere = Overlays.addOverlay("sphere", sphereProps);
Script.clearInterval(fadeSphereInterval)
Script.update.connect(_this.updateFadeSphere);
if (USE_FADE_OUT === true) {
this.fadeSphereOut();
}
};
this.fadeSphereOut = function() {
fadeSphereInterval = Script.setInterval(function() {
if (currentFadeSphereOpacity <= 0) {
Script.clearInterval(fadeSphereInterval);
_this.deleteFadeSphere();
fadeSphereInterval = null;
return;
}
if (currentFadeSphereOpacity > 0) {
currentFadeSphereOpacity = currentFadeSphereOpacity - 1;
}
Overlays.editOverlay(_this.fadeSphere, {
alpha: currentFadeSphereOpacity / 10
})
}, FADE_OUT_INTERVAL);
};
this.updateFadeSphere = function() {
var headPosition = MyAvatar.getHeadPosition();
Overlays.editOverlay(_this.fadeSphere, {
position: headPosition
})
};
this.deleteFadeSphere = function() {
if (_this.fadeSphere !== null) {
Script.update.disconnect(_this.updateFadeSphere);
Overlays.deleteOverlay(_this.fadeSphere);
_this.fadeSphere = null;
}
};
this.deleteTargetOverlay = function() { this.deleteTargetOverlay = function() {
if (this.targetOverlay === null) { if (this.targetOverlay === null) {
@ -221,6 +159,10 @@ function Teleporter() {
} }
this.exitTeleportMode = function(value) { this.exitTeleportMode = function(value) {
if (activationTimeout !== null) {
Script.clearTimeout(activationTimeout);
activationTimeout = null;
}
if (this.updateConnected === true) { if (this.updateConnected === true) {
Script.update.disconnect(this.update); Script.update.disconnect(this.update);
} }
@ -239,19 +181,26 @@ function Teleporter() {
this.update = function() { this.update = function() {
if (isDisabled === 'both') {
return;
}
if (teleporter.teleportHand === 'left') { if (teleporter.teleportHand === 'left') {
if (isDisabled === 'left') {
return;
}
teleporter.leftRay(); teleporter.leftRay();
if ((leftPad.buttonValue === 0) && inTeleportMode === true) {
if ((leftPad.buttonValue === 0 || leftTrigger.buttonValue === 0) && inTeleportMode === true) {
_this.teleport(); _this.teleport();
return; return;
} }
} else { } else {
if (isDisabled === 'right') {
return;
}
teleporter.rightRay(); teleporter.rightRay();
if ((rightPad.buttonValue === 0) && inTeleportMode === true) {
if ((rightPad.buttonValue === 0 || rightTrigger.buttonValue === 0) && inTeleportMode === true) {
_this.teleport(); _this.teleport();
return; return;
} }
@ -261,14 +210,12 @@ function Teleporter() {
this.rightRay = function() { this.rightRay = function() {
var rightPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getPoseValue(Controller.Standard.RightHand).translation), MyAvatar.position); var rightPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getPoseValue(Controller.Standard.RightHand).translation), MyAvatar.position);
var rightControllerRotation = Controller.getPoseValue(Controller.Standard.RightHand).rotation; var rightControllerRotation = Controller.getPoseValue(Controller.Standard.RightHand).rotation;
var rightRotation = Quat.multiply(MyAvatar.orientation, rightControllerRotation) var rightRotation = Quat.multiply(MyAvatar.orientation, rightControllerRotation)
var rightFinal = Quat.multiply(rightRotation, Quat.angleAxis(90, { var rightFinal = Quat.multiply(rightRotation, Quat.angleAxis(90, {
x: 1, x: 1,
y: 0, y: 0,
@ -308,14 +255,12 @@ function Teleporter() {
var leftRotation = Quat.multiply(MyAvatar.orientation, Controller.getPoseValue(Controller.Standard.LeftHand).rotation) var leftRotation = Quat.multiply(MyAvatar.orientation, Controller.getPoseValue(Controller.Standard.LeftHand).rotation)
var leftFinal = Quat.multiply(leftRotation, Quat.angleAxis(90, { var leftFinal = Quat.multiply(leftRotation, Quat.angleAxis(90, {
x: 1, x: 1,
y: 0, y: 0,
z: 0 z: 0
})); }));
var leftPickRay = { var leftPickRay = {
origin: leftPosition, origin: leftPosition,
direction: Quat.getUp(leftRotation), direction: Quat.getUp(leftRotation),
@ -337,7 +282,6 @@ function Teleporter() {
this.createTargetOverlay(); this.createTargetOverlay();
} }
} else { } else {
this.deleteTargetOverlay(); this.deleteTargetOverlay();
@ -351,7 +295,7 @@ function Teleporter() {
start: closePoint, start: closePoint,
end: farPoint, end: farPoint,
color: color, color: color,
ignoreRayIntersection: true, // always ignore this ignoreRayIntersection: true,
visible: true, visible: true,
alpha: 1, alpha: 1,
solid: true, solid: true,
@ -363,14 +307,9 @@ function Teleporter() {
} else { } else {
var success = Overlays.editOverlay(this.rightOverlayLine, { var success = Overlays.editOverlay(this.rightOverlayLine, {
lineWidth: 50,
start: closePoint, start: closePoint,
end: farPoint, end: farPoint,
color: color, color: color
visible: true,
ignoreRayIntersection: true, // always ignore this
alpha: 1,
glow: 1.0
}); });
} }
}; };
@ -378,7 +317,7 @@ function Teleporter() {
this.leftLineOn = function(closePoint, farPoint, color) { this.leftLineOn = function(closePoint, farPoint, color) {
if (this.leftOverlayLine === null) { if (this.leftOverlayLine === null) {
var lineProperties = { var lineProperties = {
ignoreRayIntersection: true, // always ignore this ignoreRayIntersection: true,
start: closePoint, start: closePoint,
end: farPoint, end: farPoint,
color: color, color: color,
@ -395,11 +334,7 @@ function Teleporter() {
var success = Overlays.editOverlay(this.leftOverlayLine, { var success = Overlays.editOverlay(this.leftOverlayLine, {
start: closePoint, start: closePoint,
end: farPoint, end: farPoint,
color: color, color: color
visible: true,
alpha: 1,
solid: true,
glow: 1.0
}); });
} }
}; };
@ -452,16 +387,11 @@ function Teleporter() {
this.exitTeleportMode(); this.exitTeleportMode();
} }
if (this.intersection !== null) { if (this.intersection !== null) {
if (USE_FADE_MODE === true) {
this.createFadeSphere();
}
var offset = getAvatarFootOffset(); var offset = getAvatarFootOffset();
this.intersection.intersection.y += offset; this.intersection.intersection.y += offset;
this.exitTeleportMode(); this.exitTeleportMode();
this.smoothArrival(); this.smoothArrival();
} }
}; };
@ -471,12 +401,8 @@ function Teleporter() {
return midpoint return midpoint
}; };
this.getArrivalPoints = function(startPoint, endPoint) { this.getArrivalPoints = function(startPoint, endPoint) {
var arrivalPoints = []; var arrivalPoints = [];
var i; var i;
var lastPoint; var lastPoint;
@ -489,9 +415,9 @@ function Teleporter() {
arrivalPoints.push(newPoint); arrivalPoints.push(newPoint);
} }
arrivalPoints.push(endPoint) arrivalPoints.push(endPoint);
return arrivalPoints return arrivalPoints;
}; };
this.smoothArrival = function() { this.smoothArrival = function() {
@ -502,7 +428,6 @@ function Teleporter() {
Script.clearInterval(_this.smoothArrivalInterval); Script.clearInterval(_this.smoothArrivalInterval);
return; return;
} }
var landingPoint = _this.arrivalPoints.shift(); var landingPoint = _this.arrivalPoints.shift();
MyAvatar.position = landingPoint; MyAvatar.position = landingPoint;
@ -510,8 +435,7 @@ function Teleporter() {
_this.deleteTargetOverlay(); _this.deleteTargetOverlay();
} }
}, SMOOTH_ARRIVAL_SPACING);
}, SMOOTH_ARRIVAL_SPACING)
} }
} }
@ -536,14 +460,14 @@ function getAvatarFootOffset() {
toe = d.translation.y; toe = d.translation.y;
} }
if (jointName === "RightToe_End") { if (jointName === "RightToe_End") {
toeTop = d.translation.y toeTop = d.translation.y;
} }
}) })
var myPosition = MyAvatar.position; var myPosition = MyAvatar.position;
var offset = upperLeg + lowerLeg + foot + toe + toeTop; var offset = upperLeg + lowerLeg + foot + toe + toeTop;
offset = offset / 100; offset = offset / 100;
return offset return offset;
}; };
function getJointData() { function getJointData() {
@ -570,8 +494,18 @@ var rightTrigger = new Trigger('right');
var mappingName, teleportMapping; var mappingName, teleportMapping;
var TELEPORT_DELAY = 100; var activationTimeout = null;
var TELEPORT_DELAY = 0;
function isMoving() {
var LY = Controller.getValue(Controller.Standard.LY);
var LX = Controller.getValue(Controller.Standard.LX);
if (LY !== 0 || LX !== 0) {
return true;
} else {
return false;
}
}
function registerMappings() { function registerMappings() {
mappingName = 'Hifi-Teleporter-Dev-' + Math.random(); mappingName = 'Hifi-Teleporter-Dev-' + Math.random();
@ -582,23 +516,49 @@ function registerMappings() {
teleportMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(rightPad.buttonPress); teleportMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(rightPad.buttonPress);
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress); teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress);
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).when(leftTrigger.down).to(function(value) { teleportMapping.from(Controller.Standard.LeftPrimaryThumb)
teleporter.enterTeleportMode('left') .to(function(value) {
return; if (isDisabled === 'left' || isDisabled === 'both') {
}); return;
teleportMapping.from(Controller.Standard.RightPrimaryThumb).when(rightTrigger.down).to(function(value) { }
teleporter.enterTeleportMode('right') if (activationTimeout !== null) {
return; return
}); }
teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) { if (leftTrigger.down()) {
teleporter.enterTeleportMode('right') return;
return; }
}); if (isMoving() === true) {
teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) { return;
teleporter.enterTeleportMode('left') }
return; activationTimeout = Script.setTimeout(function() {
}); Script.clearTimeout(activationTimeout);
activationTimeout = null;
teleporter.enterTeleportMode('left')
}, TELEPORT_DELAY)
return;
});
teleportMapping.from(Controller.Standard.RightPrimaryThumb)
.to(function(value) {
if (isDisabled === 'right' || isDisabled === 'both') {
return;
}
if (activationTimeout !== null) {
return
}
if (rightTrigger.down()) {
return;
}
if (isMoving() === true) {
return;
}
activationTimeout = Script.setTimeout(function() {
teleporter.enterTeleportMode('right')
Script.clearTimeout(activationTimeout);
activationTimeout = null;
}, TELEPORT_DELAY)
return;
});
} }
registerMappings(); registerMappings();
@ -614,8 +574,32 @@ function cleanup() {
teleporter.disableMappings(); teleporter.disableMappings();
teleporter.deleteTargetOverlay(); teleporter.deleteTargetOverlay();
teleporter.turnOffOverlayBeams(); teleporter.turnOffOverlayBeams();
teleporter.deleteFadeSphere();
if (teleporter.updateConnected !== null) { if (teleporter.updateConnected !== null) {
Script.update.disconnect(teleporter.update); Script.update.disconnect(teleporter.update);
} }
} }
var isDisabled = false;
var handleHandMessages = function(channel, message, sender) {
var data;
if (sender === MyAvatar.sessionUUID) {
if (channel === 'Hifi-Teleport-Disabler') {
if (message === 'both') {
isDisabled = 'both';
}
if (message === 'left') {
isDisabled = 'left';
}
if (message === 'right') {
isDisabled = 'right'
}
if (message === 'none') {
isDisabled = false;
}
}
}
}
Messages.subscribe('Hifi-Teleport-Disabler');
Messages.messageReceived.connect(handleHandMessages);