From 56abdca5519fb92e6442a34db60e8c415b5be8fe Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 19 Aug 2024 12:33:39 +0200 Subject: [PATCH] nilrider:: levels no longer require dimensions to be powers of 2 --- rogueviz/nilrider/level.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rogueviz/nilrider/level.cpp b/rogueviz/nilrider/level.cpp index 31d6bc52..97cce967 100644 --- a/rogueviz/nilrider/level.cpp +++ b/rogueviz/nilrider/level.cpp @@ -7,6 +7,8 @@ void level::init_textures() { create_castle(); int tY = isize(map_tiles); int tX = isize(map_tiles[0]); + int ttY = next_p2(tY); + int ttX = next_p2(tX); transmatrix T = gpushxto0(new_levellines_for); @@ -24,8 +26,8 @@ void level::init_textures() { auto& tex = *target; if(regen) { - tex.twidth = tex.tx = tX * texture_density; - tex.theight = tex.ty = tY * texture_density; + tex.twidth = tex.tx = ttX * texture_density; + tex.theight = tex.ty = ttY * texture_density; tex.stretched = false; tex.strx = tex.tx; tex.stry = tex.ty; @@ -99,6 +101,8 @@ void level::init_shapes() { int tY = isize(map_tiles); int tX = isize(map_tiles[0]); + int ttY = next_p2(tY); + int ttX = next_p2(tX); for(int s=0; s<3; s++) { if(euclid && s != 1) continue; @@ -116,7 +120,7 @@ void level::init_shapes() { bool need_uniltinf = uniltinf.tvertices.empty(); auto pt = [&] (int x, int y, int qx, int qy) { - if(need_uniltinf) uniltinf.tvertices.push_back(glhr::makevertex(x * 1. / tX / prec, y * 1. / tY / prec, 0)); + if(need_uniltinf) uniltinf.tvertices.push_back(glhr::makevertex(x * 1. / ttX / prec, y * 1. / ttY / prec, 0)); if(s == 2) { ld ax = x, ay = y; if(qx) { @@ -135,7 +139,7 @@ void level::init_shapes() { ay += .5; ay += (y % cdiv) * (cdiv/2-1.) / (cdiv/2); } - uniltinf_stepped.tvertices.push_back(glhr::makevertex((ax+qx) / tX / prec, (ay+qy) / tY / prec, 0)); + uniltinf_stepped.tvertices.push_back(glhr::makevertex((ax+qx) / ttX / prec, (ay+qy) / ttY / prec, 0)); } hyperpoint h = mappt(x, y, prec);