some work on 3D view

This commit is contained in:
? 2019-02-21 18:46:53 +01:00 committed by Zeno Rogue
parent a3eb161235
commit e73d2f2f22
12 changed files with 118 additions and 59 deletions

View File

@ -235,7 +235,7 @@ void display_data::set_projection(int ed, bool apply_models) {
}
else {
if(hyperbolic && vid.alpha > -1) {
if(hyperbolic && vid.alpha > -1 && DIM == 2) {
// Because of the transformation from H3 to the Minkowski hyperboloid,
// points with negative Z can be generated in some 3D settings.
// This happens for points below the camera, but above the plane.
@ -299,7 +299,7 @@ void display_data::set_viewport(int ed) {
}
bool model_needs_depth() {
return pmodel == mdBall;
return DIM == 3 || pmodel == mdBall;
}
void setGLProjection(color_t col) {

View File

@ -644,16 +644,16 @@ namespace conformal {
"the point z is mapped to f(z). You can also use the underlying coordinates ux, uy, uz."
) + "\n\n" + parser_help()
);
#if CAP_POLY
#if CAP_QUEUE && CAP_CURVE
dialog::extra_options = [] () {
initquickqueue();
queuereset(mdUnchanged, PPR::LINE);
for(int a=-1; a<=1; a++) {
curvepoint(hpxyz(-M_PI/2 * current_display->radius, a*current_display->radius, 0));
curvepoint(hpxyz(+M_PI/2 * current_display->radius, a*current_display->radius, 0));
curvepoint(point2(-M_PI/2 * current_display->radius, a*current_display->radius));
curvepoint(point2(+M_PI/2 * current_display->radius, a*current_display->radius));
queuecurve(forecolor, 0, PPR::LINE);
curvepoint(hpxyz(a*current_display->radius, -M_PI/2*current_display->radius, 0));
curvepoint(hpxyz(a*current_display->radius, +M_PI/2*current_display->radius, 0));
curvepoint(point2(a*current_display->radius, -M_PI/2*current_display->radius));
curvepoint(point2(a*current_display->radius, +M_PI/2*current_display->radius));
queuecurve(forecolor, 0, PPR::LINE);
}
queuereset(pmodel, PPR::LINE);

View File

@ -177,6 +177,7 @@ void closeJoysticks() {
}
void checkjoy() {
#if DIM == 2
DEBB(DF_GRAPH, (debugfile,"check joy\n"));
if(!DEFAULTCONTROL) return;
ld joyvalue1 = sqr(vid.joyvalue);
@ -199,10 +200,11 @@ void checkjoy() {
}
joydir = vectodir(hpxy(jx, jy));
#endif
}
void checkpanjoy(double t) {
#if DIM == 2
if(shmup::on) return;
if(vid.joypanspeed < 1e-7) return;
@ -215,6 +217,7 @@ void checkpanjoy(double t) {
playermoved = false;
View = gpushxto0(hpxy(jx, jy)) * View;
#endif
}
#endif
@ -245,27 +248,38 @@ void handlePanning(int sym, int uni) {
if(rug::rugged) return;
#if !ISPANDORA
if(sym == SDLK_END && DIM == 3) {
View = cpush(2, -0.2*shiftmul) * View, didsomething = true, playermoved = false;
}
if(sym == SDLK_RIGHT) {
if(conformal::on)
conformal::lvspeed += 0.1 * shiftmul;
else if(DIM == 3)
View = cspin(0, 2, -0.2*shiftmul) * View, didsomething = true;
else
View = xpush(-0.2*shiftmul) * View, playermoved = false, didsomething = true;
}
if(sym == SDLK_LEFT) {
if(conformal::on)
conformal::lvspeed -= 0.1 * shiftmul;
else if(DIM == 3)
View = cspin(0, 2, 0.2*shiftmul) * View, didsomething = true;
else
View = xpush(+0.2*shiftmul) * View, playermoved = false, didsomething = true;
}
if(sym == SDLK_UP) {
if(conformal::on)
conformal::lvspeed += 0.1 * shiftmul;
else if(DIM == 3)
View = cspin(1, 2, 0.2*shiftmul) * View, didsomething = true;
else
View = ypush(+0.2*shiftmul) * View, playermoved = false, didsomething = true;
}
if(sym == SDLK_DOWN) {
if(conformal::on)
conformal::lvspeed -= 0.1 * shiftmul;
else if(DIM == 3)
View = cspin(1, 2, -0.2*shiftmul) * View, didsomething = true;
else
View = ypush(-0.2*shiftmul) * View, playermoved = false, didsomething = true;
}
@ -286,6 +300,7 @@ void handlePanning(int sym, int uni) {
if(sym == SDLK_PAGEUP || sym == SDLK_PAGEDOWN)
if(isGravityLand(cwt.at->land)) playermoved = false;
#if DIM == 2
if(sym == PSEUDOKEY_WHEELUP) {
ld jx = (mousex - current_display->xcenter - .0) / current_display->radius / 10;
ld jy = (mousey - current_display->ycenter - .0) / current_display->radius / 10;
@ -293,6 +308,7 @@ void handlePanning(int sym, int uni) {
View = gpushxto0(hpxy(jx, jy)) * View;
sym = 1;
}
#endif
}
#ifdef SCALETUNER
@ -760,7 +776,7 @@ void handle_event(SDL_Event& ev) {
vid.xposition += (mousex - lmousex) * 1. / current_display->scrsize,
vid.yposition += (mousey - lmousey) * 1. / current_display->scrsize;
}
else if(mouseh[2] < 50 && mouseoh[2] < 50) {
else if(mouseh[DIM] < 50 && mouseoh[DIM] < 50) {
panning(mouseoh, mouseh);
}
}
@ -892,6 +908,7 @@ bool haveMobileCompass() {
}
bool handleCompass() {
#if DIM == 2
if(!haveMobileCompass()) return false;
using namespace shmupballs;
@ -913,6 +930,9 @@ bool handleCompass() {
}
return false;
#else
return false;
#endif
}
// orientation sensitivity

View File

@ -197,7 +197,7 @@ void precalc() {
transmatrix xspinpush(ld dir, ld dist) {
if(euclid)
return eupush(cos(dir) * dist, -sin(dir) * dist);
return eupush(cos(dir) * dist, -sin(dir) * dist DC(,0));
else
return spin(dir) * xpush(dist) * spin(-dir);
}

View File

@ -362,7 +362,7 @@ void virtualRebase(cell*& base, transmatrix& at, bool tohex) {
void virtualRebase(cell*& base, hyperpoint& h, bool tohex) {
// we perform fixing in check, so that it works with larger range
virtualRebase(base, h, tohex, [] (const hyperpoint& h) { return hyperbolic ? hpxy(h[0], h[1]) :h; });
virtualRebase(base, h, tohex, [] (const hyperpoint& h) { return hyperbolic ? hpxy(h[0], h[1] DC(,h[2])) :h; });
}
// works only in geometries similar to the standard one, and only on heptagons

View File

@ -3777,10 +3777,10 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(!inmirrorcount) {
transmatrix& gm = gmatrix[c];
orig =
gm[2][2] == 0 ? true :
euwrap ? hypot(gm[0][2], gm[1][2]) >= hypot(V[0][2], V[1][2]) :
sphereflipped() ? fabs(gm[2][2]-1) <= fabs(V[2][2]-1) :
fabs(gm[2][2]-1) >= fabs(V[2][2]-1) - 1e-8;
gm[DIM][DIM] == 0 ? true :
euwrap ? hypot(gm[0][DIM], gm[1][DIM]) >= hypot(V[0][DIM], V[1][DIM]) :
sphereflipped() ? fabs(gm[DIM][DIM]-1) <= fabs(V[DIM][DIM]-1) :
fabs(gm[DIM][DIM]-1) >= fabs(V[DIM][DIM]-1) - 1e-8;
if(orig) gm = V;
}
@ -3853,7 +3853,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
if(!euclid) {
double dfc = euclid ? intval(VC0, C0) : VC0[2];
double dfc = euclid ? intval(VC0, C0) : VC0[DIM];
if(dfc < centdist) {
centdist = dfc;
@ -5553,7 +5553,7 @@ purehookset hooks_drawmap;
transmatrix cview() {
sphereflip = Id;
if(sphereflipped()) sphereflip[2][2] = -1;
if(sphereflipped()) sphereflip[DIM][DIM] = -1;
return ypush(vid.yshift) * sphereflip * View;
}
@ -5768,10 +5768,10 @@ void drawmovestar(double dx, double dy) {
transmatrix Centered = Id;
if(masterless)
Centered = eupush(H[0], H[1]);
Centered = eupush(H);
else if(R > 1e-9) Centered = rgpushxto0(H);
Centered = Centered * rgpushxto0(hpxy(dx*5, dy*5));
Centered = Centered * rgpushxto0(hpxy0(dx*5, dy*5));
if(multi::cpid >= 0) multi::crosscenter[multi::cpid] = Centered;
int rax = vid.axes;

29
hyper.h
View File

@ -189,7 +189,6 @@ typedef complex<ld> cld;
#define DEBSM(x)
#define DIM 2
#define MDIM (DIM+1)
#if DIM == 2
@ -224,7 +223,7 @@ inline transmatrix operator * (const transmatrix& T, const transmatrix& U) {
transmatrix R;
// for(int i=0; i<3; i++) for(int j=0; j<3; j++) R[i][j] = 0;
for(int i=0; i<MDIM; i++) for(int j=0; j<MDIM; j++) // for(int k=0; k<3; k++)
R[i][j] = T[i][0] * U[0][j] + T[i][1] * U[1][j] + T[i][2] * U[2][j];
R[i][j] = T[i][0] * U[0][j] + T[i][1] * U[1][j] + T[i][2] * U[2][j] D3(+ T[i][3] * U[3][j]);
return R;
}
@ -258,9 +257,11 @@ const static transmatrix centralsym = diag(-1,-1,-1,-1);
#define hpxyz hyperpoint
#if DIM == 3
hyperpoint point3(ld x, ld y, ld z) { return hpxyz(x,y,z,0); }
static hyperpoint point3(ld x, ld y, ld z) { return hpxyz(x,y,z,0); }
static hyperpoint point2(ld x, ld y) { return hpxyz(x,y,0,0); }
#else
#define point3 hpxyz
static hyperpoint point2(ld x, ld y) { return hpxyz(x,y,0); }
#endif
namespace hyperpoint_vec {
@ -3381,7 +3382,7 @@ int fiftyval200(cell *c);
// T * C0, optimized
inline hyperpoint tC0(const transmatrix &T) {
hyperpoint z;
z[0] = T[0][2]; z[1] = T[1][2]; z[2] = T[2][2];
for(int i=0; i<MDIM; i++) z[i] = T[i][DIM];
return z;
}
@ -3572,7 +3573,7 @@ void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame =
string fts(float x);
bool model_needs_depth();
hyperpoint hpxy(ld x, ld y);
hyperpoint hpxy(ld x, ld y DC(, ld z));
ld sqhypot2(const hyperpoint& h);
ld hypot2(const hyperpoint& h);
transmatrix pushxto0(const hyperpoint& H);
@ -3580,6 +3581,12 @@ transmatrix rpushxto0(const hyperpoint& H);
transmatrix spintox(const hyperpoint& H);
transmatrix ypush(ld alpha);
#if DIM == 3
static hyperpoint hpxy0(ld x, ld y) { return hpxy(x, y, 0); }
#else
static hyperpoint hpxy0(ld x, ld y) { return hpxy(x, y); }
#endif
#if CAP_SURFACE
namespace surface {
@ -3772,7 +3779,7 @@ extern ld intval(const hyperpoint &h1, const hyperpoint &h2);
extern ld intvalxy(const hyperpoint &h1, const hyperpoint &h2);
transmatrix euscalezoom(hyperpoint h);
transmatrix euaffine(hyperpoint h);
transmatrix eupush(ld x, ld y);
transmatrix eupush(ld x, ld y DC(, ld z));
transmatrix eupush(hyperpoint h);
transmatrix rspintox(const hyperpoint& H);
transmatrix gpushxto0(const hyperpoint& H);
@ -4206,10 +4213,11 @@ bool saved_tortoise_on(cell *c);
#if CAP_BT
void horopoint(ld y, ld x);
hyperpoint get_horopoint(ld y, ld x DC(,ld z));
namespace binary {
heptagon *createStep(heptagon *parent, int d);
transmatrix parabolic(ld u);
transmatrix parabolic(ld u DC(, ld v));
}
#endif
@ -4466,11 +4474,11 @@ struct comma_printer {
template<class T, size_t X> void print(hstream& hs, const array<T, X>& a) { print(hs, "("); comma_printer c(hs); for(const T& t: a) c(t); print(hs, ")"); }
template<class T> void print(hstream& hs, const vector<T>& a) { print(hs, "("); comma_printer c(hs); for(const T& t: a) c(t); print(hs, ")"); }
inline void print(hstream& hs, const hyperpoint h) { print(hs, (const array<ld, 3>&)h); }
inline void print(hstream& hs, const hyperpoint h) { print(hs, (const array<ld, MDIM>&)h); }
inline void print(hstream& hs, const transmatrix T) {
print(hs, "("); comma_printer c(hs);
for(int i=0; i<3; i++)
for(int j=0; j<3; j++) c(T[i][j]);
for(int i=0; i<MDIM; i++)
for(int j=0; j<MDIM; j++) c(T[i][j]);
print(hs, ")"); }
template<class T, class U> void print(hstream& hs, const pair<T, U> & t) { print(hs, "(", t.first, ",", t.second, ")"); }
@ -4740,6 +4748,7 @@ extern int cells_drawn;
void menuitem_sightrange(char c = 'r');
bool invis_point(const hyperpoint h);
bool invalid_point(const hyperpoint h);
bool invalid_point(const transmatrix T);
bool in_smart_range(const transmatrix& T);

View File

@ -438,7 +438,7 @@ void fixmatrix(transmatrix& T) {
// show the matrix on screen
ld det(const transmatrix& T) {
#if DIM == 3
#if DIM == 2
ld det = 0;
for(int i=0; i<3; i++)
det += T[0][i] * T[1][(i+1)%3] * T[2][(i+2)%3];
@ -472,7 +472,7 @@ void inverse_error(const transmatrix& T) {
transmatrix inverse(const transmatrix& T) {
profile_start(7);
#if DIM == 3
#if DIM == 2
ld d = det(T);
transmatrix T2;
if(d == 0) {
@ -493,8 +493,7 @@ transmatrix inverse(const transmatrix& T) {
if(T1[b][a]) {
if(b != a)
for(int c=0; c<MDIM; c++)
tie(T1[b][c], T1[a][c]) = make_pair(T1[a][c], T1[b][c]),
tie(T2[b][c], T2[a][c]) = make_pair(T2[a][c], T2[b][c]);
swap(T1[b][c], T1[a][c]), swap(T2[b][c], T2[a][c]);
break;
}
if(!T1[a][a]) { inverse_error(T); return Id; }
@ -612,7 +611,7 @@ transmatrix mzscale(const transmatrix& t, double fac) {
return res;
}
transmatrix pushone() { return euclid ? eupush(1, 0) : xpush(sphere?.5 : 1); }
transmatrix pushone() { return xpush(sphere?.5 : 1); }
bool operator == (hyperpoint h1, hyperpoint h2) {
for(int i=0; i<MDIM; i++) if(h1[i] != h2[i]) return false;

View File

@ -34,7 +34,7 @@ hyperpoint perspective_to_space(hyperpoint h, ld alpha, eGeometryClass gc) {
ld hx = h[0], hy = h[1];
if(gc == gcEuclid)
return hpxy(hx * (1 + alpha), hy * (1 + alpha));
return hpxy0(hx * (1 + alpha), hy * (1 + alpha));
ld hr = hx*hx+hy*hy;
@ -58,7 +58,7 @@ hyperpoint perspective_to_space(hyperpoint h, ld alpha, eGeometryClass gc) {
hyperpoint H;
H[0] = hx * (hz+vid.alpha);
H[1] = hy * (hz+vid.alpha);
H[2] = hz;
H[DIM] = hz;
return H;
}
@ -66,10 +66,10 @@ hyperpoint perspective_to_space(hyperpoint h, ld alpha, eGeometryClass gc) {
hyperpoint space_to_perspective(hyperpoint z, ld alpha = vid.alpha);
hyperpoint space_to_perspective(hyperpoint z, ld alpha) {
ld s = 1 / (alpha + z[2]);
ld s = 1 / (alpha + z[DIM]);
z[0] *= s;
z[1] *= s;
z[2] = 0;
z[DIM] = 0;
return z;
}
@ -90,7 +90,7 @@ hyperpoint gethyper(ld x, ld y) {
void ballmodel(hyperpoint& ret, double alpha, double d, double zl) {
hyperpoint H = ypush(geom3::camera) * xpush(d) * ypush(zl) * C0;
ld tzh = vid.ballproj + H[2];
ld tzh = vid.ballproj + H[DIM];
ld ax = H[0] / tzh;
ld ay = H[1] / tzh;
@ -232,6 +232,13 @@ hyperpoint mobius(hyperpoint h, ld angle, ld scale = 1) {
}
void applymodel(hyperpoint H, hyperpoint& ret) {
if(DIM == 3) {
ret[0] = H[0]/H[2];
ret[1] = H[1]/H[2];
ret[2] = 1;
return;
}
using namespace hyperpoint_vec;
@ -723,6 +730,10 @@ transmatrix applyspin(const heptspin& hs, const transmatrix& V) {
return hs.spin ? V * spin(hs.spin*2*M_PI/S7) : V;
}
bool invis_point(const hyperpoint h) {
return h[2] < 0;
}
bool invalid_point(const hyperpoint h) {
return std::isnan(h[2]) || h[2] > 1e8 || std::isinf(h[2]);
}
@ -1040,7 +1051,7 @@ void centerpc(ld aspd) {
ors::unrotate(cwtV); ors::unrotate(View);
hyperpoint H = ypush(-vid.yshift) * sphereflip * tC0(cwtV);
ld R = H[0] == 0 && H[1] == 0 ? 0 : hdist0(H); // = sqrt(H[0] * H[0] + H[1] * H[1]);
ld R = zero2(H) ? 0 : hdist0(H); // = sqrt(H[0] * H[0] + H[1] * H[1]);
if(R < 1e-9) {
// either already centered or direction unknown
/* if(playerfoundL && playerfoundR) {
@ -1057,8 +1068,8 @@ void centerpc(ld aspd) {
aspd *= (2+3*R*R);
if(aspd > R) aspd = R;
View[0][2] -= cwtV[0][2] * aspd / R;
View[1][2] -= cwtV[1][2] * aspd / R;
for(int i=0; i<DIM; i++)
View[i][DIM] -= cwtV[i][DIM] * aspd / R;
}
@ -1098,7 +1109,7 @@ void optimizeview() {
#if CAP_BT || CAP_ARCM
else if(binarytiling || archimedean) {
turn = -1, best = View[2][2];
turn = -1, best = View[DIM][DIM];
for(int i=0; i<viewctr.at->c7->type; i++) {
int i1 = i * DUALMUL;
heptagon *h2 = createStep(viewctr.at, i1);
@ -1110,7 +1121,7 @@ void optimizeview() {
if(archimedean) T = arcm::relative_matrix(h2, viewctr.at);
#endif
hyperpoint H = View * tC0(T);
ld quality = euclid ? hdist0(H) : H[2];
ld quality = euclid ? hdist0(H) : H[DIM];
if(quality < best) best = quality, turn = i1, TB = T;
}
if(turn >= 0) {
@ -1128,7 +1139,7 @@ void optimizeview() {
ld trot = -i * M_PI * 2 / (S7+.0);
transmatrix T = i < 0 ? Id : spin(trot) * xpush(tessf) * pispin;
hyperpoint H = View * tC0(T);
if(H[2] < best) best = H[2], turn = i, TB = T;
if(H[DIM] < best) best = H[DIM], turn = i, TB = T;
}
if(turn >= 0) {
@ -1267,8 +1278,8 @@ void draw_model_elements() {
case mdHyperboloid: {
if(hyperbolic) {
#if CAP_QUEUE
curvepoint(hpxyz(0,0,1));
curvepoint(hpxyz(0,0,-vid.alpha));
curvepoint(point3(0,0,1));
curvepoint(point3(0,0,-vid.alpha));
queuecurve(ringcolor, 0, PPR::CIRCLE);
ld& tz = conformal::top_z;
@ -1281,16 +1292,16 @@ void draw_model_elements() {
a[1] = sb * a[2] / -cb;
a[0] = sqrt(-1 + a[2] * a[2] - a[1] * a[1]);
curvepoint(hpxyz(0,0,-vid.alpha));
curvepoint(point3(0,0,-vid.alpha));
curvepoint(a);
curvepoint(hpxyz(0,0,0));
curvepoint(point3(0,0,0));
a[0] = -a[0];
curvepoint(a);
curvepoint(hpxyz(0,0,-vid.alpha));
curvepoint(point3(0,0,-vid.alpha));
queuecurve(ringcolor, 0, PPR::CIRCLE);
curvepoint(hpxyz(-1,0,0));
curvepoint(hpxyz(1,0,0));
curvepoint(point3(-1,0,0));
curvepoint(point3(1,0,0));
queuecurve(ringcolor, 0, PPR::CIRCLE);
a[1] = sb * tz / -cb;
@ -1298,7 +1309,7 @@ void draw_model_elements() {
a[2] = tz - vid.alpha;
curvepoint(a);
curvepoint(hpxyz(0,0,-vid.alpha));
curvepoint(point3(0,0,-vid.alpha));
a[0] = -a[0];
curvepoint(a);
queuecurve(ringcolor, 0, PPR::CIRCLE);
@ -1374,7 +1385,7 @@ void draw_boundary(int w) {
ld z = -sqrt(1 - x*x);
conformal::apply_orientation(y, x);
hyperpoint h1;
applymodel(hpxyz(x,y,z), h1);
applymodel(hpxyz(x,y,DC(0,) z), h1);
conformal::apply_orientation(h1[0], h1[1]);
h1[1] = abs(h1[1]) * b;
@ -1424,7 +1435,7 @@ void draw_boundary(int w) {
queuereset(mdUnchanged, p);
for(int i=0; i<=360; i++) {
ld s = sin(i * degree);
curvepoint(hpxyz(current_display->radius * cos(i * degree), current_display->radius * s * (conformal::cos_ball * s >= 0 - 1e-6 ? 1 : abs(conformal::sin_ball)), 0));
curvepoint(point3(current_display->radius * cos(i * degree), current_display->radius * s * (conformal::cos_ball * s >= 0 - 1e-6 ? 1 : abs(conformal::sin_ball)), 0));
}
queuecurve(lc, fc, p);
queuereset(pmodel, p);
@ -1433,7 +1444,7 @@ void draw_boundary(int w) {
for(int i=0; i<=360; i++) {
ld s = sin(i * degree);
curvepoint(hpxyz(current_display->radius * cos(i * degree), current_display->radius * s * conformal::sin_ball, 0));
curvepoint(point3(current_display->radius * cos(i * degree), current_display->radius * s * conformal::sin_ball, 0));
}
queuecurve(lc, fc, p);
queuereset(pmodel, p);
@ -1441,7 +1452,7 @@ void draw_boundary(int w) {
if(euclid || sphere) {
queuereset(mdUnchanged, p);
for(int i=0; i<=360; i++) {
curvepoint(hpxyz(current_display->radius * cos(i * degree), current_display->radius * sin(i * degree), 0));
curvepoint(point3(current_display->radius * cos(i * degree), current_display->radius * sin(i * degree), 0));
}
queuecurve(lc, fc, p);
queuereset(pmodel, p);
@ -1511,7 +1522,7 @@ void draw_boundary(int w) {
queuereset(mdUnchanged, p);
for(ld a=-10; a<=10; a+=0.01 / (1 << vid.linequality) / u) {
cld z = exp(cld(a, a * imag(sm) / real(sm) + M_PI));
hyperpoint ret = hpxyz(real(z), imag(z), 0);
hyperpoint ret = point2(real(z), imag(z));
ret = mobius(ret, vid.skiprope, 1);
ret *= current_display->radius;
curvepoint(ret);

View File

@ -490,6 +490,9 @@ vector<glvertex> line_vertices;
#endif
void glapplymatrix(const transmatrix& V) {
#if DIM == 3
glhr::set_modelview(glhr::id);
#else
GLfloat mat[16];
int id = 0;
@ -509,6 +512,7 @@ void glapplymatrix(const transmatrix& V) {
conformal::apply_orientation(mat[a*4], mat[a*4+1]);
glhr::set_modelview(glhr::as_glmatrix(mat));
#endif
}
void dqi_poly::gldraw() {
@ -632,12 +636,16 @@ void dqi_poly::gldraw() {
#endif
double scale_at(const transmatrix& T) {
#if DIM==3
return 1 / (tC0(T))[2];
#else
using namespace hyperpoint_vec;
hyperpoint h1, h2, h3;
applymodel(tC0(T), h1);
applymodel(T * xpush0(.01), h2);
applymodel(T * ypush(.01) * C0, h3);
return sqrt(hypot2(h2-h1) * hypot2(h3-h1) / .0001);
#endif
}
double linewidthat(const hyperpoint& h) {
@ -1262,7 +1270,7 @@ void dqi_string::draw() {
svg::text(x, y, size, str, frame, color, align);
return;
}
#elseif ISMOBILE==0
#elif ISMOBILE==0
int fr = frame & 255;
displayfrSP(x, y, shift, fr, size, str, color, align, frame >> 8);
#else
@ -2872,12 +2880,14 @@ void queuechr(const transmatrix& V, double size, char chr, color_t col, int fram
void queuestr(const hyperpoint& h, int size, const string& chr, color_t col, int frame) {
if(invalid_point(h)) return;
if(DIM == 3 && invis_point(h)) return;
int xc, yc, sc; getcoord0(h, xc, yc, sc);
queuestr(xc, yc, sc, size, chr, col, frame);
}
void queuestr(const transmatrix& V, double size, const string& chr, color_t col, int frame, int align) {
if(invalid_point(V)) return;
if(DIM == 3 && invis_point(tC0(V))) return;
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
// int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
@ -2886,6 +2896,7 @@ void queuestr(const transmatrix& V, double size, const string& chr, color_t col,
void queuecircle(const transmatrix& V, double size, color_t col) {
if(invalid_point(V)) return;
if(DIM == 3 && invis_point(tC0(V))) return;
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
queuecircle(xc, yc, scale_in_pixels(V) * size, col);

View File

@ -845,11 +845,15 @@ void handleInput(int delta) {
multi::mdx[i] = multi::mdx[i] * (1 - delta / 1000.) + mdx * delta / 2000.;
multi::mdy[i] = multi::mdy[i] * (1 - delta / 1000.) + mdy * delta / 2000.;
#if DIM == 2
if(mdx != 0 || mdy != 0) if(!multi::combo[i]) {
cwtV = multi::whereis[i]; cwt = multi::player[i];
flipplayer = multi::flipped[i];
multi::whereto[i] = vectodir(hpxy(multi::mdx[i], multi::mdy[i]));
}
#else
ignore(mdx); ignore(mdy);
#endif
if(multi::actionspressed[b+pcFire] ||
(multi::actionspressed[b+pcMoveLeft] && multi::actionspressed[b+pcMoveRight]))
@ -1536,6 +1540,7 @@ void movePlayer(monster *m, int delta) {
#endif
double mturn = 0, mgo = 0, mdx = 0, mdy = 0;
ignore(mdx); ignore(mdy);
bool shotkey = false, dropgreen = false, facemouse = false;
if(facemouse) {
@ -1621,6 +1626,7 @@ void movePlayer(monster *m, int delta) {
playerturn[cpid] = mturn * delta / 150.0;
#if DIM == 2
double mdd = hypot(mdx, mdy);
if(mdd > 1e-6) {
@ -1634,6 +1640,7 @@ void movePlayer(monster *m, int delta) {
playerturn[cpid] = -atan2(h[1], h[0]);
mgo += mdd;
}
#endif
#if CAP_SDL
Uint8 *keystate = SDL_GetKeyState(NULL);

View File

@ -443,6 +443,8 @@ union SDL_Event;
#endif
#endif
#define DIM 3
#ifndef CAP_GEOMETRY
#define CAP_GEOMETRY (!(ISMINI))
#endif