scriptum / Cheetah-Texture-Packer

High efficient and fast 2D bin packing tool
GNU Lesser General Public License v3.0
237 stars 49 forks source link

Aligning sprites? [enhancement] #11

Open pdJeeves opened 6 years ago

pdJeeves commented 6 years ago

I want the sprites to be 4-pixel aligned, so that when it undergoes S3 compression there aren't any blocks of pixels that contain parts of two different sprites, and I can't figure out how to do it. I've already made it extrude the sprites so that they're dimensions are both multiples of 4 (see my fork); thinking that would automatically pack them in an aligned way, which didn't work. Then I tried dividing the size by the alignment at the start of MaxRects::insertNode, and multiplying the resulting position by the alignment before returning, and that didin't work either, so I'm out of ideas.

scriptum commented 6 years ago

Hello! Possible solution - "virtualize" extrusion of sprites. Means that while packing sprites, algorithm should operate with 4-pixel rounded rectangles, while sprites remain with its own size. I think this method should work, didn't look at source code.