[Bf-blender-cvs] [4e59ec01107] temp-sculpt-cavity-mask: Merge branch 'master' into temp-sculpt-cavity-mask

Joseph Eagar noreply at git.blender.org
Fri Sep 23 03:38:45 CEST 2022


Commit: 4e59ec01107bd0030bb830ea9ad28d60773363cd
Author: Joseph Eagar
Date:   Mon Aug 29 11:59:39 2022 -0700
Branches: temp-sculpt-cavity-mask
https://developer.blender.org/rB4e59ec01107bd0030bb830ea9ad28d60773363cd

Merge branch 'master' into temp-sculpt-cavity-mask

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



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

diff --cc source/blender/blenkernel/intern/paint.cc
index 00000000000,a6b0a4d96ee..f26cbf9ed9c
mode 000000,100644..100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@@ -1,0 -1,2383 +1,2387 @@@
+ /* SPDX-License-Identifier: GPL-2.0-or-later
+  * Copyright 2009 by Nicholas Bishop. All rights reserved. */
+ 
+ /** \file
+  * \ingroup bke
+  */
+ 
+ #include <cstdlib>
+ #include <cstring>
+ 
+ #include "MEM_guardedalloc.h"
+ 
+ #include "DNA_brush_types.h"
+ #include "DNA_gpencil_types.h"
+ #include "DNA_mesh_types.h"
+ #include "DNA_meshdata_types.h"
+ #include "DNA_modifier_types.h"
+ #include "DNA_object_types.h"
+ #include "DNA_scene_types.h"
+ #include "DNA_space_types.h"
+ #include "DNA_view3d_types.h"
+ #include "DNA_workspace_types.h"
+ 
+ #include "BLI_bitmap.h"
+ #include "BLI_hash.h"
+ #include "BLI_listbase.h"
+ #include "BLI_math_vector.h"
+ #include "BLI_utildefines.h"
+ 
+ #include "BLT_translation.h"
+ 
+ #include "BKE_attribute.h"
+ #include "BKE_attribute.hh"
+ #include "BKE_brush.h"
+ #include "BKE_ccg.h"
+ #include "BKE_colortools.h"
+ #include "BKE_context.h"
+ #include "BKE_crazyspace.h"
+ #include "BKE_deform.h"
+ #include "BKE_gpencil.h"
+ #include "BKE_idtype.h"
+ #include "BKE_image.h"
+ #include "BKE_key.h"
+ #include "BKE_lib_id.h"
+ #include "BKE_main.h"
+ #include "BKE_material.h"
+ #include "BKE_mesh.h"
+ #include "BKE_mesh_mapping.h"
+ #include "BKE_mesh_runtime.h"
+ #include "BKE_modifier.h"
+ #include "BKE_multires.h"
+ #include "BKE_object.h"
+ #include "BKE_paint.h"
+ #include "BKE_pbvh.h"
+ #include "BKE_subdiv_ccg.h"
+ #include "BKE_subsurf.h"
+ 
+ #include "DEG_depsgraph.h"
+ #include "DEG_depsgraph_query.h"
+ 
+ #include "RNA_enum_types.h"
+ 
+ #include "BLO_read_write.h"
+ 
+ #include "bmesh.h"
+ 
+ static void palette_init_data(ID *id)
+ {
+   Palette *palette = (Palette *)id;
+ 
+   BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(palette, id));
+ 
+   /* Enable fake user by default. */
+   id_fake_user_set(&palette->id);
+ }
+ 
+ static void palette_copy_data(Main *UNUSED(bmain),
+                               ID *id_dst,
+                               const ID *id_src,
+                               const int UNUSED(flag))
+ {
+   Palette *palette_dst = (Palette *)id_dst;
+   const Palette *palette_src = (const Palette *)id_src;
+ 
+   BLI_duplicatelist(&palette_dst->colors, &palette_src->colors);
+ }
+ 
+ static void palette_free_data(ID *id)
+ {
+   Palette *palette = (Palette *)id;
+ 
+   BLI_freelistN(&palette->colors);
+ }
+ 
+ static void palette_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+ {
+   Palette *palette = (Palette *)id;
+ 
+   BLO_write_id_struct(writer, Palette, id_address, &palette->id);
+   BKE_id_blend_write(writer, &palette->id);
+ 
+   BLO_write_struct_list(writer, PaletteColor, &palette->colors);
+ }
+ 
+ static void palette_blend_read_data(BlendDataReader *reader, ID *id)
+ {
+   Palette *palette = (Palette *)id;
+   BLO_read_list(reader, &palette->colors);
+ }
+ 
+ static void palette_undo_preserve(BlendLibReader *UNUSED(reader), ID *id_new, ID *id_old)
+ {
+   /* Whole Palette is preserved across undo-steps, and it has no extra pointer, simple. */
+   /* NOTE: We do not care about potential internal references to self here, Palette has none. */
+   /* NOTE: We do not swap IDProperties, as dealing with potential ID pointers in those would be
+    *       fairly delicate. */
+   BKE_lib_id_swap(nullptr, id_new, id_old);
+   SWAP(IDProperty *, id_new->properties, id_old->properties);
+ }
+ 
+ IDTypeInfo IDType_ID_PAL = {
+     /* id_code */ ID_PAL,
+     /* id_filter */ FILTER_ID_PAL,
+     /* main_listbase_index */ INDEX_ID_PAL,
+     /* struct_size */ sizeof(Palette),
+     /* name */ "Palette",
+     /* name_plural */ "palettes",
+     /* translation_context */ BLT_I18NCONTEXT_ID_PALETTE,
+     /* flags */ IDTYPE_FLAGS_NO_ANIMDATA,
+     /* asset_type_info */ nullptr,
+ 
+     /* init_data */ palette_init_data,
+     /* copy_data */ palette_copy_data,
+     /* free_data */ palette_free_data,
+     /* make_local */ nullptr,
+     /* foreach_id */ nullptr,
+     /* foreach_cache */ nullptr,
+     /* foreach_path */ nullptr,
+     /* owner_get */ nullptr,
+ 
+     /* blend_write */ palette_blend_write,
+     /* blend_read_data */ palette_blend_read_data,
+     /* blend_read_lib */ nullptr,
+     /* blend_read_expand */ nullptr,
+ 
+     /* blend_read_undo_preserve */ palette_undo_preserve,
+ 
+     /* lib_override_apply_post */ nullptr,
+ };
+ 
+ static void paint_curve_copy_data(Main *UNUSED(bmain),
+                                   ID *id_dst,
+                                   const ID *id_src,
+                                   const int UNUSED(flag))
+ {
+   PaintCurve *paint_curve_dst = (PaintCurve *)id_dst;
+   const PaintCurve *paint_curve_src = (const PaintCurve *)id_src;
+ 
+   if (paint_curve_src->tot_points != 0) {
+     paint_curve_dst->points = static_cast<PaintCurvePoint *>(
+         MEM_dupallocN(paint_curve_src->points));
+   }
+ }
+ 
+ static void paint_curve_free_data(ID *id)
+ {
+   PaintCurve *paint_curve = (PaintCurve *)id;
+ 
+   MEM_SAFE_FREE(paint_curve->points);
+   paint_curve->tot_points = 0;
+ }
+ 
+ static void paint_curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+ {
+   PaintCurve *pc = (PaintCurve *)id;
+ 
+   BLO_write_id_struct(writer, PaintCurve, id_address, &pc->id);
+   BKE_id_blend_write(writer, &pc->id);
+ 
+   BLO_write_struct_array(writer, PaintCurvePoint, pc->tot_points, pc->points);
+ }
+ 
+ static void paint_curve_blend_read_data(BlendDataReader *reader, ID *id)
+ {
+   PaintCurve *pc = (PaintCurve *)id;
+   BLO_read_data_address(reader, &pc->points);
+ }
+ 
+ IDTypeInfo IDType_ID_PC = {
+     /* id_code */ ID_PC,
+     /* id_filter */ FILTER_ID_PC,
+     /* main_listbase_index */ INDEX_ID_PC,
+     /* struct_size */ sizeof(PaintCurve),
+     /* name */ "PaintCurve",
+     /* name_plural */ "paint_curves",
+     /* translation_context */ BLT_I18NCONTEXT_ID_PAINTCURVE,
+     /* flags */ IDTYPE_FLAGS_NO_ANIMDATA,
+     /* asset_type_info */ nullptr,
+ 
+     /* init_data */ nullptr,
+     /* copy_data */ paint_curve_copy_data,
+     /* free_data */ paint_curve_free_data,
+     /* make_local */ nullptr,
+     /* foreach_id */ nullptr,
+     /* foreach_cache */ nullptr,
+     /* foreach_path */ nullptr,
+     /* owner_get */ nullptr,
+ 
+     /* blend_write */ paint_curve_blend_write,
+     /* blend_read_data */ paint_curve_blend_read_data,
+     /* blend_read_lib */ nullptr,
+     /* blend_read_expand */ nullptr,
+ 
+     /* blend_read_undo_preserve */ nullptr,
+ 
+     /* lib_override_apply_post */ nullptr,
+ };
+ 
+ const uchar PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
+ const uchar PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
+ const uchar PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
+ const uchar PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
+ 
+ static ePaintOverlayControlFlags overlay_flags = (ePaintOverlayControlFlags)0;
+ 
+ void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, const Tex *tex)
+ {
+   Paint *p = BKE_paint_get_active(scene, view_layer);
+   if (!p) {
+     return;
+   }
+ 
+   Brush *br = p->brush;
+   if (!br) {
+     return;
+   }
+ 
+   if (br->mtex.tex == tex) {
+     overlay_flags |= PAINT_OVERLAY_INVALID_TEXTURE_PRIMARY;
+   }
+   if (br->mask_mtex.tex == tex) {
+     overlay_flags |= PAINT_OVERLAY_INVALID_TEXTURE_SECONDARY;
+   }
+ }
+ 
+ void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, CurveMapping *curve)
+ {
+   Paint *p = BKE_paint_get_active(scene, view_layer);
+   if (p == nullptr) {
+     return;
+   }
+ 
+   Brush *br = p->brush;
+   if (br && br->curve == curve) {
+     overlay_flags |= PAINT_OVERLAY_INVALID_CURVE;
+   }
+ }
+ 
+ void BKE_paint_invalidate_overlay_all(void)
+ {
+   overlay_flags |= (PAINT_OVERLAY_INVALID_TEXTURE_SECONDARY |
+                     PAINT_OVERLAY_INVALID_TEXTURE_PRIMARY | PAINT_OVERLAY_INVALID_CURVE);
+ }
+ 
+ ePaintOverlayControlFlags BKE_paint_get_overlay_flags(void)
+ {
+   return overlay_flags;
+ }
+ 
+ void BKE_paint_set_overlay_override(eOverlayFlags flags)
+ {
+   if (flags & BRUSH_OVERLAY_OVERRIDE_MASK) {
+     if (flags & BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE) {
+       overlay_flags |= PAINT_OVERLAY_OVERRIDE_CURSOR;
+     }
+     if (flags & BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE) {
+       overlay_flags |= PAINT_OVERLAY_OVERRIDE_PRIMARY;
+     }
+     if (flags & BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE) {
+       overlay_flags |= PAINT_OVERLAY_OVERRIDE_SECONDARY;
+     }
+   }
+   else {
+     overlay_flags &= ~(PAINT_OVERRIDE_MASK);
+   }
+ }
+ 
+ void BKE_paint_reset_overlay_invalid(ePaintOverlayControlFlags flag)
+ {
+   overlay_flags &= ~(flag);
+ }
+ 
+ bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
+ {
+   ToolSettings *ts = sce->toolsettings;
+   Paint **paint_ptr = nullptr;
+   /* Some paint modes don't store paint settings as pointer, for these this can be set and
+    * referenced by paint_ptr. */
+   Paint *paint_tmp = nullptr;
+ 
+   switch (mode) {
+     case PAINT_MODE_SCULPT:
+       paint_ptr = (Paint **)&ts->sculpt;
+       break;
+     case PAINT_MODE_VERTEX:
+       paint_ptr = (Paint **)&ts->vpaint;
+       break;
+     case PAINT_MODE_WEIGHT:
+       paint_ptr = (Paint **)&ts->wpaint;
+       break;
+     case PAINT_MODE_TEXTURE_2D:
+     case PAINT_MODE_TEXTURE_3D:
+       paint_tmp = (Paint *)&ts->imapaint;
+       paint_ptr = &paint_tmp;
+       break;
+     case PAINT_MODE_SCULPT_UV:
+       paint_ptr = (Paint **)&ts->uvsculpt;
+       break;
+     case PAINT_MODE_GPENCIL:
+       paint_ptr = (Paint **)&ts->gp_paint;
+       break;
+     case PAINT_MODE_VERTEX_GPENCIL:
+       paint_ptr = (Paint **)&ts->gp_vertexpaint;
+       break;
+     case PAINT_MODE_SCULPT_GPENCIL:
+       paint_ptr = (Paint **)&ts->gp_sculptpaint;
+       break;
+     case PAINT_MODE_WEIGHT_GPENCIL:
+       paint_ptr = (Paint **)&ts->gp_weightpaint;
+       break;
+     case PAINT_MODE_SCULPT_CURVES:
+       paint_ptr = (Paint **)&ts->curves_sculpt;
+       break;
+     case PAINT_MODE

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list