Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Mon, 7 May 2018 16:02:48 +0000 (18:02 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 7 May 2018 16:02:48 +0000 (18:02 +0200)
15 files changed:
1  2 
source/blender/alembic/intern/abc_mesh.cc
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenlib/intern/math_color.c
source/blender/collada/MeshImporter.cpp
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/sculpt_paint/paint_image_2d.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/gpu/intern/gpu_buffers.c
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_image.c
source/blender/modifiers/intern/MOD_particleinstance.c
source/blender/render/intern/source/multires_bake.c

@@@ -1535,111 -1471,6 +1535,111 @@@ void UI_GetThemeColorShade3ubv(int colo
        col[2] = b;
  }
  
-       F3TOCHAR3(blend, col);
 +void UI_GetThemeColorBlendShade3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3])
 +{
 +      const unsigned char *cp1, *cp2;
 +
 +      cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
 +      cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
 +
 +      CLAMP(fac, 0.0f, 1.0f);
 +
 +      float blend[3];
 +      blend[0] = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
 +      blend[1] = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
 +      blend[2] = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
 +
++      unit_float_to_uchar_clamp_v3(col, blend);
 +}
 +
 +void UI_GetThemeColorShade4ubv(int colorid, int offset, unsigned char col[4])
 +{
 +      int r, g, b;
 +      const unsigned char *cp;
 +
 +      cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
 +      r = offset + (int) cp[0];
 +      CLAMP(r, 0, 255);
 +      g = offset + (int) cp[1];
 +      CLAMP(g, 0, 255);
 +      b = offset + (int) cp[2];
 +      CLAMP(b, 0, 255);
 +
 +      col[0] = r;
 +      col[1] = g;
 +      col[2] = b;
 +      col[3] = cp[3];
 +}
 +
 +void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4])
 +{
 +      int r, g, b, a;
 +      const unsigned char *cp;
 +
 +      cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
 +
 +      r = coloffset + (int) cp[0];
 +      CLAMP(r, 0, 255);
 +      g = coloffset + (int) cp[1];
 +      CLAMP(g, 0, 255);
 +      b = coloffset + (int) cp[2];
 +      CLAMP(b, 0, 255);
 +      a = alphaoffset + (int) cp[3];
 +      CLAMP(b, 0, 255);
 +
 +      col[0] = ((float)r) / 255.0f;
 +      col[1] = ((float)g) / 255.0f;
 +      col[2] = ((float)b) / 255.0f;
 +      col[3] = ((float)a) / 255.0f;
 +}
 +
 +void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int offset, float col[3])
 +{
 +      int r, g, b;
 +      const unsigned char *cp1, *cp2;
 +
 +      cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
 +      cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
 +
 +      CLAMP(fac, 0.0f, 1.0f);
 +
 +      r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
 +      CLAMP(r, 0, 255);
 +      g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
 +      CLAMP(g, 0, 255);
 +      b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
 +      CLAMP(b, 0, 255);
 +
 +      col[0] = ((float)r) / 255.0f;
 +      col[1] = ((float)g) / 255.0f;
 +      col[2] = ((float)b) / 255.0f;
 +}
 +
 +void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
 +{
 +      int r, g, b, a;
 +      const unsigned char *cp1, *cp2;
 +
 +      cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
 +      cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
 +
 +      CLAMP(fac, 0.0f, 1.0f);
 +
 +      r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
 +      CLAMP(r, 0, 255);
 +      g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
 +      CLAMP(g, 0, 255);
 +      b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
 +      CLAMP(b, 0, 255);
 +      a = offset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
 +      CLAMP(a, 0, 255);
 +
 +      col[0] = ((float)r) / 255.0f;
 +      col[1] = ((float)g) / 255.0f;
 +      col[2] = ((float)b) / 255.0f;
 +      col[3] = ((float)a) / 255.0f;
 +}
 +
  /* get the color, in char pointer */
  void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
  {
@@@ -438,26 -1283,22 +438,26 @@@ void GPU_pbvh_grid_buffers_update
                                for (y = 0; y < key->grid_size; y++) {
                                        for (x = 0; x < key->grid_size; x++) {
                                                CCGElem *elem = CCG_grid_elem(key, grid, x, y);
 -                                              
 -                                              copy_v3_v3(vd->co, CCG_elem_co(key, elem));
 +                                              GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem));
 +
                                                if (buffers->smooth) {
 -                                                      normal_float_to_short_v3(vd->no, CCG_elem_no(key, elem));
 +                                                      short no_short[3];
 +                                                      normal_float_to_short_v3(no_short, CCG_elem_no(key, elem));
 +                                                      GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short);
  
                                                        if (has_mask) {
 +                                                              uchar color_ub[3];
                                                                if (show_mask) {
                                                                        gpu_color_from_mask_copy(*CCG_elem_mask(key, elem),
 -                                                                                               diffuse_color, vd->color);
 +                                                                                               diffuse_color, color_ub);
                                                                }
                                                                else {
-                                                                       F3TOCHAR3(diffuse_color, color_ub);
 -                                                                      unit_float_to_uchar_clamp_v3(vd->color, diffuse_color);
++                                                                      unit_float_to_uchar_clamp_v3(color_ub, diffuse_color);
                                                                }
 +                                                              GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
                                                        }
                                                }
 -                                              vd++;
 +                                              vbo_index += 1;
                                        }
                                }
                                
                                                                                                      elems[2],
                                                                                                      elems[3],
                                                                                                      diffuse_color,
 -                                                                                                    vd->color);
 +                                                                                                    color_ub);
                                                                }
                                                                else {
-                                                                       F3TOCHAR3(diffuse_color, color_ub);
 -                                                                      unit_float_to_uchar_clamp_v3(vd->color, diffuse_color);
++                                                                      unit_float_to_uchar_clamp_v3(color_ub, diffuse_color);
                                                                }
 +                                                              GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub);
                                                        }
                                                }
                                        }
