Added ground texture resetting while changing time of day
This commit is contained in:
parent
e84698dbb3
commit
fc15f7d9b8
6 changed files with 38 additions and 14 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "AtmosphereDefinition.h"
|
||||
#include "OpenGLRenderer.h"
|
||||
#include "OpenGLSkybox.h"
|
||||
#include "OpenGLTerrain.h"
|
||||
|
||||
AtmosphereModeler::AtmosphereModeler(MainModelerWindow *main):
|
||||
main(main)
|
||||
|
@ -23,4 +24,7 @@ void AtmosphereModeler::daytimeChanged(double value)
|
|||
main->getRenderer()->getScenery()->setAtmosphere(main->getScenery()->getAtmosphere());
|
||||
|
||||
main->getRenderer()->getSkybox()->update();
|
||||
|
||||
// Update terrain textures according to new lighting
|
||||
main->getRenderer()->getTerrain()->resetTextures();
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
|||
{
|
||||
render_process->stopRender();
|
||||
|
||||
rootObject()->setProperty("state", QString("Init"));
|
||||
setState("Init");
|
||||
}
|
||||
else if (event->key() == Qt::Key_Q)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,8 @@ ExplorerChunkTerrain::ExplorerChunkTerrain(OpenGLRenderer* renderer, double x, d
|
|||
_renderer(renderer)
|
||||
{
|
||||
priority = 0.0;
|
||||
_reset_needed = false;
|
||||
_reset_topology = false;
|
||||
_reset_texture = false;
|
||||
|
||||
interrupt = false;
|
||||
|
||||
|
@ -58,13 +59,17 @@ bool ExplorerChunkTerrain::maintain()
|
|||
bool subchanged;
|
||||
|
||||
_lock_data.lock();
|
||||
if (_reset_needed)
|
||||
if (_reset_topology)
|
||||
{
|
||||
_reset_needed = false;
|
||||
_texture_current_size = 0;
|
||||
_reset_topology = false;
|
||||
_tessellation_current_size = 0;
|
||||
overwater = false;
|
||||
}
|
||||
if (_reset_texture)
|
||||
{
|
||||
_reset_texture = false;
|
||||
_texture_current_size = 0;
|
||||
}
|
||||
_lock_data.unlock();
|
||||
|
||||
// Improve heightmap resolution
|
||||
|
@ -103,7 +108,7 @@ bool ExplorerChunkTerrain::maintain()
|
|||
tessellated->setGridVertex(tessellation_count, i, j, v);
|
||||
}
|
||||
}
|
||||
if (interrupt or _reset_needed)
|
||||
if (interrupt or _reset_topology)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -143,7 +148,7 @@ bool ExplorerChunkTerrain::maintain()
|
|||
}
|
||||
}
|
||||
|
||||
if (interrupt or _reset_needed)
|
||||
if (interrupt or _reset_texture)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -216,7 +221,7 @@ void ExplorerChunkTerrain::updatePriority(CameraDefinition* camera)
|
|||
}
|
||||
|
||||
// Update priority
|
||||
if (_reset_needed || (_texture_max_size > 1 && _texture_current_size <= 1))
|
||||
if (_reset_topology || _reset_texture || (_texture_max_size > 1 && _texture_current_size <= 1))
|
||||
{
|
||||
priority = 1000.0;
|
||||
}
|
||||
|
@ -259,7 +264,7 @@ void ExplorerChunkTerrain::render(QOpenGLShaderProgram* program, OpenGLFunctions
|
|||
_lock_data.unlock();
|
||||
|
||||
// Render tessellated mesh
|
||||
if (!_reset_needed)
|
||||
if (!_reset_topology)
|
||||
{
|
||||
_lock_data.lock();
|
||||
int tessellation_size = _tessellation_current_size;
|
||||
|
@ -280,9 +285,10 @@ void ExplorerChunkTerrain::render(QOpenGLShaderProgram* program, OpenGLFunctions
|
|||
}
|
||||
}
|
||||
|
||||
void ExplorerChunkTerrain::askReset()
|
||||
void ExplorerChunkTerrain::askReset(bool topology, bool texture)
|
||||
{
|
||||
_reset_needed = true;
|
||||
_reset_topology = _reset_topology or topology;
|
||||
_reset_texture = _reset_texture or texture;
|
||||
}
|
||||
|
||||
void ExplorerChunkTerrain::askInterrupt()
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
void updatePriority(CameraDefinition* camera);
|
||||
void render(QOpenGLShaderProgram* program, OpenGLFunctions* functions);
|
||||
|
||||
void askReset();
|
||||
void askReset(bool topology = true, bool texture = true);
|
||||
void askInterrupt();
|
||||
|
||||
Color getTextureColor(double x, double y);
|
||||
|
@ -54,7 +54,8 @@ private:
|
|||
|
||||
OpenGLRenderer* _renderer;
|
||||
|
||||
bool _reset_needed;
|
||||
bool _reset_topology;
|
||||
bool _reset_texture;
|
||||
bool interrupt;
|
||||
|
||||
QImage* _texture;
|
||||
|
|
|
@ -95,12 +95,20 @@ void OpenGLTerrain::render()
|
|||
|
||||
void OpenGLTerrain::interrupt()
|
||||
{
|
||||
for (auto chunk: _chunks)
|
||||
for (auto &chunk: _chunks)
|
||||
{
|
||||
chunk->askInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLTerrain::resetTextures()
|
||||
{
|
||||
for (auto &chunk: _chunks)
|
||||
{
|
||||
chunk->askReset(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
static bool _cmpChunks(const ExplorerChunkTerrain* c1, const ExplorerChunkTerrain* c2)
|
||||
{
|
||||
return c1->priority > c2->priority;
|
||||
|
|
|
@ -23,6 +23,11 @@ public:
|
|||
virtual void render() override;
|
||||
virtual void interrupt() override;
|
||||
|
||||
/**
|
||||
* Reset the color textures, without changing the tessellation.
|
||||
*/
|
||||
void resetTextures();
|
||||
|
||||
void performChunksMaintenance();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue