mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 18:04:12 +02:00
use a ray from the near clip for action ray
This commit is contained in:
parent
8452182b45
commit
f53455ee55
6 changed files with 17 additions and 6 deletions
|
@ -81,7 +81,8 @@ function drawLobby() {
|
||||||
size: RETICLE_SPHERE_SIZE,
|
size: RETICLE_SPHERE_SIZE,
|
||||||
color: { red: 0, green: 255, blue: 0 },
|
color: { red: 0, green: 255, blue: 0 },
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
solid: true
|
solid: true,
|
||||||
|
ignoreRayIntersection: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// add an attachment on this avatar so other people see them in the lobby
|
// add an attachment on this avatar so other people see them in the lobby
|
||||||
|
@ -128,6 +129,7 @@ function cleanupLobby() {
|
||||||
|
|
||||||
function actionStartEvent(event) {
|
function actionStartEvent(event) {
|
||||||
if (panelWall) {
|
if (panelWall) {
|
||||||
|
|
||||||
// we've got an action event and our panel wall is up
|
// we've got an action event and our panel wall is up
|
||||||
// check if we hit a panel and if we should jump there
|
// check if we hit a panel and if we should jump there
|
||||||
var result = Overlays.findRayIntersection(event.actionRay);
|
var result = Overlays.findRayIntersection(event.actionRay);
|
||||||
|
|
|
@ -1117,7 +1117,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
if (!event->isAutoRepeat()) {
|
if (!event->isAutoRepeat()) {
|
||||||
// this starts an HFActionEvent
|
// this starts an HFActionEvent
|
||||||
HFActionEvent startActionEvent(HFActionEvent::startType(),
|
HFActionEvent startActionEvent(HFActionEvent::startType(),
|
||||||
Application::getInstance()->getCamera()->getPickRay());
|
_viewFrustum.computePickRay(0.5f, 0.5f));
|
||||||
sendEvent(this, &startActionEvent);
|
sendEvent(this, &startActionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1208,7 +1208,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
case Qt::Key_Space: {
|
case Qt::Key_Space: {
|
||||||
if (!event->isAutoRepeat()) {
|
if (!event->isAutoRepeat()) {
|
||||||
// this ends the HFActionEvent
|
// this ends the HFActionEvent
|
||||||
HFActionEvent endActionEvent(HFActionEvent::endType(), Application::getInstance()->getCamera()->getPickRay());
|
HFActionEvent endActionEvent(HFActionEvent::endType(), _viewFrustum.computePickRay(0.5f, 0.5f));
|
||||||
sendEvent(this, &endActionEvent);
|
sendEvent(this, &endActionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,6 @@ public:
|
||||||
void setEyeOffsetOrientation(const glm::quat& o) { _eyeOffsetOrientation = o; }
|
void setEyeOffsetOrientation(const glm::quat& o) { _eyeOffsetOrientation = o; }
|
||||||
void setScale(const float s) { _scale = s; }
|
void setScale(const float s) { _scale = s; }
|
||||||
|
|
||||||
PickRay getPickRay() const { return PickRay(getPosition(), getRotation() * IDENTITY_FRONT); }
|
|
||||||
|
|
||||||
glm::vec3 getPosition() const { return _position + _hmdPosition; }
|
glm::vec3 getPosition() const { return _position + _hmdPosition; }
|
||||||
glm::quat getRotation() const { return _rotation * _hmdRotation; }
|
glm::quat getRotation() const { return _rotation * _hmdRotation; }
|
||||||
const glm::vec3& getHmdPosition() const { return _hmdPosition; }
|
const glm::vec3& getHmdPosition() const { return _hmdPosition; }
|
||||||
|
|
|
@ -129,7 +129,8 @@ void JoystickScriptingInterface::update() {
|
||||||
: HFActionEvent::endType();
|
: HFActionEvent::endType();
|
||||||
|
|
||||||
// global action events fire in the center of the screen
|
// global action events fire in the center of the screen
|
||||||
HFActionEvent actionEvent(actionType, Application::getInstance()->getCamera()->getPickRay());
|
HFActionEvent actionEvent(actionType,
|
||||||
|
Application::getInstance()->getViewFrustum()->computePickRay(0.5f, 0.5f));
|
||||||
qApp->sendEvent(qApp, &actionEvent);
|
qApp->sendEvent(qApp, &actionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -583,6 +583,13 @@ bool ViewFrustum::isVerySimilar(const ViewFrustum& compareTo, bool debug) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PickRay ViewFrustum::computePickRay(float x, float y) {
|
||||||
|
glm::vec3 pickRayOrigin;
|
||||||
|
glm::vec3 pickRayDirection;
|
||||||
|
computePickRay(x, y, pickRayOrigin, pickRayDirection);
|
||||||
|
return PickRay(pickRayOrigin, pickRayDirection);
|
||||||
|
}
|
||||||
|
|
||||||
void ViewFrustum::computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const {
|
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));
|
direction = glm::normalize(origin - (_position + _orientation * _eyeOffsetPosition));
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
|
#include <RegisteredMetaTypes.h>
|
||||||
|
|
||||||
#include "AABox.h"
|
#include "AABox.h"
|
||||||
#include "AACube.h"
|
#include "AACube.h"
|
||||||
#include "Plane.h"
|
#include "Plane.h"
|
||||||
|
@ -105,6 +107,7 @@ public:
|
||||||
bool isVerySimilar(const ViewFrustum& compareTo, bool debug = false) const;
|
bool isVerySimilar(const ViewFrustum& compareTo, bool debug = false) const;
|
||||||
bool isVerySimilar(const ViewFrustum* compareTo, bool debug = false) const { return isVerySimilar(*compareTo, debug); }
|
bool isVerySimilar(const ViewFrustum* compareTo, bool debug = false) const { return isVerySimilar(*compareTo, debug); }
|
||||||
|
|
||||||
|
PickRay computePickRay(float x, float y);
|
||||||
void computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const;
|
void computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const;
|
||||||
|
|
||||||
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearValue, float& farValue,
|
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearValue, float& farValue,
|
||||||
|
|
Loading…
Reference in a new issue