mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:03:53 +02:00
Fix hover -> unhover overlay behavior
This commit is contained in:
parent
e3f2e70bca
commit
0eafdeab14
2 changed files with 12 additions and 6 deletions
|
@ -65,6 +65,7 @@ static const uint32_t LEFT_HAND_HW_ID = 1;
|
|||
static const xColor CONTEXT_OVERLAY_COLOR = { 255, 255, 255 };
|
||||
static const float CONTEXT_OVERLAY_INSIDE_DISTANCE = 1.0f; // in meters
|
||||
static const float CONTEXT_OVERLAY_SIZE = 0.09f; // in meters, same x and y dims
|
||||
static const float CONTEXT_OVERLAY_OFFSET_DISTANCE = 0.1f;
|
||||
static const float CONTEXT_OVERLAY_OFFSET_ANGLE = 10.0f;
|
||||
static const float CONTEXT_OVERLAY_UNHOVERED_ALPHA = 0.85f;
|
||||
static const float CONTEXT_OVERLAY_HOVERED_ALPHA = 1.0f;
|
||||
|
@ -72,7 +73,6 @@ static const float CONTEXT_OVERLAY_UNHOVERED_PULSEMIN = 0.6f;
|
|||
static const float CONTEXT_OVERLAY_UNHOVERED_PULSEMAX = 1.0f;
|
||||
static const float CONTEXT_OVERLAY_UNHOVERED_PULSEPERIOD = 1.0f;
|
||||
static const float CONTEXT_OVERLAY_UNHOVERED_COLORPULSE = 1.0f;
|
||||
static const float CONTEXT_OVERLAY_FAR_OFFSET = 0.1f;
|
||||
|
||||
void ContextOverlayInterface::setEnabled(bool enabled) {
|
||||
_enabled = enabled;
|
||||
|
@ -124,14 +124,18 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
|
|||
contextOverlayPosition = cameraPosition + CONTEXT_OVERLAY_INSIDE_DISTANCE * (qApp->getCamera().getOrientation() * Vectors::FRONT);
|
||||
contextOverlayDimensions = glm::vec2(CONTEXT_OVERLAY_SIZE, CONTEXT_OVERLAY_SIZE) * glm::distance(contextOverlayPosition, cameraPosition);
|
||||
} else {
|
||||
// Else if the entity is too close to the camera...
|
||||
// ...rotate the Context Overlay some number of degrees offset from the entity.
|
||||
// This makes it easy to inspect things you're holding.
|
||||
// Rotate the Context Overlay some number of degrees offset from the entity
|
||||
// along the line cast from your head to the entity's bounding box.
|
||||
glm::vec3 direction = glm::normalize(entityPosition - cameraPosition);
|
||||
float distance;
|
||||
BoxFace face;
|
||||
glm::vec3 normal;
|
||||
boundingBox.findRayIntersection(cameraPosition, direction, distance, face, normal);
|
||||
float offsetAngle = -CONTEXT_OVERLAY_OFFSET_ANGLE;
|
||||
if (event.getID() == LEFT_HAND_HW_ID) {
|
||||
offsetAngle *= -1;
|
||||
}
|
||||
contextOverlayPosition = (glm::quat(glm::radians(glm::vec3(0.0f, offsetAngle, 0.0f))) * (entityPosition - cameraPosition)) + cameraPosition;
|
||||
contextOverlayPosition = (glm::quat(glm::radians(glm::vec3(0.0f, offsetAngle, 0.0f)))) * ((cameraPosition + direction * distance) - direction * CONTEXT_OVERLAY_OFFSET_DISTANCE);
|
||||
contextOverlayDimensions = glm::vec2(CONTEXT_OVERLAY_SIZE, CONTEXT_OVERLAY_SIZE) * glm::distance(contextOverlayPosition, cameraPosition);
|
||||
}
|
||||
|
||||
|
|
|
@ -298,6 +298,9 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
var intersection = controllerData.rayPicks[this.hand];
|
||||
var offOverlay = (intersection.type !== RayPick.INTERSECTED_OVERLAY);
|
||||
var triggerOff = (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE);
|
||||
if (triggerOff) {
|
||||
this.deleteContextOverlay();
|
||||
}
|
||||
var grabbingOverlay = this.grabModuleWantsNearbyOverlay(controllerData);
|
||||
return offOverlay || grabbingOverlay || triggerOff;
|
||||
};
|
||||
|
@ -308,7 +311,6 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.laserPressExit();
|
||||
this.laserPressingTarget = false;
|
||||
}
|
||||
this.deleteContextOverlay();
|
||||
this.relinquishTouchFocus();
|
||||
this.reset();
|
||||
this.updateLaserPointer();
|
||||
|
|
Loading…
Reference in a new issue