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;
CommandSender sender;
long timeaccum;
HashSet<MapType> renderedmaps = new HashSet<MapType>();
String activemaps;
List<String> activemaplist;
/* Full world, all maps render */
FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender) {
@ -195,21 +198,40 @@ public class MapManager {
/* If render queue is empty, start next map */
if(renderQueue.isEmpty()) {
if(map_index >= 0) { /* Finished a map? */
double msecpertile = (double)timeaccum / (double)((rendercnt>0)?rendercnt:1);
sender.sendMessage("Full render of map '" + world.maps.get(map_index).getClass().getSimpleName() + "' of world '" +
double msecpertile = (double)timeaccum / (double)((rendercnt>0)?rendercnt:1)/(double)activemaplist.size();
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).");
}
found.clear();
rendered.clear();
rendercnt = 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? */
sender.sendMessage("Full render of '" + world.world.getName() + "' finished.");
cleanup();
return;
}
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 */
for (MapTile mt : map.getTiles(loc)) {
@ -264,9 +286,13 @@ public class MapManager {
rendercnt++;
timeaccum += System.currentTimeMillis() - tstart;
if((rendercnt % 100) == 0) {
double msecpertile = (double)timeaccum / (double)rendercnt;
sender.sendMessage("Full render of map '" + world.maps.get(map_index).getClass().getSimpleName() + "' on world '" +
w.getName() + "' in progress - " + rendercnt + " tiles rendered (" + String.format("%.2f", msecpertile) + " msec/tile).");
double msecpertile = (double)timeaccum / (double)rendercnt / (double)activemaplist.size();
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).");
}
}
}

View File

@ -20,6 +20,11 @@ public abstract class MapType {
}
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 {
X_PLUS_Y_PLUS,

View File

@ -6,6 +6,7 @@ import static org.dynmap.JSONUtils.s;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.imageio.ImageIO;
@ -35,6 +36,7 @@ import org.json.simple.JSONObject;
public class FlatMap extends MapType {
private ConfigurationNode configuration;
private String prefix;
private String name;
private ColorScheme colorScheme;
private int maximumHeight = 127;
private int ambientlight = 15;;
@ -47,7 +49,8 @@ public class FlatMap extends MapType {
public FlatMap(ConfigurationNode 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"));
Object o = configuration.get("maximumheight");
if (o != null) {
@ -412,6 +415,16 @@ public class FlatMap extends MapType {
public String getName() {
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() {
ArrayList<String> s = new ArrayList<String>();

View File

@ -14,6 +14,7 @@ import org.dynmap.Log;
import org.dynmap.MapManager;
import org.dynmap.MapTile;
import org.dynmap.MapType;
import org.dynmap.kzedmap.MapTileRenderer;
import org.dynmap.utils.MapChunkCache;
import org.json.simple.JSONObject;
@ -130,6 +131,38 @@ public class HDMap extends MapType {
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
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) {
ConfigurationNode c = configuration;

View File

@ -147,7 +147,7 @@ public class HDMapManager {
}
return shaders.toArray(new HDShaderState[shaders.size()]);
}
private static final int BIOMEDATAFLAG = 0;
private static final int HIGHESTZFLAG = 1;
private static final int RAWBIOMEFLAG = 2;

View File

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

View File

@ -5,6 +5,7 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@ -358,6 +359,23 @@ public class KzedMap extends MapType {
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
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) {
for(MapTileRenderer renderer : renderers) {

View File

@ -32,9 +32,9 @@ public class KzedMapTile extends MapTile {
public String getFilename() {
if(fname == null) {
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
fname = renderer.getName() + "_" + px + "_" + py + ".png";
fname = renderer.getPrefix() + "_" + px + "_" + py + ".png";
}
return fname;
}
@ -43,9 +43,9 @@ public class KzedMapTile extends MapTile {
public String getDayFilename() {
if(fname_day == null) {
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
fname_day = renderer.getName() + "_day_" + px + "_" + py + ".png";
fname_day = renderer.getPrefix() + "_day_" + px + "_" + py + ".png";
}
return fname_day;
}
@ -68,7 +68,7 @@ public class KzedMapTile extends MapTile {
}
public String getKey() {
return getWorld().getName() + "." + renderer.getName();
return getWorld().getName() + "." + renderer.getPrefix();
}
public String toString() {

View File

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

View File

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

View File

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

View File

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