packing

Packing rectangular image data into a square texture

空扰寡人 提交于 2019-11-28 18:21:22
I have N items of 2D image data that will be rectangular and I want to pack them into a single power of 2 texture as efficiently as possible. A simple non-efficient and naive implementation of an algorithm to pack these rects would be easy to whip up, but I'm sure people have come up with algorithms to do this as space efficiently as possible. I've found various references to lightmap packing which is similar to what I'm looking for, but the algorithms for lightmapping tend to take non-rectangular images into account which actually complicates things more than I need them to be. Does anyone

Why does git keep telling me it's “Auto packing the repository in background for optimum performance”?

蹲街弑〆低调 提交于 2019-11-28 15:54:19
问题 Note : I don't think this is a duplicate of this question, which is talking about a non-background pack which hangs git with a subtly different error message . In one of my git repositories, each time I invoke (for example) git fetch , git prints: Auto packing the repository in background for optimum performance. See "git help gc" for manual housekeeping. It appears to print this every time if I do a git fetch repeatedly, even when there are no changes and nothing for git fetch to do. This

C++ Data Member Alignment and Array Packing

北慕城南 提交于 2019-11-28 11:57:35
During a code review I've come across some code that defines a simple structure as follows: class foo { unsigned char a; unsigned char b; unsigned char c; } Elsewhere, an array of these objects is defined: foo listOfFoos[SOME_NUM]; Later, the structures are raw-copied into a buffer: memcpy(pBuff,listOfFoos,3*SOME_NUM); This code relies on the assumptions that: a.) The size of foo is 3, and no padding is applied, and b.) An array of these objects is packed with no padding between them. I've tried it with GNU on two platforms (RedHat 64b, Solaris 9), and it worked on both. Are the assumptions

Text packing algorithm

和自甴很熟 提交于 2019-11-28 11:21:06
I bet somebody has solved this before, but my searches have come up empty. I want to pack a list of words into a buffer, keeping track of the starting position and length of each word. The trick is that I'd like to pack the buffer efficiently by eliminating the redundancy. Example: doll dollhouse house These can be packed into the buffer simply as dollhouse , remembering that doll is four letters starting at position 0, dollhouse is nine letters at 0, and house is five letters at 3. What I've come up with so far is: Sort the words longest to shortest: (dollhouse, house, doll) Scan the buffer

Packing problem revisited

可紊 提交于 2019-11-28 05:49:36
问题 I'm developing a game and I found a problem that I have to solve to handle the layout of a component which resembles me a packing problem. To summarize what I need to do suppose I've got a space similar to the following one: +------------+---------+------------+ | 0 | 1 | 2 | | | | | | | | | | | | | +------------+---------+------------+ | 3 | 4 | 5 | | | | | | | | | +------------+---------+------------+ | 6 | 7 | 8 | | | | | | | | | | | | | +------------+---------+------------+ in which every

packing algorithm in rtree in boost

巧了我就是萌 提交于 2019-11-28 03:16:31
问题 Hi all I understand that if rtree is created with range values in boost it would use packing algorithm. I need an example of rtree using packing algorithm. Here is my code that uses quadratic algorithm using point = bg::model::point < int, 2, bg::cs::cartesian >; using pointI = std::pair<point, std::size_t>; vector<point> contourCenters // has some value bgi::rtree< pointI, bgi::quadratic<16> > rtree; vector< pointI > cloud; for (size_t i = 0; i < contourCenters.size(); ++i) { int x =

Given a target sum and a set of integers, find the closest subset of numbers that add to that target

元气小坏坏 提交于 2019-11-27 12:22:38
问题 I have a set of integers M and a target sum k. I want to find the subset of M that when added together is the closest to k without going over. For example: M = {1, 3, 5, 5, 14} k = 12 answer = {1, 5, 5} because 1 + 5 + 5 = 11 and there is no way to make 12. I have the additional constraint that the subset can contain at most 4 elements. In my application, the size of |M| can be large (on the order of thousands of elements). If it is not possible to find the optimal answer in a reasonable time

Packing rectangular image data into a square texture

馋奶兔 提交于 2019-11-27 11:28:45
问题 I have N items of 2D image data that will be rectangular and I want to pack them into a single power of 2 texture as efficiently as possible. A simple non-efficient and naive implementation of an algorithm to pack these rects would be easy to whip up, but I'm sure people have come up with algorithms to do this as space efficiently as possible. I've found various references to lightmap packing which is similar to what I'm looking for, but the algorithms for lightmapping tend to take non

Why doesn't C++ make the structure tighter?

安稳与你 提交于 2019-11-27 07:59:52
For example, I have a class , class naive { public: char a; long long b; char c; int d; }; and according to my testing program, a to d are built one after another, like a------- bbbbbbbb c---dddd - means unused. Why does not C++ make it tighter, like ac--dddd bbbbbbbb Class and struct members are required by the standard to be stored in memory in the same order in which they are declared. So in your example, it wouldn't be possible for d to appear before b . Also, most architectures prefer that multi-byte types are aligned on 4- or 8-byte boundaries. So all the compiler can do is leave empty

C++ Data Member Alignment and Array Packing

烈酒焚心 提交于 2019-11-27 06:44:33
问题 During a code review I've come across some code that defines a simple structure as follows: class foo { unsigned char a; unsigned char b; unsigned char c; } Elsewhere, an array of these objects is defined: foo listOfFoos[SOME_NUM]; Later, the structures are raw-copied into a buffer: memcpy(pBuff,listOfFoos,3*SOME_NUM); This code relies on the assumptions that: a.) The size of foo is 3, and no padding is applied, and b.) An array of these objects is packed with no padding between them. I've