Skip to content
Snippets Groups Projects

WIP: Feature/#294 untangle hmd open vr

Closed Jan Delember requested to merge feature/#294_Untangle_HMD_OpenVR into develop
2 unresolved threads
15 files
+ 247
121
Compare changes
  • Side-by-side
  • Inline

Files

@@ -31,21 +31,20 @@
#include "phx/display_system.hpp"
#include "phx/engine.hpp"
#include "phx/entity.hpp"
#include "phx/hmd.hpp"
#include "phx/openvr_unit.hpp"
#include "phx/scene.hpp"
#include "phx/transform.hpp"
void NavigationBehavior::OnUpdate() {
// If there exists an HMD and a transform.
const auto hmd = GetEntity()
->GetScene()
->GetEngine()
->GetSystem<phx::DisplaySystem>()
->GetHMD();
const auto openvr_unit = GetEntity()
->GetScene()
->GetEngine()
->GetSystem<phx::DisplaySystem>()
->GetOpenVRUnit();
const auto transform = GetEntity()->GetFirstComponent<phx::Transform>();
if (!hmd || !transform) return;
if (!openvr_unit || !transform) return;
auto indices = hmd->GetControllerIndices();
auto indices = openvr_unit->GetControllerIndices();
for (auto i = 0u; i < indices.size(); ++i) {
vr::VRControllerState_t controller_state;
@@ -56,10 +55,12 @@ void NavigationBehavior::OnUpdate() {
if (controller_state.ulButtonTouched &
vr::ButtonMaskFromId(vr::EVRButtonId::k_EButton_SteamVR_Trigger))
transform->Translate(
-0.05F * glm::column(hmd->GetRightControllerTransformation(), 2));
-0.05F *
glm::column(openvr_unit->GetRightControllerTransformation(), 2));
if (controller_state.ulButtonTouched &
vr::ButtonMaskFromId(vr::EVRButtonId::k_EButton_SteamVR_Touchpad))
transform->Translate(
0.05F * glm::column(hmd->GetRightControllerTransformation(), 2));
0.05F *
glm::column(openvr_unit->GetRightControllerTransformation(), 2));
}
}
Loading