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

This commit is contained in:
samcake 2016-03-14 10:11:46 -07:00
commit dc1f787873
13 changed files with 310 additions and 107 deletions

View file

@ -272,6 +272,18 @@ void EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectio
tree->setWantTerseEditLogging(wantTerseEditLogging);
}
void EntityServer::nodeAdded(SharedNodePointer node) {
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
tree->knowAvatarID(node->getUUID());
OctreeServer::nodeAdded(node);
}
void EntityServer::nodeKilled(SharedNodePointer node) {
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
tree->deleteDescendantsOfAvatar(node->getUUID());
tree->forgetAvatarID(node->getUUID());
OctreeServer::nodeKilled(node);
}
// FIXME - this stats tracking is somewhat temporary to debug the Whiteboard issues. It's not a bad
// set of stats to have, but we'd probably want a different data structure if we keep it very long.

View file

@ -58,6 +58,8 @@ public:
virtual void trackViewerGone(const QUuid& sessionID) override;
public slots:
virtual void nodeAdded(SharedNodePointer node);
virtual void nodeKilled(SharedNodePointer node);
void pruneDeletedEntities();
protected:

View file

@ -127,8 +127,8 @@ public:
public slots:
/// runs the octree server assignment
void run();
void nodeAdded(SharedNodePointer node);
void nodeKilled(SharedNodePointer node);
virtual void nodeAdded(SharedNodePointer node);
virtual void nodeKilled(SharedNodePointer node);
void sendStatsPacket();
private slots:

View file

