diff --git a/src/basics/Color.h b/src/basics/Color.h index a6a1ba4..5dd8aaa 100644 --- a/src/basics/Color.h +++ b/src/basics/Color.h @@ -59,71 +59,4 @@ BASICSSHARED_EXPORT extern const Color COLOR_GREY; #endif #endif -// Compat API - -static inline void colorSave(PackStream* stream, Color* col) -{ - col->save(stream); -} -static inline void colorLoad(PackStream* stream, Color* col) -{ - col->load(stream); -} -static inline Color colorFromValues(double r, double g, double b, double a) -{ - return Color(r, g, b, a); -} -static inline unsigned int colorTo32BitRGBA(Color* col) -{ - return col->to32BitRGBA(); -} -static inline unsigned int colorTo32BitBGRA(Color* col) -{ - return col->to32BitBGRA(); -} -static inline unsigned int colorTo32BitARGB(Color* col) -{ - return col->to32BitARGB(); -} -static inline unsigned int colorTo32BitABGR(Color* col) -{ - return col->to32BitABGR(); -} -static inline Color colorFrom32BitRGBA(unsigned int col) -{ - return Color::from32BitRGBA(col); -} -static inline Color colorFrom32BitBGRA(unsigned int col) -{ - return Color::from32BitBGRA(col); -} -static inline Color colorFrom32BitARGB(unsigned int col) -{ - return Color::from32BitARGB(col); -} -static inline Color colorFrom32BitABGR(unsigned int col) -{ - return Color::from32BitABGR(col); -} -static inline void colorMask(Color* base, Color* mask) -{ - base->mask(*mask); -} -static inline double colorNormalize(Color* col) -{ - return col->normalize(); -} -static inline double colorGetValue(Color* col) -{ - return col->getValue(); -} -static inline double colorGetPower(Color* col) -{ - return col->getPower(); -} -static inline void colorLimitPower(Color* col, double max_power) -{ - col->limitPower(max_power); -} - #endif // COLOR_H diff --git a/src/basics/Texture2D.cpp b/src/basics/Texture2D.cpp index 3c20307..5950490 100644 --- a/src/basics/Texture2D.cpp +++ b/src/basics/Texture2D.cpp @@ -130,7 +130,7 @@ void Texture2D::save(PackStream* stream) n = this->xsize * this->ysize; for (i = 0; i < n; i++) { - colorSave(stream, this->data + i); + (this->data + i)->save(stream); } } @@ -144,7 +144,7 @@ void Texture2D::load(PackStream* stream) this->data = new Color[n]; for (i = 0; i < n; i++) { - colorLoad(stream, this->data + i); + (this->data + i)->load(stream); } } diff --git a/src/basics/Texture3D.cpp b/src/basics/Texture3D.cpp index fd5c54d..bca20a7 100644 --- a/src/basics/Texture3D.cpp +++ b/src/basics/Texture3D.cpp @@ -155,7 +155,7 @@ void Texture3D::save(PackStream* stream) n = this->xsize * this->ysize * this->zsize; for (i = 0; i < n; i++) { - colorSave(stream, this->data + i); + (this->data + i)->save(stream); } } @@ -170,7 +170,7 @@ void Texture3D::load(PackStream* stream) this->data = new Color[n]; for (i = 0; i < n; i++) { - colorLoad(stream, this->data + i); + (this->data + i)->load(stream); } } diff --git a/src/basics/Texture4D.cpp b/src/basics/Texture4D.cpp index b8fd9ad..8700ecd 100644 --- a/src/basics/Texture4D.cpp +++ b/src/basics/Texture4D.cpp @@ -188,7 +188,7 @@ void Texture4D::save(PackStream* stream) n = this->xsize * this->ysize * this->zsize * this->wsize; for (i = 0; i < n; i++) { - colorSave(stream, this->data + i); + (this->data + i)->save(stream); } } @@ -204,7 +204,7 @@ void Texture4D::load(PackStream* stream) this->data = new Color[n]; for (i = 0; i < n; i++) { - colorLoad(stream, this->data + i); + (this->data + i)->load(stream); } } diff --git a/src/definition/TextureLayerDefinition.cpp b/src/definition/TextureLayerDefinition.cpp index 689dfe9..70ae38f 100644 --- a/src/definition/TextureLayerDefinition.cpp +++ b/src/definition/TextureLayerDefinition.cpp @@ -113,7 +113,7 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset) displacement_height = 0.05; displacement_scaling = 3.0; displacement_offset = 0.0; - material->base = colorToHSL(colorFromValues(0.4, 0.38, 0.35, 1.0)); + material->base = colorToHSL(Color(0.4, 0.38, 0.35, 1.0)); material->reflection = 0.003; material->shininess = 4.0; break; @@ -122,7 +122,7 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset) displacement_height = 0.3; displacement_scaling = 2.0; displacement_offset = 0.0; - material->base = colorToHSL(colorFromValues(0.6, 0.55, 0.57, 1.0)); + material->base = colorToHSL(Color(0.6, 0.55, 0.57, 1.0)); material->reflection = 0.006; material->shininess = 6.0; break; @@ -132,7 +132,7 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset) displacement_height = 0.0; displacement_scaling = 1.0; displacement_offset = 0.0; - material->base = colorToHSL(colorFromValues(0.12, 0.19, 0.035, 1.0)); + material->base = colorToHSL(Color(0.12, 0.19, 0.035, 1.0)); material->reflection = 0.001; material->shininess = 4.0; break; @@ -142,7 +142,7 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset) displacement_height = 0.02; displacement_scaling = 5.0; displacement_offset = 0.0; - material->base = colorToHSL(colorFromValues(0.93, 0.9, 0.8, 1.0)); + material->base = colorToHSL(Color(0.93, 0.9, 0.8, 1.0)); material->reflection = 0.008; material->shininess = 1.0; break; @@ -152,7 +152,7 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset) displacement_height = 0.1; displacement_scaling = 1.0; displacement_offset = 0.0; - material->base = colorToHSL(colorFromValues(1.0, 1.0, 1.0, 1.0)); + material->base = colorToHSL(Color(1.0, 1.0, 1.0, 1.0)); material->reflection = 0.25; material->shininess = 0.6; break; diff --git a/src/definition/WaterDefinition.cpp b/src/definition/WaterDefinition.cpp index 25f3e43..c0121d1 100644 --- a/src/definition/WaterDefinition.cpp +++ b/src/definition/WaterDefinition.cpp @@ -37,7 +37,7 @@ void WaterDefinition::save(PackStream* stream) const BaseDefinition::save(stream); materialSave(stream, material); - colorSave(stream, depth_color); + depth_color->save(stream); stream->write(&transparency_depth); stream->write(&transparency); stream->write(&reflection); @@ -59,7 +59,7 @@ void WaterDefinition::load(PackStream* stream) BaseDefinition::load(stream); materialLoad(stream, material); - colorLoad(stream, depth_color); + depth_color->load(stream); stream->read(&transparency_depth); stream->read(&transparency); stream->read(&reflection); @@ -129,7 +129,7 @@ void WaterDefinition::applyPreset(WaterPreset preset) transparency = 0.5; reflection = 0.4; transparency_depth = 4.0; - material->base = colorToHSL(colorFromValues(0.08, 0.15, 0.2, 1.0)); + material->base = colorToHSL(Color(0.08, 0.15, 0.2, 1.0)); depth_color->r = 0.0; depth_color->g = 0.1; depth_color->b = 0.1; @@ -145,7 +145,7 @@ void WaterDefinition::applyPreset(WaterPreset preset) transparency = 0.4; reflection = 0.35; transparency_depth = 3.0; - material->base = colorToHSL(colorFromValues(0.05, 0.18, 0.2, 1.0)); + material->base = colorToHSL(Color(0.05, 0.18, 0.2, 1.0)); depth_color->r = 0.0; depth_color->g = 0.18; depth_color->b = 0.15; @@ -161,7 +161,7 @@ void WaterDefinition::applyPreset(WaterPreset preset) material->base.a = 1.0; material->reflection = 1.0; material->shininess = 16.0; - foam_material->base = colorToHSL(colorFromValues(0.8, 0.8, 0.8, 1.0)); + foam_material->base = colorToHSL(Color(0.8, 0.8, 0.8, 1.0)); foam_material->reflection = 0.1; foam_material->shininess = 1.5; diff --git a/src/interface/desktop/tools.h b/src/interface/desktop/tools.h index 006e721..147e95c 100644 --- a/src/interface/desktop/tools.h +++ b/src/interface/desktop/tools.h @@ -9,7 +9,7 @@ static inline QColor colorToQColor(Color color) { - colorNormalize(&color); + color.normalize(); return QColor(color.r * 255.0, color.g * 255.0, color.b * 255.0, color.a * 255.0); } diff --git a/src/render/opengl/BaseExplorerChunk.cpp b/src/render/opengl/BaseExplorerChunk.cpp index e2cf009..82f7322 100644 --- a/src/render/opengl/BaseExplorerChunk.cpp +++ b/src/render/opengl/BaseExplorerChunk.cpp @@ -59,8 +59,8 @@ bool BaseExplorerChunk::maintain() { Color color = getTextureColor((double)i / (double)new_texture_size, 1.0 - (double)j / (double)new_texture_size); color = _color_profile->apply(color); - colorNormalize(&color); - new_image->setPixel(i, j, colorTo32BitBGRA(&color)); + color.normalize(); + new_image->setPixel(i, j, color.to32BitBGRA()); } } } diff --git a/src/render/preview/WaterCoveragePreviewRenderer.cpp b/src/render/preview/WaterCoveragePreviewRenderer.cpp index 1275219..5865610 100644 --- a/src/render/preview/WaterCoveragePreviewRenderer.cpp +++ b/src/render/preview/WaterCoveragePreviewRenderer.cpp @@ -51,7 +51,7 @@ Color WaterCoveragePreviewRenderer::getWaterColor(double x, double y, double) if (highlight) { Color mask = {0.5, 0.5, 1.0, 0.5}; - colorMask(&base, &mask); + base.mask(mask); } return base; diff --git a/src/render/software/AtmosphereRenderer.cpp b/src/render/software/AtmosphereRenderer.cpp index 1b12220..a637ad6 100644 --- a/src/render/software/AtmosphereRenderer.cpp +++ b/src/render/software/AtmosphereRenderer.cpp @@ -48,7 +48,7 @@ static inline void _applyWeatherEffects(AtmosphereDefinition* definition, Atmosp { /* Limit scattering on ultra clear day */ double force = (0.15 - definition->humidity) / 0.15; - colorLimitPower(&result->inscattering, 100.0 - 90.0 * pow(force, 0.1)); + result->inscattering.limitPower(100.0 - 90.0 * pow(force, 0.1)); } else { diff --git a/src/render/software/AtmosphereResult.cpp b/src/render/software/AtmosphereResult.cpp index a038493..a6c6be2 100644 --- a/src/render/software/AtmosphereResult.cpp +++ b/src/render/software/AtmosphereResult.cpp @@ -17,5 +17,5 @@ void AtmosphereResult::updateFinal() final.b = base.b * attenuation.b + inscattering.b; final.a = 1.0; - colorMask(&final, &mask); + final.mask(mask); } diff --git a/src/render/software/CloudBasicLayerRenderer.cpp b/src/render/software/CloudBasicLayerRenderer.cpp index fdf751d..bf8b505 100644 --- a/src/render/software/CloudBasicLayerRenderer.cpp +++ b/src/render/software/CloudBasicLayerRenderer.cpp @@ -176,7 +176,7 @@ Color CloudBasicLayerRenderer::getColor(BaseCloudsModel *model, const Vector3 &e col = parent->applyLightingToSurface(segments[i].start, parent->getAtmosphereRenderer()->getSunDirection(), material); col.a = (segments[i].length >= transparency_depth) ? 1.0 : (segments[i].length / transparency_depth); - colorMask(&result, &col); + result.mask(col); } if (inside_length >= transparency_depth) { diff --git a/src/render/software/CloudsRenderer.cpp b/src/render/software/CloudsRenderer.cpp index e88eb17..9e13d67 100644 --- a/src/render/software/CloudsRenderer.cpp +++ b/src/render/software/CloudsRenderer.cpp @@ -126,7 +126,7 @@ Color CloudsRenderer::getColor(const Vector3 &eye, const Vector3 &location, cons Color layer_color = layer_renderer->getColor(layer_model, eye, location); - colorMask(&cumul, &layer_color); + cumul.mask(layer_color); } return cumul; diff --git a/src/render/software/TexturesRenderer.cpp b/src/render/software/TexturesRenderer.cpp index e0c3a7b..ac3f6a0 100644 --- a/src/render/software/TexturesRenderer.cpp +++ b/src/render/software/TexturesRenderer.cpp @@ -205,7 +205,7 @@ TexturesRenderer::TexturesResult TexturesRenderer::applyToTerrain(double x, doub if (result.layers[i].presence > 0.0) { result.layers[i].color.a = result.layers[i].presence; - colorMask(&result.final_color, &result.layers[i].color); + result.final_color.mask(result.layers[i].color); } } diff --git a/src/render/software/WaterRenderer.cpp b/src/render/software/WaterRenderer.cpp index 57d70e1..151cf3e 100644 --- a/src/render/software/WaterRenderer.cpp +++ b/src/render/software/WaterRenderer.cpp @@ -236,7 +236,7 @@ WaterRenderer::WaterResult WaterRenderer::getResult(double x, double z) Color depth_color = *definition->depth_color; refracted = parent->rayWalking(location, _refractRay(look_direction, normal), 1, 0, 1, 1); depth = v3Norm(v3Sub(location, refracted.hit_location)); - colorLimitPower(&depth_color, colorGetPower(&refracted.hit_color)); + depth_color.limitPower(refracted.hit_color.getPower()); if (depth > definition->transparency_depth) { result.refracted = depth_color; @@ -260,7 +260,7 @@ WaterRenderer::WaterResult WaterRenderer::getResult(double x, double z) /* Merge with foam */ foam = _getFoamMask(parent, definition, location, normal, detail); - colorMask(&color, &foam); + color.mask(foam); /* Bring color to the camera */ color = parent->applyMediumTraversal(location, color);