Merge branch 'master' of https://github.com/highfidelity/hifi into orange

This commit is contained in:
Sam Gateau 2015-04-17 11:33:39 -07:00
commit f1e0d5855e
7 changed files with 188 additions and 15 deletions

View file

@ -302,6 +302,9 @@ bool DomainServer::didSetupAccountManagerWithAccessToken() {
<< "at keypath metaverse.access_token or in your ENV at key DOMAIN_SERVER_ACCESS_TOKEN";
return false;
}
} else {
qDebug() << "Using access token from DOMAIN_SERVER_ACCESS_TOKEN in env. This overrides any access token present"
<< " in the user or master config.";
}
// give this access token to the AccountManager

163
examples/acScripts/rain.js Normal file
View file

@ -0,0 +1,163 @@
//
// rain.js
// examples
//
// Created by David Rowe on 9 Apr 2015.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var RainSquall = function (properties) {
var // Properties
squallOrigin,
squallRadius,
dropsPerMinute = 60,
dropSize = { x: 0.1, y: 0.1, z: 0.1 },
dropFallSpeed = 1, // m/s
dropLifetime = 60, // Seconds
dropSpinMax = 0, // Maximum angular velocity per axis; deg/s
debug = false, // Display origin circle; don't use running on Stack Manager
// Other
squallCircle,
SQUALL_CIRCLE_COLOR = { red: 255, green: 0, blue: 0 },
SQUALL_CIRCLE_ALPHA = 0.5,
SQUALL_CIRCLE_ROTATION = Quat.fromPitchYawRollDegrees(90, 0, 0),
raindropProperties,
RAINDROP_MODEL_URL = "https://s3.amazonaws.com/hifi-public/ozan/Polyworld/Sets/sky/tetrahedron_v1-Faceted2.fbx",
raindropTimer,
raindrops = [], // HACK: Work around raindrops not always getting velocities
raindropVelocities = [], // HACK: Work around raindrops not always getting velocities
DEGREES_TO_RADIANS = Math.PI / 180;
function processProperties() {
if (!properties.hasOwnProperty("origin")) {
print("ERROR: Rain squall origin must be specified");
return;
}
squallOrigin = properties.origin;
if (!properties.hasOwnProperty("radius")) {
print("ERROR: Rain squall radius must be specified");
return;
}
squallRadius = properties.radius;
if (properties.hasOwnProperty("dropsPerMinute")) {
dropsPerMinute = properties.dropsPerMinute;
}
if (properties.hasOwnProperty("dropSize")) {
dropSize = properties.dropSize;
}
if (properties.hasOwnProperty("dropFallSpeed")) {
dropFallSpeed = properties.dropFallSpeed;
}
if (properties.hasOwnProperty("dropLifetime")) {
dropLifetime = properties.dropLifetime;
}
if (properties.hasOwnProperty("dropSpinMax")) {
dropSpinMax = properties.dropSpinMax;
}
if (properties.hasOwnProperty("debug")) {
debug = properties.debug;
}
raindropProperties = {
type: "Model",
modelURL: RAINDROP_MODEL_URL,
lifetime: dropLifetime,
dimensions: dropSize,
velocity: { x: 0, y: -dropFallSpeed, z: 0 },
damping: 0,
angularDamping: 0,
ignoreForCollisions: true
};
}
function createRaindrop() {
var angle,
radius,
offset,
drop,
spin = { x: 0, y: 0, z: 0 },
maxSpinRadians = properties.dropSpinMax * DEGREES_TO_RADIANS,
i;
// HACK: Work around rain drops not always getting velocities set at creation
for (i = 0; i < raindrops.length; i += 1) {
Entities.editEntity(raindrops[i], raindropVelocities[i]);
}
angle = Math.random() * 360;
radius = Math.random() * squallRadius;
offset = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, angle, 0), { x: 0, y: -0.1, z: radius });
raindropProperties.position = Vec3.sum(squallOrigin, offset);
if (properties.dropSpinMax > 0) {
spin = {
x: Math.random() * maxSpinRadians,
y: Math.random() * maxSpinRadians,
z: Math.random() * maxSpinRadians
};
raindropProperties.angularVelocity = spin;
}
drop = Entities.addEntity(raindropProperties);
// HACK: Work around rain drops not always getting velocities set at creation
raindrops.push(drop);
raindropVelocities.push({
velocity: raindropProperties.velocity,
angularVelocity: spin
});
if (raindrops.length > 5) {
raindrops.shift();
raindropVelocities.shift();
}
}
function setUp() {
if (debug) {
squallCircle = Overlays.addOverlay("circle3d", {
size: { x: 2 * squallRadius, y: 2 * squallRadius },
color: SQUALL_CIRCLE_COLOR,
alpha: SQUALL_CIRCLE_ALPHA,
solid: true,
visible: debug,
position: squallOrigin,
rotation: SQUALL_CIRCLE_ROTATION
});
}
raindropTimer = Script.setInterval(createRaindrop, 60000 / dropsPerMinute);
}
function tearDown() {
Script.clearInterval(raindropTimer);
if (debug) {
Overlays.deleteOverlay(squallCircle);
}
}
processProperties();
setUp();
Script.scriptEnding.connect(tearDown);
return {
};
};
var rainSquall1 = new RainSquall({
origin: { x: 1195, y: 1223, z: 1020 },
radius: 25,
dropsPerMinute: 120,
dropSize: { x: 0.1, y: 0.1, z: 0.1 },
dropFallSpeed: 3,
dropLifetime: 30,
dropSpinMax: 180,
debug: false
});

