Merge branch 'master' into 21070

This commit is contained in:
David Rowe 2016-10-15 11:20:30 +13:00
commit eff8502f67
11 changed files with 151 additions and 50 deletions

View file

@ -414,6 +414,7 @@ void OpenGLDisplayPlugin::customizeContext() {
_cursorPipeline = gpu::Pipeline::create(program, state);
}
}
updateCompositeFramebuffer();
}
void OpenGLDisplayPlugin::uncustomizeContext() {
@ -557,10 +558,7 @@ void OpenGLDisplayPlugin::compositeScene() {
}
void OpenGLDisplayPlugin::compositeLayers() {
auto renderSize = getRecommendedRenderSize();
if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) {
_compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("displayPlugin::composite", gpu::Element::COLOR_RGBA_32, renderSize.x, renderSize.y));
}
updateCompositeFramebuffer();
{
PROFILE_RANGE_EX("compositeScene", 0xff0077ff, (uint64_t)presentCount())
@ -760,3 +758,10 @@ void OpenGLDisplayPlugin::render(std::function<void(gpu::Batch& batch)> f) {
OpenGLDisplayPlugin::~OpenGLDisplayPlugin() {
qDebug() << "Destroying OpenGLDisplayPlugin";
}
void OpenGLDisplayPlugin::updateCompositeFramebuffer() {
auto renderSize = getRecommendedRenderSize();
if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) {
_compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("OpenGLDisplayPlugin::composite", gpu::Element::COLOR_RGBA_32, renderSize.x, renderSize.y));
}
}

View file

@ -78,6 +78,8 @@ protected:
glm::uvec2 getSurfaceSize() const;
glm::uvec2 getSurfacePixels() const;
void updateCompositeFramebuffer();
virtual void compositeLayers();
virtual void compositeScene();
virtual void compositeOverlay();

View file

@ -365,6 +365,7 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Damping, damping, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Restitution, restitution, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Friction, friction, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Created, created, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Lifetime, lifetime, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Script, script, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, ScriptTimestamp, scriptTimestamp, "");

View file

@ -945,6 +945,9 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
properties.setLifetime(_maxTmpEntityLifetime);
// also bump up the lastEdited time of the properties so that the interface that created this edit
// will accept our adjustment to lifetime back into its own entity-tree.
if (properties.getLastEdited() == UNKNOWN_CREATED_TIME) {
properties.setLastEdited(usecTimestampNow());
}
properties.setLastEdited(properties.getLastEdited() + LAST_EDITED_SERVERSIDE_BUMP);
}
}

View file

