Combining shape into fewest number of rectangles

   1652   4   1
User Avatar
Member
34 posts
Joined: Nov. 2016
Offline
I'm stuck trying to come up with a solution in Houdini to handle taking a 2d input shape and creating the fewest number of rectangles to fill the space. Something similar to these examples in order to generate a series of rectangular volumes in a game engine.



algorithm for finding fewest rectangles to cover a set [stackoverflow.com]

I thought maybe I could abuse the UVlayout SOP to do some box packing but I havent had much luck on that front.
I've managed to take an input shape (red) and convert it into a rectilinear polygon. I'm stuck at trying to figure out how to now recursively subdivide it down into the fewest number of rectangles.



Hoping someone may have a suggestion on how to approach this. Thanks!
Edited by TheProgg - March 9, 2022 10:33:53
User Avatar
Member
339 posts
Joined: June 2013
Online
Would like to know if there's indeed a solution to this.
User Avatar
Member
339 posts
Joined: June 2013
Online
Some progress, but still some edge cases to solve
User Avatar
Member
5 posts
Joined: Oct. 2014
Offline
Any tips on how you're achieving this? I'm trying to solve a similar problem, where I'm trying to partition heightmap cliff geometry into rectangular-ish clusters in order to instance rocks.

Attachments:
1.PNG (712.9 KB)

User Avatar
Member
339 posts
Joined: June 2013
Online
Jolly
Any tips on how you're achieving this? I'm trying to solve a similar problem, where I'm trying to partition heightmap cliff geometry into rectangular-ish clusters in order to instance rocks.

I don't see how this is the same problem. Is HF a grid? Yes, but much much finer one than the one I'm dealing with, then you also have height which what I was looking for does account for. I presume you want the edges aligned with the slope. In my case they are always aligned with the axis. Maybe another time I come up with an abstract solution for any orientation (2D)
  • Quick Links