mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 15:40:26 +00:00
improved INVERSE issues in stereographic
This commit is contained in:
parent
7515503dee
commit
04554a436f
2
hyper.h
2
hyper.h
@ -2550,6 +2550,7 @@ struct dqi_poly : drawqueueitem {
|
|||||||
double linewidth;
|
double linewidth;
|
||||||
int flags;
|
int flags;
|
||||||
textureinfo *tinf;
|
textureinfo *tinf;
|
||||||
|
hyperpoint intester;
|
||||||
void draw();
|
void draw();
|
||||||
void gldraw();
|
void gldraw();
|
||||||
void draw_back();
|
void draw_back();
|
||||||
@ -3598,6 +3599,7 @@ struct hpcshape {
|
|||||||
int s, e;
|
int s, e;
|
||||||
PPR prio;
|
PPR prio;
|
||||||
int flags;
|
int flags;
|
||||||
|
hyperpoint intester;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern hpcshape shFullCross[2];
|
extern hpcshape shFullCross[2];
|
||||||
|
48
polygons.cpp
48
polygons.cpp
@ -16,8 +16,6 @@ ld xcross(ld x1, ld y1, ld x2, ld y2) {
|
|||||||
return x1 + (x2 - x1) * y1 / (y1 - y2);
|
return x1 + (x2 - x1) * y1 / (y1 - y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
hyperpoint intester;
|
|
||||||
|
|
||||||
// draw the lines
|
// draw the lines
|
||||||
static const int POLY_DRAWLINES = 1;
|
static const int POLY_DRAWLINES = 1;
|
||||||
// draw the area
|
// draw the area
|
||||||
@ -62,6 +60,9 @@ static const int POLY_NOTINFRONT = (1<<16);
|
|||||||
// points moved to the outline cross the image, disable
|
// points moved to the outline cross the image, disable
|
||||||
static const int POLY_NIF_ERROR = (1<<17);
|
static const int POLY_NIF_ERROR = (1<<17);
|
||||||
|
|
||||||
|
// new system of side checking
|
||||||
|
static const int POLY_BADCENTERIN = (1<<18);
|
||||||
|
|
||||||
vector<hyperpoint> hpc;
|
vector<hyperpoint> hpc;
|
||||||
|
|
||||||
int prehpc;
|
int prehpc;
|
||||||
@ -892,6 +893,15 @@ void dqi_poly::draw() {
|
|||||||
outline = (flags & POLY_CENTERIN) ? 0x00FF00FF : 0xFF0000FF;
|
outline = (flags & POLY_CENTERIN) ? 0x00FF00FF : 0xFF0000FF;
|
||||||
addpoint(hscr); */
|
addpoint(hscr); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(poly_flags & POLY_BADCENTERIN) {
|
||||||
|
glcoords.push_back(make_array<GLfloat>(hscr[0]+10, hscr[1]*vid.stretch, hscr[2]));
|
||||||
|
glcoords.push_back(make_array<GLfloat>(hscr[0], hscr[1]*vid.stretch+10, hscr[2]));
|
||||||
|
glcoords.push_back(make_array<GLfloat>(hscr[0]-10, hscr[1]*vid.stretch, hscr[2]));
|
||||||
|
glcoords.push_back(make_array<GLfloat>(hscr[0], hscr[1]*vid.stretch-10, hscr[2]));
|
||||||
|
glcoords.push_back(make_array<GLfloat>(hscr[0]+10, hscr[1]*vid.stretch, hscr[2]));
|
||||||
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@ -1072,6 +1082,7 @@ void prettyline(hyperpoint h1, hyperpoint h2, color_t col, int lev) {
|
|||||||
ptd.outline = col;
|
ptd.outline = col;
|
||||||
ptd.flags = POLY_ISSIDE;
|
ptd.flags = POLY_ISSIDE;
|
||||||
ptd.tinf = NULL;
|
ptd.tinf = NULL;
|
||||||
|
ptd.intester = C0;
|
||||||
ptd.draw();
|
ptd.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1090,6 +1101,7 @@ void prettypoly(const vector<hyperpoint>& t, color_t fillcol, color_t linecol, i
|
|||||||
ptd.outline = linecol;
|
ptd.outline = linecol;
|
||||||
ptd.flags = POLY_ISSIDE;
|
ptd.flags = POLY_ISSIDE;
|
||||||
ptd.tinf = NULL;
|
ptd.tinf = NULL;
|
||||||
|
ptd.intester = C0;
|
||||||
ptd.draw();
|
ptd.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1486,16 +1498,36 @@ void finishshape() {
|
|||||||
if(abs(area) < 1e-9) last->flags |= POLY_ISSIDE;
|
if(abs(area) < 1e-9) last->flags |= POLY_ISSIDE;
|
||||||
if(area >= 0) last->flags |= POLY_INVERSE;
|
if(area >= 0) last->flags |= POLY_INVERSE;
|
||||||
|
|
||||||
|
for(int s=0; s<4; s++) {
|
||||||
|
last->intester = C0;
|
||||||
|
if(s == 0) {
|
||||||
|
for(int i=last->s; i<last->e-1; i++)
|
||||||
|
for(int j=0; j<3; j++)
|
||||||
|
last->intester[j] += hpc[i][j];
|
||||||
|
last->intester = mid(last->intester, last->intester);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(s == 2)
|
||||||
|
last->intester = hpxy(.5, .2);
|
||||||
|
|
||||||
|
if(s == 3)
|
||||||
|
last->intester = hpxy(.2, .2518);
|
||||||
|
|
||||||
|
last->flags &=~ POLY_BADCENTERIN;
|
||||||
|
|
||||||
for(int i=last->s; i<last->e-1; i++) {
|
for(int i=last->s; i<last->e-1; i++) {
|
||||||
ld x1 = hpc[i][0] - intester[0], y1 = hpc[i][1] - intester[1], x2 = hpc[i+1][0] - intester[0], y2 = hpc[i+1][1] - intester[1];
|
ld x1 = hpc[i][0] - last->intester[0], y1 = hpc[i][1] - last->intester[1], x2 = hpc[i+1][0] - last->intester[0], y2 = hpc[i+1][1] - last->intester[1];
|
||||||
if(asign(y1, y2)) {
|
if(asign(y1, y2)) {
|
||||||
ld x = xcross(x1, y1, x2, y2);
|
ld x = xcross(x1, y1, x2, y2);
|
||||||
if(abs(x) < 1e-6 && !(last->flags & POLY_ISSIDE)) {
|
if(abs(x) < 1e-3 && !(last->flags & POLY_ISSIDE)) {
|
||||||
printf("close call, x = %lf\n", x);
|
printf("close call [%d], x = %lf\n", s, x);
|
||||||
|
last->flags |= POLY_BADCENTERIN;
|
||||||
}
|
}
|
||||||
if(x < 0) last->flags ^= POLY_CENTERIN;
|
if(x < 0) last->flags ^= POLY_CENTERIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!(last->flags & POLY_BADCENTERIN)) break;
|
||||||
|
}
|
||||||
|
|
||||||
bool allplus = true, allminus = true;
|
bool allplus = true, allminus = true;
|
||||||
for(int i=last->s; i<last->e-1; i++) {
|
for(int i=last->s; i<last->e-1; i++) {
|
||||||
@ -1664,8 +1696,6 @@ ld dlow_table[SIDEPARS], dhi_table[SIDEPARS];
|
|||||||
|
|
||||||
void buildpolys() {
|
void buildpolys() {
|
||||||
|
|
||||||
intester = hpxy(1e-3, 1.3e-3);
|
|
||||||
|
|
||||||
symmetriesAt.clear();
|
symmetriesAt.clear();
|
||||||
allshapes.clear();
|
allshapes.clear();
|
||||||
geom3::compute();
|
geom3::compute();
|
||||||
@ -2517,6 +2547,7 @@ dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, PPR
|
|||||||
ptd.linewidth = vid.linewidth;
|
ptd.linewidth = vid.linewidth;
|
||||||
ptd.flags = h.flags;
|
ptd.flags = h.flags;
|
||||||
ptd.tinf = NULL;
|
ptd.tinf = NULL;
|
||||||
|
ptd.intester = h.intester;
|
||||||
return ptd;
|
return ptd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2535,8 +2566,9 @@ dqi_poly& queuetable(const transmatrix& V, const vector<glvertex>& f, int cnt, c
|
|||||||
ptd.color = fillcol;
|
ptd.color = fillcol;
|
||||||
ptd.outline = linecol;
|
ptd.outline = linecol;
|
||||||
ptd.linewidth = vid.linewidth;
|
ptd.linewidth = vid.linewidth;
|
||||||
ptd.flags = 0;
|
ptd.flags = POLY_ISSIDE;
|
||||||
ptd.tinf = NULL;
|
ptd.tinf = NULL;
|
||||||
|
ptd.intester = C0;
|
||||||
return ptd;
|
return ptd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user