73 Commits

Author SHA1 Message Date
Rogier
03926420d0 Implement bounded block-list query for postgresql
i.e. allow minetestmapper to query the database for a list of
blocks in a specific range (corresponding to the requested geometry),
instead of always obtaining a full list off all blocks.

As postgresql is the only database which supports this efficiently,
this option is only effective for postgresql.
2016-01-17 10:37:51 +01:00
Rogier
2ec0988e32 Abstract & improve some stream operations, and make them idempotent.
<stream>.eof() may require the stream to be read (peeked) before giving the
correct result. But it can't be peeked if already at EOF - see below.

<stream>.peek() is not idempotent:
If the stream is at EOF, but not known to be, it sets eofbit.
However, if the stream is known to be at EOF, it sets the failbit :-(
2016-01-17 10:37:51 +01:00
Rogier
8f6c9d7557 Improve an error message 2016-01-17 10:37:51 +01:00
Rogier
2ca8ce4c53 Print suggestion messages related to the use of --disable-blocklist-prefetch 2015-03-10 18:12:53 +01:00
Rogier
0a5e24b7d7 Add option --silence-suggestions, to disable certain messages
Specific message types will be in a later commit
2015-03-10 18:12:53 +01:00
Rogier
b3ce6116a5 Add an option to specify database format (for use with --disable-blocklist-prefetch)
When using --disable-blocklist-prefetch, the database key format for every leveldb
block, which is normally determined when prefetching the block list, is not known.

In order to avoid duplicate queries using both key formats, the key format can now
be specified using --database-format
2015-03-10 18:12:53 +01:00
Rogier
38f4272dd3 Add an option to disable prefetching the block list from the database
This introduces a speed tradeoff.

When mapping a small part of a large world, the prefetch time dominates
the mapping time, and it is more advantageous to skip the prefetch and
query all possible blocks in the mapped space.

When mapping a large fraction of a world, in particular when a lot of
the mapped space is empty, the time spent querying non-existing blocks can
dominate mapping time, and it is more advantageous to prefetch the list
of existing blocks, so that querying huge numbers of non-existing blocks
can be avoided.
2015-03-10 18:12:53 +01:00
Rogier
f7e822adf0 Change verboseStatistics to int (from bool) 2015-03-10 17:47:29 +01:00
Rogier
10be8ebfe6 Improve colors file searching on Windows
On Windows, minetestmapper now uses the colors files from the
directory where it is installed.

If the last directory is named 'bin', that part is stripped,
and the resulting directory, and a subdirectory named 'colors'
are searched.

All depends on the whether on invocation, argv[0] contains the full
path of the exe file. It works under Wine when compiled with MinGW.

I haven't been able to test on a real copy of windows, or when
compiled using msvc, but I assume that will work too.
2015-03-10 12:01:55 +01:00
Rogier
7c2cf3efa9 Cleanup sqlite3 database code a bit
As tests using --sqlite-cacheworldrow showed a consistently
lower performance than without, this option was effectively
disabled. It is still recognised for compatibility, but
it may be removed some time in the future.
2015-03-10 12:01:55 +01:00
Rogier
7c8a99599f Improve memory use of BlockPos 2015-03-03 08:29:04 +01:00
Rogier
a6eed3a1ed Add options to specify a custom major and minor interval in the scale(s). 2015-02-20 13:10:09 +01:00
Rogier
5ce7ff4bce Allow scaling a map to a smaller size while generating. (1/2, 1/4 .. 1/16)
Scaling will not average nodes across block boundaries, This implies
that the only scale factors supported are 1:2, 1:4, 1:8 and 1:16.
2015-02-20 13:10:09 +01:00
Rogier
994e9d7171 Add the option to draw a height scale for the height map 2015-02-20 13:10:09 +01:00
Rogier
4476de429d Allow reading heightmap colors from file, and use separate option for nodes file 2015-02-20 13:10:09 +01:00
Rogier
3812e31fc9 Add options to generate a height map of the world.
--heightmap: generate the height map, in colors
--heightmap-grey: use shades of grey instead of colors
--sealevel <n>: define the sea level (below sea level is drawn in blue)
--heightmap-scale <f>: scale the heights by f (for the purpose of
  color selection)

When generating a heightmap, a special colors file is needed,
that defines just the blocks that should be considered part
of the ground. That means that normally, any plants, special
nodes and water should not be included.
2015-02-20 13:10:09 +01:00
Rogier
d538398c31 Allow selecting which sides to draw the scale on (top and/or left) 2015-02-20 13:10:09 +01:00
Rogier
722086781d Allow specifying lighter or darker variants of built-in colors. 2015-02-20 13:10:09 +01:00
Rogier
1854ef34e6 Recognise some symbolic colors (red, green, blue, yellow, black, white, gr[ae]y, and more) 2015-02-20 13:10:09 +01:00
Rogier
185bf90c4b Sanitize the code that searches for a colors.txt file 2015-02-20 13:10:08 +01:00
Rogier
22041a8603 Add shorthand options to draw tiles matching map-blocks and map-chunks
The option --tiles has two new possible values: 'block' and 'chunk'
'block' creates tiles corresponding to map blocks
'chunk' creates tiles corresponding to map chunks
(chunks are the unit of map generation).

An option --chunksize was added to manually override the chunk size.
2015-02-20 13:10:08 +01:00
Rogier
5aa358aafe Rename some constants for clarity 2015-02-20 13:10:08 +01:00
Rogier
b99111e038 Add a --drawalpha mode that keeps water (etc.) transparent to great depths
This new mode averages the colors of all transparent blocks, instead of
making the colors progressively darker and more opaque.

This 'average' mode is now the default when using --drawalpha. It can be
explicitly selected using --drawalpha=average. The old modes can be selected
using --drawalpha=cumulative[-darken].

It is recommended to change the colors of water as well. These are in a
separate patch.
2014-06-19 13:30:00 +02:00
Rogier
a065e68eac Make darkening of thick transparent stacks (e.g. deep water) configurable.
In order to reduce rendering surprises, this darkening is off by default
(it was on previously).
2014-06-18 21:19:14 +02:00
Rogier
f832530bf8 Allow air nodes to have a color.
As this comes with a significant performance penalty, this
feature must be enabled using the command-line option --drawair

For best results, the color of air should be fully transparent,
so that underlying nodes will override it.
2014-06-18 10:07:55 +02:00
Rogier
ced0390611 Add a default color for nodes
This is useful to show invisible ('air' or 'invalid') nodes in blocks
that are in the database using a different color than blocks that are
not in the database (which will have no color at all, causing the
background color to show).
2014-06-18 10:06:46 +02:00
Rogier
224c6b1df7 Add a command-line option to report which colors file is being used. 2014-06-18 09:50:41 +02:00
Rogier
b7fe1404fa Add support for system-wide colors.txt file 2014-06-10 17:41:28 +02:00
Rogier
f6adec1bf9 Configure a better version number (partly or fully auto-computed) 2014-05-26 21:31:29 +02:00
Rogier
f3c25ac729 Fix and improve configuration of tiles location 2014-05-23 13:47:41 +02:00
Rogier
20163ec7a4 Fix to geometrymode option parsing code (allow empty optarg) 2014-05-23 13:47:41 +02:00
Rogier
736e2a8d27 Add command-line options to draw geometrical figures on the map
Supported figures are points, lines, ellipses, rectangles
and text.

The figures' locations can be specified using either world
coordinates, or map coordinates.
2014-05-23 13:47:41 +02:00
Rogier
c00cc13e6a Generalize the parsing of coordinates and geometry strings.
In preparation for future changes.

New geometry and new coordinate syntax has been added as well:

Additional node coordinate formats:
    <block>#[<node>]
    <block>.[<node>]

Additional geometry formats:
    <x1>,<y1>:<x2>,<y2>
    <x>,<y>:<w>x<h>

Also: the old geometry behavior (block granularity and map shrinking)
is now enabled only if the old geometry format is used (for compatibility)
2014-05-23 13:47:40 +02:00
Rogier
6544d4de37 Catch block data parsing errors (e.g. caused by a corrupt map block)
Corrupt blocks are reported, and map generation continues. Map
generation aborts only after 100 or more corrupt map blocks.
2014-05-23 13:47:40 +02:00
Rogier
2fabf991ab Make sqlite backend optional (enabled by default) 2014-05-22 10:41:48 +02:00
Rogier
d707b882e8 Add redis database backend (port of sfan5's patches)
Patches included/ported:
	2553e44e8dec75d99408b56f469ff4be61c84336
	79d338a90c1a99fce9334bea5d4c296f190373fc
2014-05-22 10:41:48 +02:00
Rogier
15bab71533 Allow setting verbosity back to 0 2014-05-22 10:41:47 +02:00
Rogier
2c00ad665c Fix SEGV caused by unknown/unrecognised option name 2014-05-22 10:41:47 +02:00
Rogier
f60fd0a9aa Search world's minetest directory for colors file as well.
(which is assumed to be the directory two levels up from the
 world's directory, if it contains 'minetest.conf')
2014-05-22 10:41:12 +02:00
Rogier
65b37bec25 Allow player and origin colors to have an alpha component.
Values: 0: fully transparent, 255: fully opaque.

Note that this doesn't yield the expected color blending just
yet, due to libgd messing it up. (Seemingly, the libgd arc
drawing function draws some pixels repeatedly, resulting in a
more opaque circle than desired)
2014-05-22 10:41:12 +02:00
Rogier
1c7b31a5dc When not using a geometry option, *do* generate the smallest possible map 2014-05-22 10:41:12 +02:00
Rogier
d5b3b2a7da Improve error messages for zlib decompression errors 2014-05-22 10:41:12 +02:00
Rogier
0117556550 Make --geometrymode accept an empty option list
An empty option list modifies the behavior of a subsequent plain
--geometry to not make the old mode (shrink,block) the default.
2014-05-12 09:26:17 +02:00
Rogier
5915e1712a Add error messages when failing to parse command-line
Mention the help option as well in the help text.
2014-05-12 09:26:17 +02:00
Rogier
5e4ee45575 Move color string parsing to constructor of class Color & add a constructor using an integer
Added formats for Color constructor:
- plain interger (2^24 * alpha + 2^16 * red + 2^8 * green + blue)
- Color string consisting of:
  - '#'
  - 3, 4, 6 or 8 hex digits
2014-05-12 09:26:17 +02:00
Rogier
e97e19921c Search more locations for the colors.txt file
The colors.txt file can now be located:
- in the directory of the world being mapped
- in the user's private minetest directory ($HOME/.minetest)
- in the current directory as a last resort

The location can also be specified using a command-line option
2014-04-16 15:13:09 +02:00
Rogier
06237f5abc Improve layout of verbose geometry messages & tune their verbosity 2014-04-16 15:12:59 +02:00
Rogier
6a26a8ef4b Make the geometry pixel-accurate instead of map-block accurate
When requesting, for instance, a 75x85 map, the mapper will
now create a 75x85 map, instead of an 80x96 (or even 96x108)
map as it did before.

This new behavior is the default when using one of the options
--centergeometry or --cornergeometry.

In addition, both of these options will no longer shrink the
map, to remove rows or columns of empty blocks at the edges.
Previously, this behavior was enabled with --forcegeometry.

An option --geometrymode has been added as well, to tune
the interpretation of the geometry. It supports 4 flags:

- pixel:  the requested geometry is interpreted with pixel
	  granularity. The map is not enlarged to include
	  entire map blocks.

- block:  the requested geometry is interpreted with block
	  granularity. The map is enlarged with at most 15
	  nodes at each of the four edges, so that it
	  includes entire map blocks only.

- fixed:  a map of the requested geometry is created (after
	  adjustmens for 'block' mode). Empty rows or
	  columns at the edges are not removed.

- shrink: Empty rows and columns at the map edges are
	  removed to generate the smallest picture possible.

Lastly, a new geometry syntax has been added, which is more
compatible with known syntax (i.e. X-Windows), and which
allows the offset to be optional. If the offset is omitted,
the picture defaults to be centered around 0,0.

`<width>x<height>[+|-<xoffset>+|-<yoffset>]`

For compatibility, the behavior of the option --geometry
was not changed. If (and only if) used before --geometrymode,
it enables block granularity and shrink.

The old option --forcegeometry is no longer documented,
but still recognised for compatibility.
2014-04-16 15:12:37 +02:00
Rogier
ec7178dde3 Change --tileorigin to accept ',' as separator
The previous separator (':') still works, but is not advertised.
2014-04-16 10:57:21 +02:00
Rogier
13463f2214 Catch option parsing errors & colors.txt errors. 2014-04-14 01:30:17 +02:00