I have been working on a game engine and for it every hitbox is made from a bunch of small rectangles on the 2D quadrant plane. What I would love to have is a function takes in a hitbox and then returns a new hitbox which covers the same shape and area but with the fewest possible number of rectangles. I have found several solutions which decrease the number but nothing which guarantees the absolutely fewest number of rectangles. Here is a few examples of me solving this problem by hand.
Edit: Thanks to Klaus Gütter for linking a solution from another thread. Sorry for the duplicate. As for an implementation in C# i recommend checking out this github repo.