Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2021-05-25 18:03:54 +0300
committerJeroen Bakker <jeroen@blender.org>2021-05-25 18:03:54 +0300
commit00955cd31eda95aca619842064d22663af4c812b (patch)
tree85a4650d260f2fdc250d433d51d7309b77f08510 /source/blender/blenkernel/intern
parentfd94e033446c72fb92048a9864c1d539fccde59a (diff)
Revert "Blenlib: Explicit Colors."
This reverts commit fd94e033446c72fb92048a9864c1d539fccde59a. does not compile against latest master.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc8
-rw-r--r--source/blender/blenkernel/intern/attribute_math.cc15
-rw-r--r--source/blender/blenkernel/intern/geometry_component_mesh.cc20
3 files changed, 19 insertions, 24 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index d36e9ed3e86..62833e10438 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -61,7 +61,7 @@ const blender::fn::CPPType *custom_data_type_to_cpp_type(const CustomDataType ty
case CD_PROP_INT32:
return &CPPType::get<int>();
case CD_PROP_COLOR:
- return &CPPType::get<ColorGeometry4f>();
+ return &CPPType::get<Color4f>();
case CD_PROP_BOOL:
return &CPPType::get<bool>();
default:
@@ -84,7 +84,7 @@ CustomDataType cpp_type_to_custom_data_type(const blender::fn::CPPType &type)
if (type.is<int>()) {
return CD_PROP_INT32;
}
- if (type.is<ColorGeometry4f>()) {
+ if (type.is<Color4f>()) {
return CD_PROP_COLOR;
}
if (type.is<bool>()) {
@@ -355,7 +355,7 @@ ReadAttributeLookup CustomDataAttributeProvider::try_get_for_read(
case CD_PROP_INT32:
return this->layer_to_read_attribute<int>(layer, domain_size);
case CD_PROP_COLOR:
- return this->layer_to_read_attribute<ColorGeometry4f>(layer, domain_size);
+ return this->layer_to_read_attribute<Color4f>(layer, domain_size);
case CD_PROP_BOOL:
return this->layer_to_read_attribute<bool>(layer, domain_size);
default:
@@ -389,7 +389,7 @@ WriteAttributeLookup CustomDataAttributeProvider::try_get_for_write(
case CD_PROP_INT32:
return this->layer_to_write_attribute<int>(layer, domain_size);
case CD_PROP_COLOR:
- return this->layer_to_write_attribute<ColorGeometry4f>(layer, domain_size);
+ return this->layer_to_write_attribute<Color4f>(layer, domain_size);
case CD_PROP_BOOL:
return this->layer_to_write_attribute<bool>(layer, domain_size);
default:
diff --git a/source/blender/blenkernel/intern/attribute_math.cc b/source/blender/blenkernel/intern/attribute_math.cc
index 5cdf329effb..4ff3a6ceff5 100644
--- a/source/blender/blenkernel/intern/attribute_math.cc
+++ b/source/blender/blenkernel/intern/attribute_math.cc
@@ -18,21 +18,18 @@
namespace blender::attribute_math {
-ColorGeometryMixer::ColorGeometryMixer(MutableSpan<ColorGeometry4f> output_buffer,
- ColorGeometry4f default_color)
+Color4fMixer::Color4fMixer(MutableSpan<Color4f> output_buffer, Color4f default_color)
: buffer_(output_buffer),
default_color_(default_color),
total_weights_(output_buffer.size(), 0.0f)
{
- buffer_.fill(ColorGeometry4f(0.0f, 0.0f, 0.0f, 0.0f));
+ buffer_.fill(Color4f(0, 0, 0, 0));
}
-void ColorGeometryMixer::mix_in(const int64_t index,
- const ColorGeometry4f &color,
- const float weight)
+void Color4fMixer::mix_in(const int64_t index, const Color4f &color, const float weight)
{
BLI_assert(weight >= 0.0f);
- ColorGeometry4f &output_color = buffer_[index];
+ Color4f &output_color = buffer_[index];
output_color.r += color.r * weight;
output_color.g += color.g * weight;
output_color.b += color.b * weight;
@@ -40,11 +37,11 @@ void ColorGeometryMixer::mix_in(const int64_t index,
total_weights_[index] += weight;
}
-void ColorGeometryMixer::finalize()
+void Color4fMixer::finalize()
{
for (const int64_t i : buffer_.index_range()) {
const float weight = total_weights_[i];
- ColorGeometry4f &output_color = buffer_[i];
+ Color4f &output_color = buffer_[i];
if (weight > 0.0f) {
const float weight_inv = 1.0f / weight;
output_color.r *= weight_inv;
diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 42f3a854aec..9e622ab2cdf 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -773,20 +773,18 @@ static void set_loop_uv(MLoopUV &uv, float2 co)
copy_v2_v2(uv.uv, co);
}
-static ColorGeometry4f get_loop_color(const MLoopCol &col)
+static Color4f get_loop_color(const MLoopCol &col)
{
- ColorGeometry4b encoded_color = ColorGeometry4b(col.r, col.g, col.b, col.a);
- ColorGeometry4f linear_color = encoded_color.decode();
+ Color4f srgb_color;
+ rgba_uchar_to_float(srgb_color, &col.r);
+ Color4f linear_color;
+ srgb_to_linearrgb_v4(linear_color, srgb_color);
return linear_color;
}
-static void set_loop_color(MLoopCol &col, ColorGeometry4f linear_color)
+static void set_loop_color(MLoopCol &col, Color4f linear_color)
{
- ColorGeometry4b encoded_color = linear_color.encode();
- col.r = encoded_color.r;
- col.g = encoded_color.g;
- col.b = encoded_color.b;
- col.a = encoded_color.a;
+ linearrgb_to_srgb_uchar4(&col.r, linear_color);
}
static float get_crease(const MEdge &edge)
@@ -1123,8 +1121,8 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
CD_PROP_COLOR,
CD_MLOOPCOL,
corner_access,
- make_derived_read_attribute<MLoopCol, ColorGeometry4f, get_loop_color>,
- make_derived_write_attribute<MLoopCol, ColorGeometry4f, get_loop_color, set_loop_color>);
+ make_derived_read_attribute<MLoopCol, Color4f, get_loop_color>,
+ make_derived_write_attribute<MLoopCol, Color4f, get_loop_color, set_loop_color>);
static VertexGroupsAttributeProvider vertex_groups;
static CustomDataAttributeProvider corner_custom_data(ATTR_DOMAIN_CORNER, corner_access);