Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Use real hitPoint distance for pointer scale (#1361)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and bluemarvin committed Jul 3, 2019
1 parent c2dfa60 commit 5048229
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
8 changes: 5 additions & 3 deletions app/src/main/cpp/Pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/Pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5048229

Please sign in to comment.