From e3a2dc5a1391d8aaaa3fdb83e946838540a07e75 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 14 Sep 2014 01:32:00 +0200 Subject: Added new Qt-based biome visualiser. Compile with Qt 5.1+ --- Tools/QtBiomeVisualiser/ChunkCache.h | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Tools/QtBiomeVisualiser/ChunkCache.h (limited to 'Tools/QtBiomeVisualiser/ChunkCache.h') diff --git a/Tools/QtBiomeVisualiser/ChunkCache.h b/Tools/QtBiomeVisualiser/ChunkCache.h new file mode 100644 index 000000000..0efa7fc39 --- /dev/null +++ b/Tools/QtBiomeVisualiser/ChunkCache.h @@ -0,0 +1,68 @@ +#pragma once + +#include +#include +#include + + + + + +class Chunk; +typedef std::shared_ptr ChunkPtr; + +class ChunkSource; + + + + + +/** Caches chunk data for reuse */ +class ChunkCache : + public QObject +{ + typedef QObject super; + Q_OBJECT + +public: + explicit ChunkCache(QObject * parent = NULL); + + /** Retrieves the specified chunk from the cache. + Only returns valid chunks; if the chunk is invalid, queues it for rendering and returns an empty ptr. */ + ChunkPtr fetch(int a_ChunkX, int a_ChunkZ); + + /** Replaces the chunk source used by the biome view to get the chunk biome data. + The cache is then invalidated. */ + void setChunkSource(std::shared_ptr a_ChunkSource); + + /** Returns true iff the chunk source has been initialized. */ + bool hasData(void) const { return (m_ChunkSource.get() != nullptr); } + +signals: + void chunkAvailable(int a_ChunkX, int a_ChunkZ); + +protected slots: + void gotChunk(int a_ChunkX, int a_ChunkZ); + +protected: + /** The cache of the chunks */ + QCache m_Cache; + + /** Locks te cache against multithreaded access */ + QMutex m_Mtx; + + /** The source used to get the biome data. */ + std::shared_ptr m_ChunkSource; + + + /** Returns the hash used by the chunk in the cache */ + quint32 getChunkHash(int a_ChunkX, int a_ChunkZ); + + /** Queues the specified chunk for rendering by m_ChunkSource. */ + void queueChunkRender(int a_ChunkX, int a_ChunkZ, ChunkPtr & a_Chunk); +}; + + + + + -- cgit v1.2.3 From 21b70f17c264de4f7c216cfca580e8254df5cbee Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 15 Sep 2014 17:29:34 +0200 Subject: QtBiomeVisualiser: Added reloading. --- Tools/QtBiomeVisualiser/ChunkCache.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/ChunkCache.h') diff --git a/Tools/QtBiomeVisualiser/ChunkCache.h b/Tools/QtBiomeVisualiser/ChunkCache.h index 0efa7fc39..0134bc7af 100644 --- a/Tools/QtBiomeVisualiser/ChunkCache.h +++ b/Tools/QtBiomeVisualiser/ChunkCache.h @@ -36,7 +36,10 @@ public: void setChunkSource(std::shared_ptr a_ChunkSource); /** Returns true iff the chunk source has been initialized. */ - bool hasData(void) const { return (m_ChunkSource.get() != nullptr); } + bool hasData() const { return (m_ChunkSource.get() != nullptr); } + + /** Reloads the current chunk source. */ + void reload(); signals: void chunkAvailable(int a_ChunkX, int a_ChunkZ); -- cgit v1.2.3 From 98f4588ed3af39af0554687b84944f12c49e87db Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 18 Sep 2014 10:24:52 +0200 Subject: QtBiomeVisualiser: Fixed linux compilation. --- Tools/QtBiomeVisualiser/ChunkCache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Tools/QtBiomeVisualiser/ChunkCache.h') diff --git a/Tools/QtBiomeVisualiser/ChunkCache.h b/Tools/QtBiomeVisualiser/ChunkCache.h index 0134bc7af..8d198f02f 100644 --- a/Tools/QtBiomeVisualiser/ChunkCache.h +++ b/Tools/QtBiomeVisualiser/ChunkCache.h @@ -3,6 +3,7 @@ #include #include #include +#include -- cgit v1.2.3