1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 23:50:27 +00:00

draw_stretch without triangles

This commit is contained in:
Zeno Rogue 2020-07-25 03:13:30 +02:00
parent 6515f5bb1b
commit c931cb93d5

View File

@ -1259,8 +1259,6 @@ EX int berger_limit = 2;
void draw_stretch(dqi_poly *p) { void draw_stretch(dqi_poly *p) {
if(!(p->flags & POLY_TRIANGLES)) return;
dqi_poly npoly = *p; dqi_poly npoly = *p;
npoly.offset = 0; npoly.offset = 0;
@ -1300,6 +1298,11 @@ void draw_stretch(dqi_poly *p) {
for(int i=0; i<p->cnt; i++) results[i] = stretch::inverse_exp_all(hs[i], berger_limit); for(int i=0; i<p->cnt; i++) results[i] = stretch::inverse_exp_all(hs[i], berger_limit);
auto test = [] (hyperpoint a, hyperpoint b) -> bool {
return sqhypot_d(3, a-b) < 2;
};
if(p->flags & POLY_TRIANGLES) {
for(int i=0; i<p->cnt; i+=3) { for(int i=0; i<p->cnt; i+=3) {
auto &la = results[i]; auto &la = results[i];
auto &lb = results[i+1]; auto &lb = results[i+1];
@ -1307,10 +1310,6 @@ void draw_stretch(dqi_poly *p) {
int ia = 0, ib = 0, ic = 0; int ia = 0, ib = 0, ic = 0;
auto test = [] (hyperpoint a, hyperpoint b) -> bool {
return sqhypot_d(3, a-b) < 2;
};
for(auto& ha: la) for(auto& hb: lb) if(test(ha, hb)) for(auto& ha: la) for(auto& hb: lb) if(test(ha, hb))
for(auto& hc: lc) if(test(ha, hc) && test(hb, hc)) { for(auto& hc: lc) if(test(ha, hc) && test(hb, hc)) {
@ -1323,11 +1322,31 @@ void draw_stretch(dqi_poly *p) {
ia++; ib++; ic++; ia++; ib++; ic++;
} }
} }
npoly.cnt = isize(glcoords); npoly.cnt = isize(glcoords);
npoly.gldraw(); npoly.gldraw();
} }
else if(p->cnt) {
for(auto& ha: results[0]) {
vector<hyperpoint> has;
has.push_back(ha);
glcoords.push_back(glhr::pointtogl(U * ha));
for(int i=1; i<p->cnt; i++) {
hyperpoint best = C0;
ld dist = 10;
for(auto& hb: results[i]) {
ld d = sqhypot_d(3, hb-has.back());
if(d < dist) dist = d, best = hb;
}
if(dist < 2) has.push_back(best);
}
if(isize(has) < 3) continue;
glcoords.clear();
for(auto& h: has) glcoords.push_back(glhr::pointtogl(U * h));
npoly.cnt = isize(glcoords);
npoly.gldraw();
}
}
}
EX namespace ods { EX namespace ods {
#if CAP_ODS #if CAP_ODS