[Bf-blender-cvs] [0132d9eba49] temp-explicit-colors: Merge branch 'master' into temp-explicit-colors

Jeroen Bakker noreply at git.blender.org
Mon May 17 07:30:04 CEST 2021


Commit: 0132d9eba49676b9139fa43777f7a13ca116e02a
Author: Jeroen Bakker
Date:   Mon May 17 07:29:58 2021 +0200
Branches: temp-explicit-colors
https://developer.blender.org/rB0132d9eba49676b9139fa43777f7a13ca116e02a

Merge branch 'master' into temp-explicit-colors

===================================================================



===================================================================

diff --cc source/blender/blenkernel/BKE_attribute_math.hh
index 28ffe9fc974,0afdc436415..ba683362e69
--- a/source/blender/blenkernel/BKE_attribute_math.hh
+++ b/source/blender/blenkernel/BKE_attribute_math.hh
@@@ -54,6 -60,32 +60,32 @@@ inline void convert_to_static_type(cons
    }
  }
  
+ template<typename Func>
+ inline void convert_to_static_type(const fn::CPPType &cpp_type, const Func &func)
+ {
+   if (cpp_type.is<float>()) {
+     func(float());
+   }
+   else if (cpp_type.is<float2>()) {
+     func(float2());
+   }
+   else if (cpp_type.is<float3>()) {
+     func(float3());
+   }
+   else if (cpp_type.is<int>()) {
+     func(int());
+   }
+   else if (cpp_type.is<bool>()) {
+     func(bool());
+   }
 -  else if (cpp_type.is<Color4f>()) {
 -    func(Color4f());
++  else if (cpp_type.is<ColorGeometry4f>()) {
++    func(ColorGeometry4f());
+   }
+   else {
+     BLI_assert_unreachable();
+   }
+ }
+ 
  /* -------------------------------------------------------------------- */
  /** \name Mix three values of the same type.
   *
@@@ -103,6 -132,48 +135,49 @@@ inline ColorGeometry4f mix3(const float
  
  /** \} */
  
+ /* -------------------------------------------------------------------- */
+ /** \name Mix two values of the same type.
+  *
+  * This is just basic linear interpolation.
+  * \{ */
+ 
+ template<typename T> T mix2(const float factor, const T &a, const T &b);
+ 
+ template<> inline bool mix2(const float factor, const bool &a, const bool &b)
+ {
+   return ((1.0f - factor) * a + factor * b) >= 0.5f;
+ }
+ 
+ template<> inline int mix2(const float factor, const int &a, const int &b)
+ {
+   return static_cast<int>((1.0f - factor) * a + factor * b);
+ }
+ 
+ template<> inline float mix2(const float factor, const float &a, const float &b)
+ {
+   return (1.0f - factor) * a + factor * b;
+ }
+ 
+ template<> inline float2 mix2(const float factor, const float2 &a, const float2 &b)
+ {
+   return float2::interpolate(a, b, factor);
+ }
+ 
+ template<> inline float3 mix2(const float factor, const float3 &a, const float3 &b)
+ {
+   return float3::interpolate(a, b, factor);
+ }
+ 
 -template<> inline Color4f mix2(const float factor, const Color4f &a, const Color4f &b)
++template<>
++inline ColorGeometry4f mix2(const float factor, const ColorGeometry4f &a, const ColorGeometry4f &b)
+ {
 -  Color4f result;
++  ColorGeometry4f result;
+   interp_v4_v4v4(result, a, b, factor);
+   return result;
+ }
+ 
+ /** \} */
+ 
  /* -------------------------------------------------------------------- */
  /** \name Mix a dynamic amount of values with weights for many elements.
   *
diff --cc source/blender/editors/space_spreadsheet/spreadsheet_cell_value.hh
index 0627cff7abc,d1e80f1d87e..c9b73aabf96
--- a/source/blender/editors/space_spreadsheet/spreadsheet_cell_value.hh
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_cell_value.hh
@@@ -44,6 -48,9 +48,9 @@@ class CellValue 
    std::optional<int> value_int;
    std::optional<float> value_float;
    std::optional<bool> value_bool;
+   std::optional<float2> value_float2;
+   std::optional<float3> value_float3;
 -  std::optional<Color4f> value_color;
++  std::optional<ColorGeometry4f> value_color;
    std::optional<ObjectCellValue> value_object;
    std::optional<CollectionCellValue> value_collection;
  };
diff --cc source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index b2627be94a8,02ffa1259fc..452885959f6
--- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@@ -120,43 -90,37 +90,37 @@@ std::unique_ptr<ColumnValues> GeometryD
              r_cell_value.value_bool = value;
            });
      case CD_PROP_FLOAT2: {
-       if (column_id.index < 0 || column_id.index > 1) {
-         return {};
-       }
-       const std::array<const char *, 2> suffixes = {" X", " Y"};
-       const std::string name = StringRef(column_id.name) + suffixes[column_id.index];
        return column_values_from_function(
-           name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) {
+           column_id.name,
+           domain_size,
+           [varray](int index, CellValue &r_cell_value) {
              float2 value;
              varray->get(index, &value);
-             r_cell_value.value_float = value[axis];
-           });
+             r_cell_value.value_float2 = value;
+           },
+           default_float2_column_width);
      }
      case CD_PROP_FLOAT3: {
-       if (column_id.index < 0 || column_id.index > 2) {
-         return {};
-       }
-       const std::array<const char *, 3> suffixes = {" X", " Y", " Z"};
-       const std::string name = StringRef(column_id.name) + suffixes[column_id.index];
        return column_values_from_function(
-           name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) {
+           column_id.name,
+           domain_size,
+           [varray](int index, CellValue &r_cell_value) {
              float3 value;
              varray->get(index, &value);
-             r_cell_value.value_float = value[axis];
-           });
+             r_cell_value.value_float3 = value;
+           },
+           default_float3_column_width);
      }
      case CD_PROP_COLOR: {
-       if (column_id.index < 0 || column_id.index > 3) {
-         return {};
-       }
-       const std::array<const char *, 4> suffixes = {" R", " G", " B", " A"};
-       const std::string name = StringRef(column_id.name) + suffixes[column_id.index];
        return column_values_from_function(
-           name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) {
+           column_id.name,
+           domain_size,
+           [varray](int index, CellValue &r_cell_value) {
 -            Color4f value;
 +            ColorGeometry4f value;
              varray->get(index, &value);
-             r_cell_value.value_float = value[axis];
-           });
+             r_cell_value.value_color = value;
+           },
+           default_color_column_width);
      }
      default:
        break;
diff --cc source/blender/editors/space_spreadsheet/spreadsheet_layout.cc
index bca80cff773,f1ca65817f6..8079763a339
--- a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc
@@@ -161,6 -161,18 +161,18 @@@ class SpreadsheetLayoutDrawer : public 
                                      nullptr);
        UI_but_drawflag_disable(but, UI_BUT_ICON_LEFT);
      }
+     else if (cell_value.value_float2.has_value()) {
+       const float2 value = *cell_value.value_float2;
+       this->draw_float_vector(params, Span(&value.x, 2));
+     }
+     else if (cell_value.value_float3.has_value()) {
+       const float3 value = *cell_value.value_float3;
+       this->draw_float_vector(params, Span(&value.x, 3));
+     }
+     else if (cell_value.value_color.has_value()) {
 -      const Color4f value = *cell_value.value_color;
++      const ColorGeometry4f value = *cell_value.value_color;
+       this->draw_float_vector(params, Span(&value.r, 4));
+     }
      else if (cell_value.value_object.has_value()) {
        const ObjectCellValue value = *cell_value.value_object;
        uiDefIconTextBut(params.block,
diff --cc source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
index 849edbdbe3e,26ddb0da515..75e6b34f1c0
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
@@@ -82,12 -84,14 +84,14 @@@ static void execute_on_component(const 
    GVArray_Typed<float> attribute_in = component.attribute_get_for_read<float>(
        input_name, result_domain, 0.0f);
  
 -  MutableSpan<Color4f> results = attribute_result.as_span();
 +  MutableSpan<ColorGeometry4f> results = attribute_result.as_span();
  
    ColorBand *color_ramp = &node_storage->color_ramp;
-   for (const int i : IndexRange(attribute_in.size())) {
-     BKE_colorband_evaluate(color_ramp, attribute_in[i], results[i]);
-   }
+   parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
+     for (const int i : range) {
+       BKE_colorband_evaluate(color_ramp, attribute_in[i], results[i]);
+     }
+   });
  
    attribute_result.save();
  }
diff --cc source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc
index 00000000000,2fc86269797..599c9e58e52
mode 000000,100644..100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc
@@@ -1,0 -1,231 +1,232 @@@
+ /*
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+  * as published by the Free Software Foundation; either version 2
+  * of the License, or (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program; if not, write to the Free Software Foundation,
+  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  */
+ 
+ #include "BLI_blenlib.h"
+ #include "BLI_task.hh"
+ 
+ #include "BKE_colortools.h"
+ 
+ #include "UI_interface.h"
+ #include "UI_resources.h"
+ 
+ #include "node_geometry_util.hh"
+ 
+ static bNodeSocketTemplate geo_node_attribute_curve_map_in[] = {
+     {SOCK_GEOMETRY, N_("Geometry")},
+     {SOCK_STRING, N_("Attribute")},
+     {SOCK_STRING, N_("Result")},
+     {-1, ""},
+ };
+ 
+ static bNodeSocketTemplate geo_node_attribute_curve_map_out[] = {
+     {SOCK_GEOMETRY, N_("Geometry")},
+     {-1, ""},
+ };
+ 
+ static void geo_node_attribute_curve_map_layout(uiLayout *layout,
+                                                 bContext *UNUSED(C),
+                                                 PointerRNA *ptr)
+ {
+   uiItemR(layout, ptr, "da

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list