#Improved Custom Formations

1 messages · Page 1 of 1 (latest)

unkempt falcon
#

Download: https://github.com/zxbc/BAR_widgets/blob/main/cmd_customformations2.lua

TL;DR version of the story: formation move (right click drag) quality should be improved for large groups (>100).

The long version:

Because @proper elbow updated the default time limit for formation move calculation to 10ms (from the old 50ms) to reduce stutter, the overall quality of node matching is worse. I have (hopefully) improved the default matching algorithm (not the Hungarian algorithm, which only takes effect for small unit count) by doing the following:

  • Distance matrices calculation and sorting are moved to Update, using stale (by 2 frames) unit and node positions during formation draw. The stale positions should not affect overall quality of matching too much while processing time is entirely removed from MouseRelease() onward to give way for more actual optimization in clash resolution.

  • Clash reduction reworked. Binning of clash checking is used as a heuristic to reduce higher tier iterations count. The algorithm now works into smaller and smaller bin sizes as more time is left. This should take care of "long distance clashes" in earlier iterations, and move fine improvements to later iterations. If/when time runs out, the code terminates just like before, hopefully at a better state as a result.

  • Added some debug messages for the new changes (set true to defaultMode at the top to see).

  • Added mouse drag threshold: now the minimal draggable formation is tied to mouse drag threshold set in options.

Please report any abnormal behavior or bugs if you encounter any, and let me know if you see any actual improvements!

NOTE: Copying the file into your widgets folder and loading it will automatically replace in-game version.

regal latch
#

Do you have a video demonstration of this widget? I'm interested to see what it does differently to the current engine release (which had formation improvements of its own.)

unkempt falcon
#

obviously I have no way to compare it to the engine improvement in the next version

regal latch
#

Sorry, I mean the improvements in engine are already live.

#

Okay, I'll take a look. Are there any special controls or does it just replace line drawing, and the ctrl+alt commands?

unkempt falcon
unkempt falcon
regal latch
#

Ah, okay. So not the shape formations (like box formations) then.

unkempt falcon
#

nope, just dragging a shape with right mouse button

#

I think you might see some differences when you have a complex shape and a very large group (>200 units)

regal latch
#

Okay, I see. Yikes. Does it really use up to 10ms?

unkempt falcon
#

I'd really like to see this functionality moved into engine tbh, it's one of those things that can be done much faster that way since a lot of it is raw computation of numbers

regal latch
#

That's what I am thinking.

unkempt falcon
#

the engine can also hide some of the UI latency introduced, by simply delaying the command issuing slightly

#

@proper elbow said it's possible to do it in a compute shader, which I have no knowledge about, but I'll look into it

regal latch
#

That's an interesting idea.

unkempt falcon
#

yeah, I think maybe it's possible to do more with compute shaders in general for what currently get relegated to simple Lua code

urban sapphire
#

just fyi, got this error during a game:

[t=08:21:09.359801][f=0079836] Error: [LuaUI::RunCallInTraceback] error=2 (LUA_ERRRUN) callin=MouseRelease trace=[Internal Lua error: Call failure] [string "LuaUI\Widgets\cmd_customformations2.lua"]:1322: attempt to index local 'aRow' (a nil value)

unkempt falcon
proper elbow
#

Damns I totally missed testing this last night 😢

unkempt falcon
#

I really want my weapon range widget to give terrain-accurate ranges for once

proper elbow
unkempt falcon
#

I'll probably do a separate addon though, but use the same or mostly same shader

#

so I can have greater control of what gets displayed and what not, I plan to make it so user can configure themselves through their own config file

proper elbow
#

It needs an unholy merger of two or more bits of code

unkempt falcon
#

I already have the bulk ready

proper elbow
#

defrange gl4 is a great base

unkempt falcon
#

I just need to copy over the shader

proper elbow
#

BUT

#

defrange gl4 is not unit-attached

unkempt falcon
#

I'm currently using drawprimitive like the DPAT example

proper elbow
#

its static world post

#

ah that is very good then

unkempt falcon
#

I have to somehow use the shader code in there though

proper elbow
#

DPAT uses a geometry shader, I would kind of advise against a geometry shader for this case

unkempt falcon
#

yes, exactly

proper elbow
#

Have a circle VBO just like defrange, but place it at worldpos via the unitID switches present in DPAT

#

DPAT isnt terribly difficult to use

#

Also, you will need the selection logic from selected units gl4 (which uses DPAT iirc)

unkempt falcon
proper elbow
#

And the whole stenciling stuff would be icing on the cake

unkempt falcon
#

I already have a stencil version

proper elbow
unkempt falcon
#

basically I have a working version with everything, stenciled ranges, on selected units, but it's drawn using the DPAT shader

#

I need to copy over the defenserange shader and then add position info update

proper elbow
#

If you are stuck with that bit, Ill gladly help

unkempt falcon
#

ok, I'll let you know if I'm stuck

proper elbow
#

thats non trivial

unkempt falcon
#

yeah I need to learn how to code shader anyway, I'll figure it out slowly

#

either that or I migrate the code over to LoS shader, which is another version of a similar shader but with positional info built in

proper elbow
unkempt falcon
#

I noticed, but nevertheless it teaches me some aspects of writing a custom shader

#

I'll try work with defenserange shader the best I can

#

this is with DPAT shader

#

this is with LoS shader

#

also, wrong thread, I'm going to talk about this in modding discussion instead from here on

proper elbow
#

Btw

#

There is a construct for fast shader reloads

#

See example in metalspots widget

urban sapphire
#

got this on latest version:

[t=08:51:20.782922][f=0008220] Error: [LuaUI::RunCallInTraceback] error=2 (LUA_ERRRUN) callin=MouseRelease trace=[Internal Lua error: Call failure] [string "LuaUI\Widgets\cmd_customformations2.lua"]:633: attempt to index local 'pos' (a nil value)

#

potentially related to dragging mouse off edge of map (happens e.g. bottom lane Koom)