This commit is contained in:
Philip Rosedale 2014-03-31 07:25:46 -07:00
commit 3babb5e0bf
8 changed files with 63 additions and 15 deletions

View file

@ -162,11 +162,11 @@ function flyWithHydra(deltaTime) {
if (thrustMultiplier < MAX_THRUST_MULTIPLIER) { if (thrustMultiplier < MAX_THRUST_MULTIPLIER) {
thrustMultiplier *= 1 + (deltaTime * THRUST_INCREASE_RATE); thrustMultiplier *= 1 + (deltaTime * THRUST_INCREASE_RATE);
} }
var currentOrientation = MyAvatar.orientation; var headOrientation = MyAvatar.headOrientation;
var front = Quat.getFront(currentOrientation); var front = Quat.getFront(headOrientation);
var right = Quat.getRight(currentOrientation); var right = Quat.getRight(headOrientation);
var up = Quat.getUp(currentOrientation); var up = Quat.getUp(headOrientation);
var thrustFront = Vec3.multiply(front, MyAvatar.scale * THRUST_MAG_HAND_JETS * var thrustFront = Vec3.multiply(front, MyAvatar.scale * THRUST_MAG_HAND_JETS *
thrustJoystickPosition.y * thrustMultiplier * deltaTime); thrustJoystickPosition.y * thrustMultiplier * deltaTime);

View file

@ -4,22 +4,22 @@
<context> <context>
<name>Application</name> <name>Application</name>
<message> <message>
<location filename="src/Application.cpp" line="1380"/> <location filename="src/Application.cpp" line="1381"/>
<source>Export Voxels</source> <source>Export Voxels</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="1381"/> <location filename="src/Application.cpp" line="1382"/>
<source>Sparse Voxel Octree Files (*.svo)</source> <source>Sparse Voxel Octree Files (*.svo)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="3617"/> <location filename="src/Application.cpp" line="3623"/>
<source>Open Script</source> <source>Open Script</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="3618"/> <location filename="src/Application.cpp" line="3624"/>
<source>JavaScript Files (*.js)</source> <source>JavaScript Files (*.js)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -170,6 +170,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_bytesPerSecond(0), _bytesPerSecond(0),
_recentMaxPackets(0), _recentMaxPackets(0),
_resetRecentMaxPacketsSoon(true), _resetRecentMaxPacketsSoon(true),
_previousScriptLocation(),
_logger(new FileLogger(this)) _logger(new FileLogger(this))
{ {
// read the ApplicationInfo.ini file for Name/Version/Domain information // read the ApplicationInfo.ini file for Name/Version/Domain information
@ -3700,12 +3701,20 @@ void Application::loadScript(const QString& scriptName) {
} }
void Application::loadDialog() { void Application::loadDialog() {
// shut down and stop any existing script QString suggestedName;
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString suggestedName = desktopLocation.append("/script.js"); if (_previousScriptLocation.isEmpty()) {
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
suggestedName = desktopLocation.append("/script.js");
} else {
suggestedName = _previousScriptLocation;
}
QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName,
tr("JavaScript Files (*.js)")); tr("JavaScript Files (*.js)"));
if (!fileNameString.isEmpty()) {
_previousScriptLocation = fileNameString;
}
loadScript(fileNameString); loadScript(fileNameString);
} }

View file

@ -484,6 +484,8 @@ private:
ControllerScriptingInterface _controllerScriptingInterface; ControllerScriptingInterface _controllerScriptingInterface;
QPointer<LogDialog> _logDialog; QPointer<LogDialog> _logDialog;
QString _previousScriptLocation;
FileLogger* _logger; FileLogger* _logger;
void checkVersion(); void checkVersion();

View file

