Description
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.