Changed some old int-bools to true booleans

This commit is contained in:
Michaël Lemaire 2014-11-21 09:45:19 +01:00
parent 1cc3a4d625
commit f7715b612e
14 changed files with 30 additions and 30 deletions

View file

@ -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)
{

View file

@ -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;

View file

@ -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();

View file

@ -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
{

View file

@ -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);

View file

@ -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;

View file

@ -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)
{

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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

View file

@ -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.

View file

@ -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 */

View file

@ -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;