fix: Minimap.GetDotsBitmap()
This change has a lot of stuff, so I'm going over it in this message.
The current version of Minimap.GetDotsBitmap() has several flaws:
- requires the dot shadows to have at least 2 black pixels visible
- It's possible to make minimap dots to have only 1 black pixel visible on certain angles and scenarios.
- They can't be just any pixels, there's only 3 combinations that will work out of the 5 or 6 that exist.
- Depending on how things overlap you might actually detect multiple dots per dot.
My change tries to address all of this.
First, the shadow logic was separated into it's own function TRSMinimap.FindDotShadows() and it's the core of all of this.
This method is large and complex but once you understand how it works it should be fairly easy to understand.
-
TRSMinimap.FindDotShadows()is slower than the current live version but only by 1.5/2 times which is pretty good if you have in mind it checks almost 20 times more pixels. -
The way it works is roughly like this:
- There's 2 main loops:
- The first one we go over all the black pixels and marks what is undoubtly a minimap dot shadow, the dot center, and what are likely map icons.
- We read colors and mark what we know so far in a matrix that is generated as we need. Generating a full matrix of the bitmap at the start was incredibly slow (70 to 90 times slower) so this was the best approach I found. Basically a hashmap of the values we are reading/setting.
- The second loop goes over the left over black pixels and generate a TPA of possible candidates for a dot shadow
- For each candidate point we apply certain rules and if they don't pass they are discarded. Some rule examples are:
- Bottom black pixels of a minimap dot can never have a black pixel right below it.
- Candidates can never exist over what is a known dot center
- We do this until we only have 4 candidates, or only 2 that could be bottom pixels or the top pixels
There are still some scenarios where this new method breaks but they are very few and way less than the previous method
- There's 2 main loops: