mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 18:13:47 +02:00
Merge branch 'ice-troubles' of github.com:sethalves/hifi into ice-troubles
This commit is contained in:
commit
e6de9d7d51
6 changed files with 116 additions and 52 deletions
|
@ -175,7 +175,7 @@ void DomainServer::parseCommandLine() {
|
|||
parser.addOption(domainIDOption);
|
||||
|
||||
if (!parser.parse(QCoreApplication::arguments())) {
|
||||
qCritical() << parser.errorText() << endl;
|
||||
qWarning() << parser.errorText() << endl;
|
||||
parser.showHelp();
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ void DomainServer::parseCommandLine() {
|
|||
}
|
||||
|
||||
if (_iceServerAddr.isEmpty()) {
|
||||
qCritical() << "Could not parse an IP address and port combination from" << hostnamePortString;
|
||||
qWarning() << "Could not parse an IP address and port combination from" << hostnamePortString;
|
||||
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ DomainServer::~DomainServer() {
|
|||
|
||||
void DomainServer::queuedQuit(QString quitMessage, int exitCode) {
|
||||
if (!quitMessage.isEmpty()) {
|
||||
qCritical() << qPrintable(quitMessage);
|
||||
qWarning() << qPrintable(quitMessage);
|
||||
}
|
||||
|
||||
QCoreApplication::exit(exitCode);
|
||||
|
|
BIN
interface/resources/images/preview-disabled.png
Normal file
BIN
interface/resources/images/preview-disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
Binary file not shown.
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 59 KiB |
|
@ -88,6 +88,7 @@ bool HmdDisplayPlugin::internalActivate() {
|
|||
_monoPreview = clicked;
|
||||
_container->setBoolSetting("monoPreview", _monoPreview);
|
||||
}, true, _monoPreview);
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
_disablePreview = true;
|
||||
#else
|
||||
|
@ -137,6 +138,7 @@ ivec4 HmdDisplayPlugin::getViewportForSourceSize(const uvec2& size) const {
|
|||
float windowAspect = aspect(windowSize);
|
||||
float sceneAspect = aspect(size);
|
||||
float aspectRatio = sceneAspect / windowAspect;
|
||||
|
||||
uvec2 targetViewportSize = windowSize;
|
||||
if (aspectRatio < 1.0f) {
|
||||
targetViewportSize.x *= aspectRatio;
|
||||
|
@ -152,6 +154,23 @@ ivec4 HmdDisplayPlugin::getViewportForSourceSize(const uvec2& size) const {
|
|||
return ivec4(targetViewportPosition, targetViewportSize);
|
||||
}
|
||||
|
||||
float HmdDisplayPlugin::getLeftCenterPixel() const {
|
||||
glm::mat4 eyeProjection = _eyeProjections[Left];
|
||||
glm::mat4 inverseEyeProjection = glm::inverse(eyeProjection);
|
||||
vec2 eyeRenderTargetSize = { _renderTargetSize.x / 2, _renderTargetSize.y };
|
||||
|
||||
vec4 left = vec4(-1, 0, -1, 1);
|
||||
vec4 right = vec4(1, 0, -1, 1);
|
||||
vec4 right2 = inverseEyeProjection * right;
|
||||
vec4 left2 = inverseEyeProjection * left;
|
||||
left2 /= left2.w;
|
||||
right2 /= right2.w;
|
||||
float width = -left2.x + right2.x;
|
||||
float leftBias = -left2.x / width;
|
||||
float leftCenterPixel = eyeRenderTargetSize.x * leftBias;
|
||||
return leftCenterPixel;
|
||||
}
|
||||
|
||||
void HmdDisplayPlugin::internalPresent() {
|
||||
PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)presentCount())
|
||||
|
||||
|
@ -164,16 +183,67 @@ void HmdDisplayPlugin::internalPresent() {
|
|||
if (_monoPreview) {
|
||||
sourceSize.x >>= 1;
|
||||
}
|
||||
auto viewport = getViewportForSourceSize(sourceSize);
|
||||
|
||||
float shiftLeftBy = getLeftCenterPixel() - (sourceSize.x / 2);
|
||||
float newWidth = sourceSize.x - shiftLeftBy;
|
||||
|
||||
const unsigned int RATIO_Y = 9;
|
||||
const unsigned int RATIO_X = 16;
|
||||
glm::uvec2 originalClippedSize { newWidth, newWidth * RATIO_Y / RATIO_X };
|
||||
|
||||
glm::ivec4 viewport = getViewportForSourceSize(sourceSize);
|
||||
glm::ivec4 scissor = viewport;
|
||||
|
||||
render([&](gpu::Batch& batch) {
|
||||
|
||||
if (_monoPreview) {
|
||||
auto window = _container->getPrimaryWidget();
|
||||
float devicePixelRatio = window->devicePixelRatio();
|
||||
glm::vec2 windowSize = toGlm(window->size());
|
||||
windowSize *= devicePixelRatio;
|
||||
|
||||
float windowAspect = aspect(windowSize); // example: 1920 x 1080 = 1.78
|
||||
float sceneAspect = aspect(originalClippedSize); // usually: 1512 x 850 = 1.78
|
||||
|
||||
|
||||
bool scaleToWidth = windowAspect < sceneAspect;
|
||||
|
||||
float ratio;
|
||||
int scissorOffset;
|
||||
|
||||
if (scaleToWidth) {
|
||||
ratio = (float)windowSize.x / (float)newWidth;
|
||||
} else {
|
||||
ratio = (float)windowSize.y / (float)originalClippedSize.y;
|
||||
}
|
||||
|
||||
float scaledShiftLeftBy = shiftLeftBy * ratio;
|
||||
|
||||
int scissorSizeX = originalClippedSize.x * ratio;
|
||||
int scissorSizeY = originalClippedSize.y * ratio;
|
||||
|
||||
int viewportSizeX = sourceSize.x * ratio;
|
||||
int viewportSizeY = sourceSize.y * ratio;
|
||||
int viewportOffset = ((int)windowSize.y - viewportSizeY) / 2;
|
||||
|
||||
if (scaleToWidth) {
|
||||
scissorOffset = ((int)windowSize.y - scissorSizeY) / 2;
|
||||
scissor = ivec4(0, scissorOffset, scissorSizeX, scissorSizeY);
|
||||
viewport = ivec4(-scaledShiftLeftBy, viewportOffset, viewportSizeX, viewportSizeY);
|
||||
} else {
|
||||
scissorOffset = ((int)windowSize.x - scissorSizeX) / 2;
|
||||
scissor = ivec4(scissorOffset, 0, scissorSizeX, scissorSizeY);
|
||||
viewport = ivec4(scissorOffset - scaledShiftLeftBy, viewportOffset, viewportSizeX, viewportSizeY);
|
||||
}
|
||||
|
||||
viewport.z *= 2;
|
||||
}
|
||||
|
||||
batch.enableStereo(false);
|
||||
batch.resetViewTransform();
|
||||
batch.setFramebuffer(gpu::FramebufferPointer());
|
||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(0));
|
||||
batch.setStateScissorRect(viewport);
|
||||
if (_monoPreview) {
|
||||
viewport.z *= 2;
|
||||
}
|
||||
batch.setStateScissorRect(scissor); // was viewport
|
||||
batch.setViewportTransform(viewport);
|
||||
batch.setResourceTexture(0, _compositeFramebuffer->getRenderBuffer(0));
|
||||
batch.setPipeline(_presentPipeline);
|
||||
|
@ -181,7 +251,13 @@ void HmdDisplayPlugin::internalPresent() {
|
|||
});
|
||||
swapBuffers();
|
||||
} else if (_clearPreviewFlag) {
|
||||
auto image = QImage(PathUtils::resourcesPath() + "images/preview.png");
|
||||
QImage image;
|
||||
if (_vsyncEnabled) {
|
||||
image = QImage(PathUtils::resourcesPath() + "images/preview.png");
|
||||
} else {
|
||||
image = QImage(PathUtils::resourcesPath() + "images/preview-disabled.png");
|
||||
}
|
||||
|
||||
image = image.mirrored();
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888);
|
||||
if (!_previewTexture) {
|
||||
|
@ -197,6 +273,7 @@ void HmdDisplayPlugin::internalPresent() {
|
|||
|
||||
if (getGLBackend()->isTextureReady(_previewTexture)) {
|
||||
auto viewport = getViewportForSourceSize(uvec2(_previewTexture->getDimensions()));
|
||||
|
||||
render([&](gpu::Batch& batch) {
|
||||
batch.enableStereo(false);
|
||||
batch.resetViewTransform();
|
||||
|
@ -213,6 +290,17 @@ void HmdDisplayPlugin::internalPresent() {
|
|||
}
|
||||
}
|
||||
postPreview();
|
||||
|
||||
// If preview is disabled, we need to check to see if the window size has changed
|
||||
// and re-render the no-preview message
|
||||
if (_disablePreview) {
|
||||
auto window = _container->getPrimaryWidget();
|
||||
glm::vec2 windowSize = toGlm(window->size());
|
||||
if (windowSize != _lastWindowSize) {
|
||||
_clearPreviewFlag = true;
|
||||
_lastWindowSize = windowSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// HMD specific stuff
|
||||
|
|
|
@ -102,11 +102,13 @@ protected:
|
|||
bool _disablePreview{ true };
|
||||
private:
|
||||
ivec4 getViewportForSourceSize(const uvec2& size) const;
|
||||
float getLeftCenterPixel() const;
|
||||
|
||||
bool _disablePreviewItemAdded { false };
|
||||
bool _monoPreview { true };
|
||||
bool _clearPreviewFlag { false };
|
||||
gpu::TexturePointer _previewTexture;
|
||||
glm::vec2 _lastWindowSize;
|
||||
|
||||
struct OverlayRenderer {
|
||||
gpu::Stream::FormatPointer format;
|
||||
|
|
|
@ -56,12 +56,6 @@ var HAND_HEAD_MIX_RATIO = 0.0; // 0 = only use hands for search/move. 1 = only
|
|||
|
||||
var PICK_WITH_HAND_RAY = true;
|
||||
|
||||
var EQUIP_SPHERE_COLOR = {
|
||||
red: 116,
|
||||
green: 90,
|
||||
blue: 238
|
||||
};
|
||||
var EQUIP_SPHERE_ALPHA = 0.15;
|
||||
var EQUIP_SPHERE_SCALE_FACTOR = 0.65;
|
||||
|
||||
|
||||
|
@ -205,6 +199,8 @@ var CONTROLLER_STATE_MACHINE = {};
|
|||
|
||||
var mostRecentSearchingHand = RIGHT_HAND;
|
||||
|
||||
var DEFAULT_SPHERE_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/equip-Fresnel-3.fbx";
|
||||
|
||||
CONTROLLER_STATE_MACHINE[STATE_OFF] = {
|
||||
name: "off",
|
||||
enterMethod: "offEnter",
|
||||
|
@ -605,43 +601,21 @@ EquipHotspotBuddy.prototype.updateHotspot = function(hotspot, timestamp) {
|
|||
|
||||
var diameter = hotspot.radius * 2;
|
||||
|
||||
if (hotspot.modelURL) {
|
||||
// override default sphere with a user specified model
|
||||
overlayInfoSet.overlays.push(Overlays.addOverlay("model", {
|
||||
url: hotspot.modelURL,
|
||||
position: hotspot.worldPosition,
|
||||
rotation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0,
|
||||
w: 1
|
||||
},
|
||||
dimensions: diameter * EQUIP_SPHERE_SCALE_FACTOR,
|
||||
scale: hotspot.modelScale,
|
||||
ignoreRayIntersection: true
|
||||
}));
|
||||
overlayInfoSet.type = "model";
|
||||
} else {
|
||||
// default sphere overlay
|
||||
overlayInfoSet.overlays.push(Overlays.addOverlay("sphere", {
|
||||
position: hotspot.worldPosition,
|
||||
rotation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0,
|
||||
w: 1
|
||||
},
|
||||
dimensions: diameter * EQUIP_SPHERE_SCALE_FACTOR,
|
||||
color: EQUIP_SPHERE_COLOR,
|
||||
alpha: EQUIP_SPHERE_ALPHA,
|
||||
solid: true,
|
||||
visible: true,
|
||||
ignoreRayIntersection: true,
|
||||
drawInFront: false
|
||||
}));
|
||||
overlayInfoSet.type = "sphere";
|
||||
}
|
||||
|
||||
// override default sphere with a user specified model, if it exists.
|
||||
overlayInfoSet.overlays.push(Overlays.addOverlay("model", {
|
||||
url: hotspot.modelURL ? hotspot.modelURL : DEFAULT_SPHERE_MODEL_URL,
|
||||
position: hotspot.worldPosition,
|
||||
rotation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0,
|
||||
w: 1
|
||||
},
|
||||
dimensions: diameter * EQUIP_SPHERE_SCALE_FACTOR,
|
||||
scale: hotspot.modelScale,
|
||||
ignoreRayIntersection: true
|
||||
}));
|
||||
overlayInfoSet.type = "model";
|
||||
this.map[hotspot.key] = overlayInfoSet;
|
||||
} else {
|
||||
overlayInfoSet.timestamp = timestamp;
|
||||
|
|
Loading…
Reference in a new issue