Re: [Algorithms] Compose rectangles within another rectangle
Brought to you by:
vexxed72
From: Jason H. <jh...@st...> - 2010-01-22 21:39:50
|
This is called bin packing. You'll find much research on it, and even this very question has been answered a few times in the archives of this list. To save you a few seconds, some folks suggest an approach similar to Tetris. Personally, I sort rectangles by the longest axis and pack from longer to shorter, minimizing the distance to the origin of the texture sheet when placing them. That tends to work pretty well. If you can do it offline, slowly shuffling the order you submit the rectangles a little bit can get you some good gains over the simple sorting method, but it all depends on how much effort you want to put into it. Best of luck, JH Jason Hughes President Steel Penny Games, Inc. Austin, TX Arno Gerretsen wrote: > Hi, > > I am looking for an algorithm that can help me to compose a number of > rectangles, with different sizes, within a bigger rectangle. So I want > to pack them most efficiently within the bigger rectangle. Does anybody > know the best approach to this, except for just trial and error. > > The background is that I want to compose a big texture sheet from a > collection of smaller texture pieces automaticaly. > > |