BiomeVisualiser: The biome settings are read from a file.
This commit is contained in:
parent
13dade5a83
commit
8acf0129e1
@ -258,6 +258,11 @@ void cBiomeCache::FilterOutItems(cItems & a_Items, int a_MinChunkX, int a_MaxChu
|
|||||||
|
|
||||||
void cBiomeCache::thrProcessQueueItem(void)
|
void cBiomeCache::thrProcessQueueItem(void)
|
||||||
{
|
{
|
||||||
|
if (m_Source == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cItem * Item = NULL;
|
cItem * Item = NULL;
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CS);
|
cCSLock Lock(m_CS);
|
||||||
|
@ -34,6 +34,8 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
|
|||||||
{
|
{
|
||||||
ASSERT(m_Wnd == NULL);
|
ASSERT(m_Wnd == NULL);
|
||||||
|
|
||||||
|
InitBiomeView();
|
||||||
|
|
||||||
// Create a regular STATIC window, then override its window procedure with our own. No need for obnoxious RegisterWindowClass() stuff.
|
// Create a regular STATIC window, then override its window procedure with our own. No need for obnoxious RegisterWindowClass() stuff.
|
||||||
m_Wnd = CreateWindow("STATIC", a_Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 400, 300, a_ParentWnd, NULL, GetModuleHandle(NULL), NULL);
|
m_Wnd = CreateWindow("STATIC", a_Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 400, 300, a_ParentWnd, NULL, GetModuleHandle(NULL), NULL);
|
||||||
if (m_Wnd == NULL)
|
if (m_Wnd == NULL)
|
||||||
@ -43,11 +45,6 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
|
|||||||
}
|
}
|
||||||
SetWindowLongPtr(m_Wnd, GWLP_WNDPROC, m_Thunk);
|
SetWindowLongPtr(m_Wnd, GWLP_WNDPROC, m_Thunk);
|
||||||
|
|
||||||
cIniFile IniFile;
|
|
||||||
cBiomeGen * BioGen = new cBioGenMultiStepMap(2);
|
|
||||||
BioGen->InitializeBiomeGen(IniFile);
|
|
||||||
m_Renderer.SetSource(new cGeneratorBiomeSource(BioGen));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +52,82 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cBiomeViewWnd::InitBiomeView(void)
|
||||||
|
{
|
||||||
|
cIniFile IniFile;
|
||||||
|
IniFile.ReadFile("world.ini");
|
||||||
|
AString BiomeGenName = IniFile.GetValueSet("Generator", "BiomeGen", "");
|
||||||
|
if (BiomeGenName.empty())
|
||||||
|
{
|
||||||
|
LOGWARN("[Generator] BiomeGen value not set in world.ini, using \"MultiStepMap\".");
|
||||||
|
BiomeGenName = "MultiStepMap";
|
||||||
|
}
|
||||||
|
|
||||||
|
int Seed = IniFile.GetValueSetI("Generator", "Seed", 0);
|
||||||
|
|
||||||
|
bool CacheOffByDefault = false;
|
||||||
|
if (NoCaseCompare(BiomeGenName, "constant") == 0)
|
||||||
|
{
|
||||||
|
m_BiomeGen = new cBioGenConstant;
|
||||||
|
CacheOffByDefault = true; // we're generating faster than a cache would retrieve data :)
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(BiomeGenName, "checkerboard") == 0)
|
||||||
|
{
|
||||||
|
m_BiomeGen = new cBioGenCheckerboard;
|
||||||
|
CacheOffByDefault = true; // we're (probably) generating faster than a cache would retrieve data
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(BiomeGenName, "voronoi") == 0)
|
||||||
|
{
|
||||||
|
m_BiomeGen = new cBioGenVoronoi(Seed);
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(BiomeGenName, "distortedvoronoi") == 0)
|
||||||
|
{
|
||||||
|
m_BiomeGen = new cBioGenDistortedVoronoi(Seed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (NoCaseCompare(BiomeGenName, "multistepmap") != 0)
|
||||||
|
{
|
||||||
|
LOGWARNING("Unknown BiomeGen \"%s\", using \"MultiStepMap\" instead.", BiomeGenName.c_str());
|
||||||
|
}
|
||||||
|
m_BiomeGen = new cBioGenMultiStepMap(Seed);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Performance-testing:
|
||||||
|
LOGINFO("Measuring performance of cBioGenMultiStepMap...");
|
||||||
|
clock_t BeginTick = clock();
|
||||||
|
for (int x = 0; x < 5000; x++)
|
||||||
|
{
|
||||||
|
cChunkDef::BiomeMap Biomes;
|
||||||
|
m_BiomeGen->GenBiomes(x * 5, x * 5, Biomes);
|
||||||
|
}
|
||||||
|
clock_t Duration = clock() - BeginTick;
|
||||||
|
LOGINFO("cBioGenMultiStepMap for 5000 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
|
||||||
|
//*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a cache, if requested:
|
||||||
|
int CacheSize = IniFile.GetValueSetI("Generator", "BiomeGenCacheSize", CacheOffByDefault ? 0 : 64);
|
||||||
|
if (CacheSize > 0)
|
||||||
|
{
|
||||||
|
if (CacheSize < 4)
|
||||||
|
{
|
||||||
|
LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
|
||||||
|
CacheSize, 4
|
||||||
|
);
|
||||||
|
CacheSize = 4;
|
||||||
|
}
|
||||||
|
LOGD("Using a cache for biomegen of size %d.", CacheSize);
|
||||||
|
m_BiomeGen = new cBioGenCache(m_BiomeGen, CacheSize);
|
||||||
|
}
|
||||||
|
m_BiomeGen->InitializeBiomeGen(IniFile);
|
||||||
|
m_Renderer.SetSource(new cGeneratorBiomeSource(m_BiomeGen));
|
||||||
|
IniFile.WriteFile("world.ini");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam)
|
LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,12 @@
|
|||||||
|
|
||||||
// Declares the cBiomeViewWnd class representing the window that displays biomes
|
// Declares the cBiomeViewWnd class representing the window that displays biomes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "WndProcThunk.h"
|
#include "WndProcThunk.h"
|
||||||
#include "BiomeRenderer.h"
|
#include "BiomeRenderer.h"
|
||||||
#include "BiomeCache.h"
|
#include "BiomeCache.h"
|
||||||
@ -12,6 +18,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// fwd:
|
||||||
|
class cBiomeGen;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cBiomeViewWnd
|
class cBiomeViewWnd
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -26,9 +39,15 @@ protected:
|
|||||||
cBiomeRenderer m_Renderer;
|
cBiomeRenderer m_Renderer;
|
||||||
cPixmap m_Pixmap;
|
cPixmap m_Pixmap;
|
||||||
|
|
||||||
|
/// The generator that is to be visualised
|
||||||
|
cBiomeGen * m_BiomeGen;
|
||||||
|
|
||||||
bool m_IsLButtonDown;
|
bool m_IsLButtonDown;
|
||||||
POINT m_MouseDown;
|
POINT m_MouseDown;
|
||||||
|
|
||||||
|
|
||||||
|
void InitBiomeView(void);
|
||||||
|
|
||||||
LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam);
|
LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
// Message handlers:
|
// Message handlers:
|
||||||
|
Loading…
Reference in New Issue
Block a user