mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 12:30:40 +02:00
Rebase fixes
This commit is contained in:
parent
52c61f069f
commit
0508091130
5 changed files with 38 additions and 32 deletions
|
@ -37,6 +37,7 @@ AvatarActionHold::~AvatarActionHold() {
|
|||
}
|
||||
#include <plugins/PluginManager.h>
|
||||
#include <input-plugins/ViveControllerManager.h>
|
||||
#include <controllers/UserInputMapper.h>
|
||||
void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||
bool gotLock = false;
|
||||
glm::quat rotation;
|
||||
|
@ -70,16 +71,16 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
|||
const glm::quat quarterX = glm::angleAxis(PI / 2.0f, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
const glm::quat yFlip = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
palmPosition = translation + rotation * vive->getPosition(index);
|
||||
palmRotation = rotation * vive->getRotation(index) * yFlip * quarterX * glm::angleAxis(PI, glm::vec3(1.0f, 0.0f, 0.0f)) * glm::angleAxis(PI_OVER_TWO, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
palmRotation = rotation * vive->getRotation(index) * yFlip * quarterX * glm::angleAxis(PI, glm::vec3(1.0f, 0.0f, 0.0f)) * glm::angleAxis(PI_OVER_TWO, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
} else
|
||||
#endif
|
||||
if (_hand == "right") {
|
||||
palmPosition = holdingAvatar->getRightPalmPosition();
|
||||
palmRotation = holdingAvatar->getRightPalmRotation();
|
||||
} else {
|
||||
palmPosition = holdingAvatar->getLeftPalmPosition();
|
||||
palmRotation = holdingAvatar->getLeftPalmRotation();
|
||||
}
|
||||
if (_hand == "right") {
|
||||
palmPosition = holdingAvatar->getRightPalmPosition();
|
||||
palmRotation = holdingAvatar->getRightPalmRotation();
|
||||
} else {
|
||||
palmPosition = holdingAvatar->getLeftPalmPosition();
|
||||
palmRotation = holdingAvatar->getLeftPalmRotation();
|
||||
}
|
||||
|
||||
rotation = palmRotation * _relativeRotation;
|
||||
offset = rotation * _relativePosition;
|
||||
|
|
|
@ -223,6 +223,7 @@ void ViveControllerManager::renderHand(const controller::Pose& pose, gpu::Batch&
|
|||
batch.drawIndexed(gpu::TRIANGLES, mesh->getNumIndices(), 0);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
glm::vec3 ViveControllerManager::getPosition(int hand) const {
|
||||
const mat4& mat = _trackedDevicePoseMat4[hand ? 3 : 4];
|
||||
return extractTranslation(mat);
|
||||
|
@ -231,6 +232,7 @@ glm::quat ViveControllerManager::getRotation(int hand) const {
|
|||
const mat4& mat = _trackedDevicePoseMat4[hand ? 3 : 4];
|
||||
return glm::quat_cast(mat);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ViveControllerManager::update(float deltaTime, bool jointsCaptured) {
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -278,18 +280,18 @@ void ViveControllerManager::update(float deltaTime, bool jointsCaptured) {
|
|||
//qDebug() << "Trackpad: " << controllerState.rAxis[0].x << " " << controllerState.rAxis[0].y;
|
||||
//qDebug() << "Trigger: " << controllerState.rAxis[1].x << " " << controllerState.rAxis[1].y;
|
||||
for (uint32_t i = 0; i < vr::k_EButton_Max; ++i) {
|
||||
auto mask = vr::ButtonMaskFromId((vr::EVRButtonId)i);
|
||||
bool pressed = 0 != (controllerState.ulButtonPressed & mask);
|
||||
auto mask = vr::ButtonMaskFromId((vr::EVRButtonId)i);
|
||||
bool pressed = 0 != (controllerState.ulButtonPressed & mask);
|
||||
handleButtonEvent(i, pressed, left);
|
||||
}
|
||||
for (uint32_t i = 0; i < vr::k_unControllerStateAxisCount; i++) {
|
||||
auto mask = vr::ButtonMaskFromId((vr::EVRButtonId)(i + vr::k_EButton_Axis0));
|
||||
bool pressed = 0 != (controllerState.ulButtonPressed & mask);
|
||||
if (pressed || true) {
|
||||
handleAxisEvent(i, controllerState.rAxis[i].x, controllerState.rAxis[i].y, left);
|
||||
} else {
|
||||
handleAxisEvent(i, 0.0f, 0.0f, left);
|
||||
}
|
||||
for (uint32_t i = 0; i < vr::k_unControllerStateAxisCount; i++) {
|
||||
auto mask = vr::ButtonMaskFromId((vr::EVRButtonId)(i + vr::k_EButton_Axis0));
|
||||
bool pressed = 0 != (controllerState.ulButtonPressed & mask);
|
||||
if (pressed || true) {
|
||||
handleAxisEvent(i, controllerState.rAxis[i].x, controllerState.rAxis[i].y, left);
|
||||
} else {
|
||||
handleAxisEvent(i, 0.0f, 0.0f, left);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -418,6 +420,7 @@ void ViveControllerManager::handlePoseEvent(const mat4& mat, bool left) {
|
|||
const glm::quat signedQuaterZ = glm::angleAxis(sign * PI / 2.0f, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
const glm::quat eighthX = glm::angleAxis(PI / 4.0f, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
|
||||
|
||||
const glm::quat rotationOffset = glm::inverse(signedQuaterZ * eighthX) * yFlip * quarterX;
|
||||
const glm::vec3 translationOffset = glm::vec3(sign * CONTROLLER_LENGTH_OFFSET / 2.0f,
|
||||
CONTROLLER_LENGTH_OFFSET / 2.0f,
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
class ViveControllerManager : public InputPlugin, public controller::InputDevice {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString NAME;
|
||||
static const QString NAME;
|
||||
|
||||
ViveControllerManager();
|
||||
|
||||
|
@ -52,9 +52,11 @@ public:
|
|||
|
||||
void setRenderControllers(bool renderControllers) { _renderControllers = renderControllers; }
|
||||
|
||||
int getNumDevices() const;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
glm::vec3 getPosition(int device) const;
|
||||
glm::quat getRotation(int device) const;
|
||||
#endif
|
||||
private:
|
||||
void renderHand(const controller::Pose& pose, gpu::Batch& batch, int sign);
|
||||
|
||||
|
|
Loading…
Reference in a new issue