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

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Feb 5, 2020
1 parent e0288d2 commit e1a64f7
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,16 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
const bool wasPressed = controller.lastButtonState & ControllerDelegate::BUTTON_TRIGGER ||
controller.lastButtonState & ControllerDelegate::BUTTON_TOUCHPAD;

bool isDrag = false;
if (pressed && wasPressed && controller.widget) {
isDrag = true;
bool dragging = false;
bool wasDragging = false;
if (wasPressed) {
if (pressed) {
if (controller.widget) {
dragging = true;
}
} else {
wasDragging = true;
}
}

const vrb::Vector start = controller.StartPoint();
Expand All @@ -381,16 +388,23 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
vrb::Vector hitPoint;
vrb::Vector hitNormal;

if (isDrag) {
if (dragging) {
WidgetPtr widget = GetWidget(controller.widget);
if (resizingWidget && resizingWidget->IsResizingActive() && resizingWidget != widget) {
// Don't interact with other widgets when resizing gesture is active.
continue;
}
if (movingWidget && movingWidget->GetWidget() != widget) {
// Don't interact with other widgets when moving gesture is active.
continue;
}
vrb::Vector result;
vrb::Vector normal;
float distance = 0.0f;
bool isInWidget = false;
const bool clamp = !widget->IsResizing() && !movingWidget && !isDrag;
const bool clamp = !widget->IsResizing() && !movingWidget && !dragging;
if (widget->TestControllerIntersection(start, direction, result, normal, clamp, isInWidget, distance)) {
hitWidget = widget;
hitDistance = distance;
hitPoint = result;
hitNormal = normal;
}
Expand Down Expand Up @@ -429,7 +443,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
if (controller.pointer) {
controller.pointer->SetVisible(hitWidget.get() != nullptr);
controller.pointer->SetHitWidget(hitWidget);
if (hitWidget || isDrag) {
if (hitWidget || dragging) {
vrb::Matrix translation = vrb::Matrix::Translation(hitPoint);
vrb::Matrix localRotation = vrb::Matrix::Rotation(hitNormal);
vrb::Matrix reorient = device->GetReorientTransform();
Expand Down Expand Up @@ -517,25 +531,11 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
}
}
} else if (controller.widget) {
if(isDrag) {
WidgetPtr widget = GetWidget(controller.widget);
vrb::Vector result;
vrb::Vector normal;
float distance = 0.0f;
bool isInWidget = false;
const bool clamp = !widget->IsResizing() && !movingWidget;
if (widget->TestControllerIntersection(start, direction, result, normal, clamp, isInWidget, distance)) {
hitPoint = result;
}

float theX = 0.0f, theY = 0.0f;
widget->ConvertToWidgetCoordinates(hitPoint, theX, theY, false);
VRBrowser::HandleMotionEvent(controller.widget, controller.index, (jboolean) pressed, theX, theY);

} else {
VRBrowser::HandleMotionEvent(0, controller.index, (jboolean) pressed, 0.0f, 0.0f);
controller.widget = 0;
if (wasDragging) {
VRBrowser::HandleMotionEvent(controller.widget, controller.index, (jboolean) pressed, controller.lastTouchX, controller.lastTouchY);
}
VRBrowser::HandleMotionEvent(0, controller.index, (jboolean) pressed, 0.0f, 0.0f);
controller.widget = 0;

} else if (wasPressed != pressed) {
VRBrowser::HandleMotionEvent(0, controller.index, (jboolean) pressed, 0.0f, 0.0f);
Expand Down

0 comments on commit e1a64f7

Please sign in to comment.