Jump to content

Movable HUD


photo

Recommended Posts

Posted

Hi,
I am currently working on a project that requires an HUD system composed of various elements (many of which are just lines, or in the worst case, very simple polygons) that need to be moved and updated every frame. Currently, I am using a single canvas to draw each of them. When I need to move them (which happens almost every frame), I clear the canvas and redraw everything with updated positions and orientations, since I haven't found a way to directly move the lines and polygons inside the canvas. However, I’m concerned that this approach might negatively impact performance.

The only alternative I can think of is to use a separate canvas for each line/polygon and move/resize the canvas itself, but that seems much more complex, and I don’t believe it would be better in terms of performance. Is there a better approach to handle this, or is my current method the best practice? Should I be concerned about performance, or is this still a lightweight operation even if it's performed every frame that won’t significantly impact the overall performance of the application , which is already quite performance-critical?

Posted

Hi Filippo,

Could you please send us your current WidgetCanvas code that's causing the lags (or perhaps a small test component with the required dependencies)?

It would be interesting to see what's going on. Maybe we could also find a way to optimize or rewrite the code to make it run faster.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

At the moment, it's actually not causing any lag, as I’ve just started developing this part related to the HUD interface. My question was more general and "theoretical" since I was wondering whether the best approach for handling a constantly moving HUD that needs to be repositioned and adjusted every frame is to draw it on a canvas, clear the canvas each frame, and redraw it, or if there’s a more efficient way to simply move the canvas elements.

I opened this topic because I know this is a very engine-specific subject, and since this will be a relatively long development process, I’d like to start with the best approach from the beginning rather than having to rework everything later on.

Thanks a lot in advance for your response and for the time you’re dedicating to me!

  • Thanks 1
Posted

yes sure, you can modify lines and polygons in runtime, to avoid full redraw canvas.
for changing points of polygon you can use setPolygonPoint for changing points of line you can use setLinePoint.
also you can change the whole transform (translate and rotation for polygon/line) throu setLineTransform and setPolygonTransform

Here is sample of how to create simple Attitude indicator by widget canvas(I'm not sure it works correctly, it's more of a snippet from one of the demo projects on how to use canvas functions.)

horizont.hpp

  • Like 2
×
×
  • Create New...