mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 01:20:37 +00:00
binary:: texture:: fixed some minor things
This commit is contained in:
parent
dac4f6fc75
commit
12ce3a6a9b
50
textures.cpp
50
textures.cpp
@ -262,7 +262,35 @@ void texture_config::mapTextureTriangle(textureinfo &mi, const array<hyperpoint,
|
|||||||
texture_triangle *edited_triangle;
|
texture_triangle *edited_triangle;
|
||||||
textureinfo *edited_tinfo;
|
textureinfo *edited_tinfo;
|
||||||
|
|
||||||
|
hyperpoint *compute_binary_vertices() {
|
||||||
|
ld yx = log(2) / 2;
|
||||||
|
ld yy = yx;
|
||||||
|
ld xx = 1 / sqrt(2)/2;
|
||||||
|
|
||||||
|
static hyperpoint vertices[8];
|
||||||
|
vertices[0] = get_horopoint(-yy, xx);
|
||||||
|
vertices[1] = get_horopoint(yy, 2*xx);
|
||||||
|
vertices[2] = get_horopoint(yy, xx);
|
||||||
|
vertices[3] = get_horopoint(yy, 0);
|
||||||
|
vertices[4] = get_horopoint(yy, -xx);
|
||||||
|
vertices[5] = get_horopoint(yy, -2*xx);
|
||||||
|
vertices[6] = get_horopoint(-yy, -xx);
|
||||||
|
vertices[7] = get_horopoint(-yy, 0);
|
||||||
|
|
||||||
|
return vertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
int celltriangles(cell *c) {
|
||||||
|
if(binarytiling) return 8;
|
||||||
|
else return c->type;
|
||||||
|
}
|
||||||
|
|
||||||
array<hyperpoint, 3> findTextureTriangle(cell *c, patterns::patterninfo& si, int i) {
|
array<hyperpoint, 3> findTextureTriangle(cell *c, patterns::patterninfo& si, int i) {
|
||||||
|
if(binarytiling) {
|
||||||
|
transmatrix M = shmup::ggmatrix(c);
|
||||||
|
auto vertices = compute_binary_vertices();
|
||||||
|
return make_array(M * C0, M * vertices[i], M * vertices[(i+1)%8]);
|
||||||
|
}
|
||||||
// auto si = getpatterninfo0(c);
|
// auto si = getpatterninfo0(c);
|
||||||
transmatrix M = shmup::ggmatrix(c) * applyPatterndir(c, si);
|
transmatrix M = shmup::ggmatrix(c) * applyPatterndir(c, si);
|
||||||
ld z = ctof(c) ? rhexf : hexvdist;
|
ld z = ctof(c) ? rhexf : hexvdist;
|
||||||
@ -276,7 +304,7 @@ int getTriangleID(cell *c, patterns::patterninfo& si, hyperpoint h) {
|
|||||||
// auto si = getpatterninfo0(c);
|
// auto si = getpatterninfo0(c);
|
||||||
ld quality = 1e10;
|
ld quality = 1e10;
|
||||||
int best = 0;
|
int best = 0;
|
||||||
for(int i=0; i<c->type; i++) {
|
for(int i=0; i<celltriangles(c); i++) {
|
||||||
auto t = findTextureTriangle(c, si, i);
|
auto t = findTextureTriangle(c, si, i);
|
||||||
ld q = intval(t[1], h) + intval(t[2], h);
|
ld q = intval(t[1], h) + intval(t[2], h);
|
||||||
if(q < quality) quality = q, best = i;
|
if(q < quality) quality = q, best = i;
|
||||||
@ -325,19 +353,7 @@ void mapTexture(cell *c, textureinfo& mi, patterns::patterninfo &si, const trans
|
|||||||
mi.M = T;
|
mi.M = T;
|
||||||
mi.triangles.clear();
|
mi.triangles.clear();
|
||||||
|
|
||||||
ld yx = log(2) / 2;
|
auto vertices = compute_binary_vertices();
|
||||||
ld yy = yx;
|
|
||||||
ld xx = 1 / sqrt(2)/2;
|
|
||||||
|
|
||||||
hyperpoint vertices[8];
|
|
||||||
vertices[0] = get_horopoint(-yy, xx);
|
|
||||||
vertices[1] = get_horopoint(yy, 2*xx);
|
|
||||||
vertices[2] = get_horopoint(yy, xx);
|
|
||||||
vertices[3] = get_horopoint(yy, 0);
|
|
||||||
vertices[4] = get_horopoint(yy, -xx);
|
|
||||||
vertices[5] = get_horopoint(yy, -2*xx);
|
|
||||||
vertices[6] = get_horopoint(-yy, -xx);
|
|
||||||
vertices[7] = get_horopoint(-yy, 0);
|
|
||||||
|
|
||||||
for(int i=0; i<8; i++) {
|
for(int i=0; i<8; i++) {
|
||||||
hyperpoint h1 = vertices[i];
|
hyperpoint h1 = vertices[i];
|
||||||
@ -400,7 +416,7 @@ bool texture_config::apply(cell *c, const transmatrix &V, int col) {
|
|||||||
|
|
||||||
set_floor(shFullFloor);
|
set_floor(shFullFloor);
|
||||||
qfi.tinf = &mi;
|
qfi.tinf = &mi;
|
||||||
qfi.spin = (gp::on || irr::on) ? Id : applyPatterndir(c, si);
|
qfi.spin = (gp::on || irr::on || binarytiling) ? Id : applyPatterndir(c, si);
|
||||||
|
|
||||||
if(grid_color) {
|
if(grid_color) {
|
||||||
draw_floorshape(c, V, shFullFloor, 0, PPR_FLOOR);
|
draw_floorshape(c, V, shFullFloor, 0, PPR_FLOOR);
|
||||||
@ -769,8 +785,8 @@ void mousemovement() {
|
|||||||
newmove = false;
|
newmove = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(edited_tinfo && isize(edited_tinfo->triangles) == c->type) {
|
if(edited_tinfo && isize(edited_tinfo->triangles) == celltriangles(c)) {
|
||||||
for(int i=0; i<c->type; i++)
|
for(int i=0; i<celltriangles(c); i++)
|
||||||
edited_tinfo->triangles[i].tv = findTextureTriangle(c, si, i);
|
edited_tinfo->triangles[i].tv = findTextureTriangle(c, si, i);
|
||||||
config.texture_tuned = true;
|
config.texture_tuned = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user