mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-04-28 13:43:20 +00:00
header cleanup (conformal/polygonal)
This commit is contained in:
parent
a9ff4e64f8
commit
6ed530c50c
143
conformal.cpp
143
conformal.cpp
@ -9,25 +9,29 @@ typedef double precise;
|
|||||||
typedef long double precise;
|
typedef long double precise;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace polygonal {
|
EX namespace polygonal {
|
||||||
|
|
||||||
|
#if HDR
|
||||||
|
static const int MSI = 120;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef long double xld;
|
typedef long double xld;
|
||||||
|
|
||||||
typedef complex<xld> cxld;
|
typedef complex<xld> cxld;
|
||||||
|
|
||||||
int SI = 4;
|
EX int SI = 4;
|
||||||
ld STAR = 0;
|
EX ld STAR = 0;
|
||||||
|
|
||||||
int deg = ISMOBWEB ? 2 : 20;
|
EX int deg = ISMOBWEB ? 2 : 20;
|
||||||
|
|
||||||
precise matrix[MSI][MSI];
|
precise matrix[MSI][MSI];
|
||||||
precise ans[MSI];
|
precise ans[MSI];
|
||||||
|
|
||||||
cxld coef[MSI];
|
cxld coef[MSI];
|
||||||
ld coefr[MSI], coefi[MSI];
|
EX ld coefr[MSI], coefi[MSI];
|
||||||
int maxcoef, coefid;
|
EX int maxcoef, coefid;
|
||||||
|
|
||||||
void solve() {
|
EX void solve() {
|
||||||
if(pmodel == mdPolynomial) {
|
if(pmodel == mdPolynomial) {
|
||||||
for(int i=0; i<MSI; i++) coef[i] = cxld(coefr[i], coefi[i]);
|
for(int i=0; i<MSI; i++) coef[i] = cxld(coefr[i], coefi[i]);
|
||||||
return;
|
return;
|
||||||
@ -67,7 +71,7 @@ namespace polygonal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<ld, ld> compute(ld x, ld y, int prec) {
|
EX pair<ld, ld> compute(ld x, ld y, int prec) {
|
||||||
if(x*x+y*y > 1) {
|
if(x*x+y*y > 1) {
|
||||||
xld r = hypot(x,y);
|
xld r = hypot(x,y);
|
||||||
x /= r;
|
x /= r;
|
||||||
@ -93,7 +97,7 @@ namespace polygonal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pair<ld, ld> compute(ld x, ld y) { return compute(x,y,deg); }
|
pair<ld, ld> compute(ld x, ld y) { return compute(x,y,deg); }
|
||||||
}
|
EX }
|
||||||
|
|
||||||
#if CAP_SDL
|
#if CAP_SDL
|
||||||
namespace spiral {
|
namespace spiral {
|
||||||
@ -233,21 +237,21 @@ namespace spiral {
|
|||||||
|
|
||||||
bool isbad(ld z) { return !isfinite(z) || fabs(z) > 1e6; }
|
bool isbad(ld z) { return !isfinite(z) || fabs(z) > 1e6; }
|
||||||
|
|
||||||
namespace conformal {
|
EX namespace conformal {
|
||||||
|
|
||||||
string formula = "z^2";
|
EX string formula = "z^2";
|
||||||
eModel basic_model;
|
EX eModel basic_model;
|
||||||
|
|
||||||
void handleKeyC(int sym, int uni);
|
void handleKeyC(int sym, int uni);
|
||||||
|
|
||||||
int lastprogress;
|
int lastprogress;
|
||||||
|
|
||||||
void progress_screen() {
|
EX void progress_screen() {
|
||||||
gamescreen(0);
|
gamescreen(0);
|
||||||
mouseovers = "";
|
mouseovers = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void progress(string str) {
|
EX void progress(string str) {
|
||||||
#if CAP_SDL
|
#if CAP_SDL
|
||||||
int tick = SDL_GetTicks();
|
int tick = SDL_GetTicks();
|
||||||
if(tick > lastprogress + 250) {
|
if(tick > lastprogress + 250) {
|
||||||
@ -259,47 +263,58 @@ namespace conformal {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool on;
|
EX bool on;
|
||||||
vector<shmup::monster*> v;
|
EX vector<shmup::monster*> v;
|
||||||
int llv;
|
int llv;
|
||||||
double phase;
|
EX double phase;
|
||||||
|
|
||||||
vector<pair<cell*, eMonster> > killhistory;
|
EX vector<pair<cell*, eMonster> > killhistory;
|
||||||
vector<pair<cell*, eItem> > findhistory;
|
EX vector<pair<cell*, eItem> > findhistory;
|
||||||
vector<cell*> movehistory;
|
EX vector<cell*> movehistory;
|
||||||
|
|
||||||
bool includeHistory;
|
EX bool includeHistory;
|
||||||
ld lvspeed = 1;
|
EX ld lvspeed = 1;
|
||||||
int bandhalf = 200;
|
EX int bandhalf = 200;
|
||||||
int bandsegment = 16000;
|
EX int bandsegment = 16000;
|
||||||
ld rotation = 0;
|
EX ld rotation = 0;
|
||||||
ld rotation_xz = 90;
|
EX ld rotation_xz = 90;
|
||||||
ld rotation_xy2 = 90;
|
EX ld rotation_xy2 = 90;
|
||||||
int do_rotate = 1;
|
EX int do_rotate = 1;
|
||||||
ld model_orientation, halfplane_scale, model_orientation_yz;
|
EX ld model_orientation, halfplane_scale, model_orientation_yz;
|
||||||
ld clip_min, clip_max;
|
EX ld clip_min, clip_max;
|
||||||
ld ocos, osin, ocos_yz, osin_yz;
|
EX ld ocos, osin, ocos_yz, osin_yz;
|
||||||
ld cos_ball, sin_ball;
|
EX ld cos_ball, sin_ball;
|
||||||
bool model_straight, model_straight_yz;
|
EX bool model_straight, model_straight_yz;
|
||||||
ld top_z = 5;
|
EX ld top_z = 5;
|
||||||
ld model_transition = 1;
|
EX ld model_transition = 1;
|
||||||
|
|
||||||
bool autoband = false;
|
EX bool autoband = false;
|
||||||
bool autobandhistory = false;
|
EX bool autobandhistory = false;
|
||||||
bool dospiral = true;
|
EX bool dospiral = true;
|
||||||
|
|
||||||
ld extra_line_steps = 0;
|
#if HDR
|
||||||
|
// screen coordinates to logical coordinates: apply_orientation(x,y)
|
||||||
|
// logical coordinates back to screen coordinates: apply_orientation(y,x)
|
||||||
|
template<class A>
|
||||||
|
void apply_orientation(A& x, A& y) { if(!model_straight) tie(x,y) = make_pair(x*ocos + y*osin, y*ocos - x*osin); }
|
||||||
|
template<class A>
|
||||||
|
void apply_orientation_yz(A& x, A& y) { if(!model_straight_yz) tie(x,y) = make_pair(x*ocos_yz + y*osin_yz, y*ocos_yz - x*osin_yz); }
|
||||||
|
template<class A>
|
||||||
|
void apply_ball(A& x, A& y) { tie(x,y) = make_pair(x*cos_ball + y*sin_ball, y*cos_ball - x*sin_ball); }
|
||||||
|
#endif
|
||||||
|
|
||||||
vector<cell*> path_for_lineanimation;
|
EX ld extra_line_steps = 0;
|
||||||
|
|
||||||
void clear() {
|
EX vector<cell*> path_for_lineanimation;
|
||||||
|
|
||||||
|
EX void clear() {
|
||||||
on = false;
|
on = false;
|
||||||
int N = isize(v);
|
int N = isize(v);
|
||||||
for(int i=0; i<N; i++) delete v[i];
|
for(int i=0; i<N; i++) delete v[i];
|
||||||
v.resize(0);
|
v.resize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create(cell *start, cell *target, transmatrix last) {
|
EX void create(cell *start, cell *target, transmatrix last) {
|
||||||
|
|
||||||
if(target == start && !(quotient && isize(path_for_lineanimation) > 1)) {
|
if(target == start && !(quotient && isize(path_for_lineanimation) > 1)) {
|
||||||
addMessage("Must go a distance from the starting point");
|
addMessage("Must go a distance from the starting point");
|
||||||
@ -358,21 +373,21 @@ namespace conformal {
|
|||||||
phase = 0;
|
phase = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_playerpath() {
|
EX void create_playerpath() {
|
||||||
create(currentmap->gamestart(), cwt.at, Id);
|
create(currentmap->gamestart(), cwt.at, Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_recenter_to_view(bool precise) {
|
EX void create_recenter_to_view(bool precise) {
|
||||||
cell *c = centerover.at ? centerover.at : cwt.at;
|
cell *c = centerover.at ? centerover.at : cwt.at;
|
||||||
create(path_for_lineanimation[0], c, precise ? inverse(ggmatrix(c)) : Id);
|
create(path_for_lineanimation[0], c, precise ? inverse(ggmatrix(c)) : Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
transmatrix rotmatrix() {
|
EX transmatrix rotmatrix() {
|
||||||
if(DIM == 2) return spin(rotation * degree);
|
if(DIM == 2) return spin(rotation * degree);
|
||||||
return spin(rotation_xy2 * degree) * cspin(0, 2, -rotation_xz * degree) * spin(rotation * degree);
|
return spin(rotation_xy2 * degree) * cspin(0, 2, -rotation_xz * degree) * spin(rotation * degree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void movetophase() {
|
EX void movetophase() {
|
||||||
|
|
||||||
int ph = int(phase);
|
int ph = int(phase);
|
||||||
int siz = isize(v);
|
int siz = isize(v);
|
||||||
@ -415,7 +430,7 @@ namespace conformal {
|
|||||||
compute_graphical_distance();
|
compute_graphical_distance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply() {
|
EX void apply() {
|
||||||
int t = ticks;
|
int t = ticks;
|
||||||
phase += (t-llv) * lvspeed / 400.;
|
phase += (t-llv) * lvspeed / 400.;
|
||||||
llv = t;
|
llv = t;
|
||||||
@ -428,19 +443,21 @@ namespace conformal {
|
|||||||
movetophase();
|
movetophase();
|
||||||
}
|
}
|
||||||
|
|
||||||
ld spiral_angle = 70, spiral_x = 10, spiral_y = 7;
|
EX ld spiral_angle = 70;
|
||||||
|
EX ld spiral_x = 10;
|
||||||
|
EX ld spiral_y = 7;
|
||||||
int spiral_id = 7;
|
int spiral_id = 7;
|
||||||
bool use_atan = false;
|
EX bool use_atan = false;
|
||||||
|
|
||||||
cld spiral_multiplier;
|
cld spiral_multiplier;
|
||||||
ld right_spiral_multiplier = 1;
|
ld right_spiral_multiplier = 1;
|
||||||
ld any_spiral_multiplier = 1;
|
ld any_spiral_multiplier = 1;
|
||||||
ld sphere_spiral_multiplier = 2;
|
ld sphere_spiral_multiplier = 2;
|
||||||
ld spiral_cone = 360;
|
EX ld spiral_cone = 360;
|
||||||
ld spiral_cone_rad;
|
ld spiral_cone_rad;
|
||||||
bool ring_not_spiral;
|
bool ring_not_spiral;
|
||||||
|
|
||||||
void configure() {
|
EX void configure() {
|
||||||
ld ball = -vid.ballangle * degree;
|
ld ball = -vid.ballangle * degree;
|
||||||
cos_ball = cos(ball), sin_ball = sin(ball);
|
cos_ball = cos(ball), sin_ball = sin(ball);
|
||||||
ocos = cos(model_orientation * degree);
|
ocos = cos(model_orientation * degree);
|
||||||
@ -629,7 +646,7 @@ namespace conformal {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool model_available(eModel pm) {
|
EX bool model_available(eModel pm) {
|
||||||
if(nonisotropic) return among(pm, mdDisk, mdPerspective, mdGeodesic);
|
if(nonisotropic) return among(pm, mdDisk, mdPerspective, mdGeodesic);
|
||||||
if(pm == mdGeodesic && !sol) return false;
|
if(pm == mdGeodesic && !sol) return false;
|
||||||
if(sphere && (pm == mdHalfplane || pm == mdBall))
|
if(sphere && (pm == mdHalfplane || pm == mdBall))
|
||||||
@ -641,18 +658,18 @@ namespace conformal {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool model_has_orientation() {
|
EX bool model_has_orientation() {
|
||||||
return
|
return
|
||||||
among(pmodel, mdHalfplane, mdPolynomial, mdPolygonal, mdTwoPoint, mdJoukowsky, mdJoukowskyInverted, mdSpiral, mdSimulatedPerspective, mdTwoHybrid) || mdBandAny();
|
among(pmodel, mdHalfplane, mdPolynomial, mdPolygonal, mdTwoPoint, mdJoukowsky, mdJoukowskyInverted, mdSpiral, mdSimulatedPerspective, mdTwoHybrid) || mdBandAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool model_has_transition() {
|
EX bool model_has_transition() {
|
||||||
return among(pmodel, mdJoukowsky, mdJoukowskyInverted, mdBand) && DIM == 2;
|
return among(pmodel, mdJoukowsky, mdJoukowskyInverted, mdBand) && DIM == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int editpos = 0;
|
int editpos = 0;
|
||||||
|
|
||||||
string get_model_name(eModel m) {
|
EX string get_model_name(eModel m) {
|
||||||
if(m == mdDisk && DIM == 3 && hyperbolic) return XLAT("ball model/Gans");
|
if(m == mdDisk && DIM == 3 && hyperbolic) return XLAT("ball model/Gans");
|
||||||
if(nonisotropic) {
|
if(nonisotropic) {
|
||||||
if(m == mdDisk) return XLAT("simple model: projection");
|
if(m == mdDisk) return XLAT("simple model: projection");
|
||||||
@ -697,7 +714,7 @@ namespace conformal {
|
|||||||
dialog::bound_up(isize(torus_zeros)-1);
|
dialog::bound_up(isize(torus_zeros)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void edit_formula() {
|
EX void edit_formula() {
|
||||||
if(pmodel != mdFormula) basic_model = pmodel;
|
if(pmodel != mdFormula) basic_model = pmodel;
|
||||||
dialog::edit_string(formula, "formula",
|
dialog::edit_string(formula, "formula",
|
||||||
XLAT(
|
XLAT(
|
||||||
@ -727,7 +744,7 @@ namespace conformal {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void edit_rotation(ld& which) {
|
EX void edit_rotation(ld& which) {
|
||||||
dialog::editNumber(which, 0, 360, 90, 0, XLAT("rotation"),
|
dialog::editNumber(which, 0, 360, 90, 0, XLAT("rotation"),
|
||||||
"This controls the automatic rotation of the world. "
|
"This controls the automatic rotation of the world. "
|
||||||
"It affects the line animation in the history mode, and "
|
"It affects the line animation in the history mode, and "
|
||||||
@ -751,7 +768,7 @@ namespace conformal {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void model_menu() {
|
EX void model_menu() {
|
||||||
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER;
|
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER;
|
||||||
gamescreen(0);
|
gamescreen(0);
|
||||||
dialog::init(XLAT("models & projections"));
|
dialog::init(XLAT("models & projections"));
|
||||||
@ -1060,11 +1077,11 @@ namespace conformal {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool band_renderable_now() {
|
EX bool band_renderable_now() {
|
||||||
return on && (pmodel == mdBand || pmodel == mdBandEquidistant || pmodel == mdBandEquiarea) && !euclid && !sphere;
|
return on && (pmodel == mdBand || pmodel == mdBandEquidistant || pmodel == mdBandEquiarea) && !euclid && !sphere;
|
||||||
}
|
}
|
||||||
|
|
||||||
void history_menu() {
|
EX void history_menu() {
|
||||||
cmode = sm::SIDE | sm::MAYDARK;
|
cmode = sm::SIDE | sm::MAYDARK;
|
||||||
gamescreen(0);
|
gamescreen(0);
|
||||||
|
|
||||||
@ -1159,7 +1176,7 @@ namespace conformal {
|
|||||||
|
|
||||||
set<cell*> inmovehistory, inkillhistory, infindhistory;
|
set<cell*> inmovehistory, inkillhistory, infindhistory;
|
||||||
|
|
||||||
void restore() {
|
EX void restore() {
|
||||||
inmovehistory.clear();
|
inmovehistory.clear();
|
||||||
inkillhistory.clear();
|
inkillhistory.clear();
|
||||||
infindhistory.clear();
|
infindhistory.clear();
|
||||||
@ -1181,7 +1198,7 @@ namespace conformal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreBack() {
|
EX void restoreBack() {
|
||||||
int sk = isize(killhistory);
|
int sk = isize(killhistory);
|
||||||
for(int i=sk-1; i>=0; i--) {
|
for(int i=sk-1; i>=0; i--) {
|
||||||
eMonster m = killhistory[i].second;
|
eMonster m = killhistory[i].second;
|
||||||
@ -1196,7 +1213,7 @@ namespace conformal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderAutoband() {
|
EX void renderAutoband() {
|
||||||
#if CAP_SDL
|
#if CAP_SDL
|
||||||
if(!cwt.at || celldist(cwt.at) <= 7) return;
|
if(!cwt.at || celldist(cwt.at) <= 7) return;
|
||||||
if(!autoband) return;
|
if(!autoband) return;
|
||||||
|
78
hyper.h
78
hyper.h
@ -1064,84 +1064,6 @@ extern ld ruggo;
|
|||||||
|
|
||||||
#define HASLINEVIEW
|
#define HASLINEVIEW
|
||||||
|
|
||||||
namespace shmup { struct monster; }
|
|
||||||
|
|
||||||
namespace conformal {
|
|
||||||
extern bool on;
|
|
||||||
extern vector<pair<cell*, eMonster> > killhistory;
|
|
||||||
extern vector<pair<cell*, eItem> > findhistory;
|
|
||||||
extern vector<cell*> movehistory;
|
|
||||||
extern set<cell*> inmovehistory, inkillhistory, infindhistory;
|
|
||||||
extern bool includeHistory;
|
|
||||||
extern bool use_atan;
|
|
||||||
extern ld rotation;
|
|
||||||
extern ld rotation_xz, rotation_xy2;
|
|
||||||
transmatrix rotmatrix();
|
|
||||||
extern int do_rotate;
|
|
||||||
extern ld model_orientation, model_orientation_yz;
|
|
||||||
extern ld halfplane_scale;
|
|
||||||
extern ld ocos, osin, ocos_yz, osin_yz;
|
|
||||||
extern ld cos_ball, sin_ball;
|
|
||||||
extern bool model_straight, model_straight_yz;
|
|
||||||
extern ld model_transition;
|
|
||||||
extern ld top_z;
|
|
||||||
extern ld spiral_angle, spiral_x, spiral_y;
|
|
||||||
extern ld spiral_cone;
|
|
||||||
extern ld clip_min, clip_max;
|
|
||||||
|
|
||||||
// screen coordinates to logical coordinates: apply_orientation(x,y)
|
|
||||||
// logical coordinates back to screen coordinates: apply_orientation(y,x)
|
|
||||||
template<class A>
|
|
||||||
void apply_orientation(A& x, A& y) { if(!model_straight) tie(x,y) = make_pair(x*ocos + y*osin, y*ocos - x*osin); }
|
|
||||||
template<class A>
|
|
||||||
void apply_orientation_yz(A& x, A& y) { if(!model_straight_yz) tie(x,y) = make_pair(x*ocos_yz + y*osin_yz, y*ocos_yz - x*osin_yz); }
|
|
||||||
template<class A>
|
|
||||||
void apply_ball(A& x, A& y) { tie(x,y) = make_pair(x*cos_ball + y*sin_ball, y*cos_ball - x*sin_ball); }
|
|
||||||
|
|
||||||
void configure();
|
|
||||||
|
|
||||||
extern bool autoband;
|
|
||||||
extern bool autobandhistory;
|
|
||||||
extern bool dospiral;
|
|
||||||
extern ld lvspeed;
|
|
||||||
extern int bandsegment;
|
|
||||||
extern int bandhalf;
|
|
||||||
extern ld extra_line_steps;
|
|
||||||
|
|
||||||
void create(cell *start, cell *target);
|
|
||||||
void create_playerpath();
|
|
||||||
void create_recenter_to_view(bool precise);
|
|
||||||
void clear();
|
|
||||||
void model_menu();
|
|
||||||
void history_menu();
|
|
||||||
string get_model_name(eModel);
|
|
||||||
void apply();
|
|
||||||
void movetophase();
|
|
||||||
void renderAutoband();
|
|
||||||
|
|
||||||
extern vector<shmup::monster*> v;
|
|
||||||
extern double phase;
|
|
||||||
void applyIB();
|
|
||||||
|
|
||||||
void progress_screen();
|
|
||||||
void progress(string str);
|
|
||||||
bool model_has_orientation();
|
|
||||||
|
|
||||||
extern string formula;
|
|
||||||
extern eModel basic_model;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace polygonal {
|
|
||||||
static const int MSI = 120;
|
|
||||||
extern int SI;
|
|
||||||
extern ld STAR;
|
|
||||||
extern int deg;
|
|
||||||
extern ld coefr[MSI], coefi[MSI];
|
|
||||||
extern int maxcoef, coefid;
|
|
||||||
void solve();
|
|
||||||
pair<ld, ld> compute(ld x, ld y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// passable flags
|
// passable flags
|
||||||
|
|
||||||
#define SAGEMELT .1
|
#define SAGEMELT .1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user