@ -377,9 +377,6 @@ void OpenVrDisplayPlugin::init() {
}
bool OpenVrDisplayPlugin::internalActivate() {
_openVrDisplayActive = true;
_container->setIsOptionChecked(StandingHMDSensorMode, true);
if (!_system) {
_system = acquireOpenVrSystem();
}
@ -388,6 +385,18 @@ bool OpenVrDisplayPlugin::internalActivate() {
return false;
}
// If OpenVR isn't running, then the compositor won't be accessible
// FIXME find a way to launch the compositor?
if (!vr::VRCompositor()) {
qWarning() << "Failed to acquire OpenVR compositor";
releaseOpenVrSystem();
_system = nullptr;
return false;
}
_openVrDisplayActive = true;
_container->setIsOptionChecked(StandingHMDSensorMode, true);
_system->GetRecommendedRenderTargetSize(&_renderTargetSize.x, &_renderTargetSize.y);
// Recommended render target size is per-eye, so double the X size for
// left + right eyes

View file

@ -109,8 +109,12 @@ void releaseOpenVrSystem() {
vr::Texture_t vrTexture{ (void*)INVALID_GL_TEXTURE_HANDLE, vr::API_OpenGL, vr::ColorSpace_Auto };
static vr::VRTextureBounds_t OPENVR_TEXTURE_BOUNDS_LEFT{ 0, 0, 0.5f, 1 };
static vr::VRTextureBounds_t OPENVR_TEXTURE_BOUNDS_RIGHT{ 0.5f, 0, 1, 1 };
vr::VRCompositor()->Submit(vr::Eye_Left, &vrTexture, &OPENVR_TEXTURE_BOUNDS_LEFT);
vr::VRCompositor()->Submit(vr::Eye_Right, &vrTexture, &OPENVR_TEXTURE_BOUNDS_RIGHT);
auto compositor = vr::VRCompositor();
if (compositor) {
compositor->Submit(vr::Eye_Left, &vrTexture, &OPENVR_TEXTURE_BOUNDS_LEFT);
compositor->Submit(vr::Eye_Right, &vrTexture, &OPENVR_TEXTURE_BOUNDS_RIGHT);
}
vr::VR_Shutdown();
_openVrQuitRequested = false;

View file

@ -2770,7 +2770,13 @@ var handleHandMessages = function(channel, message, sender) {
Messages.messageReceived.connect(handleHandMessages);
var BASIC_TIMER_INTERVAL = 20; // 20ms = 50hz good enough
var updateIntervalTimer = Script.setInterval(function(){
update();
}, BASIC_TIMER_INTERVAL);
function cleanup() {
Script.clearInterval(updateIntervalTimer);
rightController.cleanup();
leftController.cleanup();
Controller.disableMapping(MAPPING_NAME);
@ -2778,6 +2784,5 @@ function cleanup() {
}
Script.scriptEnding.connect(cleanup);
Script.update.connect(update);
}()); // END LOCAL_SCOPE

View file

@ -507,10 +507,15 @@ function update() {
clearSystemLaser();
Reticle.visible = false;
}
setupHandler(Script.update, update);
var BASIC_TIMER_INTERVAL = 20; // 20ms = 50hz good enough
var updateIntervalTimer = Script.setInterval(function(){
update();
}, BASIC_TIMER_INTERVAL);
// Check periodically for changes to setup.
var SETTINGS_CHANGE_RECHECK_INTERVAL = 10 * 1000; // milliseconds
var SETTINGS_CHANGE_RECHECK_INTERVAL = 10 * 1000; // 10 seconds
function checkSettings() {
updateFieldOfView();
updateRecommendedArea();
@ -520,6 +525,7 @@ checkSettings();
var settingsChecker = Script.setInterval(checkSettings, SETTINGS_CHANGE_RECHECK_INTERVAL);
Script.scriptEnding.connect(function () {
Script.clearInterval(settingsChecker);
Script.clearInterval(updateIntervalTimer);
OffscreenFlags.navigationFocusDisabled = false;
});

View file

@ -91,7 +91,6 @@ function Teleporter() {
this.tooClose = false;
this.inCoolIn = false;
this.initialize = function() {
this.createMappings();
};
@ -142,7 +141,10 @@ function Teleporter() {
};
this.createTargetOverlay = function() {
this.createTargetOverlay = function(visible) {
if (visible == undefined) {
visible = true;
}
if (_this.targetOverlay !== null) {
return;
@ -150,20 +152,17 @@ function Teleporter() {
var targetOverlayProps = {
url: TARGET_MODEL_URL,
dimensions: TARGET_MODEL_DIMENSIONS,
visible: true
};
var cancelOverlayProps = {
url: TOO_CLOSE_MODEL_URL,
dimensions: TARGET_MODEL_DIMENSIONS,
visible: true
visible: visible
};
_this.targetOverlay = Overlays.addOverlay("model", targetOverlayProps);
};
this.createCancelOverlay = function() {
this.createCancelOverlay = function(visible) {
if (visible == undefined) {
visible = true;
}
if (_this.cancelOverlay !== null) {
return;
@ -172,7 +171,7 @@ function Teleporter() {
var cancelOverlayProps = {
url: TOO_CLOSE_MODEL_URL,
dimensions: TARGET_MODEL_DIMENSIONS,
visible: true
visible: visible
};
_this.cancelOverlay = Overlays.addOverlay("model", cancelOverlayProps);
@ -187,6 +186,23 @@ function Teleporter() {
this.cancelOverlay = null;
}
this.hideCancelOverlay = function() {
if (this.cancelOverlay === null) {
return;
}
this.intersection = null;
Overlays.editOverlay(this.cancelOverlay, { visible: false });
}
this.showCancelOverlay = function() {
if (this.cancelOverlay === null) {
return this.createCancelOverlay();
}
Overlays.editOverlay(this.cancelOverlay, { visible: true });
}
this.deleteTargetOverlay = function() {
if (this.targetOverlay === null) {
return;
@ -197,6 +213,22 @@ function Teleporter() {
this.targetOverlay = null;
}
this.hideTargetOverlay = function() {
if (this.targetOverlay === null) {
return;
}
this.intersection = null;
Overlays.editOverlay(this.targetOverlay, { visible: false });
}
this.showTargetOverlay = function() {
if (this.targetOverlay === null) {
return this.createTargetOverlay();
}
Overlays.editOverlay(this.targetOverlay, { visible: true });
}
this.turnOffOverlayBeams = function() {
this.rightOverlayOff();
this.leftOverlayOff();
@ -232,8 +264,8 @@ function Teleporter() {
if ((leftPad.buttonValue === 0) && inTeleportMode === true) {
if (_this.inCoolIn === true) {
_this.exitTeleportMode();
_this.deleteTargetOverlay();
_this.deleteCancelOverlay();
_this.hideTargetOverlay();
_this.hideCancelOverlay();
} else {
_this.teleport();
}
@ -248,8 +280,8 @@ function Teleporter() {
if ((rightPad.buttonValue === 0) && inTeleportMode === true) {
if (_this.inCoolIn === true) {
_this.exitTeleportMode();
_this.deleteTargetOverlay();
_this.deleteCancelOverlay();
_this.hideTargetOverlay();
_this.hideCancelOverlay();
} else {
_this.teleport();
}
@ -283,7 +315,7 @@ function Teleporter() {
if (rightIntersection.intersects) {
if (this.tooClose === true) {
this.deleteTargetOverlay();
this.hideTargetOverlay();
this.rightLineOn(rightPickRay.origin, rightIntersection.intersection, COLORS_TELEPORT_TOO_CLOSE);
if (this.cancelOverlay !== null) {
@ -293,7 +325,7 @@ function Teleporter() {
}
} else {
if (this.inCoolIn === true) {
this.deleteTargetOverlay();
this.hideTargetOverlay();
this.rightLineOn(rightPickRay.origin, rightIntersection.intersection, COLORS_TELEPORT_TOO_CLOSE);
if (this.cancelOverlay !== null) {
this.updateCancelOverlay(rightIntersection);
@ -301,7 +333,7 @@ function Teleporter() {
this.createCancelOverlay();
}
} else {
this.deleteCancelOverlay();
this.hideCancelOverlay();
this.rightLineOn(rightPickRay.origin, rightIntersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
if (this.targetOverlay !== null) {
@ -316,7 +348,7 @@ function Teleporter() {
} else {
this.deleteTargetOverlay();
this.hideTargetOverlay();
this.rightLineOn(rightPickRay.origin, location, COLORS_TELEPORT_CANNOT_TELEPORT);
}
}
@ -347,7 +379,7 @@ function Teleporter() {
if (leftIntersection.intersects) {
if (this.tooClose === true) {
this.deleteTargetOverlay();
this.hideTargetOverlay();
this.leftLineOn(leftPickRay.origin, leftIntersection.intersection, COLORS_TELEPORT_TOO_CLOSE);
if (this.cancelOverlay !== null) {
this.updateCancelOverlay(leftIntersection);
@ -356,7 +388,7 @@ function Teleporter() {
}
} else {
if (this.inCoolIn === true) {
this.deleteTargetOverlay();
this.hideTargetOverlay();
this.leftLineOn(leftPickRay.origin, leftIntersection.intersection, COLORS_TELEPORT_TOO_CLOSE);
if (this.cancelOverlay !== null) {
this.updateCancelOverlay(leftIntersection);
@ -364,7 +396,7 @@ function Teleporter() {
this.createCancelOverlay();
}
} else {
this.deleteCancelOverlay();
this.hideCancelOverlay();
this.leftLineOn(leftPickRay.origin, leftIntersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
if (this.targetOverlay !== null) {
@ -380,7 +412,7 @@ function Teleporter() {
} else {
this.deleteTargetOverlay();
this.hideTargetOverlay();
this.leftLineOn(leftPickRay.origin, location, COLORS_TELEPORT_CANNOT_TELEPORT);
}
};
@ -463,6 +495,7 @@ function Teleporter() {
var towardUs = Quat.fromPitchYawRollDegrees(0, euler.y, 0);
Overlays.editOverlay(this.targetOverlay, {
visible: true,
position: position,
rotation: towardUs
});
@ -484,6 +517,7 @@ function Teleporter() {
var towardUs = Quat.fromPitchYawRollDegrees(0, euler.y, 0);
Overlays.editOverlay(this.cancelOverlay, {
visible: true,
position: position,
rotation: towardUs
});
@ -503,7 +537,7 @@ function Teleporter() {
if (this.intersection !== null) {
if (this.tooClose === true) {
this.exitTeleportMode();
this.deleteCancelOverlay();
this.hideCancelOverlay();
return;
}
var offset = getAvatarFootOffset();
@ -512,8 +546,8 @@ function Teleporter() {
// Disable smooth arrival, possibly temporarily
//this.smoothArrival();
MyAvatar.position = _this.intersection.intersection;
_this.deleteTargetOverlay();
_this.deleteCancelOverlay();
_this.hideTargetOverlay();
_this.hideCancelOverlay();
HMD.centerUI();
}
};
@ -556,14 +590,16 @@ function Teleporter() {
MyAvatar.position = landingPoint;
if (_this.arrivalPoints.length === 1 || _this.arrivalPoints.length === 0) {
_this.deleteTargetOverlay();
_this.deleteCancelOverlay();
_this.hideTargetOverlay();
_this.hideCancelOverlay();
}
}, SMOOTH_ARRIVAL_SPACING);
}
this.createTargetOverlay(false);
this.createCancelOverlay(false);
}
//related to repositioning the avatar after you teleport

View file

@ -39,7 +39,7 @@ function calcSpawnInfo() {
}
// ctor
WebTablet = function (url, width, dpi) {
WebTablet = function (url, width, dpi, clientOnly) {
var ASPECT = 4.0 / 3.0;
var WIDTH = width || DEFAULT_WIDTH;
@ -63,7 +63,7 @@ WebTablet = function (url, width, dpi) {
dimensions: {x: WIDTH, y: HEIGHT, z: DEPTH},
parentID: MyAvatar.sessionUUID,
parentJointIndex: -2
});
}, clientOnly);
var WEB_ENTITY_REDUCTION_FACTOR = {x: 0.78, y: 0.85};
var WEB_ENTITY_Z_OFFSET = -0.01;
@ -84,7 +84,7 @@ WebTablet = function (url, width, dpi) {
dpi: DPI,
parentID: this.tabletEntityID,
parentJointIndex: -1
});
}, clientOnly);
this.state = "idle";
};
@ -93,4 +93,14 @@ WebTablet.prototype.destroy = function () {
Entities.deleteEntity(this.webEntityID);
Entities.deleteEntity(this.tabletEntityID);
};
WebTablet.prototype.pickle = function () {
return JSON.stringify({webEntityID: this.webEntityID, tabletEntityID: this.tabletEntityID});
};
WebTablet.unpickle = function (string) {
if (!string) {
return;
}
var tablet = JSON.parse(string);
tablet.__proto__ = WebTablet.prototype;
return tablet;
};

View file

@ -30,6 +30,10 @@ var TOOLBAR_MARGIN_Y = 0;
var marketplaceVisible = false;
var marketplaceWebTablet;
// We persist clientOnly data in the .ini file, and reconsistitute it on restart.
// To keep things consistent, we pickle the tablet data in Settings, and kill any existing such on restart and domain change.
var persistenceKey = "io.highfidelity.lastDomainTablet";
function shouldShowWebTablet() {
var rightPose = Controller.getPoseValue(Controller.Standard.RightHand);
var leftPose = Controller.getPoseValue(Controller.Standard.LeftHand);
@ -40,7 +44,8 @@ function shouldShowWebTablet() {
function showMarketplace(marketplaceID) {
if (shouldShowWebTablet()) {
updateButtonState(true);
marketplaceWebTablet = new WebTablet("https://metaverse.highfidelity.com/marketplace");
marketplaceWebTablet = new WebTablet("https://metaverse.highfidelity.com/marketplace", null, null, true);
Settings.setValue(persistenceKey, marketplaceWebTablet.pickle());
} else {
var url = MARKETPLACE_URL;
if (marketplaceID) {
@ -54,14 +59,25 @@ function showMarketplace(marketplaceID) {
UserActivityLogger.openedMarketplace();
}
function hideTablet(tablet) {
if (!tablet) {
return;
}
updateButtonState(false);
tablet.destroy();
marketplaceWebTablet = null;
Settings.setValue(persistenceKey, "");
}
function clearOldTablet() { // If there was a tablet from previous domain or session, kill it and let it be recreated
var tablet = WebTablet.unpickle(Settings.getValue(persistenceKey, ""));
hideTablet(tablet);
}
function hideMarketplace() {
if (marketplaceWindow.visible) {
marketplaceWindow.setVisible(false);
marketplaceWindow.setURL("about:blank");
} else if (marketplaceWebTablet) {
updateButtonState(false);
marketplaceWebTablet.destroy();
marketplaceWebTablet = null;
hideTablet(marketplaceWebTablet);
}
marketplaceVisible = false;
}
@ -102,6 +118,10 @@ function onClick() {
browseExamplesButton.clicked.connect(onClick);
marketplaceWindow.visibleChanged.connect(onMarketplaceWindowVisibilityChanged);
clearOldTablet(); // Run once at startup, in case there's anything laying around from a crash.
// We could also optionally do something like Window.domainChanged.connect(function () {Script.setTimeout(clearOldTablet, 2000)}),
// but the HUD version stays around, so lets do the same.
Script.scriptEnding.connect(function () {
toolBar.removeButton("marketplace");
browseExamplesButton.clicked.disconnect(onClick);