[Bf-blender-cvs] [71c9af7eb58] sculpt-dev: Sculpt: Cleaned up custom customdata api
Joseph Eagar
noreply at git.blender.org
Mon Sep 27 00:16:59 CEST 2021
Commit: 71c9af7eb583869153f7f8de795d618c9a125809
Author: Joseph Eagar
Date: Sun Sep 26 15:11:42 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB71c9af7eb583869153f7f8de795d618c9a125809
Sculpt: Cleaned up custom customdata api
* Cleaned up the SculptCustomLayer API that is
used for custom data.
* Various SculptCustomLayer references are now maintained
in ss->custom_layers and are updated automatically when
the CD layout changes.
* PBVH_GRIDS now forcibly allocate custom layers in simple_array
mode (i.e. they don't allocated real customdata layers at all).
* SculptCustomLayers can optionally be preserved in the final mesh.
* Fixed handling of CD_TEMPORARY which was broken.
* The layer brush can now split the pbvh during use.
* Persistent base data is now saved as permanent CD layers (except
for PBVH_GRIDS). This is necessary for undo, if we want we can
add special code to remove them on exising sculpt mode.
* The layer brush now uses the SculptCustomLayer API instead of
having seperate bmesh and faces/grids implementations.
* In unrelated changes, fixed curve presets for clay brushes.
- Still need to implement stabilized input mappings, which the
clay thumb brush needs.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/BKE_brush_engine.h
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/brush_engine.c
M source/blender/blenkernel/intern/brush_engine_presets.c
M source/blender/blenkernel/intern/customdata.c
M source/blender/blenkernel/intern/paint.c
M source/blender/blenloader/intern/versioning_300.c
M source/blender/bmesh/intern/bmesh_interp.c
M source/blender/bmesh/intern/bmesh_mesh_convert.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_automasking.c
M source/blender/editors/sculpt_paint/sculpt_cloth.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_smooth.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
M source/blender/makesrna/intern/rna_internal.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 95a94a9db95..610ec7c1ad5 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -500,12 +500,46 @@ class VIEW3D_PT_tools_brush_color(Panel, View3DPaintPanel):
draw_color_settings(context, layout, brush, color_type=not context.vertex_paint_object)
-
-class VIEW3D_PT_tools_brush_swatches(Panel, View3DPaintPanel, ColorPalettePanel):
+class VIEW3D_PT_tools_persistent_base_channels(Panel, View3DPaintPanel):
bl_context = ".paint_common"
- bl_parent_id = "VIEW3D_PT_tools_brush_settings"
- bl_label = "Color Palette"
+ bl_parent_id = "VIEW3D_PT_tools_brush_settings_channels"
+ bl_label = "Persistent Base"
bl_options = {'DEFAULT_CLOSED'}
+
+ @classmethod
+ def poll(cls, context):
+ settings = cls.paint_settings(context)
+ brush = settings.brush
+
+ ch = UnifiedPaintPanel.get_channel(context, brush, "use_persistent")
+
+ ok = context.mode == "SCULPT"
+ ok = ok and ch and ch.show_in_workspace
+ ok = ok or capabilities.has_persistence
+
+ return ok
+
+ def draw(self, context):
+ layout = self.layout
+ settings = self.paint_settings(context)
+ brush = settings.brush
+ sculpt = context.tool_settings.sculpt
+
+ UnifiedPaintPanel.channel_unified(
+ layout,
+ context,
+ brush,
+ "use_persistent",
+ #text="Weight By Face Area",
+ ui_editing=False
+ )
+
+ layout.operator("sculpt.set_persistent_base")
+
+ if sculpt.has_persistent_base():
+ layout.label(text="Persistent base exists")
+ else:
+ layout.label(text="No persisent base data")
class VIEW3D_PT_tools_brush_swatches_channels(Panel, View3DPaintPanel, ColorPalettePanel):
bl_context = ".paint_common"
@@ -513,6 +547,12 @@ class VIEW3D_PT_tools_brush_swatches_channels(Panel, View3DPaintPanel, ColorPale
bl_label = "Color Palette"
bl_options = {'DEFAULT_CLOSED'}
+class VIEW3D_PT_tools_brush_swatches(Panel, View3DPaintPanel, ColorPalettePanel):
+ bl_context = ".brush_editor"
+ bl_parent_id = "VIEW3D_PT_tools_brush_settings"
+ bl_label = "Color Palette"
+ bl_options = {'DEFAULT_CLOSED'}
+
class VIEW3D_PT_tools_brush_clone(Panel, View3DPaintPanel, ClonePanel):
bl_context = ".paint_common"
@@ -866,7 +906,7 @@ class VIEW3D_PT_sculpt_dyntopo_advanced(Panel, View3DPaintPanel):
)
keys = ["dyntopo_spacing", "dyntopo_detail_size", "dyntopo_detail_range", "dyntopo_detail_percent",
- "dyntopo_constant_detail", "dyntopo_radius_scale"]
+ "dyntopo_constant_detail", "dyntopo_radius_scale", "dyntopo_disabled"]
for k in keys:
UnifiedPaintPanel.channel_unified(
layout,
@@ -2608,6 +2648,7 @@ classes = (
VIEW3D_PT_tools_grease_pencil_brush_vertex_palette,
VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff,
VIEW3D_PT_tools_brush_swatches_channels,
+ VIEW3D_PT_tools_persistent_base_channels,
VIEW3D_PT_sculpt_dyntopo_advanced,
SCULPT_OT_set_dyntopo_mode
)
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 9458f179dc0..5d386a89c70 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -56,6 +56,7 @@ struct ID;
struct BlendExpander;
struct Brush;
struct Sculpt;
+struct LibraryForeachIDData;
#define MAKE_BUILTIN_CH_NAME(idname) BRUSH_BUILTIN_##idname
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 994993e9d39..bc35fd30094 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -68,6 +68,7 @@ struct Scene;
struct StrokeCache;
struct SubdivCCG;
struct Tex;
+struct SculptCustomLayer;
struct ToolSettings;
struct UnifiedPaintSettings;
struct View3D;
@@ -380,12 +381,6 @@ typedef struct SculptClothSimulation {
int cd_pers_disp;
} SculptClothSimulation;
-typedef struct SculptPersistentBase {
- float co[3];
- float no[3];
- float disp;
-} SculptPersistentBase;
-
typedef struct SculptVertexInfo {
/* Indexed by vertex, stores and ID of its topologically connected component. */
int *connected_component;
@@ -559,6 +554,22 @@ typedef struct SculptFakeNeighbors {
/* Session data (mode-specific) */
+/* These custom attributes have references
+ (SculptCustomLayer pointers) inside of ss->custom_layers
+ that are kept up to date with SCULPT_update_customdata_refs.
+ */
+enum {
+ SCULPT_SCL_FAIRING_MASK,
+ SCULPT_SCL_FAIRING_FADE,
+ SCULPT_SCL_PREFAIRING_CO,
+ SCULPT_SCL_PERS_CO,
+ SCULPT_SCL_PERS_NO,
+ SCULPT_SCL_PERS_DISP,
+ SCULPT_SCL_LAYER_DISP,
+ SCULPT_SCL_LAYER_STROKE_ID,
+ SCULPT_SCL_LAYER_MAX
+};
+
typedef struct SculptSession {
/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
struct { /* Special handling for multires meshes */
@@ -699,10 +710,6 @@ typedef struct SculptSession {
/* Boundary Brush Preview */
SculptBoundary *boundary_preview;
- /* Mesh State Persistence */
- /* This is freed with the PBVH, so it is always in sync with the mesh. */
- SculptPersistentBase *persistent_base;
-
// float (*limit_surface)[3];
struct SculptCustomLayer *limit_surface;
@@ -764,6 +771,18 @@ typedef struct SculptSession {
bool fast_draw; // hides facesets/masks and forces smooth to save GPU bandwidth
struct MDynTopoVert *mdyntopo_verts; // for non-bmesh
int mdyntopo_verts_size;
+
+ /*list of up to date custom layer references,
+ note that entries can be NULL if layer doesn't
+ exist. See SCULPT_SCL_XXX enum above.*/
+ struct SculptCustomLayer *custom_layers[SCULPT_SCL_LAYER_MAX];
+
+ /*
+ PBVH_GRIDS cannot store customdata layers in real CustomDataLayers,
+ so we queue the memory allocated for them to free later
+ */
+ struct SculptCustomLayer **layers_to_free;
+ int tot_layers_to_free;
} SculptSession;
void BKE_sculptsession_free(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index e6a55af2fd3..d795d788fc7 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -1499,6 +1499,7 @@ void BKE_builtin_commandlist_create(Brush *brush,
bool no_autosmooth = ELEM(
brush->sculpt_tool, SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK);
+ bool no_rake = no_autosmooth;
/* build autosmooth command */
float autosmooth_scale = BKE_brush_channelset_get_float(
@@ -1565,7 +1566,7 @@ void BKE_builtin_commandlist_create(Brush *brush,
topology_rake_spacing = BKE_brush_channelset_get_float(chset, "spacing", mapdata);
}
- if (topology_rake > 0.0f) {
+ if (!no_rake && topology_rake > 0.0f) {
cmd = BKE_brush_command_init(BKE_brush_commandlist_add(cl, chset, true),
SCULPT_TOOL_TOPOLOGY_RAKE);
@@ -1651,7 +1652,6 @@ void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannelSet *chset)
curve = mp->curve = MEM_callocN(sizeof(CurveMapping), "CurveMapping");
BKE_curvemapping_set_defaults(curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
-
BKE_curvemap_reset(curve->cm,
&(struct rctf){.xmin = 0, .ymin = 0.0, .xmax = 1.0, .ymax = 1.0},
CURVE_PRESET_LINE,
@@ -1669,7 +1669,7 @@ void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannelSet *chset)
ch->def = BKE_brush_builtin_channel_def_find(ch->idname);
if (!ch->def) {
- printf("failed to find brush definition");
+ printf("failed to find brush definition for %s\n", ch->idname);
ch->def = BKE_brush_default_channel_def();
}
else {
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 21a1180044e..cd9816c91bc 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -28,6 +28,7 @@
#include "BKE_colorband.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
+#include "BKE_curvemapping_cache.h"
#include "BKE_node.h"
#include "BKE_paint.h"
@@ -735,6 +736,56 @@ void BKE_brush_channelset_compat_load(BrushChannelSet *chset, Brush *brush, bool
}
}
+ATTR_NO_OPT static void reset_clay_mappings(BrushChannelSet *chset, bool strips)
+{
+ BrushMapping *mp = BRUSHSET_LOOKUP(chset, radius)->mappings + BRUSH_MAPPING_PRESSURE;
+ BKE_brush_mapping_ensure_write(mp);
+ CurveMapping *curve = mp->curve;
+
+ BKE_curvemapping_set_defaults(curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ BKE_curvemap_reset(curve->cm,
+ &(struct rctf){.xmin = 0, .ymin = 0.0, .xmax = 1.0, .ymax = 1.0},
+ CURVE_PRESET_LINE,
+ 1);
+ BKE_curvemapping_init(curve);
+
+ CurveMap *cuma = curve->cm;
+
+ if (!strips) { //[[0,0.200], [0.354,0.200], [0.595,0.210], [0.806,0.523], [1,1.000]
+ cuma->curve[0].x = 0.0f;
+ cuma->curve[0].y = 0.2f;
+
+ BKE_curvemap_insert(cuma, 0.35f, 0.2f);
+ BKE_curvemap_insert(cuma, 0.6f, 0.210f);
+ BKE_curvemap_insert(cuma, 0.8f, 0.525f);
+
+ BKE_curvemapping_changed(curve, true);
+ }
+ else {
+ //[[0,0], [0.250,0.050], [0.500,0.125], [0.750,0.422], [1,1]
+ cuma->curve[0].x = 0.0f;
+ cuma->curve[0].y = 0.55f;
+ BKE_curvemap_insert(cuma, 0.5f, 0.7f);
+ cuma->curve[2].x = 1.0f;
+ cuma->curve[2].y = 1.0f;
+ BKE_curvemapping_changed(curve, true);
+ }
+
+ mp = BRUSHSET_LOOKUP(chset, strength)->mappings + BRUSH_MAPPING_PRESSURE;
+ BKE_brush_mapping_ensure_write(mp);
+ curve = mp->curve;
+
+ BKE_curvemapping_set_defaults(curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ BKE_curvemap_reset(curve->cm,
+ &(struct rctf){.xmin = 0, .ymin = 0.0, .xmax = 1.0, .ymax = 1.0},
+ CURVE_PRESET_LINE,
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list