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:
parent
6515f5bb1b
commit
c931cb93d5
35
drawing.cpp
35
drawing.cpp
@ -1259,8 +1259,6 @@ EX int berger_limit = 2;
|
||||
|
||||
void draw_stretch(dqi_poly *p) {
|
||||
|
||||
if(!(p->flags & POLY_TRIANGLES)) return;
|
||||
|
||||
dqi_poly npoly = *p;
|
||||
|
||||
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);
|
||||
|
||||
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) {
|
||||
auto &la = results[i];
|
||||
auto &lb = results[i+1];
|
||||
@ -1307,10 +1310,6 @@ void draw_stretch(dqi_poly *p) {
|
||||
|
||||
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& hc: lc) if(test(ha, hc) && test(hb, hc)) {
|
||||
|
||||
@ -1323,11 +1322,31 @@ void draw_stretch(dqi_poly *p) {
|
||||
ia++; ib++; ic++;
|
||||
}
|
||||
}
|
||||
|
||||
npoly.cnt = isize(glcoords);
|
||||
|
||||
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 {
|
||||
#if CAP_ODS
|
||||
|
Loading…
Reference in New Issue
Block a user