From 50482291ce74bb262e5332ddccfba6fc3e6a7348 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Thu, 4 Jul 2019 01:03:04 +0200 Subject: [PATCH] Use real hitPoint distance for pointer scale (#1361) --- app/src/main/cpp/BrowserWorld.cpp | 1 + app/src/main/cpp/Pointer.cpp | 8 +++++--- app/src/main/cpp/Pointer.h | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/BrowserWorld.cpp b/app/src/main/cpp/BrowserWorld.cpp index 779bba1c9..290f9cce6 100644 --- a/app/src/main/cpp/BrowserWorld.cpp +++ b/app/src/main/cpp/BrowserWorld.cpp @@ -367,6 +367,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) { vrb::Matrix localRotation = vrb::Matrix::Rotation(hitNormal); vrb::Matrix reorient = device->GetReorientTransform(); controller.pointer->SetTransform(reorient.AfineInverse().PostMultiply(translation).PostMultiply(localRotation)); + controller.pointer->SetScale(hitPoint, device->GetHeadTransform()); } } diff --git a/app/src/main/cpp/Pointer.cpp b/app/src/main/cpp/Pointer.cpp index 294101090..651d3650e 100644 --- a/app/src/main/cpp/Pointer.cpp +++ b/app/src/main/cpp/Pointer.cpp @@ -153,9 +153,11 @@ Pointer::SetVisible(bool aVisible) { void Pointer::SetTransform(const vrb::Matrix& aTransform) { m.transform->SetTransform(aTransform); - vrb::Vector point; - point = aTransform.MultiplyPosition(point); - const float scale = fabsf(point.z()); +} + +void +Pointer::SetScale(const vrb::Vector& aHitPoint, const vrb::Matrix& aHeadTransform) { + const float scale = (aHitPoint - aHeadTransform.MultiplyPosition(vrb::Vector(0.0f, 0.0f, 0.0f))).Magnitude(); m.pointerScale->SetTransform(vrb::Matrix::Identity().ScaleInPlace(vrb::Vector(scale, scale, scale))); } diff --git a/app/src/main/cpp/Pointer.h b/app/src/main/cpp/Pointer.h index a7ce43199..db3d9d6ec 100644 --- a/app/src/main/cpp/Pointer.h +++ b/app/src/main/cpp/Pointer.h @@ -27,6 +27,7 @@ class Pointer { bool IsLoaded() const; void SetVisible(bool aVisible); void SetTransform(const vrb::Matrix& aTransform); + void SetScale(const vrb::Vector& aHitPoint, const vrb::Matrix& aHeadTransform); void SetPointerColor(const vrb::Color& aColor); void SetHitWidget(const WidgetPtr& aWidget);