mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 14:12:50 +02:00
working on overlay bugs
This commit is contained in:
parent
e77cdfc0d2
commit
71653f95d7
8 changed files with 19 additions and 31 deletions
|
@ -2282,7 +2282,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
|
||||
// Setup the mouse ray pick and related operators
|
||||
{
|
||||
auto mouseRayPick = std::make_shared<RayPick>(Vectors::ZERO, Vectors::UP, PickFilter(PickScriptingInterface::PICK_ENTITIES()), 0.0f, true);
|
||||
auto mouseRayPick = std::make_shared<RayPick>(Vectors::ZERO, Vectors::UP, PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_LOCAL_ENTITIES()), 0.0f, true);
|
||||
mouseRayPick->parentTransform = std::make_shared<MouseTransformNode>();
|
||||
mouseRayPick->setJointState(PickQuery::JOINT_STATE_MOUSE);
|
||||
auto mouseRayPickID = DependencyManager::get<PickManager>()->addPick(PickQuery::Ray, mouseRayPick);
|
||||
|
|
|
@ -70,7 +70,6 @@ ContextOverlayInterface::ContextOverlayInterface() {
|
|||
}
|
||||
});
|
||||
connect(entityScriptingInterface, &EntityScriptingInterface::deletingEntity, this, &ContextOverlayInterface::deletingEntity);
|
||||
connect(&qApp->getOverlays(), &Overlays::mousePressOnOverlay, this, &ContextOverlayInterface::contextOverlays_mousePressOnOverlay);
|
||||
connect(&qApp->getOverlays(), &Overlays::hoverEnterOverlay, this, &ContextOverlayInterface::contextOverlays_hoverEnterOverlay);
|
||||
connect(&qApp->getOverlays(), &Overlays::hoverLeaveOverlay, this, &ContextOverlayInterface::contextOverlays_hoverLeaveOverlay);
|
||||
|
||||
|
@ -103,10 +102,14 @@ void ContextOverlayInterface::setEnabled(bool enabled) {
|
|||
}
|
||||
}
|
||||
|
||||
void ContextOverlayInterface::clickDownOnEntity(const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||
if (_enabled && event.getButton() == PointerEvent::SecondaryButton && contextOverlayFilterPassed(entityItemID)) {
|
||||
_mouseDownEntity = entityItemID;
|
||||
void ContextOverlayInterface::clickDownOnEntity(const EntityItemID& id, const PointerEvent& event) {
|
||||
if (_enabled && event.getButton() == PointerEvent::SecondaryButton && contextOverlayFilterPassed(id)) {
|
||||
_mouseDownEntity = id;
|
||||
_mouseDownEntityTimestamp = usecTimestampNow();
|
||||
} else if (id == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
|
||||
qCDebug(context_overlay) << "Clicked Context Overlay. Entity ID:" << _currentEntityWithContextOverlay << "ID:" << id;
|
||||
emit contextOverlayClicked(_currentEntityWithContextOverlay);
|
||||
_contextOverlayJustClicked = true;
|
||||
} else {
|
||||
if (!_currentEntityWithContextOverlay.isNull()) {
|
||||
disableEntityHighlight(_currentEntityWithContextOverlay);
|
||||
|
@ -249,14 +252,6 @@ bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityIt
|
|||
return ContextOverlayInterface::destroyContextOverlay(entityItemID, PointerEvent());
|
||||
}
|
||||
|
||||
void ContextOverlayInterface::contextOverlays_mousePressOnOverlay(const QUuid& id, const PointerEvent& event) {
|
||||
if (id == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
|
||||
qCDebug(context_overlay) << "Clicked Context Overlay. Entity ID:" << _currentEntityWithContextOverlay << "ID:" << id;
|
||||
emit contextOverlayClicked(_currentEntityWithContextOverlay);
|
||||
_contextOverlayJustClicked = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContextOverlayInterface::contextOverlays_hoverEnterOverlay(const QUuid& id, const PointerEvent& event) {
|
||||
if (_contextOverlayID != UNKNOWN_ENTITY_ID) {
|
||||
qCDebug(context_overlay) << "Started hovering over Context Overlay. ID:" << id;
|
||||
|
|
|
@ -65,7 +65,6 @@ public slots:
|
|||
bool createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||
bool destroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||
bool destroyContextOverlay(const EntityItemID& entityItemID);
|
||||
void contextOverlays_mousePressOnOverlay(const QUuid& id, const PointerEvent& event);
|
||||
void contextOverlays_hoverEnterOverlay(const QUuid& id, const PointerEvent& event);
|
||||
void contextOverlays_hoverLeaveOverlay(const QUuid& id, const PointerEvent& event);
|
||||
void contextOverlays_hoverEnterEntity(const EntityItemID& entityID, const PointerEvent& event);
|
||||
|
|
|
@ -63,13 +63,6 @@ Overlays::Overlays() {
|
|||
ADD_TYPE_MAP(PolyLine, line3d);
|
||||
ADD_TYPE_MAP(Grid, grid);
|
||||
ADD_TYPE_MAP(Gizmo, circle3d);
|
||||
|
||||
auto mouseRayPick = std::make_shared<RayPick>(Vectors::ZERO, Vectors::UP,
|
||||
PickFilter(PickFilter::getBitMask(PickFilter::FlagBit::LOCAL_ENTITIES) |
|
||||
PickFilter::getBitMask(PickFilter::FlagBit::VISIBLE)), 0.0f, true);
|
||||
mouseRayPick->parentTransform = std::make_shared<MouseTransformNode>();
|
||||
mouseRayPick->setJointState(PickQuery::JOINT_STATE_MOUSE);
|
||||
_mouseRayPickID = DependencyManager::get<PickManager>()->addPick(PickQuery::Ray, mouseRayPick);
|
||||
}
|
||||
|
||||
void Overlays::cleanupAllOverlays() {
|
||||
|
@ -1228,12 +1221,12 @@ static PointerEvent::Button toPointerButton(const QMouseEvent& event) {
|
|||
}
|
||||
}
|
||||
|
||||
RayToOverlayIntersectionResult getPrevPickResult(unsigned int mouseRayPickID) {
|
||||
RayToOverlayIntersectionResult getPrevPickResult() {
|
||||
RayToOverlayIntersectionResult overlayResult;
|
||||
overlayResult.intersects = false;
|
||||
auto pickResult = DependencyManager::get<PickManager>()->getPrevPickResultTyped<RayPickResult>(mouseRayPickID);
|
||||
auto pickResult = DependencyManager::get<PickManager>()->getPrevPickResultTyped<RayPickResult>(DependencyManager::get<EntityTreeRenderer>()->getMouseRayPickID());
|
||||
if (pickResult) {
|
||||
overlayResult.intersects = pickResult->type != IntersectionType::NONE;
|
||||
overlayResult.intersects = pickResult->type == IntersectionType::LOCAL_ENTITY;
|
||||
if (overlayResult.intersects) {
|
||||
overlayResult.intersection = pickResult->intersection;
|
||||
overlayResult.distance = pickResult->distance;
|
||||
|
@ -1281,7 +1274,7 @@ std::pair<float, QUuid> Overlays::mousePressEvent(QMouseEvent* event) {
|
|||
PerformanceTimer perfTimer("Overlays::mousePressEvent");
|
||||
|
||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||
RayToOverlayIntersectionResult rayPickResult = getPrevPickResult(_mouseRayPickID);
|
||||
RayToOverlayIntersectionResult rayPickResult = getPrevPickResult();
|
||||
if (rayPickResult.intersects) {
|
||||
_currentClickingOnOverlayID = rayPickResult.overlayID;
|
||||
|
||||
|
@ -1305,7 +1298,7 @@ bool Overlays::mouseDoublePressEvent(QMouseEvent* event) {
|
|||
PerformanceTimer perfTimer("Overlays::mouseDoublePressEvent");
|
||||
|
||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||
RayToOverlayIntersectionResult rayPickResult = getPrevPickResult(_mouseRayPickID);
|
||||
RayToOverlayIntersectionResult rayPickResult = getPrevPickResult();
|
||||
if (rayPickResult.intersects) {
|
||||
_currentClickingOnOverlayID = rayPickResult.overlayID;
|
||||
|
||||
|
@ -1321,7 +1314,7 @@ bool Overlays::mouseReleaseEvent(QMouseEvent* event) {
|
|||
PerformanceTimer perfTimer("Overlays::mouseReleaseEvent");
|
||||
|
||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||
RayToOverlayIntersectionResult rayPickResult = getPrevPickResult(_mouseRayPickID);
|
||||
RayToOverlayIntersectionResult rayPickResult = getPrevPickResult();
|
||||
if (rayPickResult.intersects) {
|
||||
auto pointerEvent = calculateOverlayPointerEvent(rayPickResult.overlayID, ray, rayPickResult, event, PointerEvent::Release);
|
||||
mouseReleasePointerEvent(rayPickResult.overlayID, pointerEvent);
|
||||
|
@ -1343,7 +1336,7 @@ bool Overlays::mouseMoveEvent(QMouseEvent* event) {
|
|||
PerformanceTimer perfTimer("Overlays::mouseMoveEvent");
|
||||
|
||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||
RayToOverlayIntersectionResult rayPickResult = getPrevPickResult(_mouseRayPickID);
|
||||
RayToOverlayIntersectionResult rayPickResult = getPrevPickResult();
|
||||
if (rayPickResult.intersects) {
|
||||
auto pointerEvent = calculateOverlayPointerEvent(rayPickResult.overlayID, ray, rayPickResult, event, PointerEvent::Move);
|
||||
mouseMovePointerEvent(rayPickResult.overlayID, pointerEvent);
|
||||
|
|
|
@ -719,7 +719,6 @@ private:
|
|||
PointerEvent calculateOverlayPointerEvent(const QUuid& id, const PickRay& ray, const RayToOverlayIntersectionResult& rayPickResult,
|
||||
QMouseEvent* event, PointerEvent::EventType eventType);
|
||||
|
||||
unsigned int _mouseRayPickID;
|
||||
QUuid _currentClickingOnOverlayID;
|
||||
QUuid _currentHoverOverOverlayID;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
static void setEntityLoadingPriorityFunction(CalculateEntityLoadingPriority fn) { _calculateEntityLoadingPriorityFunc = fn; }
|
||||
|
||||
void setMouseRayPickID(unsigned int rayPickID) { _mouseRayPickID = rayPickID; }
|
||||
unsigned int getMouseRayPickID() { return _mouseRayPickID; }
|
||||
void setMouseRayPickResultOperator(std::function<RayToEntityIntersectionResult(unsigned int)> getPrevRayPickResultOperator) { _getPrevRayPickResultOperator = getPrevRayPickResultOperator; }
|
||||
void setSetPrecisionPickingOperator(std::function<void(unsigned int, bool)> setPrecisionPickingOperator) { _setPrecisionPickingOperator = setPrecisionPickingOperator; }
|
||||
|
||||
|
|
|
@ -578,7 +578,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
}
|
||||
_this.teleportedFadeTimer = null;
|
||||
Selection.disableListHighlight(this.teleporterSelectionName);
|
||||
Selection.disableListHighlight(_this.teleporterSelectionName);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -161,7 +161,8 @@ ExtendedOverlay.unHover = function () { // calls hover(false) on lastHoveringId
|
|||
// hit(overlay) on the one overlay intersected by pickRay, if any.
|
||||
// noHit() if no ExtendedOverlay was intersected (helps with hover)
|
||||
ExtendedOverlay.applyPickRay = function (pickRay, hit, noHit) {
|
||||
var pickedOverlay = Overlays.findRayIntersection(pickRay); // Depends on nearer coverOverlays to extend closer to us than farther ones.
|
||||
// TODO: this could just include the necessary overlays for better performance
|
||||
var pickedOverlay = Overlays.findRayIntersection(pickRay, true); // Depends on nearer coverOverlays to extend closer to us than farther ones.
|
||||
if (!pickedOverlay.intersects) {
|
||||
if (noHit) {
|
||||
return noHit();
|
||||
|
|
Loading…
Reference in a new issue