mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-27 20:07:40 +00:00
slr:: virtualRebase
This commit is contained in:
@@ -244,6 +244,28 @@ struct horo_distance {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T, class U>
|
||||||
|
void virtualRebase_cell(cell*& base, T& at, const U& check) {
|
||||||
|
horo_distance currz(check(at));
|
||||||
|
T best_at = at;
|
||||||
|
while(true) {
|
||||||
|
cell *newbase = NULL;
|
||||||
|
forCellCM(c2, base) {
|
||||||
|
transmatrix V2 = calc_relative_matrix(base, c2, C0);
|
||||||
|
T cand_at = V2 * at;
|
||||||
|
horo_distance newz(check(cand_at));
|
||||||
|
if(newz < currz) {
|
||||||
|
currz = newz;
|
||||||
|
best_at = cand_at;
|
||||||
|
newbase = c2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!newbase) break;
|
||||||
|
base = newbase;
|
||||||
|
at = best_at;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, class U>
|
template<class T, class U>
|
||||||
void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
|
void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
|
||||||
if(prod) {
|
if(prod) {
|
||||||
@@ -257,6 +279,10 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
|
|||||||
base = hybrid::get_at(w.first, w.second);
|
base = hybrid::get_at(w.first, w.second);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(sl2) {
|
||||||
|
virtualRebase_cell(base, at, check);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if((euclid || sphere) && WDIM == 2) {
|
if((euclid || sphere) && WDIM == 2) {
|
||||||
again:
|
again:
|
||||||
if(euwrap) for(int i=0; i<6; i++) {
|
if(euwrap) for(int i=0; i<6; i++) {
|
||||||
@@ -326,23 +352,8 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
|
|||||||
at = bestV * at;
|
at = bestV * at;
|
||||||
}
|
}
|
||||||
else at = master_relative(base, true) * at;
|
else at = master_relative(base, true) * at;
|
||||||
if(binarytiling || (tohex && (GOLDBERG || IRREGULAR)) || WDIM == 3 || penrose) {
|
if(binarytiling || (tohex && (GOLDBERG || IRREGULAR)) || WDIM == 3 || penrose)
|
||||||
while(true) {
|
virtualRebase_cell(base, at, check);
|
||||||
newbase = NULL;
|
|
||||||
forCellCM(c2, base) {
|
|
||||||
transmatrix V2 = calc_relative_matrix(base, c2, C0);
|
|
||||||
horo_distance newz(check(V2 * at));
|
|
||||||
if(newz < currz) {
|
|
||||||
currz = newz;
|
|
||||||
bestV = V2;
|
|
||||||
newbase = c2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!newbase) break;
|
|
||||||
base = newbase;
|
|
||||||
at = bestV * at;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user