Skip to content

Commit

Permalink
Fix Z color delay #23
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Aug 26, 2024
1 parent 533d8d7 commit 6ba5768
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,32 @@ Drawer::Drawer(SDL_Window *window, DataFrame df)

this->npoints = x.length();

this->minx = min(x);
this->miny = min(y);
this->minz = min(z);
this->maxx = max(x);
this->maxy = max(y);
this->maxz = max(z);
PSquare zp99(0.99);
this->minx = this->maxx = x[0];
this->miny = this->maxy = y[0];
this->minz = this->maxz = z[0];
for (int i = 1; i < this->npoints; ++i)
{
if (x[i] < this->minx) this->minx = x[i];
if (x[i] > this->maxx) this->maxx = x[i];

if (y[i] < this->miny) this->miny = y[i];
if (y[i] > this->maxy) this->maxy = y[i];

if (z[i] < this->minz) this->minz = z[i];
if (z[i] > this->maxz) this->maxz = z[i];

zp99.addDataPoint(z[i]);
}
this->xcenter = (maxx+minx)/2;
this->ycenter = (maxy+miny)/2;
this->zcenter = (maxz+minz)/2;
this->xrange = maxx-minx;
this->yrange = maxy-miny;
this->zrange = maxz-minz;
this->range = std::max(xrange, yrange);
this->zqmin = minz;
this->zqmax = zp99.getQuantile();

this->draw_index = false;
this->point_budget = 300000;
Expand Down Expand Up @@ -185,11 +198,9 @@ void Drawer::setAttribute(Attribute x)
}
else
{
PSquare p99(0.99);
for (const auto& pz : z) p99.addDataPoint(pz);
this->attr = Attribute::Z;
this->minattr = minz;
this->maxattr = p99.getQuantile();
this->minattr = zqmin;
this->maxattr = zqmax;
this->attrrange = maxattr - minattr;
camera.changed = true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/drawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class Drawer
double yrange;
double zrange;
double range;
double zqmin;
double zqmax;
double minattr;
double maxattr;
double attrrange;
Expand Down

0 comments on commit 6ba5768

Please sign in to comment.