mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-10 01:10:35 +00:00
moved the virtual functions in hrmap and its basic subclasses outside of the classes
This commit is contained in:
parent
d10181e363
commit
2e47da5d2c
82
cell.cpp
82
cell.cpp
@ -20,24 +20,16 @@ struct hrmap {
|
|||||||
virtual vector<cell*>& allcells();
|
virtual vector<cell*>& allcells();
|
||||||
virtual void verify() { }
|
virtual void verify() { }
|
||||||
virtual void on_dim_change() { }
|
virtual void on_dim_change() { }
|
||||||
virtual bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) { return true; }
|
virtual bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir);
|
||||||
virtual void generateAlts(heptagon *h, int levs = default_levs(), bool link_cdata = true);
|
virtual void generateAlts(heptagon *h, int levs = default_levs(), bool link_cdata = true);
|
||||||
heptagon *may_create_step(heptagon *h, int direction) {
|
heptagon *may_create_step(heptagon *h, int direction) {
|
||||||
if(h->move(direction)) return h->move(direction);
|
if(h->move(direction)) return h->move(direction);
|
||||||
return create_step(h, direction);
|
return create_step(h, direction);
|
||||||
}
|
}
|
||||||
virtual heptagon *create_step(heptagon *h, int direction) {
|
virtual heptagon *create_step(heptagon *h, int direction);
|
||||||
printf("create_step called unexpectedly\n"); exit(1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
virtual transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) {
|
virtual transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint);
|
||||||
printf("relative_matrixh called unexpectedly\n");
|
virtual transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint);
|
||||||
return Id;
|
|
||||||
}
|
|
||||||
virtual transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) {
|
|
||||||
return relative_matrixh(c2->master, c1->master, hint);
|
|
||||||
}
|
|
||||||
public:
|
public:
|
||||||
transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) { return relative_matrixh(h2, h1, hint); }
|
transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) { return relative_matrixh(h2, h1, hint); }
|
||||||
transmatrix relative_matrix(cell *h2, cell *h1, const hyperpoint& hint) { return relative_matrixc(h2, h1, hint); }
|
transmatrix relative_matrix(cell *h2, cell *h1, const hyperpoint& hint) { return relative_matrixc(h2, h1, hint); }
|
||||||
@ -51,10 +43,7 @@ public:
|
|||||||
virtual void draw_all();
|
virtual void draw_all();
|
||||||
virtual void draw_at(cell *at, const shiftmatrix& where);
|
virtual void draw_at(cell *at, const shiftmatrix& where);
|
||||||
|
|
||||||
virtual void virtualRebase(heptagon*& base, transmatrix& at) {
|
virtual void virtualRebase(heptagon*& base, transmatrix& at);
|
||||||
printf("virtualRebase called unexpectedly\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr ld SPIN_NOT_AVAILABLE = 1e5;
|
static constexpr ld SPIN_NOT_AVAILABLE = 1e5;
|
||||||
virtual ld spin_angle(cell *c, int d) { return SPIN_NOT_AVAILABLE; }
|
virtual ld spin_angle(cell *c, int d) { return SPIN_NOT_AVAILABLE; }
|
||||||
@ -73,28 +62,18 @@ public:
|
|||||||
virtual transmatrix master_relative(cell *c, bool get_inverse = false) { return Id; }
|
virtual transmatrix master_relative(cell *c, bool get_inverse = false) { return Id; }
|
||||||
virtual int wall_offset(cell *c);
|
virtual int wall_offset(cell *c);
|
||||||
|
|
||||||
virtual transmatrix ray_iadj(cell *c, int i) {
|
virtual transmatrix ray_iadj(cell *c, int i);
|
||||||
if(WDIM == 2) {
|
|
||||||
return to_other_side(get_corner(c, i), get_corner(c, (i+1)));
|
|
||||||
}
|
|
||||||
return currentmap->iadj(c, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual subcellshape& get_cellshape(cell *c) {
|
virtual subcellshape& get_cellshape(cell *c);
|
||||||
if(cgi.heptshape) return *cgi.heptshape;
|
|
||||||
throw hr_exception("get_cellshape called unexpectedly");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief in 3D honeycombs, returns a cellwalker res at cw->move(j) such that the face pointed at by cw and res share an edge */
|
/** \brief in 3D honeycombs, returns a cellwalker res at cw->move(j) such that the face pointed at by cw and res share an edge */
|
||||||
virtual cellwalker strafe(cellwalker cw, int j) { throw hr_exception("strafe called unexpectedly"); }
|
virtual cellwalker strafe(cellwalker cw, int j);
|
||||||
|
|
||||||
/** \brief in 3D honeycombs, returns a vector<bool> v, where v[j] iff faces i and j are adjacent */
|
/** \brief in 3D honeycombs, returns a vector<bool> v, where v[j] iff faces i and j are adjacent */
|
||||||
const vector<char>& dirdist(cellwalker cw) { return get_cellshape(cw.at).dirdist[cw.spin]; }
|
const vector<char>& dirdist(cellwalker cw) { return get_cellshape(cw.at).dirdist[cw.spin]; }
|
||||||
|
|
||||||
/** \brief the sequence of heptagon movement direction to get from c->master to c->move(i)->master; implemented only for reg3 */
|
/** \brief the sequence of heptagon movement direction to get from c->master to c->move(i)->master; implemented only for reg3 */
|
||||||
virtual const vector<int>& get_move_seq(cell *c, int i) {
|
virtual const vector<int>& get_move_seq(cell *c, int i);
|
||||||
throw hr_exception("get_move_seq not implemented for this map class");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient
|
/** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient
|
||||||
@ -135,6 +114,49 @@ struct hrmap_hyperbolic : hrmap_standard {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
heptagon *hrmap::create_step(heptagon *h, int direction) {
|
||||||
|
throw hr_exception("create_step called unexpectedly");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
transmatrix hrmap::relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) {
|
||||||
|
println(hlog, "relative_matrixh called unexpectedly\n");
|
||||||
|
return Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
transmatrix hrmap::relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) {
|
||||||
|
return relative_matrixh(c2->master, c1->master, hint);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hrmap::link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hrmap::virtualRebase(heptagon*& base, transmatrix& at) {
|
||||||
|
printf("virtualRebase called unexpectedly\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transmatrix hrmap::ray_iadj(cell *c, int i) {
|
||||||
|
if(WDIM == 2) {
|
||||||
|
return to_other_side(get_corner(c, i), get_corner(c, (i+1)));
|
||||||
|
}
|
||||||
|
return currentmap->iadj(c, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
subcellshape& hrmap::get_cellshape(cell *c) {
|
||||||
|
if(cgi.heptshape) return *cgi.heptshape;
|
||||||
|
throw hr_exception("get_cellshape called unexpectedly");
|
||||||
|
}
|
||||||
|
|
||||||
|
cellwalker hrmap::strafe(cellwalker cw, int j) {
|
||||||
|
throw hr_exception("strafe called unexpectedly");
|
||||||
|
}
|
||||||
|
|
||||||
|
const vector<int>& hrmap::get_move_seq(cell *c, int i) {
|
||||||
|
throw hr_exception("get_move_seq not implemented for this map class");
|
||||||
|
}
|
||||||
|
|
||||||
transmatrix hrmap::spin_to(cell *c, int d, ld bonus) {
|
transmatrix hrmap::spin_to(cell *c, int d, ld bonus) {
|
||||||
ld sa = spin_angle(c, d);
|
ld sa = spin_angle(c, d);
|
||||||
if(sa != SPIN_NOT_AVAILABLE) { return spin(bonus + sa); }
|
if(sa != SPIN_NOT_AVAILABLE) { return spin(bonus + sa); }
|
||||||
|
Loading…
Reference in New Issue
Block a user