Removed old C-Api from Color

This commit is contained in:
Michaël Lemaire 2013-12-11 10:24:35 +01:00 committed by Michael Lemaire
parent 84608a66a8
commit 88517af86f
15 changed files with 27 additions and 94 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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