GPv3: Implementation of sculpt mode tools #120508

Merged
Lukas Tönne merged 98 commits from LukasTonne/blender:gp3-sculpt-tools into main 2024-04-25 20:20:41 +02:00
Member

This implements all the sculpt tools in Grease Pencil 3.

UI changes in the 3D view header and keymap entries for sculpt mode are
still minimal, more entries should be added once the relevant operators
are supported.

A set of utility functions and a shared base class
GreasePencilStrokeOperationCommon for sculpt operations has been added
to make individual operations less verbose.
The GreasePencilStrokeParams struct bundles common arguments to reduce
the amount of boilerplate code. The foreach_editable_drawing utility
function takes care of setting up the parameters and finding the right
drawings, so the tool only has to modify the data. Common features like
tracking mouse movement and inverting brush influence are handled by the
common base class.

Most operations are then relatively simple, with the exception of the
Grab and Clone operations.

  • Grab stores a stroke mask and weights on initialization of the
    stroke, rather than working with the usual selection mask.
  • Clone needs access to the clipboard, which requires exposing the
    clipboard in the editor API.
This implements all the sculpt tools in Grease Pencil 3. UI changes in the 3D view header and keymap entries for sculpt mode are still minimal, more entries should be added once the relevant operators are supported. A set of utility functions and a shared base class `GreasePencilStrokeOperationCommon` for sculpt operations has been added to make individual operations less verbose. The `GreasePencilStrokeParams` struct bundles common arguments to reduce the amount of boilerplate code. The `foreach_editable_drawing` utility function takes care of setting up the parameters and finding the right drawings, so the tool only has to modify the data. Common features like tracking mouse movement and inverting brush influence are handled by the common base class. Most operations are then relatively simple, with the exception of the Grab and Clone operations. - __Grab__ stores a stroke mask and weights on initialization of the stroke, rather than working with the usual selection mask. - __Clone__ needs access to the clipboard, which requires exposing the clipboard in the editor API.
Lukas Tönne added 74 commits 2024-04-11 10:50:58 +02:00
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
c5379f55d7
Removed unused parameters when creating GPv3 strokes.
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
d73680f819
Remove unused code.
657bca7846 Merged thickness sculpt tool branch for easier development.
This may be split up again for review, but developing shared sculpt
utilities for GPv3 tools is easier this way.
7715a41431 Revert usage of the OB_SCULPT mode for grease pencil v3.
Use the legacy OB_MODE_SCULPT_GPENCIL_LEGACY instead.
87c9ee48a3 Replace "common" virtual functions with a foreach function and callback.
This should have the same performance, but makes it easier to bind to
additional arguments (e.g. weights span in the grab tool). Each tool is
forced to implement the virtual functions, using the common base class
utilities.
Lukas Tönne added this to the Grease Pencil project 2024-04-11 10:51:06 +02:00
Falk David requested review from Falk David 2024-04-11 10:56:13 +02:00
Lukas Tönne added 1 commit 2024-04-11 11:15:15 +02:00
Member

During compilation I'm getting

blender/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc:2202:12: warning: no previous declaration for ‘blender::ed::greasepencil::Clipboard& blender::ed::greasepencil::ensure_grease_pencil_clipboard()[-Wmissing-declarations]
 2202 | Clipboard &ensure_grease_pencil_clipboard()
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
During compilation I'm getting ```bash blender/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc:2202:12: warning: no previous declaration for ‘blender::ed::greasepencil::Clipboard& blender::ed::greasepencil::ensure_grease_pencil_clipboard()’ [-Wmissing-declarations] 2202 | Clipboard &ensure_grease_pencil_clipboard() | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
Lukas Tönne added 1 commit 2024-04-11 14:22:29 +02:00
Sietse Brouwer reviewed 2024-04-11 19:16:48 +02:00
Sietse Brouwer left a comment
Member

Great work! I took a first peek at the tools: they all work smooth and behave as I expected.

I added two remarks related to multi frame editing.

Probably for a separate PR: there is no overlay yet for displaying selected strokes/points, right? I can see that sculpting on selected strokes/points is already working, but the selection state isn't visible in the viewport.

And: all is fine as long as I have one layer. With multiple layers, I get a crash in GreasePencilStrokeParams GreasePencilStrokeParams::from_context(), where there is something spooky going on with the context, resulting in null pointers for e.g. view3d and ob_orig.

