Merge branch 'domain-check' of https://github.com/highfidelity/hifi into summon-crowd

This commit is contained in:
howard-stearns 2016-10-04 10:40:48 -07:00
commit 1c73b3c043
9 changed files with 92 additions and 70 deletions

View file

@ -2170,7 +2170,7 @@ bool Application::event(QEvent* event) {
// handle custom URL // handle custom URL
if (event->type() == QEvent::FileOpen) { if (event->type() == QEvent::FileOpen) {
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event); QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
QUrl url = fileEvent->url(); QUrl url = fileEvent->url();
@ -4361,8 +4361,13 @@ namespace render {
auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage(); auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
auto sceneKeyLight = scene->getKeyLight(); auto sceneKeyLight = scene->getKeyLight();
auto defaultSkyboxAmbientTexture = qApp->getDefaultSkyboxAmbientTexture(); auto defaultSkyboxAmbientTexture = qApp->getDefaultSkyboxAmbientTexture();
sceneKeyLight->setAmbientSphere(defaultSkyboxAmbientTexture->getIrradiance()); if (defaultSkyboxAmbientTexture) {
sceneKeyLight->setAmbientMap(defaultSkyboxAmbientTexture); sceneKeyLight->setAmbientSphere(defaultSkyboxAmbientTexture->getIrradiance());
sceneKeyLight->setAmbientMap(defaultSkyboxAmbientTexture);
} else {
static QString repeatedMessage = LogHandler::getInstance().addRepeatedMessageRegex(
"Failed to get a valid Default Skybox Ambient Texture ? probably because it couldn't be find during initialization step");
}
// fall through: render defaults skybox // fall through: render defaults skybox
} else { } else {
break; break;

View file

@ -125,3 +125,8 @@ void MenuScriptingInterface::setIsOptionChecked(const QString& menuOption, bool
Q_ARG(const QString&, menuOption), Q_ARG(const QString&, menuOption),
Q_ARG(bool, isChecked)); Q_ARG(bool, isChecked));
} }
void MenuScriptingInterface::triggerOption(const QString& menuOption) {
QMetaObject::invokeMethod(Menu::getInstance(), "triggerOption", Q_ARG(const QString&, menuOption));
}

View file

@ -48,6 +48,8 @@ public slots:
bool isOptionChecked(const QString& menuOption); bool isOptionChecked(const QString& menuOption);
void setIsOptionChecked(const QString& menuOption, bool isChecked); void setIsOptionChecked(const QString& menuOption, bool isChecked);
void triggerOption(const QString& menuOption);
signals: signals:
void menuItemEvent(const QString& menuItem); void menuItemEvent(const QString& menuItem);

View file

