mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 00:13:53 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi
This commit is contained in:
commit
bde0f0ef73
5 changed files with 109 additions and 16 deletions
|
@ -23,6 +23,7 @@
|
|||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QActionGroup>
|
||||
#include <QColorDialog>
|
||||
#include <QDesktopWidget>
|
||||
|
@ -144,6 +145,37 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D
|
|||
|
||||
const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
class MyNativeEventFilter : public QAbstractNativeEventFilter {
|
||||
public:
|
||||
static MyNativeEventFilter& getInstance() {
|
||||
static MyNativeEventFilter staticInstance;
|
||||
return staticInstance;
|
||||
}
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void* msg, long* result) Q_DECL_OVERRIDE {
|
||||
if (eventType == "windows_generic_MSG") {
|
||||
MSG* message = (MSG*)msg;
|
||||
if (message->message == UWM_IDENTIFY_INSTANCES) {
|
||||
*result = UWM_IDENTIFY_INSTANCES;
|
||||
return true;
|
||||
}
|
||||
if (message->message == WM_SHOWWINDOW) {
|
||||
Application::getInstance()->getWindow()->showNormal();
|
||||
}
|
||||
if (message->message == WM_COPYDATA) {
|
||||
COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
|
||||
QUrl url = QUrl((const char*)(pcds->lpData));
|
||||
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
||||
DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
|
||||
|
||||
|
@ -244,6 +276,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_aboutToQuit(false),
|
||||
_notifiedPacketVersionMismatchThisDomain(false)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
installNativeEventFilter(&MyNativeEventFilter::getInstance());
|
||||
#endif
|
||||
|
||||
_logger = new FileLogger(this); // After setting organization name in order to get correct directory
|
||||
qInstallMessageHandler(messageHandler);
|
||||
|
||||
|
|
|
@ -114,6 +114,11 @@ static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS
|
|||
static const QString INFO_HELP_PATH = "html/interface-welcome-allsvg.html";
|
||||
static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html";
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static const UINT UWM_IDENTIFY_INSTANCES =
|
||||
RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}");
|
||||
#endif
|
||||
|
||||
class Application;
|
||||
#if defined(qApp)
|
||||
#undef qApp
|
||||
|
|
|
@ -15,9 +15,53 @@
|
|||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "AddressManager.h"
|
||||
#include "Application.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static BOOL CALLBACK enumWindowsCallback(HWND hWnd, LPARAM lParam) {
|
||||
const UINT TIMEOUT = 200; // ms
|
||||
DWORD response;
|
||||
LRESULT result = SendMessageTimeout(hWnd, UWM_IDENTIFY_INSTANCES, 0, 0, SMTO_BLOCK | SMTO_ABORTIFHUNG, TIMEOUT, &response);
|
||||
if (result == 0) { // Timeout; continue search.
|
||||
return TRUE;
|
||||
}
|
||||
if (response == UWM_IDENTIFY_INSTANCES) {
|
||||
HWND* target = (HWND*)lParam;
|
||||
*target = hWnd;
|
||||
return FALSE; // Found; terminate search.
|
||||
}
|
||||
return TRUE; // Not found; continue search.
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// Run only one instance of Interface at a time.
|
||||
HANDLE mutex = CreateMutex(NULL, FALSE, "High Fidelity Interface");
|
||||
DWORD result = GetLastError();
|
||||
if (result == ERROR_ALREADY_EXISTS || result == ERROR_ACCESS_DENIED) {
|
||||
// Interface is already running.
|
||||
HWND otherInstance = NULL;
|
||||
EnumWindows(enumWindowsCallback, (LPARAM)&otherInstance);
|
||||
if (otherInstance) {
|
||||
ShowWindow(otherInstance, SW_RESTORE);
|
||||
SetForegroundWindow(otherInstance);
|
||||
|
||||
QUrl url = QUrl(argv[1]);
|
||||
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
||||
COPYDATASTRUCT cds;
|
||||
cds.cbData = strlen(argv[1]) + 1;
|
||||
cds.lpData = (PVOID)argv[1];
|
||||
SendMessage(otherInstance, WM_COPYDATA, 0, (LPARAM)&cds);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
QElapsedTimer startupTime;
|
||||
startupTime.start();
|
||||
|
||||
|
@ -44,6 +88,11 @@ int main(int argc, const char * argv[]) {
|
|||
qDebug( "Created QT Application.");
|
||||
exitCode = app.exec();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
ReleaseMutex(mutex);
|
||||
#endif
|
||||
|
||||
qDebug("Normal exit.");
|
||||
return exitCode;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
|||
glPushMatrix();
|
||||
glm::vec3 positionToCenter = center - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
glScalef(dimensions.x, dimensions.y, 1.0f);
|
||||
glScalef(dimensions.x / 2.0f, dimensions.y / 2.0f, 1.0f);
|
||||
|
||||
glLineWidth(_lineWidth);
|
||||
|
||||
|
@ -417,19 +417,19 @@ bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin,
|
|||
const glm::vec3& direction, float& distance, BoxFace& face) {
|
||||
|
||||
bool intersects = Planar3DOverlay::findRayIntersection(origin, direction, distance, face);
|
||||
if (intersects) {
|
||||
glm::vec3 hitAt = origin + (direction * distance);
|
||||
float distanceToHit = glm::distance(hitAt, _position);
|
||||
|
||||
float maxDimension = glm::max(_dimensions.x, _dimensions.y);
|
||||
float innerRadius = maxDimension * getInnerRadius();
|
||||
float outerRadius = maxDimension * getOuterRadius();
|
||||
|
||||
// TODO: this really only works for circles, we should be handling the ellipse case as well...
|
||||
if (distanceToHit < innerRadius || distanceToHit > outerRadius) {
|
||||
intersects = false;
|
||||
}
|
||||
if (intersects) {
|
||||
glm::vec3 hitPosition = origin + (distance * direction);
|
||||
glm::vec3 localHitPosition = glm::inverse(_rotation) * (hitPosition - _position);
|
||||
localHitPosition.y = localHitPosition.y * _dimensions.x / _dimensions.y; // Scale to make circular
|
||||
|
||||
float distanceToHit = glm::length(localHitPosition);
|
||||
float innerRadius = _dimensions.x / 2.0f * _innerRadius;
|
||||
float outerRadius = _dimensions.x / 2.0f * _outerRadius;
|
||||
|
||||
intersects = innerRadius <= distanceToHit && distanceToHit <= outerRadius;
|
||||
}
|
||||
|
||||
return intersects;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,6 @@ QScriptValue Planar3DOverlay::getProperty(const QString& property) {
|
|||
|
||||
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face) {
|
||||
|
||||
RayIntersectionInfo rayInfo;
|
||||
rayInfo._rayStart = origin;
|
||||
rayInfo._rayDirection = direction;
|
||||
|
@ -110,9 +109,13 @@ bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::ve
|
|||
|
||||
if (intersects) {
|
||||
distance = rayInfo._hitDistance;
|
||||
// TODO: if it intersects, we want to check to see if the intersection point is within our dimensions
|
||||
// glm::vec3 hitAt = origin + direction * distance;
|
||||
// _dimensions
|
||||
|
||||
glm::vec3 hitPosition = origin + (distance * direction);
|
||||
glm::vec3 localHitPosition = glm::inverse(_rotation) * (hitPosition - _position);
|
||||
glm::vec2 halfDimensions = _dimensions / 2.0f;
|
||||
|
||||
intersects = -halfDimensions.x <= localHitPosition.x && localHitPosition.x <= halfDimensions.x
|
||||
&& -halfDimensions.y <= localHitPosition.y && localHitPosition.y <= halfDimensions.y;
|
||||
}
|
||||
return intersects;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue