1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-30 15:39:54 +00:00

nilrider:: fixed incorrect vertexlists in cgi

This commit is contained in:
Zeno Rogue 2022-05-06 17:10:10 +02:00
parent bc8811530f
commit 0f07b7866f
4 changed files with 79 additions and 43 deletions

View File

@ -74,50 +74,18 @@ void level::init_textures() {
} }
} }
void level::init() { void level::init_shapes() {
if(initialized) return;
initialized = true;
check_cgi(); check_cgi();
string s = "nillevel-" + name;
real_minx = HUGE_VAL; if(cgi.ext.count(s)) return;
real_miny = HUGE_VAL; cgi.ext[s] = nullptr;
real_maxx = -HUGE_VAL;
real_maxy = -HUGE_VAL;
if(flags & nrlPolar)
scale = 1;
else
scale = abs(maxx - minx) / isize(map_tiles[0]);
println(hlog, "SCALE IS ", this->scale);
init_textures();
int tY = isize(map_tiles); int tY = isize(map_tiles);
int tX = isize(map_tiles[0]); int tX = isize(map_tiles[0]);
start.where = mappt(startx+.5, starty+.5, 1);
start.t = 0;
start.timer = 0;
current = start;
println(hlog, "start.where = ", start.where);
println(hlog, "current.where = ", current.where, " : ", format("%p", &current));
int qgoals = isize(goals);
records[0].resize(qgoals, 0);
records[1].resize(qgoals, 0);
current_score.resize(qgoals, 0);
/* start facing slightly to the right from the slope */
for(auto b: {true, false}) while(true) {
auto c = start;
/* no treasures are known, which confuses goals */
dynamicval<bool> lop1(loaded_or_planned, true);
dynamicval<bool> lop2(planning_mode, false);
if(c.tick(this) == b) break;
start.heading_angle -= 1 * degree;
}
for(int s=0; s<3; s++) { for(int s=0; s<3; s++) {
if(euclid && s != 1) continue;
if(nil && s == 1) continue;
cgi.bshape(s == 0 ? shFloor : s == 1 ? shPlanFloor : shStepFloor, PPR::WALL); cgi.bshape(s == 0 ? shFloor : s == 1 ? shPlanFloor : shStepFloor, PPR::WALL);
shFloor.flags |= POLY_TRIANGLES; shFloor.flags |= POLY_TRIANGLES;
shPlanFloor.flags |= POLY_TRIANGLES; shPlanFloor.flags |= POLY_TRIANGLES;
@ -127,8 +95,10 @@ void level::init() {
if(s == 2) prec *= 4; if(s == 2) prec *= 4;
int cdiv = prec / steps_per_block; int cdiv = prec / steps_per_block;
bool need_uniltinf = uniltinf.tvertices.empty();
auto pt = [&] (int x, int y, int qx, int qy) { auto pt = [&] (int x, int y, int qx, int qy) {
if(s == 0) 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. / tX / prec, y * 1. / tY / prec, 0));
if(s == 2) { if(s == 2) {
ld ax = x, ay = y; ld ax = x, ay = y;
if(qx) { if(qx) {
@ -335,6 +305,36 @@ void level::init() {
} }
} }
} }
}
cgi.finishshape();
}
cgi.extra_vertices();
}
void level::init() {
if(initialized) return;
initialized = true;
check_cgi();
real_minx = HUGE_VAL;
real_miny = HUGE_VAL;
real_maxx = -HUGE_VAL;
real_maxy = -HUGE_VAL;
if(flags & nrlPolar)
scale = 1;
else
scale = abs(maxx - minx) / isize(map_tiles[0]);
println(hlog, "SCALE IS ", this->scale);
if(1) {
int tY = isize(map_tiles);
int tX = isize(map_tiles[0]);
for(int y=0; y<tY; y++)
for(int x=0; x<tX; x++) {
char bmch = map_tiles[y][x];
if(bmch == 'o') { if(bmch == 'o') {
hyperpoint h = mappt(x+.5, y+.5, 1); hyperpoint h = mappt(x+.5, y+.5, 1);
@ -363,6 +363,31 @@ void level::init() {
cgi.finishshape(); cgi.finishshape();
} }
init_textures();
init_shapes();
start.where = mappt(startx+.5, starty+.5, 1);
start.t = 0;
start.timer = 0;
current = start;
println(hlog, "start.where = ", start.where);
println(hlog, "current.where = ", current.where, " : ", format("%p", &current));
int qgoals = isize(goals);
records[0].resize(qgoals, 0);
records[1].resize(qgoals, 0);
current_score.resize(qgoals, 0);
/* start facing slightly to the right from the slope */
for(auto b: {true, false}) while(true) {
auto c = start;
/* no treasures are known, which confuses goals */
dynamicval<bool> lop1(loaded_or_planned, true);
dynamicval<bool> lop2(planning_mode, false);
if(c.tick(this) == b) break;
start.heading_angle -= 1 * degree;
}
if(flags & nrlOrder) { if(flags & nrlOrder) {
sort(triangles.begin(), triangles.end(), [this] (triangledata a, triangledata b) { sort(triangles.begin(), triangles.end(), [this] (triangledata a, triangledata b) {
return atan2(spin(120*degree)*(a.where - start.where)) < atan2(spin(120*degree)*(b.where - start.where)); return atan2(spin(120*degree)*(a.where - start.where)) < atan2(spin(120*degree)*(b.where - start.where));
@ -370,7 +395,6 @@ void level::init() {
for(auto t: triangles) println(hlog, t.where); for(auto t: triangles) println(hlog, t.where);
} }
cgi.extra_vertices();
init_plan(); init_plan();
} }
@ -433,6 +457,9 @@ bool stepped_display;
void level::draw_level(const shiftmatrix& V) { void level::draw_level(const shiftmatrix& V) {
int id = 0; int id = 0;
init_statues();
curlev->init_shapes();
for(auto& t: triangles) { for(auto& t: triangles) {
bool gotit = current.collected_triangles & Flag(id); bool gotit = current.collected_triangles & Flag(id);
id++; id++;

View File

@ -134,6 +134,9 @@ struct level {
/** initialize textures */ /** initialize textures */
void init_textures(); void init_textures();
/** initialize shapes */
void init_shapes();
/** initialize all */ /** initialize all */
void init(); void init();

View File

@ -100,6 +100,9 @@ void level::draw_planning_screen() {
dynamicval<eModel> pm(pmodel, mdDisk); dynamicval<eModel> pm(pmodel, mdDisk);
dynamicval<bool> ga(vid.always3, false); dynamicval<bool> ga(vid.always3, false);
dynamicval<geometryinfo1> gi(ginf[gEuclid].g, giEuclid2); dynamicval<geometryinfo1> gi(ginf[gEuclid].g, giEuclid2);
check_cgi();
cgi.require_shapes();
curlev->init_shapes();
initquickqueue(); initquickqueue();
if(recompute_plan_transform) { if(recompute_plan_transform) {

View File

@ -114,6 +114,9 @@ template<class T1, class T2> void add_statue(const T1& grid, const T2& f) {
hpcshape shGeostatue; hpcshape shGeostatue;
void init_statues() { void init_statues() {
check_cgi();
if(cgi.ext.count("nil-statues")) return;
cgi.ext["nil-statues"] = nullptr;
create_minitriangle(); create_minitriangle();
create_castle(); create_castle();