Merge pull request #303 from mikeprimm/hdrender

Improve progress messages, make sure HDMaps that share render only render
This commit is contained in:
mikeprimm 2011-07-21 23:47:17 -07:00
commit ce76cfd695
12 changed files with 124 additions and 21 deletions

View File

@ -160,6 +160,9 @@ public class MapManager {
int rendercnt = 0; int rendercnt = 0;
CommandSender sender; CommandSender sender;
long timeaccum; long timeaccum;
HashSet<MapType> renderedmaps = new HashSet<MapType>();
String activemaps;
List<String> activemaplist;
/* Full world, all maps render */ /* Full world, all maps render */
FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender) { FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender) {
@ -195,21 +198,40 @@ public class MapManager {
/* If render queue is empty, start next map */ /* If render queue is empty, start next map */
if(renderQueue.isEmpty()) { if(renderQueue.isEmpty()) {
if(map_index >= 0) { /* Finished a map? */ if(map_index >= 0) { /* Finished a map? */
double msecpertile = (double)timeaccum / (double)((rendercnt>0)?rendercnt:1); double msecpertile = (double)timeaccum / (double)((rendercnt>0)?rendercnt:1)/(double)activemaplist.size();
sender.sendMessage("Full render of map '" + world.maps.get(map_index).getClass().getSimpleName() + "' of world '" + if(activemaplist.size() > 1)
sender.sendMessage("Full render of maps [" + activemaps + "] of '" +
world.world.getName() + "' completed - " + rendercnt + " tiles rendered each (" + String.format("%.2f", msecpertile) + " msec/map-tile).");
else
sender.sendMessage("Full render of map '" + activemaps + "' of '" +
world.world.getName() + "' completed - " + rendercnt + " tiles rendered (" + String.format("%.2f", msecpertile) + " msec/tile)."); world.world.getName() + "' completed - " + rendercnt + " tiles rendered (" + String.format("%.2f", msecpertile) + " msec/tile).");
} }
found.clear(); found.clear();
rendered.clear(); rendered.clear();
rendercnt = 0; rendercnt = 0;
timeaccum = 0; timeaccum = 0;
map_index++; /* Next map */ /* Advance to next unrendered map */
while(map_index < world.maps.size()) {
map_index++; /* Move to next one */
if((map_index < world.maps.size()) && (renderedmaps.contains(world.maps.get(map_index)) == false))
break;
}
if(map_index >= world.maps.size()) { /* Last one done? */ if(map_index >= world.maps.size()) { /* Last one done? */
sender.sendMessage("Full render of '" + world.world.getName() + "' finished."); sender.sendMessage("Full render of '" + world.world.getName() + "' finished.");
cleanup(); cleanup();
return; return;
} }
map = world.maps.get(map_index); map = world.maps.get(map_index);
activemaplist = map.getMapNamesSharingRender(world);
/* Build active map list */
activemaps = "";
for(String n : activemaplist) {
if(activemaps.length() > 0)
activemaps += ",";
activemaps += n;
}
/* Mark all the concurrently rendering maps rendered */
renderedmaps.addAll(map.getMapsSharingRender(world));
/* Now, prime the render queue */ /* Now, prime the render queue */
for (MapTile mt : map.getTiles(loc)) { for (MapTile mt : map.getTiles(loc)) {
@ -264,8 +286,12 @@ public class MapManager {
rendercnt++; rendercnt++;
timeaccum += System.currentTimeMillis() - tstart; timeaccum += System.currentTimeMillis() - tstart;
if((rendercnt % 100) == 0) { if((rendercnt % 100) == 0) {
double msecpertile = (double)timeaccum / (double)rendercnt; double msecpertile = (double)timeaccum / (double)rendercnt / (double)activemaplist.size();
sender.sendMessage("Full render of map '" + world.maps.get(map_index).getClass().getSimpleName() + "' on world '" + if(activemaplist.size() > 1)
sender.sendMessage("Full render of maps [" + activemaps + "] of '" +
w.getName() + "' in progress - " + rendercnt + " tiles rendered each (" + String.format("%.2f", msecpertile) + " msec/map-tile).");
else
sender.sendMessage("Full render of map '" + activemaps + "' of '" +
w.getName() + "' in progress - " + rendercnt + " tiles rendered (" + String.format("%.2f", msecpertile) + " msec/tile)."); w.getName() + "' in progress - " + rendercnt + " tiles rendered (" + String.format("%.2f", msecpertile) + " msec/tile).");
} }
} }

View File

@ -21,6 +21,11 @@ public abstract class MapType {
public abstract String getName(); public abstract String getName();
/* Get maps rendered concurrently with this map in this world */
public abstract List<MapType> getMapsSharingRender(DynmapWorld w);
/* Get names of maps rendered concurrently with this map type in this world */
public abstract List<String> getMapNamesSharingRender(DynmapWorld w);
public enum MapStep { public enum MapStep {
X_PLUS_Y_PLUS, X_PLUS_Y_PLUS,
X_PLUS_Y_MINUS, X_PLUS_Y_MINUS,

View File

@ -6,6 +6,7 @@ import static org.dynmap.JSONUtils.s;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -35,6 +36,7 @@ import org.json.simple.JSONObject;
public class FlatMap extends MapType { public class FlatMap extends MapType {
private ConfigurationNode configuration; private ConfigurationNode configuration;
private String prefix; private String prefix;
private String name;
private ColorScheme colorScheme; private ColorScheme colorScheme;
private int maximumHeight = 127; private int maximumHeight = 127;
private int ambientlight = 15;; private int ambientlight = 15;;
@ -47,7 +49,8 @@ public class FlatMap extends MapType {
public FlatMap(ConfigurationNode configuration) { public FlatMap(ConfigurationNode configuration) {
this.configuration = configuration; this.configuration = configuration;
prefix = (String) configuration.get("prefix"); name = configuration.getString("name", null);
prefix = configuration.getString("prefix", name);
colorScheme = ColorScheme.getScheme((String) configuration.get("colorscheme")); colorScheme = ColorScheme.getScheme((String) configuration.get("colorscheme"));
Object o = configuration.get("maximumheight"); Object o = configuration.get("maximumheight");
if (o != null) { if (o != null) {
@ -413,6 +416,16 @@ public class FlatMap extends MapType {
return prefix; return prefix;
} }
/* Get maps rendered concurrently with this map in this world */
public List<MapType> getMapsSharingRender(DynmapWorld w) {
return Collections.singletonList((MapType)this);
}
/* Get names of maps rendered concurrently with this map type in this world */
public List<String> getMapNamesSharingRender(DynmapWorld w) {
return Collections.singletonList(name);
}
public List<String> baseZoomFilePrefixes() { public List<String> baseZoomFilePrefixes() {
ArrayList<String> s = new ArrayList<String>(); ArrayList<String> s = new ArrayList<String>();
s.add(getName() + "_128"); s.add(getName() + "_128");

View File

@ -14,6 +14,7 @@ import org.dynmap.Log;
import org.dynmap.MapManager; import org.dynmap.MapManager;
import org.dynmap.MapTile; import org.dynmap.MapTile;
import org.dynmap.MapType; import org.dynmap.MapType;
import org.dynmap.kzedmap.MapTileRenderer;
import org.dynmap.utils.MapChunkCache; import org.dynmap.utils.MapChunkCache;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
@ -130,6 +131,38 @@ public class HDMap extends MapType {
return prefix; return prefix;
} }
/* Get maps rendered concurrently with this map in this world */
public List<MapType> getMapsSharingRender(DynmapWorld w) {
ArrayList<MapType> maps = new ArrayList<MapType>();
for(MapType mt : w.maps) {
if(mt instanceof HDMap) {
HDMap hdmt = (HDMap)mt;
if(hdmt.perspective == this.perspective) { /* Same perspective */
maps.add(hdmt);
}
}
}
return maps;
}
/* Get names of maps rendered concurrently with this map type in this world */
public List<String> getMapNamesSharingRender(DynmapWorld w) {
ArrayList<String> lst = new ArrayList<String>();
for(MapType mt : w.maps) {
if(mt instanceof HDMap) {
HDMap hdmt = (HDMap)mt;
if(hdmt.perspective == this.perspective) { /* Same perspective */
if(hdmt.lighting.isNightAndDayEnabled())
lst.add(hdmt.getName() + "(night/day)");
else
lst.add(hdmt.getName());
}
}
}
return lst;
}
@Override @Override
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) { public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) {
ConfigurationNode c = configuration; ConfigurationNode c = configuration;

View File

@ -30,6 +30,7 @@ import org.json.simple.JSONObject;
public class DefaultTileRenderer implements MapTileRenderer { public class DefaultTileRenderer implements MapTileRenderer {
protected static final Color translucent = new Color(0, 0, 0, 0); protected static final Color translucent = new Color(0, 0, 0, 0);
protected String name; protected String name;
protected String prefix;
protected ConfigurationNode configuration; protected ConfigurationNode configuration;
protected int maximumHeight = 127; protected int maximumHeight = 127;
protected ColorScheme colorScheme; protected ColorScheme colorScheme;
@ -45,7 +46,12 @@ public class DefaultTileRenderer implements MapTileRenderer {
NONE, BIOME, TEMPERATURE, RAINFALL NONE, BIOME, TEMPERATURE, RAINFALL
} }
protected BiomeColorOption biomecolored = BiomeColorOption.NONE; /* Use biome for coloring */ protected BiomeColorOption biomecolored = BiomeColorOption.NONE; /* Use biome for coloring */
@Override @Override
public String getPrefix() {
return prefix;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -54,7 +60,8 @@ public class DefaultTileRenderer implements MapTileRenderer {
public DefaultTileRenderer(ConfigurationNode configuration) { public DefaultTileRenderer(ConfigurationNode configuration) {
this.configuration = configuration; this.configuration = configuration;
name = (String) configuration.get("prefix"); name = configuration.getString("name", null);
prefix = configuration.getString("prefix", name);
Object o = configuration.get("maximumheight"); Object o = configuration.get("maximumheight");
if (o != null) { if (o != null) {
maximumHeight = Integer.parseInt(String.valueOf(o)); maximumHeight = Integer.parseInt(String.valueOf(o));

View File

@ -5,6 +5,7 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -358,6 +359,23 @@ public class KzedMap extends MapType {
return "KzedMap"; return "KzedMap";
} }
/* Get maps rendered concurrently with this map in this world */
public List<MapType> getMapsSharingRender(DynmapWorld w) {
return Collections.singletonList((MapType)this);
}
/* Get names of maps rendered concurrently with this map type in this world */
public List<String> getMapNamesSharingRender(DynmapWorld w) {
ArrayList<String> lst = new ArrayList<String>();
for(MapTileRenderer rend : renderers) {
if(rend.isNightAndDayEnabled())
lst.add(rend.getName() + "(night/day)");
else
lst.add(rend.getName());
}
return lst;
}
@Override @Override
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) { public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) {
for(MapTileRenderer renderer : renderers) { for(MapTileRenderer renderer : renderers) {

View File

@ -32,9 +32,9 @@ public class KzedMapTile extends MapTile {
public String getFilename() { public String getFilename() {
if(fname == null) { if(fname == null) {
if(map.isBigWorldMap(world)) if(map.isBigWorldMap(world))
fname = renderer.getName() + "/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png"; fname = renderer.getPrefix() + "/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png";
else else
fname = renderer.getName() + "_" + px + "_" + py + ".png"; fname = renderer.getPrefix() + "_" + px + "_" + py + ".png";
} }
return fname; return fname;
} }
@ -43,9 +43,9 @@ public class KzedMapTile extends MapTile {
public String getDayFilename() { public String getDayFilename() {
if(fname_day == null) { if(fname_day == null) {
if(map.isBigWorldMap(world)) if(map.isBigWorldMap(world))
fname_day = renderer.getName() + "_day/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png"; fname_day = renderer.getPrefix() + "_day/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png";
else else
fname_day = renderer.getName() + "_day_" + px + "_" + py + ".png"; fname_day = renderer.getPrefix() + "_day_" + px + "_" + py + ".png";
} }
return fname_day; return fname_day;
} }
@ -68,7 +68,7 @@ public class KzedMapTile extends MapTile {
} }
public String getKey() { public String getKey() {
return getWorld().getName() + "." + renderer.getName(); return getWorld().getName() + "." + renderer.getPrefix();
} }
public String toString() { public String toString() {

View File

@ -15,10 +15,10 @@ public class KzedZoomedMapTile extends MapTile {
public String getFilename() { public String getFilename() {
if(fname == null) { if(fname == null) {
if(world.bigworld) if(world.bigworld)
fname = "z" + originalTile.renderer.getName() + "/" + (getTileX()>>12) + '_' + fname = "z" + originalTile.renderer.getPrefix() + "/" + (getTileX()>>12) + '_' +
(getTileY() >> 12) + '/' + getTileX() + "_" + getTileY() + ".png"; (getTileY() >> 12) + '/' + getTileX() + "_" + getTileY() + ".png";
else else
fname = "z" + originalTile.renderer.getName() + "_" + getTileX() + "_" + getTileY() + ".png"; fname = "z" + originalTile.renderer.getPrefix() + "_" + getTileX() + "_" + getTileY() + ".png";
} }
return fname; return fname;
} }
@ -27,10 +27,10 @@ public class KzedZoomedMapTile extends MapTile {
public String getDayFilename() { public String getDayFilename() {
if(fname_day == null) { if(fname_day == null) {
if(world.bigworld) if(world.bigworld)
fname_day = "z" + originalTile.renderer.getName() + "_day/" + (getTileX()>>12) + '_' + fname_day = "z" + originalTile.renderer.getPrefix() + "_day/" + (getTileX()>>12) + '_' +
(getTileY() >> 12) + '/' + getTileX() + "_" + getTileY() + ".png"; (getTileY() >> 12) + '/' + getTileX() + "_" + getTileY() + ".png";
else else
fname_day = "z" + originalTile.renderer.getName() + "_day_" + getTileX() + "_" + getTileY() + ".png"; fname_day = "z" + originalTile.renderer.getPrefix() + "_day_" + getTileX() + "_" + getTileY() + ".png";
} }
return fname_day; return fname_day;
} }
@ -80,7 +80,7 @@ public class KzedZoomedMapTile extends MapTile {
public String getKey() { public String getKey() {
return getWorld().getName() + ".z" + originalTile.renderer.getName(); return getWorld().getName() + ".z" + originalTile.renderer.getPrefix();
} }
@Override @Override

View File

@ -8,6 +8,7 @@ import org.dynmap.utils.MapChunkCache;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
public interface MapTileRenderer { public interface MapTileRenderer {
String getPrefix();
String getName(); String getName();
boolean render(MapChunkCache cache, KzedMapTile tile, File outputFile); boolean render(MapChunkCache cache, KzedMapTile tile, File outputFile);

View File

@ -72,7 +72,7 @@ FlatMapType.prototype = $.extend(new DynMapType(), {
updateTileSize: function(zoom) { updateTileSize: function(zoom) {
var size; var size;
var extrazoom = this.dynmap.world.extrazoomout; var extrazoom = this.dynmap.world.extrazoomout;
var mapzoomin = this.dynmap.world.mapzoomin; var mapzoomin = this.mapzoomin;
this.projection.extrazoom = extrazoom; this.projection.extrazoom = extrazoom;
this.maxZoom = mapzoomin + extrazoom; this.maxZoom = mapzoomin + extrazoom;
if (zoom <= extrazoom) { if (zoom <= extrazoom) {

View File

@ -115,7 +115,7 @@ KzedMapType.prototype = $.extend(new DynMapType(), {
updateTileSize: function(zoom) { updateTileSize: function(zoom) {
var size; var size;
var extrazoom = this.dynmap.world.extrazoomout; var extrazoom = this.dynmap.world.extrazoomout;
var mapzoomin = this.dynmap.world.mapzoomin; var mapzoomin = this.mapzoomin;
this.projection.extrazoom = extrazoom; this.projection.extrazoom = extrazoom;
this.maxZoom = mapzoomin + extrazoom; this.maxZoom = mapzoomin + extrazoom;
if (zoom <= extrazoom) { if (zoom <= extrazoom) {