@@@ -1162,68 -1173,6 +1162,68 @@@ static void apply_ao_callback(DerivedMe
                rrgb[3] = 255;
        }
  }
-                               cp[0] = cp[1] = cp[2] = FTOCHAR(normalized_displacement);
 +#endif
 +
 +/* ******$***************** Post processing ************************* */
 +
 +static void bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter)
 +{
 +      /* must check before filtering */
 +      const bool is_new_alpha = (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_imbuf_alpha_test(ibuf);
 +
 +      /* Margin */
 +      if (filter) {
 +              IMB_filter_extend(ibuf, mask, filter);
 +      }
 +
 +      /* if the bake results in new alpha then change the image setting */
 +      if (is_new_alpha) {
 +              ibuf->planes = R_IMF_PLANES_RGBA;
 +      }
 +      else {
 +              if (filter && ibuf->planes != R_IMF_PLANES_RGBA) {
 +                      /* clear alpha added by filtering */
 +                      IMB_rectfill_alpha(ibuf, 1.0f);
 +              }
 +      }
 +}
 +
 +static void bake_ibuf_normalize_displacement(ImBuf *ibuf, float *displacement, char *mask, float displacement_min, float displacement_max)
 +{
 +      int i;
 +      const float *current_displacement = displacement;
 +      const char *current_mask = mask;
 +      float max_distance;
 +
 +      max_distance = max_ff(fabsf(displacement_min), fabsf(displacement_max));
 +
 +      for (i = 0; i < ibuf->x * ibuf->y; i++) {
 +              if (*current_mask == FILTER_MASK_USED) {
 +                      float normalized_displacement;
 +
 +                      if (max_distance > 1e-5f)
 +                              normalized_displacement = (*current_displacement + max_distance) / (max_distance * 2);
 +                      else
 +                              normalized_displacement = 0.5f;
 +
 +                      if (ibuf->rect_float) {
 +                              /* currently baking happens to RGBA only */
 +                              float *fp = ibuf->rect_float + i * 4;
 +                              fp[0] = fp[1] = fp[2] = normalized_displacement;
 +                              fp[3] = 1.0f;
 +                      }
 +
 +                      if (ibuf->rect) {
 +                              unsigned char *cp = (unsigned char *) (ibuf->rect + i);
++                              cp[0] = cp[1] = cp[2] = unit_float_to_uchar_clamp(normalized_displacement);
 +                              cp[3] = 255;
 +                      }
 +              }
 +
 +              current_displacement++;
 +              current_mask++;
 +      }
 +}
  
  /* **************** Common functions public API relates on **************** */