new Nil model used in Nil Rider

This commit is contained in:
Zeno Rogue 2023-01-30 01:20:12 +01:00
parent 439850f74c
commit 98690c225c
4 changed files with 27 additions and 16 deletions

View File

@ -54,7 +54,7 @@ void level::init_textures() {
col = bcols[c];
if(levels && new_levellines_for[3]) {
hyperpoint h = T * mappt(x, y, texture_density);
ld z = h[2] - sym_to_heis_bonus(h);
ld z = h[2] - sym_to_used_bonus(h);
if(z > 0) col = gradient(col, 0xFFFF0000, 0, z - floor(z), 4);
if(z < 0) col = gradient(col, 0xFF0000FF, 0, -z - floor(-z), 4);
}
@ -151,7 +151,7 @@ void level::init_shapes() {
gh[0] = gh[0] - ah[0];
gh[1] = gh[1] - ah[1];
gh[2] = 0;
gh = sym_to_heis(gh);
gh = sym_to_used(gh);
h = rgpushxto0(ah) * gh;
ld delta = 0;
// make sure steps are below the actual level
@ -163,7 +163,7 @@ void level::init_shapes() {
uh[0] = zh[0] - ah[0];
uh[1] = zh[1] - ah[1];
uh[2] = 0; uh[3] = 1;
uh = sym_to_heis(uh);
uh = sym_to_used(uh);
uh = rgpushxto0(ah) * uh;
delta = max(delta, uh[2] - zh[2]);
}
@ -462,7 +462,7 @@ ld level::safe_alt(hyperpoint h, ld mul, ld mulx) {
ld maxv = 0;
for(int x: {-1, 0, 1})
for(int y: {-1, 0, 1}) {
hyperpoint c = sym_to_heis(point31(x*.5*scale*mulx, y*.5*scale*mulx, 0));
hyperpoint c = sym_to_used(point31(x*.5*scale*mulx, y*.5*scale*mulx, 0));
hyperpoint j = rgpushxto0(h) * c;
maxv = max(maxv, mul * (surface(j) - j[2]));
}

View File

@ -83,6 +83,8 @@ struct goal {
using surface_fun = std::function<ld(hyperpoint h)>;
ld heis_to_used_bonus(const hyperpoint&);
struct level {
string name;
char hotkey;
@ -92,12 +94,13 @@ struct level {
vector<string> map_tiles;
ld startx, starty;
ld scale;
surface_fun surface;
surface_fun surface_heisenberg;
ld surface(hyperpoint h) { return surface_heisenberg(h) + heis_to_used_bonus(h); }
bool initialized;
level(string name, char hotkey, flagtype flags, string longdesc, ld minx, ld miny, ld maxx, ld maxy, const vector<string>& mt, ld sx, ld sy, const std::function<ld(hyperpoint h)>& surf, vector<goal> g) :
name(name), hotkey(hotkey), longdesc(longdesc), flags(flags), minx(minx), miny(miny), maxx(maxx), maxy(maxy), map_tiles(mt), startx(sx), starty(sy), surface(surf), goals(g) { initialized = false; }
name(name), hotkey(hotkey), longdesc(longdesc), flags(flags), minx(minx), miny(miny), maxx(maxx), maxy(maxy), map_tiles(mt), startx(sx), starty(sy), surface_heisenberg(surf), goals(g) { initialized = false; }
ld real_minx, real_miny, real_maxx, real_maxy;
@ -211,7 +214,7 @@ inline double dft_block = 1;
extern map<char, color_t> bcols;
extern map<char, array<string, 16> > submaps;
hyperpoint sym_to_heis(hyperpoint H);
hyperpoint sym_to_used(hyperpoint H);
extern int reversals;
extern bool loaded_or_planned;

View File

@ -134,7 +134,7 @@ void init_statues() {
add_statue(closed_grid, [&] (ld lon, ld lat) {
lat = lat * .75;
hyperpoint h = direct_exp(ih * (.5 + lat / M_PI));
return rgpushxto0(h) * sym_to_heis(point31(sin(lon)*.1, cos(lon)*.1, 0));
return rgpushxto0(h) * sym_to_used(point31(sin(lon)*.1, cos(lon)*.1, 0));
});
}
cgi.finishshape();

View File

@ -2,15 +2,23 @@ namespace nilrider {
ld timestamp::energy_in_squares() { return vel * vel / (2 * gravity); }
EX ld sym_to_heis_bonus(const hyperpoint& H) {
return H[0] * H[1] / 2;
EX ld sym_to_used_bonus(const hyperpoint& H) {
return nilv::sym_to_heis_bonus(H) * (nilv::model_used - nilv::nmSym);
}
/** convert rotationally symmetric to Heisenberg model */
EX hyperpoint sym_to_heis(hyperpoint H) {
if(nil) {
H[2] += sym_to_heis_bonus(H);
}
EX ld heis_to_used_bonus(const hyperpoint& H) {
return nilv::sym_to_heis_bonus(H) * (nilv::model_used - nilv::nmHeis);
}
/** convert rotationally symmetric to internal model */
EX hyperpoint sym_to_used(hyperpoint H) {
if(nil) H[2] += sym_to_used_bonus(H);
return H;
}
/** convert Heisenberg to internal model */
EX hyperpoint heis_to_used(hyperpoint H) {
if(nil) H[2] += heis_to_used_bonus(H);
return H;
}
@ -180,7 +188,7 @@ void timestamp::centerview(level *lev) {
auto w = where;
w[2] += 0.2 * lev->scale;
hyperpoint front = rgpushxto0(w) * sym_to_heis(hyperpoint(1e-3 * cos(heading_angle), 1e-3*sin(heading_angle), 0, 1));
hyperpoint front = rgpushxto0(w) * sym_to_used(hyperpoint(1e-3 * cos(heading_angle), 1e-3*sin(heading_angle), 0, 1));
hyperpoint up = w; up[2] += 1e-3;
set_view(w, front, up);