new command mapareacheck

Calculate some key values to determine map geometry viability.

mapareacheck <what>
  Returns different sets of statistics, depending on the keyword "what":

  vdelta
    Returns table of numbers of cubes within a certain range of vdelta
    differences (steepness)". First entry is "0..2 cubes steep", next is
    "2..4" and so on.

  steepest
    Returns the coordinates of the steepest heightfield cube.

  total
    Returns the number of non-solid cubes on the map.

  pprest
    Returns the number of cubes _not_ visible from one of the probe
    positions.

  pp (default)
    Returns a table of all (currently 64) probe points of the map. Each
    probe point is listed with:
      - x-coordinate
      - y-coordinate
      - floor height
      - area visible
      - volume of visible area
      - average height in visible area

DOCREF mapareacheck
This commit is contained in:
ac-stef
2016-08-26 14:08:56 +02:00
parent 77b7e9bb87
commit 084be76825
2 changed files with 34 additions and 0 deletions
+1
View File
@@ -86,6 +86,7 @@ looplist [
] [ cmd options ] [ listcomplete $cmd (listoptions $options)
]
listcomplete getvarrange "min max default"
listcomplete mapareacheck "vdelta steepest total pprest pp"
looplist [ addzipmod zipmodremove zipmodgetdesc ] cmd [complete $cmd "mods" zip]
// set up list of skymaps
+33
View File
@@ -928,3 +928,36 @@ void mapmrproper(bool manual)
}
}
COMMANDF(mapmrproper, "", () { mapmrproper(true); });
void mapareacheck(char *what) // "vdelta" | "steepest" | "total" | "pprest" | "pp"(default)
{
mapareastats_s ms;
mapdim_s md;
stopwatch ti;
ti.start();
servsqr *sw = createservworld(world, cubicsize);
calcmapdims(md, sw, ssize);
calcmapareastats(ms, sw, ssize, md);
delete[] sw;
vector<char> res;
if(!strcasecmp(what, "vdelta"))
{
loopi(MAS_VDELTA_TABSIZE) cvecprintf(res, "%d ", ms.vdd[i]);
}
else if(!strcasecmp(what, "steepest")) cvecprintf(res, "%d.5 %d.5 %d ", ms.steepest % ssize, ms.steepest / ssize, world[ms.steepest % cubicsize].floor);
else if(!strcasecmp(what, "total")) cvecprintf(res, "%d ", ms.total);
else if(!strcasecmp(what, "pprest")) cvecprintf(res, "%d ", ms.rest);
else // default
{
loopi(MAS_GRID2)
{
int x = ms.ppp[i] % ssize, y = ms.ppp[i] / ssize, z = OUTBORD(x, y) ? 0 : S(x, y)->floor;
cvecprintf(res, "%d %d %d %d %d %.5g\n", x, y, z, ms.ppa[i], ms.ppv[i], ms.ppa[i] ? float(ms.ppv[i]) / ms.ppa[i] : 0.0f);
}
}
res.last() = '\0';
result(res.getbuf());
}
COMMAND(mapareacheck, "s");