mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-07-05 11:12:49 +00:00
better algorithm for drawing Euclidean projections
This commit is contained in:
parent
cf52faa484
commit
6c8661b484
64
hypgraph.cpp
64
hypgraph.cpp
@ -906,63 +906,35 @@ void drawEuclidean() {
|
|||||||
// mindx, mindy, maxdx, maxdy);
|
// mindx, mindy, maxdx, maxdy);
|
||||||
int pvec = cellwalker_to_vec(centerover);
|
int pvec = cellwalker_to_vec(centerover);
|
||||||
|
|
||||||
int minsx = mindx-1, maxsx=maxdx+1, minsy=mindy-1, maxsy=maxdy+1;
|
set<int> visited = {0};
|
||||||
mindx=maxdx=mindy=maxdy=0;
|
vector<int> dfs = {0};
|
||||||
|
|
||||||
transmatrix View0 = View;
|
ld centerd = matrixnorm(View);
|
||||||
|
auto View0 = View;
|
||||||
|
|
||||||
ld cellrad = vid.radius / (1 + vid.alpha);
|
for(int i=0; i<isize(dfs); i++) {
|
||||||
|
int at = dfs[i];
|
||||||
ld centerd = matrixnorm(View0);
|
|
||||||
|
|
||||||
for(int dx=minsx; dx<=maxsx; dx++)
|
|
||||||
for(int dy=minsy; dy<=maxsy; dy++) {
|
|
||||||
torusconfig::torus_cx = dx;
|
|
||||||
torusconfig::torus_cy = dy;
|
|
||||||
cellwalker cw = vec_to_cellwalker(pvec + euclid_getvec(dx, dy));
|
|
||||||
transmatrix Mat = eumove(dx,dy);
|
|
||||||
|
|
||||||
|
cellwalker cw = vec_to_cellwalker(pvec + at);
|
||||||
if(!cw.at) continue;
|
if(!cw.at) continue;
|
||||||
|
auto p = vec_to_pair(at);
|
||||||
Mat = View0 * Mat;
|
transmatrix Mat = View0 * eumove(p.first,p.second);
|
||||||
|
|
||||||
if(true) {
|
if(true) {
|
||||||
ld locald = matrixnorm(Mat);
|
ld locald = matrixnorm(Mat);
|
||||||
if(locald < centerd) centerd = locald, centerover = cw, View = View0 * eumove(dx, dy);
|
if(locald < centerd) centerd = locald, centerover = cw, View = Mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mat[0][0] = -1;
|
if(i < 30 || in_smart_range(Mat)) {
|
||||||
// Mat[1][1] = -1;
|
if(vid.use_smart_range == 2) setdist(cw.at, 7, cw.at);
|
||||||
|
if(dodrawcell(cw.at))
|
||||||
// Mat[2][0] = x*x/10;
|
drawcell(cw.at, cw.mirrored ? Mat * Mirror : Mat, cw.spin, cw.mirrored);
|
||||||
// Mat[2][1] = y*y/10;
|
for(int x=-1; x<=+1; x++)
|
||||||
// Mat = Mat * xpush(x-30) * ypush(y-30);
|
for(int y=-1; y<=+1; y++) {
|
||||||
|
auto p = at + pair_to_vec(x, y);
|
||||||
if(vid.use_smart_range) {
|
if(!visited.count(p)) visited.insert(p), dfs.push_back(p);
|
||||||
if(in_smart_range(Mat)) {
|
|
||||||
if(vid.use_smart_range == 2) setdist(cw.at, 7, cw.at);
|
|
||||||
if(dx < mindx) mindx = dx;
|
|
||||||
if(dy < mindy) mindy = dy;
|
|
||||||
if(dx > maxdx) maxdx = dx;
|
|
||||||
if(dy > maxdy) maxdy = dy;
|
|
||||||
if(dodrawcell(cw.at))
|
|
||||||
drawcell(cw.at, cw.mirrored ? Mat * Mirror : Mat, cw.spin, cw.mirrored);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
int cx, cy, shift;
|
|
||||||
getcoord0(tC0(Mat), cx, cy, shift);
|
|
||||||
if(cx >= 0 && cy >= 0 && cx < vid.xres && cy < vid.yres) {
|
|
||||||
if(dx < mindx) mindx = dx;
|
|
||||||
if(dy < mindy) mindy = dy;
|
|
||||||
if(dx > maxdx) maxdx = dx;
|
|
||||||
if(dy > maxdy) maxdy = dy;
|
|
||||||
}
|
|
||||||
if(cx >= -cellrad && cy >= -cellrad && cx < vid.xres+cellrad && cy < vid.yres+cellrad)
|
|
||||||
if(dodrawcell(cw.at)) {
|
|
||||||
drawcell(cw.at, cw.mirrored ? Mat * Mirror : Mat, cw.spin, cw.mirrored);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user