@ -51,6 +51,7 @@ Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const
_lastHeardMicrostamp(usecTimestampNow()), _lastHeardMicrostamp(usecTimestampNow()),
_publicSocket(publicSocket), _publicSocket(publicSocket),
_localSocket(localSocket), _localSocket(localSocket),
_symmetricSocket(),
_activeSocket(NULL), _activeSocket(NULL),
_connectionSecret(), _connectionSecret(),
_bytesReceivedMovingAverage(NULL), _bytesReceivedMovingAverage(NULL),
@ -84,6 +85,15 @@ void Node::setLocalSocket(const HifiSockAddr& localSocket) {
_localSocket = localSocket; _localSocket = localSocket;
} }
void Node::setSymmetricSocket(const HifiSockAddr& symmetricSocket) {
if (_activeSocket == &_symmetricSocket) {
// if the active socket was the symmetric socket then reset it to NULL
_activeSocket = NULL;
}
_symmetricSocket = symmetricSocket;
}
void Node::activateLocalSocket() { void Node::activateLocalSocket() {
qDebug() << "Activating local socket for node" << *this; qDebug() << "Activating local socket for node" << *this;
_activeSocket = &_localSocket; _activeSocket = &_localSocket;
@ -94,6 +104,11 @@ void Node::activatePublicSocket() {
_activeSocket = &_publicSocket; _activeSocket = &_publicSocket;
} }
void Node::activateSymmetricSocket() {
qDebug() << "Activating symmetric socket for node" << *this;
_activeSocket = &_symmetricSocket;
}
void Node::recordBytesReceived(int bytesReceived) { void Node::recordBytesReceived(int bytesReceived) {
if (!_bytesReceivedMovingAverage) { if (!_bytesReceivedMovingAverage) {
_bytesReceivedMovingAverage = new SimpleMovingAverage(100); _bytesReceivedMovingAverage = new SimpleMovingAverage(100);

View file

@ -70,11 +70,14 @@ public:
void setPublicSocket(const HifiSockAddr& publicSocket); void setPublicSocket(const HifiSockAddr& publicSocket);
const HifiSockAddr& getLocalSocket() const { return _localSocket; } const HifiSockAddr& getLocalSocket() const { return _localSocket; }
void setLocalSocket(const HifiSockAddr& localSocket); void setLocalSocket(const HifiSockAddr& localSocket);
const HifiSockAddr& getSymmetricSocket() const { return _symmetricSocket; }
void setSymmetricSocket(const HifiSockAddr& symmetricSocket);
const HifiSockAddr* getActiveSocket() const { return _activeSocket; } const HifiSockAddr* getActiveSocket() const { return _activeSocket; }
void activatePublicSocket(); void activatePublicSocket();
void activateLocalSocket(); void activateLocalSocket();
void activateSymmetricSocket();
const QUuid& getConnectionSecret() const { return _connectionSecret; } const QUuid& getConnectionSecret() const { return _connectionSecret; }
void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; } void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; }
@ -110,6 +113,7 @@ private:
quint64 _lastHeardMicrostamp; quint64 _lastHeardMicrostamp;
HifiSockAddr _publicSocket; HifiSockAddr _publicSocket;
HifiSockAddr _localSocket; HifiSockAddr _localSocket;
HifiSockAddr _symmetricSocket;
HifiSockAddr* _activeSocket; HifiSockAddr* _activeSocket;
QUuid _connectionSecret; QUuid _connectionSecret;
SimpleMovingAverage* _bytesReceivedMovingAverage; SimpleMovingAverage* _bytesReceivedMovingAverage;

View file

@ -294,6 +294,15 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr
matchingNode->setLastHeardMicrostamp(usecTimestampNow()); matchingNode->setLastHeardMicrostamp(usecTimestampNow());
QByteArray replyPacket = constructPingReplyPacket(packet); QByteArray replyPacket = constructPingReplyPacket(packet);
writeDatagram(replyPacket, matchingNode, senderSockAddr); writeDatagram(replyPacket, matchingNode, senderSockAddr);
// If we don't have a symmetric socket for this node and this socket doesn't match
// what we have for public and local then set it as the symmetric.
// This allows a server on a reachable port to communicate with nodes on symmetric NATs
if (matchingNode->getSymmetricSocket().isNull()) {
if (senderSockAddr != matchingNode->getLocalSocket() && senderSockAddr != matchingNode->getPublicSocket()) {
matchingNode->setSymmetricSocket(senderSockAddr);
}
}
} }
break; break;
@ -782,7 +791,7 @@ QByteArray NodeList::constructPingReplyPacket(const QByteArray& pingPacket) {
return replyPacket; return replyPacket;
} }
void NodeList::pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer& node) { void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) {
// send the ping packet to the local and public sockets for this node // send the ping packet to the local and public sockets for this node
QByteArray localPingPacket = constructPingPacket(PingType::Local); QByteArray localPingPacket = constructPingPacket(PingType::Local);
@ -790,6 +799,11 @@ void NodeList::pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer&
QByteArray publicPingPacket = constructPingPacket(PingType::Public); QByteArray publicPingPacket = constructPingPacket(PingType::Public);
writeDatagram(publicPingPacket, node, node->getPublicSocket()); writeDatagram(publicPingPacket, node, node->getPublicSocket());
if (!node->getSymmetricSocket().isNull()) {
QByteArray symmetricPingPacket = constructPingPacket(PingType::Symmetric);
writeDatagram(symmetricPingPacket, node, node->getSymmetricSocket());
}
} }
SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType, SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
@ -860,7 +874,7 @@ void NodeList::pingInactiveNodes() {
foreach (const SharedNodePointer& node, getNodeHash()) { foreach (const SharedNodePointer& node, getNodeHash()) {
if (!node->getActiveSocket()) { if (!node->getActiveSocket()) {
// we don't have an active link to this node, ping it to set that up // we don't have an active link to this node, ping it to set that up
pingPublicAndLocalSocketsForInactiveNode(node); pingPunchForInactiveNode(node);
} }
} }
} }
@ -879,6 +893,9 @@ void NodeList::activateSocketFromNodeCommunication(const QByteArray& packet, con
sendingNode->activateLocalSocket(); sendingNode->activateLocalSocket();
} else if (pingType == PingType::Public && !sendingNode->getActiveSocket()) { } else if (pingType == PingType::Public && !sendingNode->getActiveSocket()) {
sendingNode->activatePublicSocket(); sendingNode->activatePublicSocket();
} else if (pingType == PingType::Symmetric && !sendingNode->getActiveSocket()) {
} }
} }

View file

@ -58,6 +58,7 @@ namespace PingType {
const PingType_t Agnostic = 0; const PingType_t Agnostic = 0;
const PingType_t Local = 1; const PingType_t Local = 1;
const PingType_t Public = 2; const PingType_t Public = 2;
const PingType_t Symmetric = 3;
} }
class NodeList : public QObject { class NodeList : public QObject {
@ -101,7 +102,7 @@ public:
QByteArray constructPingPacket(PingType_t pingType = PingType::Agnostic); QByteArray constructPingPacket(PingType_t pingType = PingType::Agnostic);
QByteArray constructPingReplyPacket(const QByteArray& pingPacket); QByteArray constructPingReplyPacket(const QByteArray& pingPacket);
void pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer& node); void pingPunchForInactiveNode(const SharedNodePointer& node);
SharedNodePointer nodeWithUUID(const QUuid& nodeUUID, bool blockingLock = true); SharedNodePointer nodeWithUUID(const QUuid& nodeUUID, bool blockingLock = true);
SharedNodePointer sendingNodeForPacket(const QByteArray& packet); SharedNodePointer sendingNodeForPacket(const QByteArray& packet);