mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-27 14:37:16 +00:00
3d:: more precise findbaseAround in binary3
This commit is contained in:
parent
81dd0c71da
commit
7d46acb1b8
@ -264,6 +264,17 @@ namespace binary {
|
||||
return hr::parabolic13(y * co, z * co);
|
||||
}
|
||||
|
||||
hyperpoint deparabolic3(hyperpoint h) {
|
||||
using namespace hyperpoint_vec;
|
||||
h /= (1 + h[3]);
|
||||
hyperpoint one = point3(1,0,0);
|
||||
h -= one;
|
||||
h /= sqhypot_d(3, h);
|
||||
h[0] += .5;
|
||||
ld co = vid.binary_width / log(2) / 8;
|
||||
return point3(log(2) + log(-h[0]), h[1] / co, h[2] / co);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
dq::visited.clear();
|
||||
dq::enqueue(viewctr.at, cview());
|
||||
|
13
shmup.cpp
13
shmup.cpp
@ -1036,6 +1036,19 @@ typedef multimap<cell*, monster*>::iterator mit;
|
||||
vector<monster*> active, nonvirtual, additional;
|
||||
|
||||
cell *findbaseAround(hyperpoint p, cell *around) {
|
||||
#if MAXMDIM == 4 && CAP_BT
|
||||
// this needs a more precise algorithm because the cells have curved faces
|
||||
if(DIM == 3 && binarytiling) {
|
||||
hyperpoint h = binary::deparabolic3(inverse(ggmatrix(around)) * p);
|
||||
if(h[0] < -log(2)/2) return around->cmove((h[1] > 0 ? 1 : 0) + (h[2] > 0 ? 2 : 0));
|
||||
if(h[1] < -1) return around->cmove(4);
|
||||
if(h[1] > +1) return around->cmove(5);
|
||||
if(h[2] < -1) return around->cmove(6);
|
||||
if(h[2] > +1) return around->cmove(7);
|
||||
if(h[0] > +log(2)/2) return around->cmove(8);
|
||||
return around;
|
||||
}
|
||||
#endif
|
||||
cell *best = around;
|
||||
double d0 = intval(p, ggmatrix(around) * C0);
|
||||
for(int i=0; i<around->type; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user