Add an option to draw 'ignore' nodes.
This does require a color definition to be added to the colors file. Implemented as a generic option to draw or ignore types of nodes (i.e. 'air', 'ignore'). Ignoring specific named nodes from the command-line is not (yet??) supported.
This commit is contained in:
parent
61fa760af5
commit
1ad247ddc4
@ -16,6 +16,7 @@
|
||||
(useful for postgresql, which doesn't do this by default).
|
||||
- Command-line options are now all case-agnostic wrt their parameters.
|
||||
- Allow nodes to be defined as air-type or ignore-type in colors.txt
|
||||
- Added an option to draw 'ignore'-nodes.
|
||||
Bugfixes:
|
||||
- Fixed possible compilation failure caused by stdint.h
|
||||
- Fixed compilation failure when some database libraries are not installed
|
||||
|
@ -139,6 +139,7 @@ TileGenerator::TileGenerator():
|
||||
m_drawScale(DRAWSCALE_NONE),
|
||||
m_drawAlpha(false),
|
||||
m_drawAir(false),
|
||||
m_drawIgnore(false),
|
||||
m_shading(true),
|
||||
m_backend(DEFAULT_BACKEND),
|
||||
m_requestedBackend(DEFAULT_BACKEND),
|
||||
@ -360,6 +361,11 @@ void TileGenerator::setDrawAir(bool drawAir)
|
||||
m_drawAir = drawAir;
|
||||
}
|
||||
|
||||
void TileGenerator::setDrawIgnore(bool drawIgnore)
|
||||
{
|
||||
m_drawIgnore = drawIgnore;
|
||||
}
|
||||
|
||||
void TileGenerator::setShading(bool shading)
|
||||
{
|
||||
m_shading = shading;
|
||||
@ -1664,14 +1670,18 @@ void TileGenerator::processMapBlock(const DB::Block &block)
|
||||
if (name == "air" && !(m_drawAir && color != m_nodeColors.end())) {
|
||||
m_nodeIDColor[nodeId] = NodeColorNotDrawn;
|
||||
}
|
||||
else if (name == "ignore") {
|
||||
else if (name == "ignore" && !(m_drawIgnore && color != m_nodeColors.end())) {
|
||||
m_nodeIDColor[nodeId] = NodeColorNotDrawn;
|
||||
}
|
||||
else {
|
||||
if (color != m_nodeColors.end()) {
|
||||
// If the color is marked 'ignore', then treat it accordingly.
|
||||
// Colors marked 'ignore' take precedence over 'air'
|
||||
if ((color->second.f & ColorEntry::FlagIgnore)) {
|
||||
m_nodeIDColor[nodeId] = NodeColorNotDrawn;
|
||||
if (m_drawIgnore)
|
||||
m_nodeIDColor[nodeId] = &color->second;
|
||||
else
|
||||
m_nodeIDColor[nodeId] = NodeColorNotDrawn;
|
||||
}
|
||||
// If the color is marked 'air', then treat it accordingly.
|
||||
else if ((color->second.f & ColorEntry::FlagAir)) {
|
||||
|
@ -133,6 +133,7 @@ public:
|
||||
void setHeightScaleInterval(int major, int minor);
|
||||
void setDrawAlpha(bool drawAlpha);
|
||||
void setDrawAir(bool drawAir);
|
||||
void setDrawIgnore(bool drawIgnore);
|
||||
void drawObject(const DrawObject &object) { m_drawObjects.push_back(object); }
|
||||
void setShading(bool shading);
|
||||
void setGeometry(const NodeCoord &corner1, const NodeCoord &corner2);
|
||||
@ -240,6 +241,7 @@ private:
|
||||
int m_drawScale;
|
||||
bool m_drawAlpha;
|
||||
bool m_drawAir;
|
||||
bool m_drawIgnore;
|
||||
bool m_shading;
|
||||
std::string m_backend;
|
||||
std::string m_requestedBackend;
|
||||
|
100
doc/manual.rst
100
doc/manual.rst
@ -268,6 +268,8 @@ Map features:
|
||||
* ``--drawplayers`` : Draw circles at player positions on the map
|
||||
* ``--drawalpha[=cumulative|cumulative-darken|average|none]`` : Enable drawing transparency for some nodes (e.g. water)
|
||||
* ``--drawair`` : Draw air nodes (read the warnings first!)
|
||||
* ``--drawnodes [no-]air,[no-]ignore`` : Draw (or ignore) types of nodes (read the warnings first!)
|
||||
* ``--ignorenodes [no-]air,[no-]ignore`` : Ignore (or draw) types of nodes (read the warnings first!)
|
||||
* ``--noshading`` : Disable shading that accentuates height differences
|
||||
|
||||
Tiles:
|
||||
@ -671,28 +673,7 @@ Detailed Description of Options
|
||||
.............
|
||||
Draw air nodes, as if they were regular nodes.
|
||||
|
||||
The color of air will be obtained from the colors file.
|
||||
|
||||
WARNING 1:
|
||||
the color of air nodes should most probably have an alpha value of
|
||||
0, so that it is fully transparent. The effect will be, that
|
||||
air nodes are only visible if nothing else is below them.
|
||||
|
||||
Setting alpha to anything other than 0, will most probably cause
|
||||
all non-air nodes to be obscured by all of the air that is
|
||||
above them.
|
||||
|
||||
WARNING 2:
|
||||
Drawing air nodes instead of ignoring them will have a significant
|
||||
performance impact (unless they happen to be defined as opaque).
|
||||
Use this with consideration.
|
||||
|
||||
Two images, one with air, the other without. Look inside the rectangle:
|
||||
|
||||
.. image:: images/background-white.png
|
||||
.. image:: images/drawair.png
|
||||
.. image:: images/drawair-detail-0.png
|
||||
.. image:: images/drawair-detail.png
|
||||
This option is synonymous with `--drawnodes air`_.
|
||||
|
||||
``--drawalpha[=cumulative|cumulative-darken|average|none]``
|
||||
...........................................................
|
||||
@ -757,6 +738,53 @@ Detailed Description of Options
|
||||
|
||||
.. image:: images/heightmap-scale.png
|
||||
|
||||
``--drawnodes [no-]air,[no-]ignore``
|
||||
....................................
|
||||
Draw air-type or ignore-type nodes, as if they were regular nodes.
|
||||
By default they are not drawn.
|
||||
|
||||
A prefix of '``no-``' inverts the effect, so that the nodes are ignored
|
||||
instead.
|
||||
|
||||
Air-type nodes are the node named '``air``', and any node that has the
|
||||
`air` flag in the colors file.
|
||||
Ignore-type nodes are the node named '``ignore``', and any node that has the
|
||||
`ignore` flag in the colors file.
|
||||
See `Colors.txt Syntax`_.
|
||||
|
||||
If a node has both the `air` flag and the `ignore` flag, the `ignore` flag
|
||||
takes precedence. I.e. the `air` flag will be ignored.
|
||||
|
||||
If drawing `air` and/or `ignore` nodes, they must obviously have an entry
|
||||
in the colors file.
|
||||
|
||||
WARNING 1:
|
||||
The color of air-type and ignore-type nodes should most probably have an
|
||||
alpha value of 0, so that they are fully transparent. The effect will be,
|
||||
that they nodes are only visible if nothing else is below them.
|
||||
|
||||
Setting alpha to anything other than 0, will most probably cause
|
||||
all non-air / non-ignore nodes to be obscured by all of the air/ignore
|
||||
nodes that are above them.
|
||||
|
||||
WARNING 2:
|
||||
Drawing '``air``' or '``ignore``' nodes instead of ignoring them will have a
|
||||
significant performance impact (unless they happen to be defined as opaque).
|
||||
Use this with consideration.
|
||||
|
||||
Instead of enabling the drawing of '``air``' or '``ignore``' nodes, it may be
|
||||
possible to achieve a similar result, with a negligible performance impact,
|
||||
by using the option `--blockcolor`_.
|
||||
|
||||
This option is the inverse of `--ignorenodes`_.
|
||||
|
||||
Two images, one with air drawn, the other without. Look inside the rectangle:
|
||||
|
||||
.. image:: images/background-white.png
|
||||
.. image:: images/drawair.png
|
||||
.. image:: images/drawair-detail-0.png
|
||||
.. image:: images/drawair-detail.png
|
||||
|
||||
``--draworigin``
|
||||
................
|
||||
Draw a circle at the world origin (coordinates 0,0)
|
||||
@ -980,6 +1008,23 @@ Detailed Description of Options
|
||||
..........
|
||||
Print the option summary.
|
||||
|
||||
``--ignorenodes [no-]air,[no-]ignore``
|
||||
......................................
|
||||
Ignore air-type or ignore-type nodes, so that they are not drawn at all.
|
||||
|
||||
A prefix of '``no-``' inverts the effect, so that the nodes are drawn
|
||||
like regular nodes.
|
||||
|
||||
This option is the inverse of `--drawnodes`_. E.g.::
|
||||
|
||||
--ignorenodes no-air,ignore
|
||||
|
||||
is equivalent to::
|
||||
|
||||
--drawnodes air,no-ignore
|
||||
|
||||
See `--drawnodes`_ for more information.
|
||||
|
||||
``--input <world_path>``
|
||||
........................
|
||||
Specify the world to map.
|
||||
@ -1690,11 +1735,12 @@ Colors.txt Syntax
|
||||
Currently, two flags are defined:
|
||||
|
||||
:air: The `air` flag causes the node to be treated like '``air``' nodes:
|
||||
by default, such nodes are ignored. The option `--drawair`_ allows
|
||||
them to be drawn instead.
|
||||
by default, such nodes are ignored. The options `--drawair`_
|
||||
and `--drawnodes air`_ allow them to be drawn instead.
|
||||
|
||||
:ignore: The `ignore` flag causes the node to be treated like '``ignore``' nodes:
|
||||
they are simply ignored.
|
||||
by default, such nodes are ignored. The option `--drawnodes ignore`_
|
||||
allows them to be drawn instead.
|
||||
|
||||
Examples::
|
||||
|
||||
@ -1976,6 +2022,10 @@ More information is available:
|
||||
.. _--colors: `--colors <file>`_
|
||||
.. _--cornergeometry: `--cornergeometry <geometry>`_
|
||||
.. _--database-format: `--database-format minetest-i64\|freeminer-axyz\|mixed\|query`_
|
||||
.. _--drawnodes: `--drawnodes [no-]air,[no-]ignore`_
|
||||
.. _--ignorenodes: `--ignorenodes [no-]air,[no-]ignore`_
|
||||
.. _--drawnodes air: `--drawnodes [no-]air,[no-]ignore`_
|
||||
.. _--drawnodes ignore: `--drawnodes [no-]air,[no-]ignore`_
|
||||
.. _--draw[map]<figure>: `--draw[map]<figure> "<geometry> <color> [<text>]"`_
|
||||
.. _--draw[map]circle: `--draw[map]circle "<geometry> <color>"`_
|
||||
.. _--draw[map]ellipse: `--draw[map]ellipse "<geometry> <color>"`_
|
||||
|
35
mapper.cpp
35
mapper.cpp
@ -45,6 +45,7 @@ using namespace std;
|
||||
#define OPT_DATABASE_FORMAT 0x91
|
||||
#define OPT_SILENCE_SUGGESTIONS 0x92
|
||||
#define OPT_PRESCAN_WORLD 0x93
|
||||
#define OPT_DRAWNODES 0x94
|
||||
|
||||
#define DRAW_ARROW_LENGTH 10
|
||||
#define DRAW_ARROW_ANGLE 30
|
||||
@ -125,6 +126,8 @@ void usage()
|
||||
" --draworigin\n"
|
||||
" --drawalpha[=cumulative|cumulative-darken|average|none]\n"
|
||||
" --drawair\n"
|
||||
" --drawnodes [no-]air,[no-]ignore\n"
|
||||
" --ignorenodes [no-]air,[no-]ignore\n"
|
||||
" --draw[map]point \"<x>,<y> color\"\n"
|
||||
" --draw[map]line \"<geometry> color\"\n"
|
||||
" --draw[map]line \"<x>,<y> <angle> <length>[np] color\"\n"
|
||||
@ -704,6 +707,8 @@ int main(int argc, char *argv[])
|
||||
{"heightscale-interval", required_argument, 0, OPT_SCALEINTERVAL},
|
||||
{"drawalpha", optional_argument, 0, 'e'},
|
||||
{"drawair", no_argument, 0, OPT_DRAWAIR},
|
||||
{"drawnodes", required_argument, 0, OPT_DRAWNODES},
|
||||
{"ignorenodes", required_argument, 0, OPT_DRAWNODES},
|
||||
{"drawpoint", required_argument, 0, OPT_DRAW_OBJECT},
|
||||
{"drawline", required_argument, 0, OPT_DRAW_OBJECT},
|
||||
{"drawcircle", required_argument, 0, OPT_DRAW_OBJECT},
|
||||
@ -1050,6 +1055,36 @@ int main(int argc, char *argv[])
|
||||
case OPT_DRAWAIR:
|
||||
generator.setDrawAir(true);
|
||||
break;
|
||||
case OPT_DRAWNODES: {
|
||||
bool draw = long_options[option_index].name[0] == 'd';
|
||||
for (char *c = optarg; *c; c++) {
|
||||
*c = tolower(*c);
|
||||
if (*c == ',') *c = ' ';
|
||||
}
|
||||
istringstream iss(optarg);
|
||||
string flag;
|
||||
iss >> std::skipws >> flag;
|
||||
while (!iss.fail()) {
|
||||
bool enable = draw;
|
||||
if (flag.substr(0,3) == "no-") {
|
||||
flag = flag.substr(3);
|
||||
enable = !enable;
|
||||
}
|
||||
if (flag == "")
|
||||
(void) true; // Empty flag - ignore
|
||||
else if (flag == "ignore")
|
||||
generator.setDrawIgnore(enable);
|
||||
else if (flag == "air")
|
||||
generator.setDrawAir(enable);
|
||||
else {
|
||||
std::cerr << "Invalid " << long_options[option_index].name << " flag '" << flag << "'" << std::endl;
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
iss >> flag;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'H':
|
||||
generator.setShading(false);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user