GPv3: Dissolve Operator #111079
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111079
Loading…
Reference in New Issue
No description provided.
Delete Branch "casey-bianco-davis/blender:GPv3-dissolve"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds the Dissolve operator.
note that this pull request contains some of the same menu code also included in #110938
I'm sure Falk will have more comments, just commented about a couple things I noticed reading through the code.
@ -561,0 +563,4 @@
* \{ */
enum DissolveMode {
/* dissolve all selected points */
Comment style: https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Comments
(begin with a capital, end with period)
Also, I'd suggest using
enum class
which forces nice name scoping:I fixed the comments, but when tried the
enum class
it broke theEnumPropertyItem
, because it could not be implicitly converted to int, but I don't know if that was just a mistake in how I implementing it.You can just use
int(DissolveMode::Points)
. That should do the trick here.Also can be
enum class DissolveMode : int8_t {
(since we know there won't be that many modes anyway).@ -561,0 +630,4 @@
curve_selection, false);
if (deselection_ranges.size() != 0) {
IndexRange first_range = deselection_ranges.first().shift(points.first());
There's a lot of nesting here-- I'd suggest splitting the operation for a CurvesGeometry to a separate function ot make it clearer what's going on.
@ -561,0 +635,4 @@
/* Because we are going to invert, fill with `!false` so that it does not get
* dissolved.*/
points_to_dissolve.as_mutable_span().slice(last_range).fill(!false);
!false
could just be written astrue
Added some comments.
I somewhat agree with @HooglyBoogly in that I think everything inside the
if (mode == DISSOLVE_BETWEEN || mode == DISSOLVE_UNSELECT) {
should be put into a static functionvoid get_points_to_dissolve(bke::CurvesGeometry &curves, const DissolveMode mode, MutableSpan<bool> r_points_to_dissolve)
.@ -561,0 +613,4 @@
/* Both `between` and `unselect` have the unselected point being dissolved.*/
if (mode == DISSOLVE_BETWEEN || mode == DISSOLVE_UNSELECT) {
threading::parallel_for(curves.curves_range(), 128, [&](const IndexRange range) {
for (const int curve_i : range) {
const int64_t curve_i
@ -561,0 +620,4 @@
if (!curve_selection.contains(true)) {
/* Because we are going to invert, fill with true so that it does not get
* dissolved.*/
points_to_dissolve.as_mutable_span().slice(points).fill(true);
It might make sense to define a
MutableSpan<bool> points_to_keep = points_to_dissolve.as_mutable_span();
with the comment above saying that this will be inverted later and thus it is the points to keep.@ -561,0 +648,4 @@
IndexMaskMemory memory;
IndexMask points_to_remove = IndexMask::from_bools(points_to_dissolve, memory);
if (!points_to_remove.is_empty()) {
It might make sense to build the
IndexMask
inside this if and check if theArray<bool>
containstrue
(usingas_span().contains(true)
).@ -561,0 +674,4 @@
/* Callbacks. */
ot->invoke = WM_menu_invoke;
ot->exec = grease_pencil_dissolve_exec;
ot->poll = editable_grease_pencil_poll;
I think this operator should only be working in point selection mode. Use
editable_grease_pencil_point_selection_poll
.Some comments to reduce indentations a bit more.
@ -561,0 +595,4 @@
}
/* Both `between` and `unselect` have the unselected point being the ones dissolved so we need
* to invert.*/
else if (mode == DISSOLVE_BETWEEN || mode == DISSOLVE_UNSELECT) {
The
else
case can be removed because we return in theif
before (no-else-after-return).If you'd like to make sure the mode is
DISSOLVE_BETWEEN
orDISSOLVE_UNSELECT
then I'd suggest to put an assert here:BLI_assert(ELEM(mode, DISSOLVE_BETWEEN, DISSOLVE_UNSELECT)
.@ -561,0 +607,4 @@
const Span<bool> curve_selection = points_to_dissolve.as_span().slice(points);
/* The unselected curves should not be dissolved.*/
if (!curve_selection.contains(true)) {
points_to_keep.slice(points).fill(true);
We can
continue;
here.@ -561,0 +611,4 @@
}
/* `between` is just `unselect` but with the first and last segments not geting
* dissolved.*/
else if (mode == DISSOLVE_BETWEEN) {
Because there is no code after this, I would prefer a
Looks good :) I will merge this soon.
Reminder to merge the PR :)
Could you update PR to match the comment style?: https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Comments
@ -561,0 +599,4 @@
}
/* Both `between` and `unselect` have the unselected point being the ones dissolved so we need
* to invert.*/
add space between
.
and*/
i.e.:
... to invert . */
@ -561,0 +603,4 @@
BLI_assert(ELEM(mode, DissolveMode::BETWEEN, DissolveMode::UNSELECT));
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
/* Because we are going to invert, these become the points to keep.*/
add space between
.
and*/
Above change is required at few more places in PR
@blender-bot build
GPv3: Dissolve Operator.to GPv3: Dissolve Operatortests are failing on bots (very likely due to the outdated code).
@casey-bianco-davis , could you update again with main branch?
or should we merge the PR directly?
@HooglyBoogly ^
Fine to merge I think. Though that does raise the point of all of this new GP code being uncovered by regression tests!
@blender-bot build