diff --git a/src/interface/desktop/formwater.cpp b/src/interface/desktop/formwater.cpp index 1d11cee..c6adefb 100644 --- a/src/interface/desktop/formwater.cpp +++ b/src/interface/desktop/formwater.cpp @@ -63,6 +63,7 @@ FormWater::~FormWater() void FormWater::revertConfig() { + previewCoverageRenderer->setTerrain(DesktopScenery::getCurrent()->getTerrain()); DesktopScenery::getCurrent()->getWater(_definition); BaseForm::revertConfig(); } diff --git a/src/render/preview/WaterAspectPreviewRenderer.cpp b/src/render/preview/WaterAspectPreviewRenderer.cpp index 392ec3c..057afbf 100644 --- a/src/render/preview/WaterAspectPreviewRenderer.cpp +++ b/src/render/preview/WaterAspectPreviewRenderer.cpp @@ -5,36 +5,7 @@ #include "WaterDefinition.h" #include "CameraDefinition.h" #include "WaterRenderer.h" - -/*static double _getWaterHeight(Renderer*) -{ - return 0.0; -} - -static void _getLightingStatus(Renderer* renderer, LightStatus* status, Vector3, int) -{ - LightDefinition light; - bool lighting = *(bool*)renderer->customData[0]; - light.color = COLOR_WHITE; - light.direction.x = 0.0; - light.direction.y = -0.4794; - light.direction.z = -0.8776; - light.altered = 0; - if (lighting) - { - light.reflection = 1.0; - } - else - { - light.reflection = 0.0; - } - lightingPushLight(status, &light); -} - -static double _getPrecision(Renderer*, Vector3) -{ - return 0.000001; -}*/ +#include "LightComponent.h" WaterAspectPreviewRenderer::WaterAspectPreviewRenderer(WaterDefinition* definition): definition(definition) @@ -64,9 +35,23 @@ void WaterAspectPreviewRenderer::updateEvent() getScenery()->getCamera()->setTarget(VECTOR_ZERO); prepare(); - //terrain->getWaterHeight = _getWaterHeight; - //atmosphere->getLightingStatus = _getLightingStatus; - //getPrecision = _getPrecision; + LightComponent light; + std::vector lights; + light.color = COLOR_WHITE; + light.direction.x = 0.0; + light.direction.y = -0.4794; + light.direction.z = -0.8776; + light.altered = 0; + if (lighting) + { + light.reflection = 1.0; + } + else + { + light.reflection = 0.0; + } + lights.push_back(light); + disableAtmosphere(lights); } void WaterAspectPreviewRenderer::cameraEvent(double, double, double scaling) @@ -116,6 +101,11 @@ void WaterAspectPreviewRenderer::choiceChangeEvent(const std::string &key, int p } } +double WaterAspectPreviewRenderer::getPrecision(const Vector3 &location) +{ + return 0.000001; +} + RayCastingResult WaterAspectPreviewRenderer::rayWalking(const Vector3 &location, const Vector3 &direction, int, int, int, int) { RayCastingResult result; diff --git a/src/render/preview/WaterAspectPreviewRenderer.h b/src/render/preview/WaterAspectPreviewRenderer.h index 8afeaf8..2a9d569 100644 --- a/src/render/preview/WaterAspectPreviewRenderer.h +++ b/src/render/preview/WaterAspectPreviewRenderer.h @@ -21,6 +21,7 @@ public: virtual void toggleChangeEvent(const std::string &key, bool value) override; virtual void choiceChangeEvent(const std::string &key, int position) override; + virtual double getPrecision(const Vector3 &location) override; virtual RayCastingResult rayWalking(const Vector3 &location, const Vector3 &direction, int terrain, int water, int sky, int clouds) override; private: diff --git a/src/render/preview/WaterCoveragePreviewRenderer.cpp b/src/render/preview/WaterCoveragePreviewRenderer.cpp index 5865610..0f37815 100644 --- a/src/render/preview/WaterCoveragePreviewRenderer.cpp +++ b/src/render/preview/WaterCoveragePreviewRenderer.cpp @@ -16,6 +16,12 @@ WaterCoveragePreviewRenderer::~WaterCoveragePreviewRenderer() delete TerrainShapePreviewRenderer::_terrain; } +void WaterCoveragePreviewRenderer::setTerrain(TerrainDefinition *terrain) +{ + terrain->copy(TerrainShapePreviewRenderer::_terrain); + getScenery()->setTerrain(terrain); +} + void WaterCoveragePreviewRenderer::bindEvent(BasePreview* preview) { TerrainShapePreviewRenderer::bindEvent(preview); @@ -36,10 +42,9 @@ void WaterCoveragePreviewRenderer::toggleChangeEvent(const std::string &key, boo void WaterCoveragePreviewRenderer::updateEvent() { - //RenderingScenery::getCurrent()->getTerrain(_terrain); - TerrainShapePreviewRenderer::updateEvent(); - getScenery()->setWater(definition); + + TerrainShapePreviewRenderer::updateEvent(); } Color WaterCoveragePreviewRenderer::getWaterColor(double x, double y, double) diff --git a/src/render/preview/WaterCoveragePreviewRenderer.h b/src/render/preview/WaterCoveragePreviewRenderer.h index 1ce8725..a472843 100644 --- a/src/render/preview/WaterCoveragePreviewRenderer.h +++ b/src/render/preview/WaterCoveragePreviewRenderer.h @@ -14,6 +14,8 @@ public: WaterCoveragePreviewRenderer(WaterDefinition* definition); virtual ~WaterCoveragePreviewRenderer(); + void setTerrain(TerrainDefinition* terrain); + virtual void bindEvent(BasePreview* preview) override; virtual void updateEvent() override;