mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-22 22:10:20 +00:00
horopoint cleanup in 2D
This commit is contained in:
parent
9946ceb877
commit
5ab7249afd
@ -793,6 +793,30 @@ void virtualRebaseSimple(heptagon*& base, transmatrix& at) {
|
||||
}
|
||||
#endif
|
||||
|
||||
hyperpoint get_horopoint(ld y, ld x) {
|
||||
return xpush(-y) * binary::parabolic(x) * C0;
|
||||
}
|
||||
|
||||
hyperpoint get_horopoint(hyperpoint h) {
|
||||
return get_horopoint(h[0], h[1]);
|
||||
}
|
||||
|
||||
hyperpoint get_corner_horo_coordinates(cell *c, int i) {
|
||||
ld yx = log(2) / 2;
|
||||
ld yy = yx;
|
||||
ld xx = 1 / sqrt(2)/2;
|
||||
switch(gmod(i, c->type)) {
|
||||
case 0: return point2(-yy, xx);
|
||||
case 1: return point2(yy, 2*xx);
|
||||
case 2: return point2(yy, xx);
|
||||
case 3: return point2(yy, -xx);
|
||||
case 4: return point2(yy, -2*xx);
|
||||
case 5: return point2(-yy, -xx);
|
||||
case 6: return point2(-yy, 0);
|
||||
default: return point2(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
116
floorshapes.cpp
116
floorshapes.cpp
@ -196,28 +196,6 @@ void bshape2(hpcshape& sh, PPR prio, int shapeid, matrixlist& m) {
|
||||
hpcpush(hpc[last->s]);
|
||||
}
|
||||
|
||||
#if CAP_BT
|
||||
void horopoint(ld y, ld x) {
|
||||
hpcpush(get_horopoint(y, x));
|
||||
}
|
||||
|
||||
void horopoint(ld y, ld x, cell &fc, int c) {
|
||||
hpcpush(iddspin(&fc, c) * get_horopoint(y, x));
|
||||
}
|
||||
|
||||
void horoline(ld y, ld x1, ld x2) {
|
||||
if(DIM == 3)
|
||||
horopoint(y, x1), horopoint(y, x2);
|
||||
else for(int a=0; a<=16; a++)
|
||||
horopoint(y, x1 + (x2-x1) * a / 16.);
|
||||
}
|
||||
|
||||
void horoline(ld y, ld x1, ld x2, cell &fc, int c) {
|
||||
for(int a=0; a<=16; a++)
|
||||
horopoint(y, x1 + (x2-x1) * a / 16., fc, c);
|
||||
}
|
||||
#endif
|
||||
|
||||
void bshape_regular(floorshape &fsh, int id, int sides, int shift, ld size) {
|
||||
|
||||
fsh.b.resize(2);
|
||||
@ -225,32 +203,41 @@ void bshape_regular(floorshape &fsh, int id, int sides, int shift, ld size) {
|
||||
|
||||
#if CAP_BT
|
||||
if(binarytiling) {
|
||||
bshape(fsh.b[id], fsh.prio);
|
||||
|
||||
ld yx = size * log(2) / 2;
|
||||
ld yy = yx;
|
||||
ld xx = size / sqrt(2)/2;
|
||||
horoline(-yx, -xx, xx); horoline(yx, xx*2, -xx*2); horopoint(-yx, -xx);
|
||||
|
||||
bshape(fsh.shadow[id], fsh.prio);
|
||||
horoline(-yx*SHADMUL, -xx*SHADMUL, xx*SHADMUL); horoline(yx*SHADMUL, xx*SHADMUL*2, -xx*SHADMUL*2); horopoint(-yx*SHADMUL, -xx*SHADMUL);
|
||||
|
||||
cell fc;
|
||||
fc.type = 6+id;
|
||||
|
||||
for(int k=0; k<SIDEPARS; k++) {
|
||||
for(int i=0; i<fc.type; i++) fsh.gpside[k][i].resize(2);
|
||||
bshape(fsh.gpside[k][0][id], PPR::LAKEWALL); horopoint(-yy, xx, fc, 0); horopoint(yy, 2*xx, fc, 0); chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
bshape(fsh.gpside[k][1][id], PPR::LAKEWALL); horoline(yy, 2*xx, xx, fc, 1); chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
bshape(fsh.gpside[k][2][id], PPR::LAKEWALL); horoline(yy, xx, -xx, fc, 2); chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
bshape(fsh.gpside[k][3][id], PPR::LAKEWALL); horoline(yy, -xx, -2*xx, fc, 3); chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
bshape(fsh.gpside[k][4][id], PPR::LAKEWALL); horopoint(yy, -2*xx, fc, 4); horopoint(-yy, -xx, fc, 4); chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
if(id == 0) {
|
||||
bshape(fsh.gpside[k][5][id], PPR::LAKEWALL); horoline(-yy, -xx, xx, fc, 5); chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
const int STEP = TEXTURE_STEP_3D;
|
||||
using namespace hyperpoint_vec;
|
||||
|
||||
for(int t=0; t<2; t++) {
|
||||
|
||||
if(t == 0)
|
||||
bshape(fsh.b[id], fsh.prio);
|
||||
if(t == 1)
|
||||
bshape(fsh.shadow[id], fsh.prio);
|
||||
|
||||
for(int i=0; i<sides; i++) {
|
||||
hyperpoint h0 = binary::get_corner_horo_coordinates(&fc, i) * size;
|
||||
hyperpoint h1 = binary::get_corner_horo_coordinates(&fc, i+1) * size;
|
||||
if(t) h0 *= SHADMUL, h1 *= SHADMUL;
|
||||
hyperpoint hd = (h1 - h0) / STEP;
|
||||
for(int j=0; j<STEP; j++)
|
||||
hpcpush(binary::get_horopoint(h0 + hd * j));
|
||||
}
|
||||
else {
|
||||
bshape(fsh.gpside[k][5][id], PPR::LAKEWALL); horoline(-yy, -xx, 0, fc, 5); chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
bshape(fsh.gpside[k][6][id], PPR::LAKEWALL); horoline(-yy, -0, xx, fc, 6); chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
|
||||
hpcpush(hpc[last->s]);
|
||||
}
|
||||
|
||||
for(int k=0; k<SIDEPARS; k++) {
|
||||
for(int i=0; i<fc.type; i++) {
|
||||
fsh.gpside[k][i].resize(2);
|
||||
bshape(fsh.gpside[k][i][id], PPR::LAKEWALL);
|
||||
hyperpoint h0 = binary::get_corner_horo_coordinates(&fc, i) * size;
|
||||
hyperpoint h1 = binary::get_corner_horo_coordinates(&fc, i+1) * size;
|
||||
hyperpoint hd = (h1 - h0) / STEP;
|
||||
for(int j=0; j<=STEP; j++)
|
||||
hpcpush(iddspin(&fc, i) * binary::get_horopoint(h0 + hd * j));
|
||||
chasmifyPoly(dlow_table[k], dhi_table[k], k);
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,39 +475,42 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
|
||||
|
||||
fsh.levels[k][id].tinf = &fsh.tinf3;
|
||||
fsh.levels[k][id].texture_offset = 0;
|
||||
auto at = [&] (hyperpoint h, int a) {
|
||||
hpcpush(normalize(h));
|
||||
};
|
||||
|
||||
|
||||
const int STEP = TEXTURE_STEP_3D;
|
||||
|
||||
int s = fsh.b[id].s;
|
||||
int e = fsh.b[id].e-1;
|
||||
|
||||
#if CAP_BT
|
||||
if(binarytiling) {
|
||||
vector<hyperpoint> cors;
|
||||
for(int i=0; i<c->type; i++) cors.push_back(get_corner_position(c, i, 3));
|
||||
cors.push_back(cors[0]);
|
||||
for(int t=0; t<c->type; t++)
|
||||
for(int y=0; y<STEP; y++)
|
||||
for(int x=0; x<STEP; x++) {
|
||||
using namespace hyperpoint_vec;
|
||||
hyperpoint center = zpush(dfloor_table[k]) * C0;
|
||||
hyperpoint v1 = (rgpushxto0(cors[t]) * center - center) / STEP;
|
||||
hyperpoint v2 = (rgpushxto0(cors[t+1]) * center - center) / STEP;
|
||||
auto at = [&] (int x, int y) {
|
||||
using namespace hyperpoint_vec;
|
||||
hyperpoint left = binary::get_corner_horo_coordinates(c, t);
|
||||
hyperpoint right = binary::get_corner_horo_coordinates(c, t+1);
|
||||
hyperpoint mid = (left * x + right * y) / STEP;
|
||||
hpcpush(binary::get_horopoint(mid));
|
||||
};
|
||||
if(x+y < STEP) {
|
||||
at(center + v1 * x + v2 * y, 0);
|
||||
at(center + v1 * (x+1) + v2 * y, 1);
|
||||
at(center + v1 * x + v2 * (y+1), 2);
|
||||
at(x, y);
|
||||
at(x+1, y);
|
||||
at(x, y+1);
|
||||
}
|
||||
if(x+y <= STEP && x && y) {
|
||||
at(center + v1 * x + v2 * y, 0);
|
||||
at(center + v1 * (x-1) + v2 * y, 1);
|
||||
at(center + v1 * x + v2 * (y-1), 2);
|
||||
at(x, y);
|
||||
at(x-1, y);
|
||||
at(x, y-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
#endif
|
||||
if(1) {
|
||||
auto at = [&] (hyperpoint h, int a) {
|
||||
hpcpush(normalize(h));
|
||||
};
|
||||
for(int t=0; t<e-s; t++)
|
||||
for(int y=0; y<STEP; y++)
|
||||
for(int x=0; x<STEP; x++) {
|
||||
|
@ -421,12 +421,6 @@ hyperpoint randomPointIn(int t) {
|
||||
}
|
||||
}
|
||||
|
||||
#if CAP_BT
|
||||
hyperpoint get_horopoint(ld y, ld x) {
|
||||
return xpush(-y) * binary::parabolic(x) * C0;
|
||||
}
|
||||
#endif
|
||||
|
||||
hyperpoint get_corner_position(cell *c, int cid, ld cf) {
|
||||
#if CAP_GP
|
||||
if(GOLDBERG) return gp::get_corner_position(c, cid, cf);
|
||||
@ -443,18 +437,7 @@ hyperpoint get_corner_position(cell *c, int cid, ld cf) {
|
||||
println(hlog, "get_corner_position called");
|
||||
return C0;
|
||||
}
|
||||
ld yx = log(2) / 2;
|
||||
ld yy = yx;
|
||||
ld xx = 1 / sqrt(2)/2;
|
||||
hyperpoint vertices[7];
|
||||
vertices[0] = get_horopoint(-yy, xx);
|
||||
vertices[1] = get_horopoint(yy, 2*xx);
|
||||
vertices[2] = get_horopoint(yy, xx);
|
||||
vertices[3] = get_horopoint(yy, -xx);
|
||||
vertices[4] = get_horopoint(yy, -2*xx);
|
||||
vertices[5] = get_horopoint(-yy, -xx);
|
||||
vertices[6] = get_horopoint(-yy, 0);
|
||||
return mid_at_actual(vertices[cid], 3/cf);
|
||||
return mid_at_actual(binary::get_horopoint(binary::get_corner_horo_coordinates(c, cid)), 3/cf);
|
||||
}
|
||||
#endif
|
||||
#if CAP_ARCM
|
||||
@ -536,16 +519,16 @@ hyperpoint nearcorner(cell *c, int i) {
|
||||
ld yy = yx;
|
||||
// ld xx = 1 / sqrt(2)/2;
|
||||
hyperpoint neis[7];
|
||||
neis[0] = get_horopoint(0, 1);
|
||||
neis[1] = get_horopoint(yy*2, 1);
|
||||
neis[2] = get_horopoint(yy*2, 0);
|
||||
neis[3] = get_horopoint(yy*2, -1);
|
||||
neis[4] = get_horopoint(0, -1);
|
||||
neis[0] = binary::get_horopoint(0, 1);
|
||||
neis[1] = binary::get_horopoint(yy*2, 1);
|
||||
neis[2] = binary::get_horopoint(yy*2, 0);
|
||||
neis[3] = binary::get_horopoint(yy*2, -1);
|
||||
neis[4] = binary::get_horopoint(0, -1);
|
||||
if(c->type == 7)
|
||||
neis[5] = get_horopoint(-yy*2, -.5),
|
||||
neis[6] = get_horopoint(-yy*2, +.5);
|
||||
neis[5] = binary::get_horopoint(-yy*2, -.5),
|
||||
neis[6] = binary::get_horopoint(-yy*2, +.5);
|
||||
else
|
||||
neis[5] = get_horopoint(-yy*2, 0);
|
||||
neis[5] = binary::get_horopoint(-yy*2, 0);
|
||||
return neis[i];
|
||||
}
|
||||
#endif
|
||||
|
@ -5587,11 +5587,11 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
ld yx = log(2) / 2;
|
||||
ld yy = yx;
|
||||
ld xx = 1 / sqrt(2)/2;
|
||||
queueline(V * get_horopoint(-yy, xx), V * get_horopoint(yy, 2*xx), gridcolor(c, c->move(binary::bd_right)), prec);
|
||||
queueline(V * binary::get_horopoint(-yy, xx), V * binary::get_horopoint(yy, 2*xx), gridcolor(c, c->move(binary::bd_right)), prec);
|
||||
auto horizontal = [&] (ld y, ld x1, ld x2, int steps, int dir) {
|
||||
if(vid.linequality > 0) steps <<= vid.linequality;
|
||||
if(vid.linequality < 0) steps >>= -vid.linequality;
|
||||
for(int i=0; i<=steps; i++) curvepoint(V * get_horopoint(y, x1 + (x2-x1) * i / steps));
|
||||
for(int i=0; i<=steps; i++) curvepoint(V * binary::get_horopoint(y, x1 + (x2-x1) * i / steps));
|
||||
queuecurve(gridcolor(c, c->move(dir)), 0, PPR::LINE);
|
||||
};
|
||||
horizontal(yy, 2*xx, xx, 4, binary::bd_up_right);
|
||||
|
6
hyper.h
6
hyper.h
@ -4387,9 +4387,6 @@ bool saved_tortoise_on(cell *c);
|
||||
#define PRING(i) for(double i=0; i<=S84+1e-6; i+= pow(.5, vid.linequality))
|
||||
#define REVPRING(i) for(double i=S84; i>=-1e-6; i-=pow(.5, vid.linequality))
|
||||
#if CAP_BT
|
||||
void horopoint(ld y, ld x);
|
||||
hyperpoint get_horopoint(ld y, ld x);
|
||||
hyperpoint get_horopoint3(ld y, ld x, ld z);
|
||||
|
||||
namespace binary {
|
||||
transmatrix parabolic(ld u);
|
||||
@ -4397,6 +4394,9 @@ namespace binary {
|
||||
extern ld btrange, btrange_cosh;
|
||||
hrmap *new_map();
|
||||
hrmap *new_alt_map(heptagon *o);
|
||||
hyperpoint get_horopoint(ld y, ld x);
|
||||
hyperpoint get_horopoint3(ld y, ld x, ld z);
|
||||
hyperpoint get_horopoint(hyperpoint h);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2112,9 +2112,9 @@ void procedural_shapes() {
|
||||
else if(binarytiling) {
|
||||
for(int i=0; i<2; i++) {
|
||||
bshape(shWall[i], PPR::WALL);
|
||||
horopoint(log(2)/8, .1);
|
||||
horopoint(log(2)/8, -.1);
|
||||
horopoint(-log(2)/8, 0);
|
||||
hpcpush(binary::get_horopoint(log(2)/8, .1));
|
||||
hpcpush(binary::get_horopoint(log(2)/8, -.1));
|
||||
hpcpush(binary::get_horopoint(-log(2)/8, 0));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user