diff --git a/src/definition/Scenery.cpp b/src/definition/Scenery.cpp index 1515b9e..7ced63c 100644 --- a/src/definition/Scenery.cpp +++ b/src/definition/Scenery.cpp @@ -182,7 +182,7 @@ void Scenery::getWater(WaterDefinition* water) void Scenery::checkCameraAboveGround() { Vector3 camera_location = camera->getLocation(); - double terrain_height = terrain->getInterpolatedHeight(camera_location.x, camera_location.z, 1, 1) + 2.0; + double terrain_height = terrain->getInterpolatedHeight(camera_location.x, camera_location.z, true, true) + 2.0; double water_height = 1.5; if (camera_location.y < water_height || camera_location.y < terrain_height) { diff --git a/src/definition/TerrainDefinition.cpp b/src/definition/TerrainDefinition.cpp index 8ec30a3..45c5a18 100644 --- a/src/definition/TerrainDefinition.cpp +++ b/src/definition/TerrainDefinition.cpp @@ -82,7 +82,7 @@ void TerrainDefinition::load(PackStream* stream) validate(); } -double TerrainDefinition::getGridHeight(int x, int z, int with_painting) +double TerrainDefinition::getGridHeight(int x, int z, bool with_painting) { double h; @@ -94,7 +94,7 @@ double TerrainDefinition::getGridHeight(int x, int z, int with_painting) return h; } -double TerrainDefinition::getInterpolatedHeight(double x, double z, int scaled, int with_painting) +double TerrainDefinition::getInterpolatedHeight(double x, double z, bool scaled, bool with_painting) { double h; x /= scaling; diff --git a/src/definition/TerrainDefinition.h b/src/definition/TerrainDefinition.h index 560c7f0..c67fac7 100644 --- a/src/definition/TerrainDefinition.h +++ b/src/definition/TerrainDefinition.h @@ -27,8 +27,8 @@ public: virtual void copy(BaseDefinition* destination) const override; virtual void validate() override; - double getGridHeight(int x, int z, int with_painting); - double getInterpolatedHeight(double x, double z, int scaled, int with_painting); + double getGridHeight(int x, int z, bool with_painting); + double getInterpolatedHeight(double x, double z, bool scaled, bool with_painting); unsigned long getMemoryStats(); HeightInfo getHeightInfo(); diff --git a/src/interface/desktop/terrain/paintingbrush.cpp b/src/interface/desktop/terrain/paintingbrush.cpp index a6e8c7c..3ab10df 100644 --- a/src/interface/desktop/terrain/paintingbrush.cpp +++ b/src/interface/desktop/terrain/paintingbrush.cpp @@ -135,7 +135,7 @@ void PaintingBrush::applyToTerrain(TerrainDefinition* terrain, double x, double case PAINTING_BRUSH_FLATTEN: if (reverse) { - _height = terrain->getInterpolatedHeight(x * terrain->scaling, z * terrain->scaling, 0, 1); + _height = terrain->getInterpolatedHeight(x * terrain->scaling, z * terrain->scaling, false, true); } else { diff --git a/src/interface/desktop/terrain/widgetheightmap.cpp b/src/interface/desktop/terrain/widgetheightmap.cpp index 5d26e7f..a115012 100644 --- a/src/interface/desktop/terrain/widgetheightmap.cpp +++ b/src/interface/desktop/terrain/widgetheightmap.cpp @@ -218,7 +218,7 @@ void WidgetHeightMap::timerEvent(QTimerEvent*) _last_time = new_time; // Update top camera - Vector3 target = {_target_x, _terrain->getInterpolatedHeight(_target_x, _target_z, 1, 1), _target_z}; + Vector3 target = {_target_x, _terrain->getInterpolatedHeight(_target_x, _target_z, true, true), _target_z}; _top_camera->setLocationCoords(target.x, target.y + 1.0, target.z + 0.1); _top_camera->setTarget(target); _top_camera->setZoomToTarget(_zoom); diff --git a/src/render/opengl/ExplorerChunkTerrain.cpp b/src/render/opengl/ExplorerChunkTerrain.cpp index 3310814..9e9636f 100644 --- a/src/render/opengl/ExplorerChunkTerrain.cpp +++ b/src/render/opengl/ExplorerChunkTerrain.cpp @@ -85,7 +85,7 @@ bool ExplorerChunkTerrain::maintain() double x = _startx + _tessellation_step * (float)i; double z = _startz + _tessellation_step * (float)j; - double height = _renderer->getTerrainRenderer()->getHeight(x, z, 1); + double height = _renderer->getTerrainRenderer()->getHeight(x, z, true); if (height >= _water_height) { overwater = true; diff --git a/src/render/preview/SceneryTopDownPreviewRenderer.cpp b/src/render/preview/SceneryTopDownPreviewRenderer.cpp index 62199b2..a5b71a6 100644 --- a/src/render/preview/SceneryTopDownPreviewRenderer.cpp +++ b/src/render/preview/SceneryTopDownPreviewRenderer.cpp @@ -46,7 +46,7 @@ void SceneryTopDownPreviewRenderer::updateEvent() Color SceneryTopDownPreviewRenderer::getColor2D(double x, double y, double scaling) { Vector3 location; - double height = getTerrainRenderer()->getHeight(x, y, 1); + double height = getTerrainRenderer()->getHeight(x, y, true); if (height < getWaterRenderer()->getHeightInfo().max_height) { diff --git a/src/render/preview/TerrainShapePreviewRenderer.cpp b/src/render/preview/TerrainShapePreviewRenderer.cpp index f053550..9e5c940 100644 --- a/src/render/preview/TerrainShapePreviewRenderer.cpp +++ b/src/render/preview/TerrainShapePreviewRenderer.cpp @@ -57,7 +57,7 @@ Color TerrainShapePreviewRenderer::getColor2D(double x, double y, double scaling { double height; - height = getTerrainRenderer()->getHeight(x, y, 1); + height = getTerrainRenderer()->getHeight(x, y, true); if (height > 0.0) { return getTerrainRenderer()->getFinalColor(Vector3(x, height, y), 0.000001); diff --git a/src/render/preview/TextureLayerCoveragePreviewRenderer.cpp b/src/render/preview/TextureLayerCoveragePreviewRenderer.cpp index 305a422..217b62b 100644 --- a/src/render/preview/TextureLayerCoveragePreviewRenderer.cpp +++ b/src/render/preview/TextureLayerCoveragePreviewRenderer.cpp @@ -53,7 +53,7 @@ Color TextureLayerCoveragePreviewRenderer::getColor2D(double x, double y, double TexturesRenderer* textures_renderer = getTexturesRenderer(); TerrainRenderer* terrain_renderer = getTerrainRenderer(); - double presence = textures_renderer->getBasePresence(layer, terrain_renderer->getResult(x, y, 1, 0)); + double presence = textures_renderer->getBasePresence(layer, terrain_renderer->getResult(x, y, true, false)); return Color(presence, presence, presence); } diff --git a/src/render/preview/TexturesMixPreviewRenderer.cpp b/src/render/preview/TexturesMixPreviewRenderer.cpp index a030da8..9802c4d 100644 --- a/src/render/preview/TexturesMixPreviewRenderer.cpp +++ b/src/render/preview/TexturesMixPreviewRenderer.cpp @@ -53,6 +53,6 @@ void TexturesMixPreviewRenderer::updateEvent() Color TexturesMixPreviewRenderer::getColor2D(double x, double y, double scaling) { TerrainRenderer* terrain_renderer = getTerrainRenderer(); - Vector3 location(x, terrain_renderer->getHeight(x, y, 1), y); + Vector3 location(x, terrain_renderer->getHeight(x, y, true), y); return terrain_renderer->getFinalColor(location, scaling); } diff --git a/src/render/software/TerrainRasterizer.cpp b/src/render/software/TerrainRasterizer.cpp index 14e7b55..f836dd3 100644 --- a/src/render/software/TerrainRasterizer.cpp +++ b/src/render/software/TerrainRasterizer.cpp @@ -17,7 +17,7 @@ TerrainRasterizer::TerrainRasterizer(SoftwareRenderer* renderer, int client_id): static inline Vector3 _getPoint(SoftwareRenderer* renderer, double x, double z) { - return Vector3(x, renderer->getTerrainRenderer()->getHeight(x, z, 1), z); + return Vector3(x, renderer->getTerrainRenderer()->getHeight(x, z, true), z); } void TerrainRasterizer::tessellateChunk(CanvasPortion* canvas, TerrainChunkInfo* chunk, int detail) @@ -52,19 +52,19 @@ void TerrainRasterizer::renderQuad(CanvasPortion *canvas, double x, double z, do ov1.x = x; ov1.z = z; - dv1 = renderer->getTerrainRenderer()->getResult(x, z, 1, 1).location; + dv1 = renderer->getTerrainRenderer()->getResult(x, z, true, true).location; ov2.x = x; ov2.z = z + size; - dv2 = renderer->getTerrainRenderer()->getResult(x, z + size, 1, 1).location; + dv2 = renderer->getTerrainRenderer()->getResult(x, z + size, true, true).location; ov3.x = x + size; ov3.z = z + size; - dv3 = renderer->getTerrainRenderer()->getResult(x + size, z + size, 1, 1).location; + dv3 = renderer->getTerrainRenderer()->getResult(x + size, z + size, true, true).location; ov4.x = x + size; ov4.z = z; - dv4 = renderer->getTerrainRenderer()->getResult(x + size, z, 1, 1).location; + dv4 = renderer->getTerrainRenderer()->getResult(x + size, z, true, true).location; if (dv1.y > water_height || dv2.y > water_height || dv3.y > water_height || dv4.y > water_height) { @@ -72,12 +72,12 @@ void TerrainRasterizer::renderQuad(CanvasPortion *canvas, double x, double z, do } } -static void _getChunk(SoftwareRenderer* renderer, TerrainRasterizer::TerrainChunkInfo* chunk, double x, double z, double size, int displaced) +static void _getChunk(SoftwareRenderer* renderer, TerrainRasterizer::TerrainChunkInfo* chunk, double x, double z, double size, bool displaced) { - chunk->point_nw = renderer->getTerrainRenderer()->getResult(x, z, 1, displaced).location; - chunk->point_sw = renderer->getTerrainRenderer()->getResult(x, z + size, 1, displaced).location; - chunk->point_se = renderer->getTerrainRenderer()->getResult(x + size, z + size, 1, displaced).location; - chunk->point_ne = renderer->getTerrainRenderer()->getResult(x + size, z, 1, displaced).location; + chunk->point_nw = renderer->getTerrainRenderer()->getResult(x, z, true, displaced).location; + chunk->point_sw = renderer->getTerrainRenderer()->getResult(x, z + size, true, displaced).location; + chunk->point_se = renderer->getTerrainRenderer()->getResult(x + size, z + size, true, displaced).location; + chunk->point_ne = renderer->getTerrainRenderer()->getResult(x + size, z, true, displaced).location; double displacement_power; if (displaced) @@ -125,7 +125,7 @@ static void _getChunk(SoftwareRenderer* renderer, TerrainRasterizer::TerrainChun } } -void TerrainRasterizer::getTessellationInfo(CanvasPortion* canvas, int displaced) +void TerrainRasterizer::getTessellationInfo(CanvasPortion* canvas, bool displaced) { TerrainChunkInfo chunk; int chunk_factor, chunk_count, i; @@ -199,7 +199,7 @@ void TerrainRasterizer::processChunk(CanvasPortion* canvas, TerrainChunkInfo* ch void TerrainRasterizer::rasterizeToCanvas(CanvasPortion *canvas) { - getTessellationInfo(canvas, 0); + getTessellationInfo(canvas, false); } Color TerrainRasterizer::shadeFragment(const CanvasFragment &fragment) const diff --git a/src/render/software/TerrainRasterizer.h b/src/render/software/TerrainRasterizer.h index 379c046..5958355 100644 --- a/src/render/software/TerrainRasterizer.h +++ b/src/render/software/TerrainRasterizer.h @@ -34,7 +34,7 @@ public: * * The terrain will be broken in chunks, most detailed near the camera. */ - void getTessellationInfo(CanvasPortion* canvas, int displaced); + void getTessellationInfo(CanvasPortion* canvas, bool displaced); /** * Tessellate a terrain chunk, pushing the quads in the render area. diff --git a/src/render/software/TerrainRenderer.cpp b/src/render/software/TerrainRenderer.cpp index e3361fd..a087b36 100644 --- a/src/render/software/TerrainRenderer.cpp +++ b/src/render/software/TerrainRenderer.cpp @@ -23,9 +23,9 @@ void TerrainRenderer::update() walker->update(); } -double TerrainRenderer::getHeight(double x, double z, int with_painting) +double TerrainRenderer::getHeight(double x, double z, bool with_painting) { - return parent->getScenery()->getTerrain()->getInterpolatedHeight(x, z, 1, with_painting); + return parent->getScenery()->getTerrain()->getInterpolatedHeight(x, z, true, with_painting); } static inline Vector3 _getNormal4(Vector3 center, Vector3 north, Vector3 east, Vector3 south, Vector3 west) @@ -50,7 +50,7 @@ static inline Vector3 _getNormal2(Vector3 center, Vector3 east, Vector3 south) return south.sub(center).crossProduct(east.sub(center)).normalize(); } -TerrainRenderer::TerrainResult TerrainRenderer::getResult(double x, double z, int with_painting, int with_textures) +TerrainRenderer::TerrainResult TerrainRenderer::getResult(double x, double z, bool with_painting, bool with_textures) { TerrainResult result; double detail = 0.001; /* TODO */ diff --git a/src/render/software/TerrainRenderer.h b/src/render/software/TerrainRenderer.h index fba3301..529e1ed 100644 --- a/src/render/software/TerrainRenderer.h +++ b/src/render/software/TerrainRenderer.h @@ -27,8 +27,8 @@ public: virtual void update(); virtual RayCastingResult castRay(const Vector3 &start, const Vector3 &direction); - virtual double getHeight(double x, double z, int with_painting); - virtual TerrainResult getResult(double x, double z, int with_painting, int with_textures); + virtual double getHeight(double x, double z, bool with_painting); + virtual TerrainResult getResult(double x, double z, bool with_painting, bool with_textures); virtual Color getFinalColor(const Vector3 &location, double precision); virtual bool applyLightFilter(LightComponent &light, const Vector3 &at) override;