mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:49:05 +02:00
Merge branch 'baseball' of https://github.com/Atlante45/hifi into baseball
This commit is contained in:
commit
666c76073a
4 changed files with 29 additions and 36 deletions
|
@ -52,9 +52,9 @@
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
spatialKey: {
|
spatialKey: {
|
||||||
relativePosition: { x: 0.9, y: 0, z: 0 },
|
relativePosition: { x: 0.9, y: 0, z: 0 },
|
||||||
relativeRotation: Quat.fromPitchYawRollDegrees(0, 90, 0),
|
relativeRotation: Quat.fromPitchYawRollDegrees(0, 0, 45),
|
||||||
perHandRelativePosition: { x: 0.0808223, y: 0.134704, z: 0.0381 },
|
perHandRelativePosition: { x: 0.0, y: -0.05, z: -0.04 },
|
||||||
perHandRelativeRotation: Quat.fromPitchYawRollDegrees(-180, 90, 45)
|
perHandRelativeRotation: Quat.fromPitchYawRollDegrees(0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ AvatarActionHold::~AvatarActionHold() {
|
||||||
|
|
||||||
void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||||
bool gotLock = false;
|
bool gotLock = false;
|
||||||
glm::quat rotation;
|
glm::quat rotation { Quaternions::IDENTITY };
|
||||||
glm::vec3 position;
|
glm::vec3 position { Vectors::ZERO };
|
||||||
std::shared_ptr<Avatar> holdingAvatar = nullptr;
|
std::shared_ptr<Avatar> holdingAvatar = nullptr;
|
||||||
|
|
||||||
gotLock = withTryReadLock([&]{
|
gotLock = withTryReadLock([&]{
|
||||||
|
@ -46,9 +46,11 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||||
|
|
||||||
if (holdingAvatar) {
|
if (holdingAvatar) {
|
||||||
bool isRightHand = (_hand == "right");
|
bool isRightHand = (_hand == "right");
|
||||||
glm::vec3 palmPosition;
|
glm::vec3 palmPosition { Vectors::ZERO };
|
||||||
glm::quat palmRotation;
|
glm::quat palmRotation { Quaternions::IDENTITY };
|
||||||
|
|
||||||
|
|
||||||
|
static const glm::quat yFlip = glm::angleAxis(PI, Vectors::UNIT_Y);
|
||||||
if (_ignoreIK && holdingAvatar->isMyAvatar()) {
|
if (_ignoreIK && holdingAvatar->isMyAvatar()) {
|
||||||
// We cannot ignore other avatars IK and this is not the point of this option
|
// We cannot ignore other avatars IK and this is not the point of this option
|
||||||
// This is meant to make the grabbing behavior more reactive.
|
// This is meant to make the grabbing behavior more reactive.
|
||||||
|
@ -58,6 +60,7 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||||
} else {
|
} else {
|
||||||
palmPosition = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getPosition();
|
palmPosition = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getPosition();
|
||||||
palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getRotation();
|
palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getRotation();
|
||||||
|
palmRotation *= yFlip; // Match right hand frame of reference
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isRightHand) {
|
if (isRightHand) {
|
||||||
|
@ -66,28 +69,31 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||||
} else {
|
} else {
|
||||||
palmPosition = holdingAvatar->getLeftPalmPosition();
|
palmPosition = holdingAvatar->getLeftPalmPosition();
|
||||||
palmRotation = holdingAvatar->getLeftPalmRotation();
|
palmRotation = holdingAvatar->getLeftPalmRotation();
|
||||||
|
palmRotation *= yFlip; // Match right hand frame of reference
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rotation = palmRotation * _relativeRotation;
|
||||||
|
position = palmPosition + rotation * _relativePosition;
|
||||||
|
|
||||||
if (isRightHand) {
|
if (isRightHand) {
|
||||||
rotation = palmRotation * _perHandRelativeRotation;
|
rotation *= _perHandRelativeRotation;
|
||||||
position = palmPosition + rotation * _perHandRelativePosition;
|
position += rotation * _perHandRelativePosition;
|
||||||
} else {
|
} else {
|
||||||
auto mirroredRotation = _perHandRelativeRotation;
|
auto mirroredRotation = _perHandRelativeRotation;
|
||||||
auto mirroredPosition = _perHandRelativePosition;
|
auto mirroredPosition = _perHandRelativePosition;
|
||||||
|
|
||||||
// Mirror along x axis
|
// Mirror along z axis
|
||||||
mirroredRotation.x *= -1;
|
auto eulerAngles = safeEulerAngles(mirroredRotation);
|
||||||
mirroredRotation.w *= -1;
|
eulerAngles.x *= -1;
|
||||||
|
eulerAngles.y *= -1;
|
||||||
|
mirroredRotation = glm::quat(eulerAngles);
|
||||||
|
|
||||||
mirroredPosition.x *= -1;
|
mirroredPosition.z *= -1;
|
||||||
|
|
||||||
rotation = palmRotation * mirroredRotation;
|
rotation *= mirroredRotation;
|
||||||
position = palmPosition + rotation * mirroredPosition;
|
position += rotation * mirroredPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
rotation = rotation * _relativeRotation;
|
|
||||||
position = position + rotation * _relativePosition;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -206,16 +206,6 @@ void ViveControllerManager::renderHand(const controller::Pose& pose, gpu::Batch&
|
||||||
batch.drawIndexed(gpu::TRIANGLES, mesh->getNumIndices(), 0);
|
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);
|
|
||||||
}
|
|
||||||
glm::quat ViveControllerManager::getRotation(int hand) const {
|
|
||||||
const mat4& mat = _trackedDevicePoseMat4[hand ? 3 : 4];
|
|
||||||
return glm::quat_cast(mat);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ViveControllerManager::pluginUpdate(float deltaTime, bool jointsCaptured) {
|
void ViveControllerManager::pluginUpdate(float deltaTime, bool jointsCaptured) {
|
||||||
_inputDevice->update(deltaTime, jointsCaptured);
|
_inputDevice->update(deltaTime, jointsCaptured);
|
||||||
|
@ -263,7 +253,7 @@ void ViveControllerManager::InputDevice::update(float deltaTime, bool jointsCapt
|
||||||
bool left = numTrackedControllers == 2;
|
bool left = numTrackedControllers == 2;
|
||||||
|
|
||||||
const mat4& mat = _trackedDevicePoseMat4[device];
|
const mat4& mat = _trackedDevicePoseMat4[device];
|
||||||
|
|
||||||
if (!jointsCaptured) {
|
if (!jointsCaptured) {
|
||||||
handlePoseEvent(mat, numTrackedControllers - 1);
|
handlePoseEvent(mat, numTrackedControllers - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ namespace vr {
|
||||||
class ViveControllerManager : public InputPlugin {
|
class ViveControllerManager : public InputPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static const QString NAME;
|
|
||||||
|
|
||||||
// Plugin functions
|
// Plugin functions
|
||||||
virtual bool isSupported() const override;
|
virtual bool isSupported() const override;
|
||||||
|
@ -47,12 +46,6 @@ public:
|
||||||
void updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges);
|
void updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges);
|
||||||
|
|
||||||
void setRenderControllers(bool renderControllers) { _renderControllers = renderControllers; }
|
void setRenderControllers(bool renderControllers) { _renderControllers = renderControllers; }
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
glm::vec3 getPosition(int device) const;
|
|
||||||
glm::quat getRotation(int device) const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class InputDevice : public controller::InputDevice {
|
class InputDevice : public controller::InputDevice {
|
||||||
|
@ -89,6 +82,10 @@ private:
|
||||||
bool _renderControllers { false };
|
bool _renderControllers { false };
|
||||||
vr::IVRSystem* _hmd { nullptr };
|
vr::IVRSystem* _hmd { nullptr };
|
||||||
std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>(_hmd) };
|
std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>(_hmd) };
|
||||||
|
|
||||||
|
static const QString NAME;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi__ViveControllerManager
|
#endif // hifi__ViveControllerManager
|
||||||
|
|
Loading…
Reference in a new issue