mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 09:00:34 +00:00
viewctr is no more... major reduction of redundancy/complexity
This commit is contained in:
parent
74a139ca3e
commit
ef9e2236ba
@ -606,7 +606,7 @@ struct hrmap_archimedean : hrmap {
|
||||
|
||||
void draw() {
|
||||
dq::visited.clear();
|
||||
dq::enqueue(viewctr.at, cview());
|
||||
dq::enqueue(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
|
@ -153,7 +153,7 @@ struct hrmap_asonov : hrmap {
|
||||
void draw() override {
|
||||
dq::visited_by_matrix.clear();
|
||||
|
||||
dq::enqueue_by_matrix(viewctr.at, cview());
|
||||
dq::enqueue_by_matrix(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
|
@ -13,16 +13,12 @@ EX int fontscale = 100;
|
||||
#if HDR
|
||||
/** configuration of the current view */
|
||||
struct display_data {
|
||||
/** This specifies the heptagon the view is currently centered on.
|
||||
* Unused in masterless tilings -- precise_center is used there.
|
||||
*/
|
||||
heptspin view_center;
|
||||
/** The current rotation, relative to viewctr. */
|
||||
/** The cell which is currently in the center. */
|
||||
cell *precise_center;
|
||||
/** The current rotation, relative to precise_center. */
|
||||
transmatrix view_matrix;
|
||||
/** The view relative to the player character. */
|
||||
transmatrix player_matrix;
|
||||
/** The cell which is precisely in the center. */
|
||||
cellwalker precise_center;
|
||||
/** On-screen coordinates for all the visible cells. */
|
||||
unordered_map<cell*, transmatrix> cellmatrices, old_cellmatrices;
|
||||
/** Position of the current map view, relative to the screen (0 to 1). */
|
||||
@ -53,7 +49,6 @@ struct display_data {
|
||||
|
||||
#define View (current_display->view_matrix)
|
||||
#define cwtV (current_display->player_matrix)
|
||||
#define viewctr (current_display->view_center)
|
||||
#define centerover (current_display->precise_center)
|
||||
#define gmatrix (current_display->cellmatrices)
|
||||
#define gmatrix0 (current_display->old_cellmatrices)
|
||||
|
@ -249,7 +249,7 @@ EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special
|
||||
alt->emeraldval = 0;
|
||||
alt->zebraval = 0;
|
||||
alt->distance = 0;
|
||||
alt->fieldval = hybrid::current_view_level;
|
||||
alt->fieldval = hybrid::get_where(centerover).second;
|
||||
alt->c7 = NULL;
|
||||
alt->alt = alt;
|
||||
h->alt = alt;
|
||||
|
@ -400,7 +400,7 @@ EX namespace binary {
|
||||
|
||||
void draw() override {
|
||||
dq::visited.clear();
|
||||
dq::enqueue(viewctr.at, cview());
|
||||
dq::enqueue(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
|
@ -1525,9 +1525,9 @@ void celldrawer::draw_features_and_walls_3d() {
|
||||
b = !isWall3(c->move(a), dummy);
|
||||
if(b) {
|
||||
if(pmodel == mdPerspective && !sphere && !quotient && !penrose && !nonisotropic && !hybri && !experimental && !nih) {
|
||||
if(a < 4 && among(geometry, gHoroTris, gBinary3) && celldistAlt(c) >= celldistAlt(viewcenter())) continue;
|
||||
else if(a < 2 && among(geometry, gHoroRec) && celldistAlt(c) >= celldistAlt(viewcenter())) continue;
|
||||
else if(c->move(a)->master->distance > c->master->distance && c->master->distance > viewctr.at->distance && !quotient) continue;
|
||||
if(a < 4 && among(geometry, gHoroTris, gBinary3) && celldistAlt(c) >= celldistAlt(centerover)) continue;
|
||||
else if(a < 2 && among(geometry, gHoroRec) && celldistAlt(c) >= celldistAlt(centerover)) continue;
|
||||
else if(c->move(a)->master->distance > c->master->distance && c->master->distance > centerover->master->distance && !quotient) continue;
|
||||
}
|
||||
else if(sol && in_perspective() && !nih && !asonov::in()) {
|
||||
ld b = vid.binary_width * log(2) / 2;
|
||||
@ -1725,15 +1725,6 @@ void celldrawer::bookkeeping() {
|
||||
mouseover2 = c;
|
||||
}
|
||||
|
||||
if(!masterless) {
|
||||
double dfc = euclid ? intval(tC0(V), C0) : V[LDIM][LDIM];
|
||||
|
||||
if(dfc < centdist) {
|
||||
centdist = dfc;
|
||||
centerover = cw;
|
||||
}
|
||||
}
|
||||
|
||||
int orbrange = (items[itRevolver] ? 3 : 2);
|
||||
|
||||
if(c->cpdist <= orbrange) if(multi::players > 1 || multi::alwaysuse)
|
||||
|
@ -57,7 +57,7 @@ EX movedir mousedest;
|
||||
EX ld shiftmul = 1;
|
||||
|
||||
EX cell *mouseover, *mouseover2, *lmouseover;
|
||||
EX ld modist, modist2, centdist;
|
||||
EX ld modist, modist2;
|
||||
|
||||
EX int lastt;
|
||||
|
||||
@ -431,7 +431,7 @@ EX void handleKeyNormal(int sym, int uni) {
|
||||
|
||||
if(DEFAULTNOR(sym)) {
|
||||
gmodekeys(sym, uni);
|
||||
if(uni == 'm' && canmove && (centerover == cwt ? mouseover : centerover.at))
|
||||
if(uni == 'm' && canmove && (centerover == cwt.at ? mouseover : centerover))
|
||||
performMarkCommand(mouseover);
|
||||
}
|
||||
|
||||
@ -440,11 +440,12 @@ EX void handleKeyNormal(int sym, int uni) {
|
||||
if((sym == SDLK_DELETE || sym == SDLK_KP_PERIOD || sym == 'g') && uni != 'G' && uni != 'G'-64)
|
||||
movepcto(MD_DROP, 1);
|
||||
if(sym == 't' && uni != 'T' && uni != 'T'-64 && canmove) {
|
||||
cell *target = GDIM == 3 ? mouseover : centerover;
|
||||
if(playermoved && items[itStrongWind]) {
|
||||
cell *c = whirlwind::jumpDestination(cwt.at);
|
||||
if(c) centerover.at = c;
|
||||
if(c) target = c;
|
||||
}
|
||||
targetRangedOrb(GDIM == 3 ? mouseover : centerover.at, roKeyboard);
|
||||
targetRangedOrb(target, roKeyboard);
|
||||
sym = 0; uni = 0;
|
||||
}
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ struct hrmap_crystal : hrmap_standard {
|
||||
// for(int i=0; i<S6; i++) queuepoly(ggmatrix(cwt.at), shWall3D[i], 0xFF0000FF);
|
||||
|
||||
dq::visited_by_matrix.clear();
|
||||
dq::enqueue_by_matrix(viewctr.at, cview());
|
||||
dq::enqueue_by_matrix(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
|
@ -559,7 +559,7 @@ EX void viewall() {
|
||||
|
||||
/** launch a debugging screen, and continue normal working only after this screen is closed */
|
||||
EX void modalDebug(cell *c) {
|
||||
viewctr.at = c->master;
|
||||
centerover = c; View = Id;
|
||||
if(noGUI) {
|
||||
fprintf(stderr, "fatal: modalDebug called on %p without GUI\n", c);
|
||||
exit(1);
|
||||
|
11
euclid.cpp
11
euclid.cpp
@ -681,7 +681,7 @@ EX namespace euclid3 {
|
||||
|
||||
void draw() override {
|
||||
dq::visited_by_matrix.clear();
|
||||
dq::enqueue_by_matrix(viewctr.at, cview());
|
||||
dq::enqueue_by_matrix(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
@ -1220,10 +1220,9 @@ EX ld matrixnorm(const transmatrix& Mat) {
|
||||
void hrmap_euclid_any::draw() {
|
||||
DEBB(DF_GRAPH, ("drawEuclidean\n"));
|
||||
sphereflip = Id;
|
||||
if(!centerover.at) centerover = cwt;
|
||||
// printf("centerover = %p player = %p [%d,%d]-[%d,%d]\n", lcenterover, cwt.c,
|
||||
// mindx, mindy, maxdx, maxdy);
|
||||
int pvec = cellwalker_to_vec(centerover);
|
||||
int pvec = cellwalker_to_vec(cellwalker(centerover));
|
||||
|
||||
typedef pair<int, int> euspot;
|
||||
|
||||
@ -1232,7 +1231,6 @@ void hrmap_euclid_any::draw() {
|
||||
set<euspot> visited = {zero};
|
||||
vector<euspot> dfs = {zero};
|
||||
|
||||
ld centerd = matrixnorm(View);
|
||||
auto View0 = cview();
|
||||
|
||||
for(int i=0; i<isize(dfs); i++) {
|
||||
@ -1245,11 +1243,6 @@ void hrmap_euclid_any::draw() {
|
||||
torusconfig::torus_cx = dx;
|
||||
torusconfig::torus_cy = dy;
|
||||
|
||||
if(true) {
|
||||
ld locald = matrixnorm(Mat);
|
||||
if(locald < centerd) centerd = locald, centerover = cw, View = inverse(actual_view_transform) * Mat;
|
||||
}
|
||||
|
||||
if(do_draw(cw.at, Mat)) {
|
||||
drawcell(cw, cw.mirrored ? Mat * spin(-2*M_PI*cw.spin / cw.at->type) * Mirror : Mat);
|
||||
for(int x=-1; x<=+1; x++)
|
||||
|
2
game.cpp
2
game.cpp
@ -3062,7 +3062,7 @@ EX int pathlock = 0;
|
||||
|
||||
EX void compute_graphical_distance() {
|
||||
if(pathlock) { printf("path error: compute_graphical_distance\n"); }
|
||||
cell *c1 = centerover.at ? centerover.at : pd_from ? pd_from : cwt.at;
|
||||
cell *c1 = centerover ? centerover : pd_from ? pd_from : cwt.at;
|
||||
int sr = get_sightrange_ambush();
|
||||
if(pd_from == c1 && pd_range == sr) return;
|
||||
clear_pathdata();
|
||||
|
@ -157,14 +157,14 @@ transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint
|
||||
EX transmatrix &ggmatrix(cell *c) {
|
||||
transmatrix& t = gmatrix[c];
|
||||
if(t[LDIM][LDIM] == 0) {
|
||||
if(euwrap && centerover.at && masterless)
|
||||
t = calc_relative_matrix(c, centerover.at, C0);
|
||||
if(euwrap && centerover && masterless)
|
||||
t = calc_relative_matrix(c, centerover, C0);
|
||||
else if(masterless && WDIM == 2) {
|
||||
if(!centerover.at) centerover = cwt;
|
||||
t = View * eumove(cell_to_vec(c) - cellwalker_to_vec(centerover));
|
||||
if(!centerover) centerover = cwt.at;
|
||||
t = View * eumove(cell_to_vec(c) - cellwalker_to_vec(cellwalker(centerover)));
|
||||
}
|
||||
else
|
||||
t = actualV(viewctr, actual_view_transform * View) * calc_relative_matrix(c, viewcenter(), C0);
|
||||
t = calc_relative_matrix(c, centerover, C0);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
38
graph.cpp
38
graph.cpp
@ -815,7 +815,7 @@ EX bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int
|
||||
|
||||
if(GDIM == 3 && mapeditor::drawUserShape(V, mapeditor::sgItem, it, darkena(icol, 0, 0xFF), c)) return false;
|
||||
|
||||
if(WDIM == 3 && c == viewcenter() && in_perspective() && hdist0(tC0(V)) < cgi.orbsize * 0.25) return false;
|
||||
if(WDIM == 3 && c == centerover && in_perspective() && hdist0(tC0(V)) < cgi.orbsize * 0.25) return false;
|
||||
|
||||
transmatrix Vit = V;
|
||||
if(GDIM == 3 && WDIM == 2 && c && it != itBabyTortoise) Vit = mscale(V, cgi.STUFF);
|
||||
@ -4068,8 +4068,8 @@ EX void drawMarkers() {
|
||||
#endif
|
||||
|
||||
#if CAP_QUEUE
|
||||
if(centerover.at && !playermoved && m && !anims::any_animation() && WDIM == 2)
|
||||
queuecircleat(centerover.at, .70 - .06 * sintick(200),
|
||||
if(centerover && !playermoved && m && !anims::any_animation() && WDIM == 2)
|
||||
queuecircleat(centerover, .70 - .06 * sintick(200),
|
||||
darkena(int(175 + 25 * sintick(200)), 0, 0xFF));
|
||||
|
||||
if(multi::players > 1 || multi::alwaysuse) for(int i=0; i<numplayers(); i++) {
|
||||
@ -4311,8 +4311,8 @@ EX void make_actual_view() {
|
||||
if(GDIM == 3) {
|
||||
ld max = WDIM == 2 ? vid.camera : vid.yshift;
|
||||
if(max) {
|
||||
transmatrix Start = inverse(actualV(viewctr, actual_view_transform * View));
|
||||
ld d = wall_radar(viewcenter(), Start, nisot::local_perspective, max);
|
||||
transmatrix Start = inverse(actual_view_transform * View);
|
||||
ld d = wall_radar(centerover, Start, nisot::local_perspective, max);
|
||||
actual_view_transform = get_shift_view_of(ztangent(d), actual_view_transform * View) * inverse(View);
|
||||
}
|
||||
camera_level = asin_auto(tC0(inverse(actual_view_transform * View))[2]);
|
||||
@ -4349,7 +4349,7 @@ EX transmatrix cview() {
|
||||
|
||||
EX void precise_mouseover() {
|
||||
if(WDIM == 3) {
|
||||
mouseover2 = mouseover = viewcenter();
|
||||
mouseover2 = mouseover = centerover;
|
||||
ld best = HUGE_VAL;
|
||||
hyperpoint h = direct_exp(lp_iapply(ztangent(0.01)), 100);
|
||||
|
||||
@ -4481,9 +4481,6 @@ EX void drawthemap() {
|
||||
|
||||
compute_graphical_distance();
|
||||
|
||||
centdist = 1e20;
|
||||
if(!masterless) centerover.at = NULL;
|
||||
|
||||
for(int i=0; i<multi::players; i++) {
|
||||
multi::ccdist[i] = 1e20; multi::ccat[i] = NULL;
|
||||
}
|
||||
@ -4794,7 +4791,7 @@ EX void gamescreen(int _darken) {
|
||||
if(racing::on) return;
|
||||
// create the gmatrix
|
||||
View = subscreens::player_displays[0].view_matrix;
|
||||
viewctr = subscreens::player_displays[0].view_center;
|
||||
centerover = subscreens::player_displays[0].precise_center;
|
||||
just_gmatrix = true;
|
||||
currentmap->draw();
|
||||
just_gmatrix = false;
|
||||
@ -5042,14 +5039,7 @@ EX void restartGraph() {
|
||||
View = Id;
|
||||
if(!autocheat) linepatterns::clearAll();
|
||||
if(currentmap) {
|
||||
if(masterless) {
|
||||
centerover = vec_to_cellwalker(0);
|
||||
}
|
||||
else {
|
||||
viewctr.at = currentmap->getOrigin();
|
||||
viewctr.spin = 0;
|
||||
viewctr.mirrored = false;
|
||||
}
|
||||
centerover = currentmap->gamestart();
|
||||
if(sphere) View = spin(-M_PI/2);
|
||||
}
|
||||
}
|
||||
@ -5062,7 +5052,7 @@ EX void clearAnimations() {
|
||||
|
||||
auto graphcm = addHook(clearmemory, 0, [] () {
|
||||
DEBBI(DF_MEMORY, ("clear graph memory"));
|
||||
mouseover = centerover.at = lmouseover = NULL;
|
||||
mouseover = centerover = lmouseover = NULL;
|
||||
gmatrix.clear(); gmatrix0.clear();
|
||||
clearAnimations();
|
||||
})
|
||||
@ -5197,18 +5187,12 @@ EX void drawBug(const cellwalker& cw, color_t col) {
|
||||
#endif
|
||||
}
|
||||
|
||||
EX cell *viewcenter() {
|
||||
if(masterless) return centerover.at;
|
||||
else if(hybri) return hybrid::get_at(viewctr.at->c7, hybrid::current_view_level);
|
||||
else return viewctr.at->c7;
|
||||
}
|
||||
|
||||
EX bool inscreenrange(cell *c) {
|
||||
if(sphere) return true;
|
||||
if(euclid) return celldistance(viewcenter(), c) <= get_sightrange_ambush();
|
||||
if(euclid) return celldistance(centerover, c) <= get_sightrange_ambush();
|
||||
if(nonisotropic) return gmatrix.count(c);
|
||||
if(geometry == gCrystal344) return gmatrix.count(c);
|
||||
return heptdistance(viewcenter(), c) <= 8;
|
||||
return heptdistance(centerover, c) <= 8;
|
||||
}
|
||||
|
||||
#if MAXMDIM >= 4
|
||||
|
2
help.cpp
2
help.cpp
@ -752,7 +752,7 @@ EX hookset<void(cell*)> *hooks_mouseover;
|
||||
EX void describeMouseover() {
|
||||
DEBBI(DF_GRAPH, ("describeMouseover"));
|
||||
|
||||
cell *c = mousing ? mouseover : playermoved ? NULL : centerover.at;
|
||||
cell *c = mousing ? mouseover : playermoved ? NULL : centerover;
|
||||
string& out = mouseovers;
|
||||
if(!c || instat || getcstat != '-') { }
|
||||
else if(c->wall != waInvisibleFloor) {
|
||||
|
17
history.cpp
17
history.cpp
@ -260,7 +260,7 @@ EX namespace history {
|
||||
}
|
||||
|
||||
EX void create_recenter_to_view(bool precise) {
|
||||
cell *c = centerover.at ? centerover.at : cwt.at;
|
||||
cell *c = centerover ? centerover : cwt.at;
|
||||
create(path_for_lineanimation[0], c, precise ? inverse(ggmatrix(c)) : Id);
|
||||
}
|
||||
|
||||
@ -271,10 +271,9 @@ EX namespace history {
|
||||
if(ph<0) ph = 0;
|
||||
if(ph >= siz-1) ph = siz-2;
|
||||
|
||||
heptagon *old = viewctr.at;
|
||||
cell *old = centerover;
|
||||
|
||||
viewctr.at = v[ph]->base->master;
|
||||
viewctr.spin = 0;
|
||||
centerover = v[ph]->base;
|
||||
|
||||
ld angle = 0;
|
||||
if(WDIM == 3) {
|
||||
@ -294,8 +293,8 @@ EX namespace history {
|
||||
View = models::rotmatrix() * View;
|
||||
}
|
||||
else {
|
||||
if(celldistance(v[ph]->base, old->c7) <= 2) {
|
||||
hyperpoint h1 = View * currentmap->relative_matrix(old, viewctr.at) * hpxy3(1,2,3);
|
||||
if(celldistance(v[ph]->base, old) <= 2) {
|
||||
hyperpoint h1 = View * currentmap->relative_matrix(old, centerover, C0) * hpxy3(1,2,3);
|
||||
ld angle1 = atan2(h1[1], h1[2]);
|
||||
View = cspin(2, 1, angle1 - angle) * View;
|
||||
}
|
||||
@ -303,7 +302,7 @@ EX namespace history {
|
||||
}
|
||||
|
||||
playermoved = false;
|
||||
centerover.at = v[ph]->base;
|
||||
centerover = v[ph]->base;
|
||||
compute_graphical_distance();
|
||||
}
|
||||
|
||||
@ -445,8 +444,8 @@ EX namespace history {
|
||||
xpos += bwidth;
|
||||
}
|
||||
|
||||
last_base = viewcenter();
|
||||
last_relative = inverse(ggmatrix(last_base)) * C0;
|
||||
last_base = centerover;
|
||||
last_relative = C0;
|
||||
}
|
||||
}
|
||||
|
||||
|
137
hypgraph.cpp
137
hypgraph.cpp
@ -1164,7 +1164,7 @@ void hrmap_standard::draw() {
|
||||
return;
|
||||
}
|
||||
drawn_cells.clear();
|
||||
drawn_cells.emplace_back(viewctr, hsOrigin, cview(), band_shift);
|
||||
drawn_cells.emplace_back(centerover->master, hsOrigin, cview() * master_relative(centerover, true), band_shift);
|
||||
for(int i=0; i<isize(drawn_cells); i++) {
|
||||
// prevent reallocation due to insertion
|
||||
if(drawn_cells.capacity() < drawn_cells.size() + 16)
|
||||
@ -1364,19 +1364,8 @@ EX void centerpc(ld aspd) {
|
||||
if(shmup::on && vid.sspeed > -5 && GDIM == 3) {
|
||||
int id = subscreens::in ? subscreens::current_player : 0;
|
||||
auto& pc = shmup::pc[id];
|
||||
if(masterless) centerover = pc->base;
|
||||
else viewctr = pc->base->master;
|
||||
centerover = pc->base;
|
||||
transmatrix T = pc->at;
|
||||
if(hybri) {
|
||||
hybrid::current_view_level = hybrid::get_where(pc->base).second;
|
||||
cell *cc = hybrid::get_at(viewctr.at->c7, hybrid::current_view_level);
|
||||
T = currentmap->relative_matrix(pc->base, cc, C0) * T;
|
||||
}
|
||||
if(WDIM == 2 && !masterless) T = master_relative(pc->base) * T;
|
||||
if(prod) {
|
||||
cell *c = hybrid::get_where(pc->base).first;
|
||||
T = PIU(master_relative(c)) * T;
|
||||
}
|
||||
int sl = snakelevel(cwt.at);
|
||||
if(sl && WDIM == 2) T = T * zpush(cgi.SLEV[sl] - cgi.FLOOR);
|
||||
View = inverse(T);
|
||||
@ -1445,123 +1434,17 @@ EX void optimizeview() {
|
||||
if(subscreens::split(optimizeview)) return;
|
||||
if(dual::split(optimizeview)) return;
|
||||
|
||||
if(hybri && !prod) {
|
||||
cell *c = viewcenter();
|
||||
cell *cbest = NULL;
|
||||
ld best = hdist0(tC0(gmatrix[c]));
|
||||
if(isnan(best)) return;
|
||||
forCellIdEx(c2, i2, c) {
|
||||
if(!gmatrix.count(c2)) return;
|
||||
if(PURE || i2 >= c->type-2) {
|
||||
ld quality = hdist0(tC0(gmatrix[c2]));
|
||||
if(quality < best) best = quality, cbest = c2;
|
||||
}
|
||||
else forCellIdEx(c3, i3, c2) if(i3%2 == 0 && i3 < c2->type-2 && gmatrix.count(c3)) {
|
||||
// cell *w = hybrid::get_where(c3).first;
|
||||
// assert (w->master->c7 != w)
|
||||
ld quality = hdist0(tC0(gmatrix[c3]));
|
||||
if(quality < best) best = quality, cbest = c3;
|
||||
}
|
||||
}
|
||||
if(cbest) {
|
||||
View = View * currentmap->relative_matrix(cbest, c, C0);
|
||||
viewctr.at = cbest->master;
|
||||
hybrid::current_view_level = hybrid::get_where(cbest).second;
|
||||
}
|
||||
return;
|
||||
}
|
||||
transmatrix iView = inverse(View);
|
||||
virtualRebase(centerover, iView, true);
|
||||
View = inverse(iView);
|
||||
|
||||
if(prod) {
|
||||
ld z = zlevel(tC0(View));
|
||||
View = mscale(View, -z);
|
||||
if(in_s2xe()) View = centralsym * View;
|
||||
hybrid::in_underlying_map(optimizeview);
|
||||
if(in_s2xe()) View = centralsym * View;
|
||||
if(z > cgi.plevel / 2) { hybrid::current_view_level--; z -= cgi.plevel; }
|
||||
if(z < -cgi.plevel / 2) { hybrid::current_view_level++; z += cgi.plevel; }
|
||||
View = mscale(View, z);
|
||||
return;
|
||||
}
|
||||
println(hlog, "centerover = ", centerover);
|
||||
|
||||
#if CAP_ANIMATIONS
|
||||
if(centerover.at && inmirror(centerover.at)) {
|
||||
if(centerover && inmirror(centerover)) {
|
||||
anims::reflect_view();
|
||||
}
|
||||
#endif
|
||||
|
||||
DEBBI(DF_GRAPH, ("optimize view"));
|
||||
int turn = 0;
|
||||
ld best = INF;
|
||||
|
||||
transmatrix TB = Id;
|
||||
|
||||
if(WDIM == 3 && (cgflags & qIDEAL)) {
|
||||
if(gmatrix.count(centerover.at)) {
|
||||
ld last = hdist0(tC0(Viewbase));
|
||||
transmatrix V = gmatrix[centerover.at];
|
||||
ld next = hdist0(tC0(V));
|
||||
if(next < last) {
|
||||
View = View * inverse(Viewbase) * V;
|
||||
fixmatrix(View);
|
||||
viewctr.at = centerover.at->master;
|
||||
viewctr.spin = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(false) ;
|
||||
|
||||
#if CAP_BT || CAP_ARCM || MAXMDIM == 4
|
||||
else if(binarytiling || archimedean || penrose || WDIM == 3) {
|
||||
turn = -1, best = hdist0(tC0(View));
|
||||
if(asonov::in()) {
|
||||
hyperpoint h = asonov::straighten * tC0(View);
|
||||
best = abs(h[2]) > 1 ? 999 : hdist0(h);
|
||||
}
|
||||
for(int i=0; i<viewctr.at->type; i++) {
|
||||
if(penrose && euclid && (i < 4 || i >= 8)) continue;
|
||||
int i1 = i * DUALMUL;
|
||||
heptagon *h2 = createStep(viewctr.at, i1);
|
||||
transmatrix T =
|
||||
asonov::in() ? asonov::adjmatrix(i) :
|
||||
nil ? nilv::adjmatrix(i) :
|
||||
currentmap->relative_matrix(h2, viewctr.at);
|
||||
#if MAXMDIM >= 4
|
||||
if(euclid && WDIM == 3)
|
||||
T = euclid3::move_matrix(viewctr.at->c7, i);
|
||||
#endif
|
||||
hyperpoint H = View * tC0(T);
|
||||
if(asonov::in()) {
|
||||
H = asonov::straighten * H;
|
||||
if(abs(H[2]) > 1) continue;
|
||||
}
|
||||
ld quality = hdist0(H);
|
||||
if(quality < best) best = quality, turn = i1, TB = T;
|
||||
}
|
||||
if(turn >= 0) {
|
||||
View = View * TB;
|
||||
fixmatrix(View);
|
||||
viewctr.at = createStep(viewctr.at, turn);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
else {
|
||||
|
||||
for(int i=-1; i<S7; i++) {
|
||||
|
||||
ld trot = -i * M_PI * 2 / (S7+.0);
|
||||
transmatrix T = i < 0 ? Id : spin(trot) * xpush(cgi.tessf) * pispin;
|
||||
hyperpoint H = View * tC0(T);
|
||||
if(H[LDIM] < best) best = H[LDIM], turn = i, TB = T;
|
||||
}
|
||||
|
||||
if(turn >= 0) {
|
||||
View = View * TB;
|
||||
fixmatrix(View);
|
||||
viewctr = viewctr + turn + wstep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addball(ld a, ld b, ld c) {
|
||||
@ -1592,13 +1475,9 @@ EX void resetview() {
|
||||
DEBBI(DF_GRAPH, ("reset view"));
|
||||
View = models::rotmatrix();
|
||||
// EUCLIDEAN
|
||||
if(!masterless)
|
||||
viewctr.at = cwt.at->master,
|
||||
viewctr.spin = cwt.spin;
|
||||
else centerover = cwt;
|
||||
centerover = cwt.at;
|
||||
cwtV = View;
|
||||
nisot::local_perspective = Id;
|
||||
if(hybri) hybrid::current_view_level = hybrid::get_where(cwt.at).second;
|
||||
// SDL_LockSurface(s);
|
||||
// SDL_UnlockSurface(s);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ void handleclick(MOBPAR_FORMAL) {
|
||||
ors::reset();
|
||||
centerpc(INF);
|
||||
View = Id;
|
||||
viewctr.at = cwt.at->master;
|
||||
centerover = cwt.at->master;
|
||||
}
|
||||
andmode = 11;
|
||||
}
|
||||
@ -151,7 +151,7 @@ void handleclick(MOBPAR_FORMAL) {
|
||||
if(!playerfound) {
|
||||
centerpc(INF);
|
||||
View = Id;
|
||||
viewctr.at = cwt.at->master;
|
||||
centerover = cwt.at->master;
|
||||
}
|
||||
playermoved = true;
|
||||
}
|
||||
|
@ -191,9 +191,9 @@ EX namespace models {
|
||||
spiral_multiplier = cld(0, 2 * M_PI) / cld(h[0], h[1]);
|
||||
}
|
||||
|
||||
if(centerover.at && !history::on)
|
||||
if(isize(history::path_for_lineanimation) == 0 || (quotient && history::path_for_lineanimation.back() != centerover.at)) {
|
||||
history::path_for_lineanimation.push_back(centerover.at);
|
||||
if(centerover && !history::on)
|
||||
if(isize(history::path_for_lineanimation) == 0 || (quotient && history::path_for_lineanimation.back() != centerover)) {
|
||||
history::path_for_lineanimation.push_back(centerover);
|
||||
}
|
||||
|
||||
band_shift = 0;
|
||||
|
@ -670,8 +670,6 @@ EX namespace netgen {
|
||||
}
|
||||
if(!created) {
|
||||
View = Id;
|
||||
if(centerover.at) viewctr.at = centerover.at->master;
|
||||
else viewctr.at = cwt.at->master;
|
||||
playermoved = false;
|
||||
dataFromHR();
|
||||
designNet();
|
||||
@ -686,8 +684,6 @@ EX namespace netgen {
|
||||
}
|
||||
if(uni == 's') {
|
||||
View = Id;
|
||||
if(centerover.at) viewctr.at = centerover.at->master;
|
||||
else viewctr.at = cwt.at->master;
|
||||
playermoved = false;
|
||||
}
|
||||
else if(uni == 'c') {
|
||||
|
@ -383,7 +383,7 @@ EX namespace solnihv {
|
||||
void draw() override {
|
||||
dq::visited.clear();
|
||||
|
||||
dq::enqueue(viewctr.at, cview());
|
||||
dq::enqueue(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
@ -829,7 +829,7 @@ EX namespace nilv {
|
||||
void draw() override {
|
||||
dq::visited_by_matrix.clear();
|
||||
|
||||
dq::enqueue_by_matrix(viewctr.at, cview());
|
||||
dq::enqueue_by_matrix(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
@ -939,7 +939,6 @@ EX bool in_h2xe() { return prod && !hybrid::over_sphere(); }
|
||||
|
||||
EX namespace hybrid {
|
||||
|
||||
EX int current_view_level;
|
||||
EX eGeometry underlying;
|
||||
EX geometry_information *underlying_cgip;
|
||||
|
||||
@ -1154,7 +1153,7 @@ EX namespace hybrid {
|
||||
}
|
||||
|
||||
EX bool do_draw(cell *c, const transmatrix& T) {
|
||||
return in_actual([&] { return hr::do_draw(hybrid::get_at(c, hybrid::current_view_level), T); });
|
||||
return in_actual([&] { return hr::do_draw(hybrid::get_at(c, get_where(centerover).second), T); });
|
||||
}
|
||||
|
||||
EX }
|
||||
@ -1167,7 +1166,7 @@ EX namespace product {
|
||||
}
|
||||
|
||||
void draw() override {
|
||||
actual_view_level = hybrid::current_view_level - floor(zlevel(tC0(cview())) / cgi.plevel + .5);
|
||||
actual_view_level = hybrid::get_where(centerover).second - floor(zlevel(tC0(cview())) / cgi.plevel + .5);
|
||||
in_underlying([] { currentmap->draw(); });
|
||||
}
|
||||
};
|
||||
@ -1178,8 +1177,9 @@ EX namespace product {
|
||||
cell *c = cw.at;
|
||||
if(sphere) gmatrix[c] = V; /* some computations need gmatrix0 for underlying geometry */
|
||||
bool s = sphere || pmodel != mdPerspective;
|
||||
int z0 = hybrid::get_where(centerover).second;
|
||||
hybrid::in_actual([&] {
|
||||
cell *c0 = hybrid::get_at(c, hybrid::current_view_level);
|
||||
cell *c0 = hybrid::get_at(c, z0);
|
||||
cwall_offset = hybrid::wall_offset(c0);
|
||||
if(s) cwall_mask = (1<<c->type) - 1;
|
||||
else {
|
||||
@ -1199,7 +1199,7 @@ EX namespace product {
|
||||
cell *c1 = hybrid::get_at(c, actual_view_level+z);
|
||||
setdist(c1, 7, NULL);
|
||||
cw.at = c1;
|
||||
drawcell(cw, V * mscale(Id, cgi.plevel * (z+actual_view_level - hybrid::current_view_level)));
|
||||
drawcell(cw, V * mscale(Id, cgi.plevel * (z+actual_view_level - z0)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1579,7 +1579,7 @@ EX namespace rots {
|
||||
void draw() override {
|
||||
set<cell*> visited;
|
||||
|
||||
cell* start = viewcenter();
|
||||
cell* start = centerover;
|
||||
vector<pair<cell*, transmatrix>> dq;
|
||||
|
||||
visited.insert(start);
|
||||
@ -1654,7 +1654,7 @@ EX namespace rots {
|
||||
|
||||
EX void draw_underlying(bool cornermode) {
|
||||
if(underlying_scale <= 0) return;
|
||||
ld d = hybrid::current_view_level;
|
||||
ld d = hybrid::get_where(centerover).second;
|
||||
d *= cgi.plevel;
|
||||
transmatrix T = rots::uzpush(-d) * spin(-2*d);
|
||||
|
||||
@ -1675,11 +1675,13 @@ EX namespace rots {
|
||||
for(int a=0; a<3; a++) pView[a] *= exp(-z);
|
||||
}
|
||||
|
||||
cell *co = hybrid::get_where(centerover).first;
|
||||
|
||||
hybrid::in_underlying_map([&] {
|
||||
cgi.require_shapes();
|
||||
dynamicval<int> pcc(corner_centering, cornermode ? 1 : 2);
|
||||
dynamicval<bool> pf(playerfound, true);
|
||||
dynamicval<cellwalker> m5(centerover, viewctr.at->c7);
|
||||
dynamicval<cell*> m5(centerover, co);
|
||||
dynamicval<transmatrix> m2(View, inprod ? pView : ypush(0) * qtm(h));
|
||||
dynamicval<transmatrix> m3(playerV, Id);
|
||||
dynamicval<transmatrix> m4(actual_view_transform, Id);
|
||||
|
@ -340,7 +340,7 @@ struct hrmap_kite : hrmap {
|
||||
void draw() override {
|
||||
|
||||
dq::visited.clear();
|
||||
dq::enqueue(viewctr.at, cview());
|
||||
dq::enqueue(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
|
@ -814,11 +814,10 @@ EX void cast() {
|
||||
|
||||
vector<cell*> lst;
|
||||
|
||||
cell *cs = viewcenter();
|
||||
cell *cs = centerover;
|
||||
|
||||
transmatrix T = cview();
|
||||
if(nonisotropic) T = nisot::local_perspective * T;
|
||||
if(prod) T = actualV(viewctr, T);
|
||||
T = inverse(T);
|
||||
|
||||
virtualRebase(cs, T, true);
|
||||
|
4
reg3.cpp
4
reg3.cpp
@ -551,7 +551,7 @@ EX namespace reg3 {
|
||||
// for(int i=0; i<S6; i++) queuepoly(ggmatrix(cwt.at), shWall3D[i], 0xFF0000FF);
|
||||
|
||||
dq::visited_by_matrix.clear();
|
||||
dq::enqueue_by_matrix(viewctr.at, cview());
|
||||
dq::enqueue_by_matrix(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
@ -844,7 +844,7 @@ EX namespace reg3 {
|
||||
// for(int i=0; i<S6; i++) queuepoly(ggmatrix(cwt.at), shWall3D[i], 0xFF0000FF);
|
||||
|
||||
dq::visited.clear();
|
||||
dq::enqueue(viewctr.at, cview());
|
||||
dq::enqueue(centerover->master, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
|
2
rug.cpp
2
rug.cpp
@ -676,7 +676,7 @@ EX void buildRug() {
|
||||
return;
|
||||
}
|
||||
|
||||
celllister cl(centerover.at ? centerover.at : cwt.at, get_sightrange(), vertex_limit, NULL);
|
||||
celllister cl(centerover ? centerover : cwt.at, get_sightrange(), vertex_limit, NULL);
|
||||
|
||||
map<cell*, rugpoint *> vptr;
|
||||
|
||||
|
@ -514,8 +514,7 @@ EX ld rug_rotation1, rug_rotation2, ballangle_rotation, env_ocean, env_volcano;
|
||||
EX bool env_shmup;
|
||||
EX ld rug_angle;
|
||||
|
||||
heptspin rotation_center_h;
|
||||
cellwalker rotation_center_c;
|
||||
cell *rotation_center;
|
||||
transmatrix rotation_center_View;
|
||||
|
||||
color_t circle_display_color = 0x00FF00FF;
|
||||
@ -526,17 +525,17 @@ EX ld circle_spins = 1;
|
||||
void moved() {
|
||||
optimizeview();
|
||||
if(cheater || autocheat) {
|
||||
if(hyperbolic && memory_saving_mode && centerover.at && gmatrix.size() && cwt.at != centerover.at && !quotient) {
|
||||
if(isNeighbor(cwt.at, centerover.at)) {
|
||||
cwt.spin = neighborId(centerover.at, cwt.at);
|
||||
if(hyperbolic && memory_saving_mode && centerover && gmatrix.size() && cwt.at != centerover && !quotient) {
|
||||
if(isNeighbor(cwt.at, centerover)) {
|
||||
cwt.spin = neighborId(centerover, cwt.at);
|
||||
flipplayer = true;
|
||||
}
|
||||
animateMovement(cwt.at, centerover.at, LAYER_SMALL, NODIR);
|
||||
cwt.at = centerover.at;
|
||||
animateMovement(cwt.at, centerover, LAYER_SMALL, NODIR);
|
||||
cwt.at = centerover;
|
||||
save_memory();
|
||||
return;
|
||||
}
|
||||
setdist(viewcenter(), 7 - getDistLimit() - genrange_bonus, NULL);
|
||||
setdist(centerover, 7 - getDistLimit() - genrange_bonus, NULL);
|
||||
}
|
||||
playermoved = false;
|
||||
}
|
||||
@ -587,10 +586,10 @@ bool needs_highqual;
|
||||
bool joukowsky_anim;
|
||||
|
||||
EX void reflect_view() {
|
||||
if(centerover.at) {
|
||||
if(centerover) {
|
||||
transmatrix T = Id;
|
||||
cell *mbase = centerover.at;
|
||||
cell *c = centerover.at;
|
||||
cell *mbase = centerover;
|
||||
cell *c = centerover;
|
||||
if(shmup::reflect(c, mbase, T))
|
||||
View = inverse(T) * View;
|
||||
}
|
||||
@ -608,10 +607,10 @@ EX void apply() {
|
||||
history::phase = (isize(history::v) - 1) * ticks * 1. / period;
|
||||
history::movetophase();
|
||||
}
|
||||
else if(centerover.at) {
|
||||
else if(centerover) {
|
||||
reflect_view();
|
||||
if((hyperbolic && !quotient &&
|
||||
(centerover.at->land != cwt.at->land || memory_saving_mode) && among(centerover.at->land, laHaunted, laIvoryTower, laDungeon, laEndorian) && centerover.at->landparam >= 10
|
||||
(centerover->land != cwt.at->land || memory_saving_mode) && among(centerover->land, laHaunted, laIvoryTower, laDungeon, laEndorian) && centerover->landparam >= 10
|
||||
) ) {
|
||||
if(memory_saving_mode) {
|
||||
activateSafety(laIce);
|
||||
@ -626,8 +625,8 @@ EX void apply() {
|
||||
);
|
||||
moved();
|
||||
if(clearup) {
|
||||
viewcenter()->wall = waNone;
|
||||
forCellEx(c1, viewcenter()) c1->wall = waNone;
|
||||
centerover->wall = waNone;
|
||||
forCellEx(c1, centerover) c1->wall = waNone;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -651,7 +650,7 @@ EX void apply() {
|
||||
moved();
|
||||
rotate_view(cspin(0, GDIM-1, 2 * M_PI * t / period));
|
||||
if(clearup) {
|
||||
viewcenter()->wall = waNone;
|
||||
centerover->wall = waNone;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -668,8 +667,7 @@ EX void apply() {
|
||||
break;
|
||||
#endif
|
||||
case maCircle: {
|
||||
if(masterless) centerover = rotation_center_c;
|
||||
else viewctr = rotation_center_h;
|
||||
centerover = rotation_center;
|
||||
ld alpha = circle_spins * 2 * M_PI * ticks / period;
|
||||
View = spin(-cos_auto(circle_radius)*alpha) * xpush(circle_radius) * spin(alpha) * rotation_center_View;
|
||||
moved();
|
||||
@ -769,13 +767,13 @@ bool record_animation() {
|
||||
void display_animation() {
|
||||
if(ma == maCircle && (circle_display_color & 0xFF)) {
|
||||
for(int s=0; s<10; s++) {
|
||||
if(s == 0) curvepoint(ggmatrix(rotation_center_c.at) * xpush0(circle_radius - .1));
|
||||
for(int z=0; z<100; z++) curvepoint(ggmatrix(rotation_center_c.at) * xspinpush0((z+s*100) * 2 * M_PI / 1000., circle_radius));
|
||||
if(s == 0) curvepoint(ggmatrix(rotation_center) * xpush0(circle_radius - .1));
|
||||
for(int z=0; z<100; z++) curvepoint(ggmatrix(rotation_center) * xspinpush0((z+s*100) * 2 * M_PI / 1000., circle_radius));
|
||||
queuecurve(circle_display_color, 0, PPR::LINE);
|
||||
}
|
||||
if(sphere) for(int s=0; s<10; s++) {
|
||||
if(s == 0) curvepoint(centralsym * ggmatrix(rotation_center_c.at) * xpush0(circle_radius - .1));
|
||||
for(int z=0; z<100; z++) curvepoint(centralsym * ggmatrix(rotation_center_c.at) * xspinpush0((z+s*100) * 2 * M_PI / 1000., circle_radius));
|
||||
if(s == 0) curvepoint(centralsym * ggmatrix(rotation_center) * xpush0(circle_radius - .1));
|
||||
for(int z=0; z<100; z++) curvepoint(centralsym * ggmatrix(rotation_center) * xspinpush0((z+s*100) * 2 * M_PI / 1000., circle_radius));
|
||||
queuecurve(circle_display_color, 0, PPR::LINE);
|
||||
}
|
||||
}
|
||||
@ -861,8 +859,7 @@ EX void show() {
|
||||
if(!prod) {
|
||||
dialog::addBoolItem(XLAT("circle"), ma == maCircle, '4');
|
||||
dialog::add_action([] () { ma = maCircle;
|
||||
rotation_center_h = viewctr;
|
||||
rotation_center_c = centerover;
|
||||
rotation_center = centerover;
|
||||
rotation_center_View = View;
|
||||
});
|
||||
}
|
||||
@ -1045,8 +1042,7 @@ int readArgs() {
|
||||
else if(argis("-animcircle")) {
|
||||
PHASE(3); start_game();
|
||||
ma = maCircle;
|
||||
rotation_center_h = viewctr;
|
||||
rotation_center_c = cwt.at;
|
||||
rotation_center = centerover;
|
||||
rotation_center_View = View;
|
||||
shift_arg_formula(circle_spins);
|
||||
shift_arg_formula(circle_radius);
|
||||
|
@ -16,7 +16,7 @@ EX int musicvolume = 60;
|
||||
EX int effvolume = 60;
|
||||
|
||||
EX eLand getCurrentLandForMusic() {
|
||||
eLand id = ((anims::center_music()) && centerover.at) ? centerover.at->land : cwt.at->land;
|
||||
eLand id = ((anims::center_music()) && centerover) ? centerover->land : cwt.at->land;
|
||||
if(isHaunted(id)) id = laHaunted;
|
||||
if(id == laWarpSea) id = laWarpCoast;
|
||||
if(id == laMercuryRiver) id = laTerracotta;
|
||||
|
@ -970,7 +970,6 @@ void init_textureconfig() {
|
||||
addsaver(si_save.id, "center type", 1);
|
||||
addsaver(si_save.dir, "center direction", 0);
|
||||
addsaver(si_save.reflect, "center reflection", false);
|
||||
addsaver(viewctr.spin, "center spin", 0);
|
||||
addsaver(config.data.twidth, "texture resolution", 2048);
|
||||
addsaver(config.gsplits, "precision", 1);
|
||||
|
||||
@ -1012,7 +1011,7 @@ bool texture_config::save() {
|
||||
targetgeometry = geometry;
|
||||
targetvariation = variation;
|
||||
|
||||
cell *ctr = viewcenter();
|
||||
cell *ctr = centerover;
|
||||
si_save = patterns::getpatterninfo0(ctr);
|
||||
|
||||
if(archimedean) csymbol = arcm::current.symbol;
|
||||
@ -1071,11 +1070,9 @@ bool texture_config::load() {
|
||||
celllister cl(currentmap->gamestart(), 20, 10000, NULL);
|
||||
bool found = false;
|
||||
for(cell *c: cl.lst) if(euclid || ctof(c)) {
|
||||
cell *ctr = viewcenter();
|
||||
auto si_here = patterns::getpatterninfo0(c);
|
||||
if(si_here.id == si_save.id && si_here.reflect == si_save.reflect && si_here.dir == si_save.dir) {
|
||||
if(euclid) centerover.at = ctr;
|
||||
else viewctr.at = ctr->master;
|
||||
centerover = c;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user