Great work! I took a first peek at the tools: they all work smooth and behave as I expected. I added two remarks related to multi frame editing. Probably for a separate PR: there is no overlay yet for displaying selected strokes/points, right? I can see that sculpting on selected strokes/points is already working, but the selection state isn't visible in the viewport. And: all is fine as long as I have one layer. With multiple layers, I get a crash in `GreasePencilStrokeParams GreasePencilStrokeParams::from_context()`, where there is something spooky going on with the context, resulting in null pointers for e.g. `view3d` and `ob_orig`.
@ -0,0 +62,4 @@
return {};
}
const Layer &active_layer = *grease_pencil.get_active_layer();
Drawing *drawing = grease_pencil.get_editable_drawing_at(active_layer, scene.r.cfra);
Member

Multi frame editing should be taken into account here, so using something like retrieve_editable_drawings_from_layer(). But then a version that calculates the multi frame falloff – we don't have that flavour yet in utilities. See retrieve_editable_drawings_with_falloff() how you could do that.

Multi frame editing should be taken into account here, so using something like `retrieve_editable_drawings_from_layer()`. But then a version that calculates the multi frame falloff – we don't have that flavour yet in utilities. See `retrieve_editable_drawings_with_falloff()` how you could do that.
LukasTonne marked this conversation as resolved
@ -0,0 +75,4 @@
}
/* Apply to all editable drawings. */
return ed::greasepencil::retrieve_editable_drawings(scene, grease_pencil);
Member

You can use ed::greasepencil::retrieve_editable_drawings_with_falloff() here. That one calculates the multi_frame_falloff factor for the drawings.

You can use `ed::greasepencil::retrieve_editable_drawings_with_falloff()` here. That one calculates the `multi_frame_falloff` factor for the drawings.
LukasTonne marked this conversation as resolved
Hans Goudey reviewed 2024-04-11 21:26:49 +02:00
Hans Goudey left a comment
Member

Looks pretty good. I read through a fair amount of the PR and only noticed a few things.

Looks pretty good. I read through a fair amount of the PR and only noticed a few things.
@ -0,0 +44,4 @@
return mouse_delta;
}
Vector<ed::greasepencil::MutableDrawingInfo> get_drawings_for_sculpt(const bContext &C)
Member

ed is unnecessary here

`ed` is unnecessary here
Author
Member

This doesn't work for me, just using greasepencil::MutableDrawingInfo is turned into blender::ed::sculpt_paint::greasepencil::MutableDrawingInfo by the compiler. I have to add the ed:: part to disambiguate it.

