Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Wed, 7 Nov 2018 00:58:57 +0000 (11:58 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 7 Nov 2018 00:59:41 +0000 (11:59 +1100)
1  2 
source/blender/blenkernel/BKE_paint.h
source/blender/blenkernel/intern/paint.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/sculpt_paint/paint_cursor.c
source/blender/editors/sculpt_paint/paint_curve.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/makesrna/intern/rna_brush.c

index b4b667ecb6b40d46370466f540de4e2625098ced,a132af41567af1839d3afeb94a66599239dc7e77..6f54e2b3b17f00bdccd024f6ee86162aee1c0641
@@@ -76,14 -69,15 +76,17 @@@ extern const char PAINT_CURSOR_TEXTURE_
  
  typedef enum ePaintMode {
        ePaintSculpt = 0,
+       /** Vertex color. */
        ePaintVertex = 1,
        ePaintWeight = 2,
-       ePaintTextureProjective = 3,
+       /** 3D view (projection painting). */
+       ePaintTexture3D = 3,
+       /** Image space (2D painting). */
        ePaintTexture2D = 4,
        ePaintSculptUV = 5,
 -      ePaintInvalid = 6
 +      ePaintGpencil = 6,
 +
 +      ePaintInvalid = 7,
  } ePaintMode;
  
  /* overlay invalidation */
index db7cd513bf469fd75eb1d927b8b80c315d4f086d,0541bd58c85bc99e836abdb3ee3f5ba1a1ba2df7..e31021d7d487e2708194d41ec698b2a086c7e6d6
@@@ -174,50 -156,13 +174,50 @@@ Paint *BKE_paint_get_active_from_paintm
        return NULL;
  }
  
 -Paint *BKE_paint_get_active(Scene *sce)
 +const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
  {
 -      if (sce) {
 +      switch (mode) {
 +              case ePaintSculpt:
 +                      return rna_enum_brush_sculpt_tool_items;
 +              case ePaintVertex:
 +                      return rna_enum_brush_vertex_tool_items;
 +              case ePaintWeight:
 +                      return rna_enum_brush_weight_tool_items;
 +              case ePaintTexture2D:
-               case ePaintTextureProjective:
++              case ePaintTexture3D:
 +                      return rna_enum_brush_image_tool_items;
 +              case ePaintSculptUV:
 +                      return NULL;
 +              case ePaintGpencil:
 +                      return rna_enum_brush_gpencil_types_items;
 +              case ePaintInvalid:
 +                      break;
 +      }
 +      return NULL;
 +}
 +
 +const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
 +{
 +      switch (mode) {
 +              case ePaintSculpt: return "sculpt_tool";
 +              case ePaintVertex: return "vertex_tool";
 +              case ePaintWeight: return "weight_tool";
 +              case ePaintTexture2D:
-               case ePaintTextureProjective: return "image_tool";
++              case ePaintTexture3D: return "image_tool";
 +              case ePaintGpencil: return "gpencil_tool";
 +              default:
 +                      /* invalid paint mode */
 +                      return NULL;
 +      }
 +}
 +
 +Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
 +{
 +      if (sce && view_layer) {
                ToolSettings *ts = sce->toolsettings;
  
 -              if (sce->basact && sce->basact->object) {
 -                      switch (sce->basact->object->mode) {
 +              if (view_layer->basact && view_layer->basact->object) {
 +                      switch (view_layer->basact->object->mode) {
                                case OB_MODE_SCULPT:
                                        return &ts->sculpt->paint;
                                case OB_MODE_VERTEX_PAINT:
@@@ -327,32 -266,6 +327,32 @@@ ePaintMode BKE_paintmode_get_active_fro
        return ePaintInvalid;
  }
  
-                               return ePaintTextureProjective;
 +ePaintMode BKE_paintmode_get_from_tool(const struct bToolRef *tref)
 +{
 +      if (tref->space_type == SPACE_VIEW3D) {
 +              switch (tref->mode) {
 +                      case CTX_MODE_SCULPT:
 +                              return ePaintSculpt;
 +                      case CTX_MODE_PAINT_VERTEX:
 +                              return ePaintVertex;
 +                      case CTX_MODE_PAINT_WEIGHT:
 +                              return ePaintWeight;
 +                      case CTX_MODE_GPENCIL_PAINT:
 +                              return ePaintGpencil;
 +                      case CTX_MODE_PAINT_TEXTURE:
++                              return ePaintTexture3D;
 +              }
 +      }
 +      else if (tref->space_type == SPACE_IMAGE) {
 +              switch (tref->mode) {
 +                      case SI_MODE_PAINT:
 +                              return ePaintTexture2D;
 +              }
 +      }
 +
 +      return ePaintInvalid;
 +}
 +
  Brush *BKE_paint_brush(Paint *p)
  {
        return p ? p->brush : NULL;
@@@ -401,27 -280,6 +401,27 @@@ void BKE_paint_runtime_init(const ToolS
        }
  }
  
-               case ePaintTextureProjective:
 +uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
 +{
 +      switch (mode) {
 +              case ePaintTexture2D:
++              case ePaintTexture3D:
 +                      return offsetof(Brush, imagepaint_tool);
 +              case ePaintSculpt:
 +                      return offsetof(Brush, sculpt_tool);
 +              case ePaintVertex:
 +                      return offsetof(Brush, vertexpaint_tool);
 +              case ePaintWeight:
 +                      return offsetof(Brush, weightpaint_tool);
 +              case ePaintGpencil:
 +                      return offsetof(Brush, gpencil_tool);
 +              case ePaintSculptUV:
 +              case ePaintInvalid:
 +                      break; /* We don't use these yet. */
 +      }
 +      return 0;
 +}
 +
  /** Free (or release) any data used by this paint curve (does not free the pcurve itself). */
  void BKE_paint_curve_free(PaintCurve *pc)
  {
@@@ -626,8 -486,9 +626,8 @@@ eObjectMode BKE_paint_object_mode_from_
                        return OB_MODE_VERTEX_PAINT;
                case ePaintWeight:
                        return OB_MODE_WEIGHT_PAINT;
 -              case ePaintTexture3D:
 -                      return OB_MODE_TEXTURE_PAINT;
                case ePaintTexture2D:
-               case ePaintTextureProjective:
++              case ePaintTexture3D:
                        return OB_MODE_TEXTURE_PAINT;
                case ePaintSculptUV:
                        return OB_MODE_EDIT;
index 79d0c9852def9e63d6e989f29e1a68ba10335e73,eed7f2ec0f20b7a626e4a9858a8fd2238e646871..5bcacca9214268c3602c81fca5782c06e8404f43
@@@ -1686,33 -1199,18 +1686,33 @@@ static int ui_id_brush_get_icon(const b
                 * be strictly in one paint mode only to avoid
                 * checking various context stuff here */
  
 -              if (CTX_wm_view3d(C) && ob) {
 -                      if (ob->mode & OB_MODE_SCULPT)
 -                              mode = OB_MODE_SCULPT;
 -                      else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
 -                              mode = OB_MODE_VERTEX_PAINT;
 -                      else if (ob->mode & OB_MODE_TEXTURE_PAINT)
 -                              mode = OB_MODE_TEXTURE_PAINT;
 +              if ((space_type == SPACE_VIEW3D) && ob) {
 +                      if (ob->mode & OB_MODE_SCULPT) {
 +                              paint_mode = ePaintSculpt;
 +                      }
 +                      else if (ob->mode & OB_MODE_VERTEX_PAINT) {
 +                              paint_mode = ePaintVertex;
 +                      }
 +                      else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
 +                              paint_mode = ePaintWeight;
 +                      }
 +                      else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
-                               paint_mode = ePaintTextureProjective;
++                              paint_mode = ePaintTexture3D;
 +                      }
                }
 -              else if ((sima = CTX_wm_space_image(C)) &&
 -                       (sima->mode == SI_MODE_PAINT))
 -              {
 -                      mode = OB_MODE_TEXTURE_PAINT;
 +              else if (space_type == SPACE_IMAGE) {
 +                      int sima_mode;
 +                      if (sa->spacetype == space_type) {
 +                              SpaceImage *sima = sa->spacedata.first;
 +                              sima_mode = sima->mode;
 +                      }
 +                      else {
 +                              sima_mode = workspace->tools_mode;
 +                      }
 +
 +                      if (sima_mode == SI_MODE_PAINT) {
 +                              paint_mode = ePaintTexture2D;
 +                      }
                }
  
                /* reset the icon */
index 294981e7303680c6ea3cc22150a72e6147535d0b,fb938ed60c98fdc57e2eeba8e2adcc27984ac7fc..dfad5afc9dc34a873381e7f19480856db1f020cf
@@@ -802,15 -788,21 +802,15 @@@ static void paint_draw_alpha_overlay
          ViewContext *vc, int x, int y, float zoom, ePaintMode mode)
  {
        /* color means that primary brush texture is colured and secondary is used for alpha/mask control */
-       bool col = ELEM(mode, ePaintTextureProjective, ePaintTexture2D, ePaintVertex) ? true : false;
+       bool col = ELEM(mode, ePaintTexture3D, ePaintTexture2D, ePaintVertex) ? true : false;
        eOverlayControlFlags flags = BKE_paint_get_overlay_flags();
 -      /* save lots of GL state
 -       * TODO: check on whether all of these are needed? */
 -      glPushAttrib(GL_COLOR_BUFFER_BIT |
 -                   GL_CURRENT_BIT |
 -                   GL_DEPTH_BUFFER_BIT |
 -                   GL_ENABLE_BIT |
 -                   GL_LINE_BIT |
 -                   GL_POLYGON_BIT |
 -                   GL_STENCIL_BUFFER_BIT |
 -                   GL_TRANSFORM_BIT |
 -                   GL_VIEWPORT_BIT |
 -                   GL_TEXTURE_BIT);
 +      gpuPushAttrib(GPU_DEPTH_BUFFER_BIT | GPU_BLEND_BIT);
  
 +      /* Translate to region. */
 +      GPU_matrix_push();
 +      GPU_matrix_translate_2f(vc->ar->winrct.xmin, vc->ar->winrct.ymin);
 +      x -= vc->ar->winrct.xmin;
 +      y -= vc->ar->winrct.ymin;
  
        /* coloured overlay should be drawn separately */
        if (col) {
index 4bd625c3cc6ca83de546a40468d7b0eb66ac63f8,6ad2f98c5201632867a435c031f17ed9dee907fb..e528c64b6e23e87daab229d105430a8232e12615
@@@ -1130,10 -1093,8 +1130,10 @@@ static int texture_paint_toggle_exec(bC
  
                ob->mode |= mode_flag;
  
-               BKE_paint_init(bmain, scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT);
+               BKE_paint_init(bmain, scene, ePaintTexture3D, PAINT_CURSOR_TEXTURE_PAINT);
  
 +              BKE_paint_toolslots_brush_validate(bmain, &imapaint->paint);
 +
                if (U.glreslimit != 0)
                        GPU_free_images(bmain);
                GPU_paint_set_mipmap(bmain, 0);
index 9bad1324aa61bc7a2f7f20e02bb5067bf883af32,07c57d1891b9569bf703d321d4947076afb3afd1..136a6c9c6645f4d79208ea5b019ad8f3b5bbca55
@@@ -482,14 -461,12 +482,14 @@@ static int brush_select_exec(bContext *
  
  static void PAINT_OT_brush_select(wmOperatorType *ot)
  {
 +      /* Keep names matching 'rna_enum_object_mode_items' (besides active). */
        static const EnumPropertyItem paint_mode_items[] = {
 -              {OB_MODE_ACTIVE, "ACTIVE", 0, "Current", "Set brush for active paint mode"},
 -              {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""},
 -              {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
 -              {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
 -              {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
 +              {ePaintInvalid, "ACTIVE", 0, "Current", "Set brush for active paint mode"},
 +              {ePaintSculpt, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""},
 +              {ePaintVertex, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
 +              {ePaintWeight, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
-               {ePaintTextureProjective, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
++              {ePaintTexture3D, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
 +              {ePaintGpencil, "GPENCIL_PAINT", ICON_GREASEPENCIL, "Grease Pencil Paint", ""},
                {0, NULL, 0, NULL, NULL}
        };
        PropertyRNA *prop;