mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-24 05:17:17 +00:00
arb:: symmetries
This commit is contained in:
parent
6de3bface4
commit
18d4165f64
@ -27,6 +27,7 @@ struct shape {
|
|||||||
void build_from_angles_edges();
|
void build_from_angles_edges();
|
||||||
vector<pair<int, int> > sublines;
|
vector<pair<int, int> > sublines;
|
||||||
vector<pair<ld, ld>> stretch_shear;
|
vector<pair<ld, ld>> stretch_shear;
|
||||||
|
int repeat_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arbi_tiling {
|
struct arbi_tiling {
|
||||||
@ -154,6 +155,7 @@ EX void load_tile(exp_parser& ep, bool unit) {
|
|||||||
auto& cc = current.shapes.back();
|
auto& cc = current.shapes.back();
|
||||||
cc.id = isize(current.shapes) - 1;
|
cc.id = isize(current.shapes) - 1;
|
||||||
cc.flags = 0;
|
cc.flags = 0;
|
||||||
|
cc.repeat_value = 1;
|
||||||
while(ep.next() != ')') {
|
while(ep.next() != ')') {
|
||||||
cld dist = 1;
|
cld dist = 1;
|
||||||
if(!unit) {
|
if(!unit) {
|
||||||
@ -341,6 +343,22 @@ EX void load(const string& fname) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(ep.eat("repeat(")) {
|
||||||
|
int i = ep.iparse(0);
|
||||||
|
verify_index(i, c.shapes, ep);
|
||||||
|
ep.force_eat(",");
|
||||||
|
int rep = ep.iparse(0);
|
||||||
|
ep.force_eat(")");
|
||||||
|
auto& sh = c.shapes[i];
|
||||||
|
int N = isize(sh.angles);
|
||||||
|
if(N % rep)
|
||||||
|
throw hr_parse_exception("repeat value should be a factor of the number of vertices, " + ep.where());
|
||||||
|
sh.repeat_value = rep;
|
||||||
|
|
||||||
|
int d = N / rep;
|
||||||
|
for(int i=d; i<N; i++)
|
||||||
|
sh.connections[i] = sh.connections[i-d];
|
||||||
|
}
|
||||||
else if(ep.eat("debug(")) {
|
else if(ep.eat("debug(")) {
|
||||||
int i = ep.iparse(0);
|
int i = ep.iparse(0);
|
||||||
verify_index(i, c.shapes, ep);
|
verify_index(i, c.shapes, ep);
|
||||||
|
@ -586,6 +586,7 @@ EX namespace patterns {
|
|||||||
int id;
|
int id;
|
||||||
int dir;
|
int dir;
|
||||||
bool reflect;
|
bool reflect;
|
||||||
|
/** 1 if no symmetries, more otherwise */
|
||||||
int symmetries;
|
int symmetries;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@ -1031,7 +1032,7 @@ EX namespace patterns {
|
|||||||
if(arb::in()) {
|
if(arb::in()) {
|
||||||
si.id = arb::id_of(c->master);
|
si.id = arb::id_of(c->master);
|
||||||
si.dir = 0;
|
si.dir = 0;
|
||||||
si.symmetries = 1;
|
si.symmetries = arb::current.shapes[si.id].repeat_value;
|
||||||
si.reflect = false;
|
si.reflect = false;
|
||||||
return si;
|
return si;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user