View file

@ -3867,6 +3867,9 @@ void Application::stopAllScripts(bool restart) {
// stops all current running scripts
for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
it != _scriptEnginesHash.constEnd(); it++) {
if (it.value()->isFinished()) {
continue;
}
if (restart && it.value()->isUserLoaded()) {
connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&)));
}

View file

@ -235,33 +235,33 @@ Menu::Menu() {
QMenu* viewMenu = addMenu("View");
addCheckableActionToQMenuAndActionHash(viewMenu,
MenuOption::Fullscreen,
#ifdef Q_OS_MAC
addCheckableActionToQMenuAndActionHash(viewMenu,
MenuOption::Fullscreen,
Qt::CTRL | Qt::META | Qt::Key_F,
false,
qApp,
SLOT(setFullscreen(bool)));
#else
addCheckableActionToQMenuAndActionHash(viewMenu,
MenuOption::Fullscreen,
Qt::CTRL | Qt::Key_F,
#endif
false,
qApp,
SLOT(setFullscreen(bool)));
#endif
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FirstPerson, Qt::Key_P, true,
qApp,SLOT(cameraMenuChanged()));
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Mirror, Qt::SHIFT | Qt::Key_H, true);
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FullscreenMirror, Qt::Key_H, false,
qApp, SLOT(cameraMenuChanged()));
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::HMDTools, Qt::CTRL | Qt::Key_H,
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::HMDTools,
#ifdef Q_OS_MAC
Qt::META | Qt::Key_H,
#else
Qt::CTRL | Qt::Key_H,
#endif
false,
dialogsManager.data(),
SLOT(hmdTools(bool)));
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::EnableVRMode, 0,
false,
qApp,

View file

@ -182,9 +182,10 @@ void DdeFaceTracker::setEnabled(bool enabled) {
_udpSocket.bind(_host, _serverPort);
}
const char* DDE_EXIT_COMMAND = "exit";
if (enabled && !_ddeProcess) {
// Terminate any existing DDE process, perhaps left running after an Interface crash
const char* DDE_EXIT_COMMAND = "exit";
_udpSocket.writeDatagram(DDE_EXIT_COMMAND, DDE_SERVER_ADDR, _controlPort);
qDebug() << "[Info] DDE Face Tracker Starting";
@ -194,7 +195,8 @@ void DdeFaceTracker::setEnabled(bool enabled) {
}
if (!enabled && _ddeProcess) {
_ddeProcess->kill(); // More robust than trying to send an "exit" command to DDE
_udpSocket.writeDatagram(DDE_EXIT_COMMAND, DDE_SERVER_ADDR, _controlPort);
delete _ddeProcess;
_ddeProcess = NULL;
qDebug() << "[Info] DDE Face Tracker Stopped";
}

View file

@ -366,7 +366,7 @@ void AccountManager::setAccessTokenForCurrentAuthURL(const QString& accessToken)
OAuthAccessToken newOAuthToken;
newOAuthToken.token = accessToken;
qCDebug(networking) << "Setting new account manager access token to" << accessToken;
qCDebug(networking) << "Setting new account manager access token. F2C:" << accessToken.left(2) << "L2C:" << accessToken.right(2);
_accountInfo.setAccessToken(newOAuthToken);
}

View file

@ -647,8 +647,10 @@ void ScriptEngine::stopAllTimers() {
}
void ScriptEngine::stop() {
_isFinished = true;
emit runningStateChanged();
if (!_isFinished) {
_isFinished = true;
emit runningStateChanged();
}
}
void ScriptEngine::timerFired() {