mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 04:03:59 +02:00
Rebase fixes
This commit is contained in:
parent
52c61f069f
commit
0508091130
5 changed files with 38 additions and 32 deletions
|
@ -37,17 +37,18 @@ 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;
|
||||
glm::vec3 position;
|
||||
std::shared_ptr<Avatar> holdingAvatar = nullptr;
|
||||
|
||||
|
||||
gotLock = withTryReadLock([&]{
|
||||
QSharedPointer<AvatarManager> avatarManager = DependencyManager::get<AvatarManager>();
|
||||
AvatarSharedPointer holdingAvatarData = avatarManager->getAvatarBySessionID(_holderID);
|
||||
holdingAvatar = std::static_pointer_cast<Avatar>(holdingAvatarData);
|
||||
|
||||
|
||||
if (holdingAvatar) {
|
||||
glm::vec3 offset;
|
||||
glm::vec3 palmPosition;
|
||||
|
@ -70,23 +71,23 @@ 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;
|
||||
position = palmPosition + offset;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (holdingAvatar) {
|
||||
if (gotLock) {
|
||||
gotLock = withTryWriteLock([&]{
|
||||
|
|
|
@ -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,22 +280,22 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
|
||||
if (numTrackedControllers == 0) {
|
||||
|
@ -412,12 +414,13 @@ void ViveControllerManager::handlePoseEvent(const mat4& mat, bool left) {
|
|||
// Q = (deltaQ * inverse(deltaQForAlignedHand)) * (yFlip * quarterTurnAboutX)
|
||||
|
||||
float sign = left ? -1.0f : 1.0f;
|
||||
|
||||
|
||||
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));
|
||||
const glm::quat signedQuaterZ = glm::angleAxis(sign * PI / 2.0f, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
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,8 +27,8 @@
|
|||
class ViveControllerManager : public InputPlugin, public controller::InputDevice {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString NAME;
|
||||
|
||||
static const QString NAME;
|
||||
|
||||
ViveControllerManager();
|
||||
|
||||
// Plugin functions
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -367,10 +367,10 @@ void ScriptEngine::init() {
|
|||
registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||
qScriptRegisterMetaType(this, animVarMapToScriptValue, animVarMapFromScriptValue);
|
||||
qScriptRegisterMetaType(this, resultHandlerToScriptValue, resultHandlerFromScriptValue);
|
||||
|
||||
|
||||
// constants
|
||||
globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE)));
|
||||
|
||||
|
||||
auto scriptingInterface = DependencyManager::get<controller::ScriptingInterface>();
|
||||
registerGlobalObject("Controller", scriptingInterface.data());
|
||||
UserInputMapper::registerControllerTypes(this);
|
||||
|
@ -706,7 +706,7 @@ void ScriptEngine::run() {
|
|||
}
|
||||
}
|
||||
lastUpdate = now;
|
||||
|
||||
|
||||
// Debug and clear exceptions
|
||||
hadUncaughtExceptions(*this, _fileNameString);
|
||||
}
|
||||
|
@ -1263,4 +1263,4 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS
|
|||
entityScript.property(methodName).call(entityScript, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,4 +205,4 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif // hifi_ScriptEngine_h
|
||||
#endif // hifi_ScriptEngine_h
|
||||
|
|
Loading…
Reference in a new issue