@ -152,9 +152,19 @@ function maybeMoveOverlay() {
// MAIN CONTROL
var wasMuted, isAway;
var wasOverlaysVisible = Menu.isOptionChecked("Overlays");
var eventMappingName = "io.highfidelity.away"; // goActive on hand controller button events, too.
var eventMapping = Controller.newMapping(eventMappingName);
// backward compatible version of getting HMD.mounted, so it works in old clients
function safeGetHMDMounted() {
if (HMD.mounted === undefined) {
return true;
}
return HMD.mounted;
}
var wasHmdMounted = safeGetHMDMounted();
function goAway() {
if (isAway) {
return;
@ -169,12 +179,20 @@ function goAway() {
playAwayAnimation(); // animation is still seen by others
showOverlay();
// remember the View > Overlays state...
wasOverlaysVisible = Menu.isOptionChecked("Overlays");
// show overlays so that people can see the "Away" message
Menu.setIsOptionChecked("Overlays", true);
// tell the Reticle, we want to stop capturing the mouse until we come back
Reticle.allowMouseCapture = false;
if (HMD.active) {
Reticle.visible = false;
}
wasHmdMounted = safeGetHMDMounted(); // always remember the correct state
}
function goActive() {
if (!isAway) {
return;
@ -188,12 +206,16 @@ function goActive() {
stopAwayAnimation();
hideOverlay();
// restore overlays state to what it was when we went "away"
Menu.setIsOptionChecked("Overlays", wasOverlaysVisible);
// tell the Reticle, we are ready to capture the mouse again and it should be visible
Reticle.allowMouseCapture = true;
Reticle.visible = true;
if (HMD.active) {
Reticle.position = HMD.getHUDLookAtPosition2D();
}
wasHmdMounted = safeGetHMDMounted(); // always remember the correct state
}
function maybeGoActive(event) {
@ -206,6 +228,7 @@ function maybeGoActive(event) {
goActive();
}
}
var wasHmdActive = HMD.active;
var wasMouseCaptured = Reticle.mouseCaptured;
@ -225,6 +248,13 @@ function maybeGoAway() {
goAway();
}
}
// If you've removed your HMD from your head, and we can detect it, we will also go away...
var hmdMounted = safeGetHMDMounted();
if (HMD.active && !hmdMounted && wasHmdMounted) {
wasHmdMounted = hmdMounted;
goAway();
}
}
Script.update.connect(maybeMoveOverlay);

96
examples/playTestSound.js Normal file
View file

@ -0,0 +1,96 @@
//
// playTestSound.js
// examples
//
// Created by Philip Rosedale
// Copyright 2014 High Fidelity, Inc.
//
// Creates an object in front of you that changes color and plays a light
// at the start of a drum clip that loops. As you move away it will tell you in the
// log how many meters you are from the source.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var sound = SoundCache.getSound("https://s3.amazonaws.com/hifi-public/sounds/Drums/deepdrum1.wav");
var position = Vec3.sum(Vec3.sum(MyAvatar.position, { x: 0, y: 0.5, z: 0 }), Quat.getFront(MyAvatar.orientation));
var time;
var soundPlaying = null;
var baseColor = { red: 100, green: 100, blue: 100 };
var litColor = { red: 255, green: 100, blue: 0 };
var lightTime = 250;
var distance = 0.0;
// Create object for visual reference
var box = Entities.addEntity({
type: "Box",
dimensions: { x: 0.25, y: 0.5, z: 0.25 },
color: baseColor,
position: position
});
function checkSound(deltaTime) {
var started = false;
if (!sound.downloaded) {
return;
}
if (soundPlaying == null) {
soundPlaying = Audio.playSound(sound, {
position: position,
volume: 1.0,
loop: false } );
started = true;
} else if (!soundPlaying.isPlaying) {
soundPlaying.restart();
started = true;
}
if (started) {
Entities.editEntity(box, { color: litColor });
Entities.addEntity({
type: "Light",
intensity: 5.0,
falloffRadius: 10.0,
dimensions: {
x: 40,
y: 40,
z: 40
},
position: Vec3.sum(position, { x: 0, y: 1, z: 0 }),
color: litColor,
lifetime: lightTime / 1000
});
Script.setTimeout(resetColor, lightTime);
}
var currentDistance = Vec3.distance(MyAvatar.position, position);
if (Math.abs(currentDistance - distance) > 1.0) {
print("Distance from source: " + currentDistance);
distance = currentDistance;
}
}
function resetColor() {
Entities.editEntity(box, { color: baseColor });
}
function scriptEnding() {
Entities.deleteEntity(box);
if (soundPlaying) {
print("stop injector");
soundPlaying.stop();
}
}
// Connect a call back that happens every frame
Script.scriptEnding.connect(scriptEnding);
Script.update.connect(checkSound);

View file

@ -141,7 +141,7 @@ void EntityTreeRenderer::update() {
// check if the texture loaded and apply it
if (!updated && (
(_pendingSkyboxTexture && (!_skyboxTexture || _skyboxTexture->isLoaded())) ||
(_pendingAmbientTexture && (!_ambientTexture && _ambientTexture->isLoaded())))) {
(_pendingAmbientTexture && (!_ambientTexture || _ambientTexture->isLoaded())))) {
applyZonePropertiesToScene(_bestZone);
}

View file

@ -86,6 +86,11 @@ void EntityTree::postAddEntity(EntityItemPointer entity) {
if (_simulation) {
_simulation->addEntity(entity);
}
if (!entity->isParentIDValid()) {
_missingParent.append(entity);
}
_isDirty = true;
maybeNotifyNewCollisionSoundURL("", entity->getCollisionSoundURL());
emit addingEntity(entity->getEntityItemID());
@ -252,6 +257,9 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
_missingParent.append(childEntity);
continue;
}
if (!childEntity->isParentIDValid()) {
_missingParent.append(childEntity);
}
UpdateEntityOperator theChildOperator(getThisPointer(), containingElement, childEntity, queryCube);
recurseTreeWithOperator(&theChildOperator);
@ -448,6 +456,17 @@ void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator)
const RemovedEntities& entities = theOperator.getEntities();
foreach(const EntityToDeleteDetails& details, entities) {
EntityItemPointer theEntity = details.entity;
if (getIsServer()) {
QSet<EntityItemID> childrenIDs;
theEntity->forEachChild([&](SpatiallyNestablePointer child) {
if (child->getNestableType() == NestableType::Entity) {
childrenIDs += child->getID();
}
});
deleteEntities(childrenIDs, true, true);
}
theEntity->die();
if (getIsServer()) {
@ -992,14 +1011,23 @@ void EntityTree::fixupMissingParents() {
EntityItemWeakPointer entityWP = iter.next();
EntityItemPointer entity = entityWP.lock();
if (entity) {
bool success;
AACube newCube = entity->getQueryAACube(success);
if (success) {
// this entity's parent (or ancestry) was previously not fully known, and now is. Update its
// location in the EntityTree.
if (entity->isParentIDValid()) {
// this entity's parent was previously not known, and now is. Update its location in the EntityTree...
bool success;
AACube newCube = entity->getQueryAACube(success);
if (!success) {
continue;
}
moveOperator.addEntityToMoveList(entity, newCube);
iter.remove();
entity->markAncestorMissing(false);
} else if (_avatarIDs.contains(entity->getParentID())) {
if (!_childrenOfAvatars.contains(entity->getParentID())) {
_childrenOfAvatars[entity->getParentID()] = QSet<EntityItemID>();
}
_childrenOfAvatars[entity->getParentID()] += entity->getEntityItemID();
iter.remove();
entity->markAncestorMissing(false);
}
} else {
// entity was deleted before we found its parent.
@ -1014,6 +1042,13 @@ void EntityTree::fixupMissingParents() {
}
void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {
if (_childrenOfAvatars.contains(avatarID)) {
deleteEntities(_childrenOfAvatars[avatarID]);
_childrenOfAvatars.remove(avatarID);
}
}
void EntityTree::update() {
fixupMissingParents();
if (_simulation) {

View file

@ -241,6 +241,10 @@ public:
Q_INVOKABLE int getJointIndex(const QUuid& entityID, const QString& name) const;
Q_INVOKABLE QStringList getJointNames(const QUuid& entityID) const;
void knowAvatarID(QUuid avatarID) { _avatarIDs += avatarID; }
void forgetAvatarID(QUuid avatarID) { _avatarIDs -= avatarID; }
void deleteDescendantsOfAvatar(QUuid avatarID);
public slots:
void callLoader(EntityItemID entityID);
@ -313,8 +317,11 @@ protected:
quint64 _maxEditDelta = 0;
quint64 _treeResetTime = 0;
void fixupMissingParents();
QVector<EntityItemWeakPointer> _missingParent;
void fixupMissingParents(); // try to hook members of _missingParent to parent instances
QVector<EntityItemWeakPointer> _missingParent; // entites with a parentID but no (yet) known parent instance
// we maintain a list of avatarIDs to notice when an entity is a child of one.
QSet<QUuid> _avatarIDs; // IDs of avatars connected to entity server
QHash<QUuid, QSet<EntityItemID>> _childrenOfAvatars; // which entities are children of which avatars
};
#endif // hifi_EntityTree_h

View file

@ -374,7 +374,8 @@ void Procedural::setupUniforms() {
v.y = date.month() - 1;
// But not the day... go figure
v.z = date.day();
v.w = (time.hour() * 3600) + (time.minute() * 60) + time.second();
float fractSeconds = (time.msec() / 1000.0f);
v.w = (time.hour() * 3600) + (time.minute() * 60) + time.second() + fractSeconds;
batch._glUniform(_standardUniformSlots[DATE], v);
});
}

View file

@ -222,8 +222,11 @@ void Menu::setIsOptionChecked(const QString& menuOption, bool isChecked) {
return;
}
QAction* menu = _actionHash.value(menuOption);
if (menu) {
menu->setChecked(isChecked);
if (menu && menu->isCheckable()) {
auto wasChecked = menu->isChecked();
if (wasChecked != isChecked) {
menu->trigger();
}
}
}

View file

@ -6,7 +6,9 @@
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
#
if (NOT WIN32)
# Windows doesn't need this, and building it currently make Linux unstable.
# if (NOT WIN32)
if (APPLE)
set(TARGET_NAME oculusLegacy)
setup_hifi_plugin()
@ -19,4 +21,4 @@ if (NOT WIN32)
target_include_directories(${TARGET_NAME} PRIVATE ${LIBOVR_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
endif()
endif()

View file

@ -86,13 +86,16 @@ void OpenVrDisplayPlugin::activate() {
}
void OpenVrDisplayPlugin::deactivate() {
// Base class deactivate must come before our local deactivate
// because the OpenGL base class handles the wait for the present
// thread before continuing
HmdDisplayPlugin::deactivate();
_container->setIsOptionChecked(StandingHMDSensorMode, false);
if (_system) {
releaseOpenVrSystem();
_system = nullptr;
}
_compositor = nullptr;
HmdDisplayPlugin::deactivate();
}
void OpenVrDisplayPlugin::customizeContext() {

View file

@ -477,118 +477,130 @@ function performContentMigration() {
var logWindow = null;
var labels = {
serverState: {
label: 'Server - Stopped',
enabled: false
},
version: {
label: 'Version - ' + buildInfo.buildIdentifier,
enabled: false
},
restart: {
label: 'Start Server',
click: function() {
homeServer.restart();
}
},
stopServer: {
label: 'Stop Server',
visible: false,
click: function() {
homeServer.stop();
}
},
goHome: {
label: 'Go Home',
click: goHomeClicked,
enabled: false
},
quit: {
label: 'Quit',
accelerator: 'Command+Q',
click: function() {
shutdown();
}
},
settings: {
label: 'Settings',
click: function() {
shell.openExternal('http://localhost:40100/settings');
},
enabled: false
},
viewLogs: {
label: 'View Logs',
click: function() {
logWindow.open();
}
},
share: {
label: 'Share',
click: function() {
shell.openExternal('http://localhost:40100/settings/?action=share')
}
},
migrateContent: {
label: 'Migrate Stack Manager Content',
click: function() {
promptToMigrateContent();
}
},
shuttingDown: {
label: "Shutting down...",
enabled: false
},
}
var separator = {
type: 'separator'
};
function buildMenuArray(serverState) {
var menuArray = null;
updateLabels(serverState);
var menuArray = [];
if (isShuttingDown) {
menuArray = [
{
label: "Shutting down...",
enabled: false
}
];
menuArray.push(labels.shuttingDown);
} else {
menuArray = [
{
label: 'Server - Stopped',
enabled: false
},
{
type: 'separator'
},
{
label: 'Go Home',
click: goHomeClicked,
enabled: false
},
{
type: 'separator'
},
{
label: 'Start Server',
click: function() { homeServer.restart(); }
},
{
label: 'Stop Server',
visible: false,
click: function() { homeServer.stop(); }
},
{
label: 'Settings',
click: function() { shell.openExternal('http://localhost:40100/settings'); },
enabled: false
},
{
label: 'View Logs',
click: function() { logWindow.open(); }
},
{
type: 'separator'
},
{
label: 'Share',
click: function() { shell.openExternal('http://localhost:40100/settings/?action=share') }
},
{
type: 'separator'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click: function() { shutdown(); }
}
];
menuArray.push(labels.serverState);
menuArray.push(labels.version);
menuArray.push(separator);
menuArray.push(labels.goHome);
menuArray.push(separator);
menuArray.push(labels.restart);
menuArray.push(labels.stopServer);
menuArray.push(labels.settings);
menuArray.push(labels.viewLogs);
menuArray.push(separator);
menuArray.push(labels.share);
menuArray.push(separator);
menuArray.push(labels.quit);
var foundStackManagerContent = isStackManagerContentPresent();
if (foundStackManagerContent) {
// add a separator and the stack manager content migration option
menuArray.splice(menuArray.length - 1, 0, {
label: 'Migrate Stack Manager Content',
click: function() { promptToMigrateContent(); }
}, {
type: 'separator'
});
menuArray.splice(menuArray.length - 1, 0, labels.migrateContent, separator);
}
updateMenuArray(menuArray, serverState);
}
return menuArray;
}
const GO_HOME_INDEX = 2;
const SERVER_LABEL_INDEX = 0;
const RESTART_INDEX = 4;
const STOP_INDEX = 5;
const SETTINGS_INDEX = 6;
function updateLabels(serverState) {
function updateMenuArray(menuArray, serverState) {
// update the tray menu state
var running = serverState == ProcessGroupStates.STARTED;
var serverLabelItem = menuArray[SERVER_LABEL_INDEX];
var restartItem = menuArray[RESTART_INDEX];
// Go Home is only enabled if running
menuArray[GO_HOME_INDEX].enabled = running;
// Stop is only visible if running
menuArray[STOP_INDEX].visible = running;
// Settings is only visible if running
menuArray[SETTINGS_INDEX].enabled = running;
labels.goHome.enabled = running;
labels.stopServer.visible = running;
labels.settings.enabled = running;
if (serverState == ProcessGroupStates.STARTED) {
serverLabelItem.label = "Server - Started";
restartItem.label = "Restart Server";
labels.serverState.label = "Server - Started";
labels.restart.label = "Restart Server";
} else if (serverState == ProcessGroupStates.STOPPED) {
serverLabelItem.label = "Server - Stopped";
restartItem.label = "Start Server";
labels.serverState.label = "Server - Stopped";
labels.restart.label = "Start Server";
labels.restart.enabled = true;
} else if (serverState == ProcessGroupStates.STOPPING) {
serverLabelItem.label = "Server - Stopping";
restartItem.label = "Restart Server";
restartItem.enabled = false;
labels.serverState.label = "Server - Stopping";
labels.restart.label = "Restart Server";
labels.restart.enabled = false;
}
}