@ -206,3 +206,7 @@ void WindowScriptingInterface::takeSnapshot(bool notify, float aspectRatio) {
void WindowScriptingInterface::shareSnapshot(const QString& path) { void WindowScriptingInterface::shareSnapshot(const QString& path) {
qApp->shareSnapshot(path); qApp->shareSnapshot(path);
} }
bool WindowScriptingInterface::isPhysicsEnabled() {
return qApp->isPhysicsEnabled();
}

View file

@ -54,6 +54,7 @@ public slots:
void copyToClipboard(const QString& text); void copyToClipboard(const QString& text);
void takeSnapshot(bool notify = true, float aspectRatio = 0.0f); void takeSnapshot(bool notify = true, float aspectRatio = 0.0f);
void shareSnapshot(const QString& path); void shareSnapshot(const QString& path);
bool isPhysicsEnabled();
signals: signals:
void domainChanged(const QString& domainHostname); void domainChanged(const QString& domainHostname);

View file

@ -511,9 +511,7 @@ void GL45Texture::stripToMip(uint16_t newMinMip) {
_minMip = newMinMip; _minMip = newMinMip;
// Re-sync the sampler to force access to the new mip level // Re-sync the sampler to force access to the new mip level
syncSampler(); syncSampler();
size_t oldSize = _size;
updateSize(); updateSize();
Q_ASSERT(_size > oldSize);
// Re-insert into the texture-by-mips map if appropriate // Re-insert into the texture-by-mips map if appropriate

View file

@ -62,7 +62,6 @@ public:
MenuWrapper* getMenu(const QString& menuName); MenuWrapper* getMenu(const QString& menuName);
MenuWrapper* getSubMenuFromName(const QString& menuName, MenuWrapper* menu); MenuWrapper* getSubMenuFromName(const QString& menuName, MenuWrapper* menu);
void triggerOption(const QString& menuOption);
QAction* getActionForOption(const QString& menuOption); QAction* getActionForOption(const QString& menuOption);
QAction* addActionToQMenuAndActionHash(MenuWrapper* destinationMenu, QAction* addActionToQMenuAndActionHash(MenuWrapper* destinationMenu,
@ -112,6 +111,8 @@ public slots:
void toggleDeveloperMenus(); void toggleDeveloperMenus();
void toggleAdvancedMenus(); void toggleAdvancedMenus();
void triggerOption(const QString& menuOption);
static bool isSomeSubmenuShown() { return _isSomeSubmenuShown; } static bool isSomeSubmenuShown() { return _isSomeSubmenuShown; }

View file

@ -20,15 +20,18 @@ var EXPECTED_HMD_FRAMERATE = 90;
var MAXIMUM_LOAD_TIME = 60; // seconds var MAXIMUM_LOAD_TIME = 60; // seconds
var MINIMUM_AVATARS = 25; // FIXME: not implemented yet. Requires agent scripts. Idea is to have them organize themselves to the right number. var MINIMUM_AVATARS = 25; // FIXME: not implemented yet. Requires agent scripts. Idea is to have them organize themselves to the right number.
var version = 1; var version = 2;
function debug() { function debug() {
print.apply(null, [].concat.apply(['hrs fixme', version], [].map.call(arguments, JSON.stringify))); print.apply(null, [].concat.apply(['hrs fixme', version], [].map.call(arguments, JSON.stringify)));
} }
var emptyishPlace = 'empty'; function isNowIn(place) { // true if currently in specified place
var cachePlaces = ['localhost', 'Welcome']; return location.hostname.toLowerCase() === place.toLowerCase();
var isInCachePlace = cachePlaces.indexOf(location.hostname) >= 0; }
var defaultPlace = isInCachePlace ? 'Playa' : location.hostname;
var cachePlaces = ['dev-Welcome', 'localhost']; // For now, list the lighter weight one first.
var isInCachePlace = cachePlaces.some(isNowIn);
var defaultPlace = isInCachePlace ? 'dev-Playa' : location.hostname;
var prompt = "domain-check.js version " + version + "\n\nWhat place should we enter?"; var prompt = "domain-check.js version " + version + "\n\nWhat place should we enter?";
debug(cachePlaces, isInCachePlace, defaultPlace, prompt); debug(cachePlaces, isInCachePlace, defaultPlace, prompt);
var entryPlace = Window.prompt(prompt, defaultPlace); var entryPlace = Window.prompt(prompt, defaultPlace);
@ -73,10 +76,17 @@ function startTwirl(targetRotation, degreesPerUpdate, interval, strafeDistance,
function doLoad(place, continuationWithLoadTime) { // Go to place and call continuationWithLoadTime(loadTimeInSeconds) function doLoad(place, continuationWithLoadTime) { // Go to place and call continuationWithLoadTime(loadTimeInSeconds)
var start = Date.now(), timeout, onDownloadUpdate, finishedTwirl = false, loadTime; var start = Date.now(), timeout, onDownloadUpdate, finishedTwirl = false, loadTime;
// There are two ways to learn of changes: connect to change signals, or poll.
// Until we get reliable results, we'll poll.
var POLL_INTERVAL = 500, poll;
function setHandlers() {
//Stats.downloadsPendingChanged.connect(onDownloadUpdate); downloadsChanged, and physics...
poll = Script.setInterval(onDownloadUpdate, POLL_INTERVAL);
}
function clearHandlers() { function clearHandlers() {
debug('clearHandlers'); debug('clearHandlers');
Stats.downloadsPendingChanged.disconnect(onDownloadUpdate); //Stats.downloadsPendingChanged.disconnect(onDownloadUpdate); downloadsChanged, and physics..
Stats.downloadsChanged.disconnect(onDownloadUpdate); Script.clearInterval(poll);
} }
function waitForLoad(flag) { function waitForLoad(flag) {
debug('entry', place, 'initial downloads/pending', Stats.downloads, Stats.downloadsPending); debug('entry', place, 'initial downloads/pending', Stats.downloads, Stats.downloadsPending);
@ -93,13 +103,11 @@ function doLoad(place, continuationWithLoadTime) { // Go to place and call conti
continuationWithLoadTime(loadTime); continuationWithLoadTime(loadTime);
} }
}); });
Stats.downloadsPendingChanged.connect(onDownloadUpdate); setHandlers();
Stats.downloadsChanged.connect(onDownloadUpdate);
} }
function isLoading() { function isLoading() {
// FIXME: This tells us when download are completed, but it doesn't tell us when the objects are parsed and loaded. // FIXME: We should also confirm that textures have loaded.
// We really want something like _physicsEnabled, but that isn't signalled. return Stats.downloads || Stats.downloadsPending || !Window.isPhysicsEnabled();
return Stats.downloads || Stats.downloadsPending;
} }
onDownloadUpdate = function onDownloadUpdate() { onDownloadUpdate = function onDownloadUpdate() {
debug('update downloads/pending', Stats.downloads, Stats.downloadsPending); debug('update downloads/pending', Stats.downloads, Stats.downloadsPending);
@ -114,17 +122,9 @@ function doLoad(place, continuationWithLoadTime) { // Go to place and call conti
} }
}; };
function doit() { debug('go', place);
debug('go', place); location.hostChanged.connect(waitForLoad);
location.hostChanged.connect(waitForLoad); location.handleLookupString(place);
location.handleLookupString(place);
}
if (location.placename.toLowerCase() === place.toLowerCase()) {
location.handleLookupString(emptyishPlace);
Script.setTimeout(doit, 1000);
} else {
doit();
}
} }
var config = Render.getConfig("Stats"); var config = Render.getConfig("Stats");
@ -144,6 +144,7 @@ function doRender(continuation) {
}); });
} }
var TELEPORT_PAUSE = 500;
function maybePrepareCache(continuation) { function maybePrepareCache(continuation) {
var prepareCache = Window.confirm("Prepare cache?\n\n\ var prepareCache = Window.confirm("Prepare cache?\n\n\
Should we start with all and only those items cached that are encountered when visiting:\n" + cachePlaces.join(', ') + "\n\ Should we start with all and only those items cached that are encountered when visiting:\n" + cachePlaces.join(', ') + "\n\
@ -151,8 +152,6 @@ If 'yes', cache will be cleared and we will visit these two, with a turn in each
You would want to say 'no' (and make other preparations) if you were testing these places."); You would want to say 'no' (and make other preparations) if you were testing these places.");
if (prepareCache) { if (prepareCache) {
location.handleLookupString(emptyishPlace);
Window.alert("Please do menu Edit->Reload Content (Clears all caches) and THEN press 'ok'.");
function loadNext() { function loadNext() {
var place = cachePlaces.shift(); var place = cachePlaces.shift();
doLoad(place, function (prepTime) { doLoad(place, function (prepTime) {
@ -164,16 +163,19 @@ You would want to say 'no' (and make other preparations) if you were testing the
} }
}); });
} }
loadNext(); location.handleLookupString(cachePlaces[cachePlaces.length - 1]);
Menu.triggerOption("Reload Content (Clears all caches)");
Script.setTimeout(loadNext, TELEPORT_PAUSE);
} else { } else {
continuation(); location.handleLookupString(isNowIn(cachePlaces[0]) ? cachePlaces[1] : cachePlaces[0]);
Script.setTimeout(continuation, TELEPORT_PAUSE);
} }
} }
function maybeRunTribbles(continuation) { function maybeRunTribbles(continuation) {
if (Window.confirm("Run tribbles?\n\n\ if (Window.confirm("Run tribbles?\n\n\
At most, only one participant should say yes.")) { At most, only one participant should say yes.")) {
Script.load('http://howard-stearns.github.io/models/scripts/tests/performance/tribbles.js'); // FIXME: replace with AWS Script.load('http://cdn.highfidelity.com/davidkelly/production/scripts/tests/performance/tribbles.js');
Script.setTimeout(continuation, 3000); Script.setTimeout(continuation, 3000);
} else { } else {
continuation(); continuation();

View file

@ -54,42 +54,46 @@ function randomVector(range) {
}; };
} }
Script.setInterval(function () { if (!Entities.canRezTmp()) {
if (!Entities.serversExist() || !Entities.canRez()) { Window.alert("Cannot create temp objects here.");
return; Script.stop();
} } else {
if (totalCreated >= NUMBER_TO_CREATE) { Script.setInterval(function () {
print("Created " + totalCreated + " tribbles."); if (!Entities.serversExist()) {
Script.stop(); return;
} }
if (totalCreated >= NUMBER_TO_CREATE) {
print("Created " + totalCreated + " tribbles.");
Script.stop();
}
var i, numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0); var i, numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0);
var parameters = JSON.stringify({ var parameters = JSON.stringify({
moveTimeout: MOVE_TIMEOUT, moveTimeout: MOVE_TIMEOUT,
moveRate: MOVE_RATE, moveRate: MOVE_RATE,
editTimeout: EDIT_TIMEOUT, editTimeout: EDIT_TIMEOUT,
editRate: EDIT_RATE, editRate: EDIT_RATE,
debug: {flow: false, send: false, receive: false} debug: {flow: false, send: false, receive: false}
});
for (i = 0; (i < numToCreate) && (totalCreated < NUMBER_TO_CREATE); i++) {
Entities.addEntity({
userData: parameters,
type: TYPE,
name: "tribble-" + totalCreated,
position: Vec3.sum(center, randomVector({ x: RANGE, y: RANGE, z: RANGE })),
dimensions: {x: SIZE, y: SIZE, z: SIZE},
color: {red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255},
velocity: VELOCITY,
angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY),
damping: DAMPING,
angularDamping: ANGULAR_DAMPING,
gravity: GRAVITY,
collisionsWillMove: true,
lifetime: LIFETIME,
script: Script.resolvePath("tribbleEntity.js")
}); });
for (i = 0; (i < numToCreate) && (totalCreated < NUMBER_TO_CREATE); i++) {
Entities.addEntity({
userData: parameters,
type: TYPE,
name: "tribble-" + totalCreated,
position: Vec3.sum(center, randomVector({ x: RANGE, y: RANGE, z: RANGE })),
dimensions: {x: SIZE, y: SIZE, z: SIZE},
color: {red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255},
velocity: VELOCITY,
angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY),
damping: DAMPING,
angularDamping: ANGULAR_DAMPING,
gravity: GRAVITY,
collisionsWillMove: true,
lifetime: LIFETIME,
script: Script.resolvePath("tribbleEntity.js")
});
totalCreated++; totalCreated++;
} }
}, SCRIPT_INTERVAL); }, SCRIPT_INTERVAL);
}