Skip to content

Commit

Permalink
*Actually* reduce the size of the structure
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Sep 20, 2023
1 parent f1d9aab commit f46680e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1296,17 +1296,20 @@ long long choose_minextent(std::vector<long long> &extents, double f) {

struct joint {
long long x : 34; // enough to wrap around the world either way
long long y : 33; // enough to touch the top and bottom of the world
unsigned long long p1 : 64 - 34;

unsigned long long p1p2 : 61;
long long y : 33; // enough to touch the top and bottom of the world
unsigned long long p2 : 64 - 34;

joint(draw one, draw hinge, draw two) {
if (one < two) {
std::swap(one, two);
}

long long coord[4] = {one.x, one.y, two.x, two.y};
p1p2 = fnv1a(std::string((const char *) &coord, sizeof(coord)));
long long coord1[2] = {one.x, one.y};
long long coord2[2] = {two.x, two.y};
p1 = fnv1a(std::string((const char *) &coord1, sizeof(coord1)));
p2 = fnv1a(std::string((const char *) &coord2, sizeof(coord2)));

x = hinge.x;
y = hinge.y;
Expand All @@ -1319,8 +1322,12 @@ struct joint {
if (x < o.x) {
return true;
} else if (x == o.x) {
if (p1p2 < o.p1p2) {
if (p1 < o.p1) {
return true;
} else if (p1 == o.p1) {
if (p2 < o.p2) {
return true;
}
}
}
}
Expand Down Expand Up @@ -2436,7 +2443,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
for (size_t i = 0; i + 1 < shared_joints.size(); i++) {
if (shared_joints[i].x == shared_joints[i + 1].x &&
shared_joints[i].y == shared_joints[i + 1].y) {
if (shared_joints[i].p1p2 != shared_joints[i + 1].p1p2) {
if (shared_joints[i].p1 != shared_joints[i + 1].p1 ||
shared_joints[i].p2 != shared_joints[i + 1].p2) {
shared_nodes.push_back(draw(VT_MOVETO, shared_joints[i].x, shared_joints[i].y));
}
}
Expand Down

0 comments on commit f46680e

Please sign in to comment.