Merge pull request #3931 from Atlante45/mouse_pick_in_oculus

Misc fixes
This commit is contained in:
Stephen Birarda 2014-12-09 12:13:24 -08:00
commit ada325da2b
6 changed files with 26 additions and 24 deletions

View file

@ -2354,12 +2354,10 @@ void Application::update(float deltaTime) {
if (OculusManager::isConnected() &&
Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)){
if (_window->cursor().shape() != Qt::BlankCursor) {
qDebug() << "Hiding cursor" << _window->cursor().shape();
cursor = _window->cursor();
_window->setCursor(QCursor(Qt::BlankCursor));
}
} else if(_window->cursor().shape() == Qt::BlankCursor) {
qDebug() << "Showing cursor" << _window->cursor().shape();
_window->setCursor(cursor);
}

View file

@ -268,7 +268,10 @@ EntityItemProperties RenderableModelEntityItem::getProperties() const {
bool RenderableModelEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,
void** intersectedObject, bool precisionPicking) const {
if (!_model) {
return true;
}
glm::vec3 originInMeters = origin * (float)TREE_SCALE;
QString extraInfo;
float localDistance;

View file

@ -103,7 +103,7 @@ bool raySphereIntersect(const glm::vec3 &dir, const glm::vec3 &origin, float r,
}
}
void renderReticule(glm::quat orientation, float alpha) {
void renderReticle(glm::quat orientation, float alpha) {
glm::vec3 topLeft = getPoint(reticleSize / 2.0f, -reticleSize / 2.0f);
glm::vec3 topRight = getPoint(-reticleSize / 2.0f, -reticleSize / 2.0f);
glm::vec3 bottomLeft = getPoint(reticleSize / 2.0f, reticleSize / 2.0f);
@ -269,7 +269,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
glm::mat4 rotation = glm::toMat4(orientation);
glMultMatrixf(&rotation[0][0]);
glScalef(scale, scale, scale);
for (int i = 0; i < NUMBER_OF_RETICULES; i++) {
for (int i = 0; i < NUMBER_OF_RETICLES; i++) {
if (_magActive[i]) {
_magSizeMult[i] += MAG_SPEED;
@ -285,8 +285,8 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
if (_magSizeMult[i] > 0.0f) {
//Render magnifier, but dont show border for mouse magnifier
glm::vec2 projection = screenToOverlay(glm::vec2(_reticulePosition[MOUSE].x(),
_reticulePosition[MOUSE].y()));
glm::vec2 projection = screenToOverlay(glm::vec2(_reticlePosition[MOUSE].x(),
_reticlePosition[MOUSE].y()));
renderMagnifier(projection, _magSizeMult[i], i != MOUSE);
}
@ -528,7 +528,7 @@ void ApplicationOverlay::renderPointers() {
QPoint position = QPoint(application->getTrueMouseX(), application->getTrueMouseY());
static const int MAX_IDLE_TIME = 3;
if (_reticulePosition[MOUSE] != position) {
if (_reticlePosition[MOUSE] != position) {
_lastMouseMove = usecTimestampNow();
} else if (usecTimestampNow() - _lastMouseMove > MAX_IDLE_TIME * USECS_PER_SECOND) {
float pitch, yaw, roll;
@ -539,7 +539,7 @@ void ApplicationOverlay::renderPointers() {
QCursor::setPos(application->getGLWidget()->mapToGlobal(position));
}
_reticulePosition[MOUSE] = position;
_reticlePosition[MOUSE] = position;
_reticleActive[MOUSE] = true;
_magActive[MOUSE] = true;
_reticleActive[LEFT_CONTROLLER] = false;
@ -561,9 +561,9 @@ void ApplicationOverlay::renderControllerPointers() {
MyAvatar* myAvatar = application->getAvatar();
//Static variables used for storing controller state
static quint64 pressedTime[NUMBER_OF_RETICULES] = { 0ULL, 0ULL, 0ULL };
static bool isPressed[NUMBER_OF_RETICULES] = { false, false, false };
static bool stateWhenPressed[NUMBER_OF_RETICULES] = { false, false, false };
static quint64 pressedTime[NUMBER_OF_RETICLES] = { 0ULL, 0ULL, 0ULL };
static bool isPressed[NUMBER_OF_RETICLES] = { false, false, false };
static bool stateWhenPressed[NUMBER_OF_RETICLES] = { false, false, false };
const HandData* handData = Application::getInstance()->getAvatar()->getHandData();
@ -610,7 +610,7 @@ void ApplicationOverlay::renderControllerPointers() {
QPoint point = getPalmClickLocation(palmData);
_reticulePosition[index] = point;
_reticlePosition[index] = point;
//When button 2 is pressed we drag the mag window
if (isPressed[index]) {
@ -685,16 +685,16 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) {
float yaw = glm::acos(-tipDirection.z) *
((yawSign == 0.0f) ? 1.0f : yawSign);
glm::quat orientation = glm::quat(glm::vec3(pitch, yaw, 0.0f));
renderReticule(orientation, _alpha);
renderReticle(orientation, _alpha);
}
}
//Mouse Pointer
if (_reticleActive[MOUSE]) {
glm::vec2 projection = screenToSpherical(glm::vec2(_reticulePosition[MOUSE].x(),
_reticulePosition[MOUSE].y()));
glm::vec2 projection = screenToSpherical(glm::vec2(_reticlePosition[MOUSE].x(),
_reticlePosition[MOUSE].y()));
glm::quat orientation(glm::vec3(-projection.y, projection.x, 0.0f));
renderReticule(orientation, _alpha);
renderReticle(orientation, _alpha);
}
glEnable(GL_DEPTH_TEST);

View file

@ -94,11 +94,11 @@ private:
float _textureFov;
float _textureAspectRatio;
enum Reticules { MOUSE, LEFT_CONTROLLER, RIGHT_CONTROLLER, NUMBER_OF_RETICULES };
bool _reticleActive[NUMBER_OF_RETICULES];
QPoint _reticulePosition[NUMBER_OF_RETICULES];
bool _magActive[NUMBER_OF_RETICULES];
float _magSizeMult[NUMBER_OF_RETICULES];
enum Reticles { MOUSE, LEFT_CONTROLLER, RIGHT_CONTROLLER, NUMBER_OF_RETICLES };
bool _reticleActive[NUMBER_OF_RETICLES];
QPoint _reticlePosition[NUMBER_OF_RETICLES];
bool _magActive[NUMBER_OF_RETICLES];
float _magSizeMult[NUMBER_OF_RETICLES];
quint64 _lastMouseMove;
float _alpha;

View file

@ -38,7 +38,8 @@ void NodeBounds::draw() {
// Compute ray to find selected nodes later on. We can't use the pre-computed ray in Application because it centers
// itself after the cursor disappears.
Application* application = Application::getInstance();
PickRay pickRay = application->getCamera()->computeViewPickRay(application->getTrueMouseX(), application->getTrueMouseY());
PickRay pickRay = application->getCamera()->computePickRay(application->getTrueMouseX(),
application->getTrueMouseY());
// Variables to keep track of the selected node and properties to draw the cube later if needed
Node* selectedNode = NULL;

View file

@ -591,7 +591,7 @@ PickRay ViewFrustum::computePickRay(float x, float y) {
}
void ViewFrustum::computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const {
origin = _nearTopLeft + x*(_nearTopRight - _nearTopLeft) + y*(_nearBottomLeft - _nearTopLeft);
origin = _nearTopLeft + x * (_nearTopRight - _nearTopLeft) + y * (_nearBottomLeft - _nearTopLeft);
direction = glm::normalize(origin - (_position + _orientation * _eyeOffsetPosition));
}