param2 coloring cleanup
This commit is contained in:
parent
2b706f0fe7
commit
5a7c8d602d
@ -14,7 +14,6 @@ import (
|
||||
"mapserver/settings"
|
||||
"mapserver/tiledb"
|
||||
"mapserver/tilerenderer"
|
||||
"mapserver/vfs"
|
||||
"mapserver/worldconfig"
|
||||
"time"
|
||||
|
||||
@ -106,14 +105,8 @@ func Setup(p params.ParamsType, cfg *Config) *App {
|
||||
|
||||
}
|
||||
|
||||
fullpalette, err := colormapping.NewPalette(vfs.FSMustByte(false, "/pics/unifieddyes_palette_extended.png"))
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//mapblock renderer
|
||||
a.Mapblockrenderer = mapblockrenderer.NewMapBlockRenderer(a.BlockAccessor, a.Colormapping, fullpalette)
|
||||
a.Mapblockrenderer = mapblockrenderer.NewMapBlockRenderer(a.BlockAccessor, a.Colormapping)
|
||||
|
||||
//mapserver database
|
||||
if a.Worldconfig[worldconfig.CONFIG_PSQL_MAPSERVER] != "" {
|
||||
|
@ -13,10 +13,17 @@ import (
|
||||
)
|
||||
|
||||
type ColorMapping struct {
|
||||
colors map[string]*color.RGBA
|
||||
colors map[string]*color.RGBA
|
||||
extendedpalette *Palette
|
||||
}
|
||||
|
||||
func (m *ColorMapping) GetColor(name string) *color.RGBA {
|
||||
func (m *ColorMapping) GetColor(name string, param2 int) *color.RGBA {
|
||||
//TODO: list of node->palette
|
||||
if name == "unifiedbricks:brickblock" {
|
||||
// param2 coloring
|
||||
return m.extendedpalette.GetColor(param2)
|
||||
}
|
||||
|
||||
return m.colors[name]
|
||||
}
|
||||
|
||||
@ -95,5 +102,14 @@ func (m *ColorMapping) LoadVFSColors(useLocal bool, filename string) (int, error
|
||||
}
|
||||
|
||||
func NewColorMapping() *ColorMapping {
|
||||
return &ColorMapping{colors: make(map[string]*color.RGBA)}
|
||||
extendedpalette, err := NewPalette(vfs.FSMustByte(false, "/pics/unifieddyes_palette_extended.png"))
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &ColorMapping{
|
||||
colors: make(map[string]*color.RGBA),
|
||||
extendedpalette: extendedpalette,
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ func TestNewMapping(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
c := m.GetColor("scifi_nodes:blacktile2")
|
||||
c := m.GetColor("scifi_nodes:blacktile2", 0)
|
||||
if c == nil {
|
||||
panic("no color")
|
||||
}
|
||||
|
||||
c = m.GetColor("default:river_water_flowing")
|
||||
c = m.GetColor("default:river_water_flowing", 0)
|
||||
if c == nil {
|
||||
panic("no color")
|
||||
}
|
||||
|
@ -17,16 +17,14 @@ import (
|
||||
type MapBlockRenderer struct {
|
||||
accessor *mapblockaccessor.MapBlockAccessor
|
||||
colors *colormapping.ColorMapping
|
||||
fullpalette *colormapping.Palette
|
||||
enableShadow bool
|
||||
enableTransparency bool
|
||||
}
|
||||
|
||||
func NewMapBlockRenderer(accessor *mapblockaccessor.MapBlockAccessor, colors *colormapping.ColorMapping, fullpalette *colormapping.Palette) *MapBlockRenderer {
|
||||
func NewMapBlockRenderer(accessor *mapblockaccessor.MapBlockAccessor, colors *colormapping.ColorMapping) *MapBlockRenderer {
|
||||
return &MapBlockRenderer{
|
||||
accessor: accessor,
|
||||
colors: colors,
|
||||
fullpalette: fullpalette,
|
||||
enableShadow: true,
|
||||
enableTransparency: false,
|
||||
}
|
||||
@ -132,18 +130,13 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *coords.MapBlockCoords) (*image.NRG
|
||||
}
|
||||
|
||||
nodeName := mb.GetNodeName(x, y, z)
|
||||
param2 := mb.GetParam2(x, y, z)
|
||||
|
||||
if nodeName == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
c := r.colors.GetColor(nodeName)
|
||||
hasfullpalette := nodeName == "unifiedbricks:brickblock"
|
||||
|
||||
if hasfullpalette && r.fullpalette != nil {
|
||||
param2 := mb.GetParam2(x, y, z)
|
||||
c = r.fullpalette.GetColor(param2)
|
||||
}
|
||||
c := r.colors.GetColor(nodeName, param2)
|
||||
|
||||
if c == nil {
|
||||
continue
|
||||
|
@ -52,18 +52,7 @@ func TestSimpleRender(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
palettedata, err := ioutil.ReadFile("./testdata/unifieddyes_palette_extended.png")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
palette, err := colormapping.NewPalette(palettedata)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
r := NewMapBlockRenderer(cache, c, palette)
|
||||
r := NewMapBlockRenderer(cache, c)
|
||||
os.Mkdir("../test-output", 0755)
|
||||
|
||||
results := make(chan JobResult, 100)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 290 B |
@ -46,7 +46,7 @@ func TestTileRender(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
r := mapblockrenderer.NewMapBlockRenderer(cache, c, nil)
|
||||
r := mapblockrenderer.NewMapBlockRenderer(cache, c)
|
||||
|
||||
tiletmpdir, err := ioutil.TempDir("", "TestTileRenderTiles.*.sqlite")
|
||||
defer os.RemoveAll(tiletmpdir)
|
||||
|
Loading…
Reference in New Issue
Block a user