This doesn't work for me, just using `greasepencil::MutableDrawingInfo` is turned into `blender::ed::sculpt_paint::greasepencil::MutableDrawingInfo` by the compiler. I have to add the `ed::` part to disambiguate it.
LukasTonne marked this conversation as resolved
@ -0,0 +54,4 @@
selection.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
float &radius = radii[point_i];
const float influence = brush_influence(*CTX_data_scene(&params.context),
Member

Seems important not to call CTX_data_scene for every point index. Better to retrieve as much as possible outside of the foreach_editable_drawing loop. Same with other places-- paint and brush and some others can always be retrieved outside of the loop.

Seems important not to call `CTX_data_scene` for every point index. Better to retrieve as much as possible outside of the `foreach_editable_drawing` loop. Same with other places-- `paint` and `brush` and some others can always be retrieved outside of the loop.
LukasTonne marked this conversation as resolved
Author
Member

Errors with multiple layers are caused by behavior of the CTX_data_*** functions that return nullptr outside of the main thread. I wasn't seeing any errors in regular debug mode, but get segfaults with ASAN enabled. It's unfortunate that this isn't more obvious, you just have to know when and where calling context functions is "allowed".

The advantage of the foreach_ style of methods is that one can get the relevant context info outside of loops and implicitly bind it to the callback. That way i should be able to avoid storing everything in the params struct, and just have local variables for the context data needed for a particular operation.

Errors with multiple layers are caused by behavior of the `CTX_data_***` functions that return nullptr outside of the main thread. I wasn't seeing any errors in regular debug mode, but get segfaults with ASAN enabled. It's unfortunate that this isn't more obvious, you just have to know when and where calling context functions is "allowed". The advantage of the `foreach_` style of methods is that one can get the relevant context info outside of loops and implicitly bind it to the callback. That way i should be able to avoid storing everything in the params struct, and just have local variables for the context data needed for a particular operation.
Lukas Tönne added 2 commits 2024-04-12 10:43:35 +02:00
Lukas Tönne added 1 commit 2024-04-12 10:50:14 +02:00
Lukas Tönne added 1 commit 2024-04-12 11:08:26 +02:00
Falk David requested changes 2024-04-12 15:33:58 +02:00
Dismissed
Falk David left a comment
Member

Did a full pass on this. Really like that all the tool implementation are this small, nice job!
Don't have any bigger concerns.

Did a full pass on this. Really like that all the tool implementation are this small, nice job! Don't have any bigger concerns.
@ -4696,0 +4696,4 @@
# Invoke sculpt operator
("grease_pencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
("grease_pencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS',
"ctrl": True}, {"properties": [("mode", 'INVERT')]}), # # Selection
Member

Looks like that comment is there by accident # # Selection

Looks like that comment is there by accident `# # Selection`
LukasTonne marked this conversation as resolved
@ -2440,0 +2391,4 @@
clipboard.curves = {};
clipboard.materials.clear_and_shrink();
clipboard.materials_in_source_num = 0;
MEM_delete(grease_pencil_clipboard);
Member

Should be enough to call MEM_delete to destruct everything inside.

Should be enough to call `MEM_delete` to destruct everything inside.
LukasTonne marked this conversation as resolved
@ -0,0 +45,4 @@
{
/* Note: GPv2 method, this does not return a different value for every invocation: the time-based
* part remains the same for one second and the pointer isn't guaranteed to be different. */
// unsigned int seed = (unsigned int)(BLI_time_now_seconds_i() & UINT_MAX);
Member

Looks like the commented code can just be removed.

Looks like the commented code can just be removed.
LukasTonne marked this conversation as resolved
@ -0,0 +128,4 @@
changed = true;
}
if (sculpt_mode_flag & GP_SCULPT_FLAGMODE_APPLY_UV) {
/* TODO stroke_u attribute not used yet. */
Member

Is this still a TODO?

Is this still a TODO?
LukasTonne marked this conversation as resolved
@ -0,0 +112,4 @@
changed = true;
}
if (sculpt_mode_flag & GP_SCULPT_FLAGMODE_APPLY_UV) {
/* TODO stroke_u attribute not used yet. */
Member

Is this still a TODO?

Is this still a TODO?
Author
Member

Should be ok with just the rotation attribute smoothing. GPv2 was also smoothing the uv_fac attribute, but afaik this will never be anything other than a linear interpolation along the length, with a possible scale + offset transformation from the UV modifier. There is RNA access to these attributes in GPv2, but anything the user might set there would get discarded by the next update in BKE_gpencil_stroke_uv_update. So the smooth tool does not actually do anything useful when smoothing the stroke UV.

Should be ok with just the `rotation` attribute smoothing. GPv2 was also smoothing the `uv_fac` attribute, but afaik this will never be anything other than a linear interpolation along the length, with a possible scale + offset transformation from the UV modifier. There is RNA access to these attributes in GPv2, but anything the user might set there would get discarded by the next update in `BKE_gpencil_stroke_uv_update`. So the smooth tool does not actually do anything useful when smoothing the stroke UV.
LukasTonne marked this conversation as resolved
Lukas Tönne added 5 commits 2024-04-13 09:57:17 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
978913cc7a
Removed outdated comments about UV rotation randomizing and smoothing.
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2024-04-13 12:27:23 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
2f7ff3ceca
Fix incorrect keymap property that broke the validation test.
Author
Member

@blender-bot build

@blender-bot build
Author
Member

@blender-bot build

@blender-bot build
Sietse Brouwer reviewed 2024-04-21 21:11:09 +02:00
@ -476,0 +507,4 @@
toolsettings->gp_sculpt.cur_falloff) :
1.0f;
editable_drawings.append(
{*drawing, layer.drawing_index_at(frame_number), frame_number, falloff});
Member

There was a bug fix in retrieve_editable_drawings_from_layer() that applies here too:
layer.drawing_index_at(frame_number) should in fact be a layer_index with

const int layer_index = *grease_pencil.get_layer_index(layer);

somewhere outside the loop.

There was [a bug fix](https://projects.blender.org/blender/blender/commit/91e50380d37528e9e91a506dd76764e131bcf6f3) in `retrieve_editable_drawings_from_layer()` that applies here too: `layer.drawing_index_at(frame_number)` should in fact be a `layer_index` with ``` const int layer_index = *grease_pencil.get_layer_index(layer); ``` somewhere outside the loop.
Author
Member

Thanks for catching this, fixed.

Thanks for catching this, fixed.
LukasTonne marked this conversation as resolved
Lukas Tönne added 2 commits 2024-04-22 09:47:34 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
965a9885d1
Fix incorrect use of drawing index instead of layer index.
Author
Member

@blender-bot build

@blender-bot build
Falk David requested review from Hans Goudey 2024-04-22 12:54:08 +02:00
Falk David approved these changes 2024-04-25 10:58:29 +02:00
Hans Goudey requested changes 2024-04-25 14:19:24 +02:00
Dismissed
Hans Goudey left a comment
Member

Overall structure is great. Just found one thread safety issue where the influence mask and weights are gathered.

Overall structure is great. Just found one thread safety issue where the influence mask and weights are gathered.
@ -0,0 +91,4 @@
(use_pressure ? sample.pressure : 1.0f);
/* Distance falloff. */
const int2 mval_i = int2(math::round(sample.mouse_position));
Member

There's some constant math being done for every element here. Maybe it's not noticeable, and I'm sure this will be much faster than GPv2 anyway, but just wanted to point it out as a place of possible improvement.

There's some constant math being done for every element here. Maybe it's not noticeable, and I'm sure this will be much faster than GPv2 anyway, but just wanted to point it out as a place of possible improvement.
Author
Member

I think this is good enough for now. The only meaningful operation i see that might be pulled out of the point loop would be the brush radius calculation. I'd rather leave it like this and not make the functions more complicated by adding parameters.

I think this is good enough for now. The only meaningful operation i see that might be pulled out of the point loop would be the brush radius calculation. I'd rather leave it like this and not make the functions more complicated by adding parameters.
LukasTonne marked this conversation as resolved
@ -0,0 +135,4 @@
const float influence = influence_base * brush_falloff;
if (influence > 0.0f) {
indices.append(point_i);
Member

Appending to a vector inside a threaded loop isn't threadsafe.
Maybe a good alternative is using one call to IndexMask::from_predicate to find the affected indices, then another loop to store the influences (using the index in the mask rather than the global index).
That might also avoid the need for the temporary indices vector.

Appending to a vector inside a threaded loop isn't threadsafe. Maybe a good alternative is using one call to `IndexMask::from_predicate` to find the affected indices, then another loop to store the influences (using the index in the mask rather than the global index). That might also avoid the need for the temporary indices vector.
LukasTonne marked this conversation as resolved
@ -0,0 +26,4 @@
/* Use a hash to generate random numbers. */
static float hash_rng(unsigned int seed1, unsigned int seed2, int index)
{
return BLI_hash_int_01(BLI_hash_int_3d(seed1, seed2, (unsigned int)index));
Member

uint32_t (here and elsewhere)

`uint32_t` (here and elsewhere)
LukasTonne marked this conversation as resolved
@ -139,3 +136,1 @@
total_weight[index] += w - w2;
dst[index] = src[index] + influence * dst[index] / total_weight[index];
}
auto mix_smoothed = [&](const int index, const float influence) {
Member

I think typically devirtualize_varray can apply this optimization without the code duplication

I think typically `devirtualize_varray` can apply this optimization without the code duplication
LukasTonne marked this conversation as resolved
Sietse Brouwer reviewed 2024-04-25 14:47:28 +02:00
Sietse Brouwer left a comment
Member

I added a few remarks concerning the UI.

In the toolbar no + - icons appear for the direction. To get those:
In rna_brush.cc:
Line 1015

    case PaintMode::SculptGPencil:
+   case PaintMode::SculptGreasePencil:

And in space_view3d.py some fixes for brush direction, falloff panel and 'Active Layer' switch:
Line 475

        # direction
        if brush.gpencil_sculpt_tool in {'THICKNESS', 'STRENGTH', 'PINCH', 'TWIST'}:
            layout.row().prop(brush, "direction", expand=True, text="")
        
        # Here or maybe around line 130?
        # Brush falloff
        layout.popover("VIEW3D_PT_tools_brush_falloff")
        
        # Active layer only switch
        layout.prop(gp_settings, "use_active_layer_only")

And to show the Multiframe editing properties:
space_view3d.py
Line 876

            if object_mode in {'PAINT_GREASE_PENCIL', 'EDIT', 'SCULPT_GPENCIL', 'WEIGHT_PAINT'}:
                row = layout.row(align=True)
                row.prop(tool_settings, "use_grease_pencil_multi_frame_editing", text="")

                if object_mode in {'EDIT', 'SCULPT_GPENCIL', 'WEIGHT_PAINT'}:
                    sub = row.row(align=True)
                    sub.enabled = tool_settings.use_grease_pencil_multi_frame_editing
                    sub.popover(
                        panel="VIEW3D_PT_grease_pencil_multi_frame",
                        text="Multiframe",
                    )
I added a few remarks concerning the UI. In the toolbar no `+` `-` icons appear for the direction. To get those: In `rna_brush.cc`: Line 1015 ``` case PaintMode::SculptGPencil: + case PaintMode::SculptGreasePencil: ``` And in `space_view3d.py` some fixes for brush direction, falloff panel and 'Active Layer' switch: Line 475 ``` # direction if brush.gpencil_sculpt_tool in {'THICKNESS', 'STRENGTH', 'PINCH', 'TWIST'}: layout.row().prop(brush, "direction", expand=True, text="") # Here or maybe around line 130? # Brush falloff layout.popover("VIEW3D_PT_tools_brush_falloff") # Active layer only switch layout.prop(gp_settings, "use_active_layer_only") ``` And to show the Multiframe editing properties: `space_view3d.py` Line 876 ``` if object_mode in {'PAINT_GREASE_PENCIL', 'EDIT', 'SCULPT_GPENCIL', 'WEIGHT_PAINT'}: row = layout.row(align=True) row.prop(tool_settings, "use_grease_pencil_multi_frame_editing", text="") if object_mode in {'EDIT', 'SCULPT_GPENCIL', 'WEIGHT_PAINT'}: sub = row.row(align=True) sub.enabled = tool_settings.use_grease_pencil_multi_frame_editing sub.popover( panel="VIEW3D_PT_grease_pencil_multi_frame", text="Multiframe", ) ```
@ -0,0 +88,4 @@
/* Basic strength factor from brush settings. */
const bool use_pressure = (brush.gpencil_settings->flag & GP_BRUSH_USE_PRESSURE);
const float influence_base = brush.alpha * multi_frame_falloff *
(use_pressure ? sample.pressure : 1.0f);
Member

Use BKE_brush_use_alpha_pressure(brush) and BKE_brush_alpha_get(scene, brush) here.

Use `BKE_brush_use_alpha_pressure(brush)` and `BKE_brush_alpha_get(scene, brush)` here.
Author
Member

I think it's correct now. Somebody should probably test this stuff with a tablet.

I _think_ it's correct now. Somebody should probably test this stuff with a tablet.
LukasTonne marked this conversation as resolved
@ -0,0 +117,4 @@
const float radius_squared = radius * radius;
const bool use_pressure = (brush.gpencil_settings->flag & GP_BRUSH_USE_PRESSURE);
const float influence_base = brush.alpha * multi_frame_falloff *
(use_pressure ? pressure : 1.0f);
Member

Same as above.

Same as above.
LukasTonne marked this conversation as resolved
@ -0,0 +147,4 @@
{
/* The basic setting is the brush's setting. */
bool invert = ((brush.gpencil_settings->sculpt_flag & GP_SCULPT_FLAG_INVERT) != 0) ||
(brush.gpencil_settings->sculpt_flag & BRUSH_DIR_IN);
Member

This should be (brush->flag & BRUSH_DIR_IN)

This should be `(brush->flag & BRUSH_DIR_IN)`
Author
Member

Yeah, super confusing. Also the GP_SCULPT_FLAG_INVERT and GP_SCULPT_FLAG_TMP_INVERT are completely unused, will throw them out.

Yeah, super confusing. Also the `GP_SCULPT_FLAG_INVERT` and `GP_SCULPT_FLAG_TMP_INVERT` are completely unused, will throw them out.
LukasTonne marked this conversation as resolved
Lukas Tönne added 2 commits 2024-04-25 15:05:52 +02:00
Lukas Tönne added 2 commits 2024-04-25 15:17:26 +02:00
Hans Goudey requested changes 2024-04-25 16:07:28 +02:00
Dismissed
Hans Goudey left a comment
Member

Can you merge main into this branch?

Can you merge main into this branch?
@ -0,0 +135,4 @@
IndexMask index_mask = IndexMask::from_predicate(
selection, GrainSize(4096), memory, [&](const int point_i) {
const float influence = calculate_influence(point_i);
Member

Not sure how I feel about calculating everything twice here. How about this?

Array<float> all_influences(selection.min_array_size());
const IndexMask influence_mask = IndexMask::from_predicate(selection, GrainSize(4096), memory, [&](const int point) { all_influences[point] = calculate_influence(point);
return all_influences[point] > 0.0f;
};
infuences.reinitialize(influence_mask.size());
array_utils::gather(all_influences, influence_mask, influences);

At the cost of a copy and potentially higher peak memory usage, that would avoid all the duplicate calculations.

Not sure how I feel about calculating everything twice here. How about this? ```Cpp Array<float> all_influences(selection.min_array_size()); const IndexMask influence_mask = IndexMask::from_predicate(selection, GrainSize(4096), memory, [&](const int point) { all_influences[point] = calculate_influence(point); return all_influences[point] > 0.0f; }; infuences.reinitialize(influence_mask.size()); array_utils::gather(all_influences, influence_mask, influences); ``` At the cost of a copy and potentially higher peak memory usage, that would avoid all the duplicate calculations.
LukasTonne marked this conversation as resolved
Lukas Tönne added 2 commits 2024-04-25 16:40:36 +02:00
Lukas Tönne requested review from Hans Goudey 2024-04-25 16:41:35 +02:00
Lukas Tönne added 2 commits 2024-04-25 16:54:15 +02:00
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
e8d8a1a7aa
Store influences in temp array to avoid calculating twice.
Hans Goudey approved these changes 2024-04-25 16:59:54 +02:00
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2024-04-25 17:17:04 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
bcc5da471e
Cleanup formatting
Author
Member

@blender-bot build

@blender-bot build
Sietse Brouwer reviewed 2024-04-25 17:49:08 +02:00
Sietse Brouwer left a comment
Member

Almost there! A last little change in the pressure handling and it's all good. I tested it with a tablet.

And btw, the direction toggle is perfect: the Ctrl key inverts the direction setting in the tool bar. That's how I implemented it in the weight paint tools also, and how GPv2 behaves – so all consistent.

Almost there! A last little change in the `pressure` handling and it's all good. I tested it with a tablet. And btw, the direction toggle is perfect: the `Ctrl` key inverts the direction setting in the tool bar. That's how I implemented it in the weight paint tools also, and how GPv2 behaves – so all consistent.
@ -0,0 +94,4 @@
BKE_brush_alpha_get(&scene, &brush) :
1.0f;
const float influence_base = brush_pressure * multi_frame_falloff *
(use_pressure ? sample.pressure : 1.0f);
Member

This is one pressure too many 😸 Now that we use the unified paint settings, we don't need the GP_BRUSH_USE_PRESSURE any more.
Change line 91-97 into this and you're good to go:

  const float brush_pressure = BKE_brush_use_alpha_pressure(&brush) ? sample.pressure : 1.0f;
  const float influence_base = BKE_brush_alpha_get(&scene, &brush) * brush_pressure *
                               multi_frame_falloff;
This is one pressure too many 😸 Now that we use the unified paint settings, we don't need the `GP_BRUSH_USE_PRESSURE` any more. Change line 91-97 into this and you're good to go: ``` const float brush_pressure = BKE_brush_use_alpha_pressure(&brush) ? sample.pressure : 1.0f; const float influence_base = BKE_brush_alpha_get(&scene, &brush) * brush_pressure * multi_frame_falloff; ```
LukasTonne marked this conversation as resolved
@ -0,0 +126,4 @@
BKE_brush_alpha_get(&scene, &brush) :
1.0f;
const float influence_base = brush_pressure * multi_frame_falloff *
(use_pressure ? pressure : 1.0f);
Member

Same as above. Line 124-129 can be:

  const float brush_pressure = BKE_brush_use_alpha_pressure(&brush) ? pressure : 1.0f;
  const float influence_base = BKE_brush_alpha_get(&scene, &brush) * brush_pressure *
                               multi_frame_falloff;
Same as above. Line 124-129 can be: ``` const float brush_pressure = BKE_brush_use_alpha_pressure(&brush) ? pressure : 1.0f; const float influence_base = BKE_brush_alpha_get(&scene, &brush) * brush_pressure * multi_frame_falloff; ```
LukasTonne marked this conversation as resolved
Lukas Tönne added 1 commit 2024-04-25 19:46:12 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
8f4bf68802
Fix incorrect brush influence factors from duplicate pressure factors.
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne merged commit 91f1f3fc06 into main 2024-04-25 20:20:41 +02:00
Lukas Tönne deleted branch gp3-sculpt-tools 2024-04-25 20:20:44 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#120508
No description provided.