8000 RmlCanvasComponent::RemapMousePos can 'leak' un-remapped screen coords through to canvas UIs. · Issue #660 · rbfx/rbfx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
RmlCanvasComponent::RemapMousePos can 'leak' un-remapped screen coords through to canvas UIs. #660
Open
@JTippetts

Description

@JTippetts

When using a RMLUI mapped to a plane for a work project, I have noticed that while the canvas UI works correctly while the mouse is over the panel geometry, when the mouse is not over the geometry the panel will still receive input events corresponding to what it would receive if the UI were placed on the screen, rather than mapped onto geometry.

https://github.com/rbfx/rbfx/blob/master/Source/Urho3D/RmlUI/RmlCanvasComponent.cpp#L221

At this block in RemapMousePos, it is supposedly iterating through a list of raycast results to find the one corresponding to the model geometry. However, instead it returns immediately if the first raycast result is not the model and is not a billboard set, leaving the input screenPos unchanged and still holding the original screen coords rather than remapped coords or invalid {-1, -1} coords. So if the mouse pointer is pointing anywhere but at the UI canvas' model, then you get the original screen coords passed along to the UI.

I can get it to work properly using something like

    for (RayQueryResult& queryResult : queryResultVector)
    {
        if (queryResult.drawable_ == model)
        {
            Vector2& uv = queryResult.textureUV_;
            IntVector2 uiSize = ToIntVector2(offScreenUI_->GetRmlContext()->GetDimensions());
            screenPos = IntVector2(static_cast<int>(uv.x_ * uiSize.x_), static_cast<int>(uv.y_ * uiSize.y_));
            return;
        }
        // Fall back to invalid coords if the model is not found in the raycast drawables vector.
        screenPos = {-1, -1};
    }

although I'm not 100% that's the right way to do it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0