I have a widget with a series of points, I’ve calculated an array of points for the convex hull, but how should I go about “drawing” it? I’m not looking for someone to do the work for me, just need some high level ideas on where to start, I’m not familiar with what options the engine has for this.
The map is zoomable and pannable, so I’m not sure if screen space solutions will work. Any ideas?
Seeing as this sounds as a fairly complex widget, I’ll assume you’re doing this in C++.
Usually when I make custom widget functionality I try to find a similar widget (either in UE or in the project), and Tools->Debug->Widget Reflector is great for that because you can inspect basically anything slate-related you find in UE. For a good example of line drawing (and other primitives) take a look at SWorldPartitionEditorGrid2D::OnPaint, which will lead you to FSlateDrawElement::MakeLines (and other similar functions).
(if you’re not using C++ you would override OnPaint in your widget graph and use DrawLine and similar functions on the context object)
I use both what ever is easier for the situation, I was looking at onpaint, and maybe I misunderstood, but would drawn elements scale and translate with the rest of the widget? Earlier I thought this could be the solution but I was told no, they wouldn’t scale or translate with the rest of the widget.
That’s correct, they wouldn’t scale or translate (if we just look at the drawing logic in a vacuum).
However, if your points are represented by widgets you can use their screen locations to draw the lines, which should cause the lines to align with the points no matter how the widget is scaled/translated.
Alternatively, if the points are not widgets (and they’re just points in the world), you can project them to the screen and draw lines that way, which should have the same effect, unless I misunderstood something.
If positions are World :You can project screen then draw or you can just use something like Niagara to construct beams between points, think can be interesting aswell.
If they are Screen/Widget : then think draw line would solve it.