GPv3: Refactor code for the hard eraser #111390
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
Asset Browser Project
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111390
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "amelief/blender:gpv3-erase-operator-refactor"
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?
This patch refactors most of the code of the hard eraser, both for readability purpose, and to prepare the integration of the soft mode of the eraser.
The refactoring includes :
SegmentCircleIntersection
,PointCircleSide
, andPointTransferData
to handle the data more easily,compute_topology_change
function that handles point insertion, removal, and curve splitting for curves geometry.b564fc1610
to9dd9bc918d
Take my comments in the context of what you find reasonable, obviously you have a better idea of what's possible here.
I'd guess the most efficient way to transfer attribute when some points are copied and some are interpolated is to do it in two loops, where one selects the source points with an index mask and the other uses the
int,float
combination. But it's probably not needed here, if this makes the code easier to deal with, that's good :)@ -115,1 +115,4 @@
struct SegmentCircleIntersection {
/* Position of the intersection in the segment. */
float factor{0.0f};
It's not in the style guide I guess, but usually these defaults are written with
=
@ -116,0 +121,4 @@
* circle, false if it corresponds to an outside/inside transition . */
bool inside_outside_intersection{false};
};
enum PointCircleSide { Outside, OutsideInsideBoundary, InsideOutsideBoundary, Inside };
enum class
is generally preferred since it requires each item to be scoped with the name of the enum. Though it's a bit longer, the context is usually helpful when reading code.@ -144,0 +148,4 @@
const int64_t squared_radius,
float &r_mu0,
float &r_mu1,
PointCircleSide &point_side,
Return arguments usually have the
r_
prefix@ -254,0 +258,4 @@
const bke::CurvesGeometry &src,
const Span<float2> screen_space_positions,
MutableSpan<PointCircleSide> r_point_side,
MutableSpan<Vector<SegmentCircleIntersection>> r_intersections) const
Not sure about the details of this case, but though the
Array<Vector>>
storage is pretty easy to use, it can be very slow and memory intensive. The overhead of a vector per point can make a big difference. Ultimately that's the goal of classes likeOffsetIndices
-- to make one alternative, slicing larger contiguous arrays, more intuitive.Agree. It was so much easier to use
Array<Vector>
to figure out how to deal with intersections, because for the hard eraser there's a max of 2 intersections per segment, but for the soft eraser, this number can be larger, depending on the brush's falloff curve.This number is the same for each segment though, so I think it's possible indeed to use a contiguous array while keeping multithread computation..
Let me know what you think of my proposed solution for this (commit
1d1f030ef0
).Yeah, seems good-- a bit of a complexity cost but hopefully people notice the tool is fast :P And if
intersections_max_per_segment
is ever too big, making it wasteful, offsets could be used too.@ -323,0 +365,4 @@
*
*/
struct PointTransferData {
int64_t src_point;
I'd recommend sticking with 32 bit integers (
int
) unless there's a reason not to. For the forseable future I don't see us supporting more than 2 billion points in these geometries, and the 2x memory consumption cam also make a difference.@ -460,3 +476,1 @@
const IndexRange dst_points(dst_interm_curves_offsets[src_curve],
dst_interm_curves_offsets[src_curve + 1] -
dst_interm_curves_offsets[src_curve]);
const IndexRange dst_points_range(dst_interm_curves_offsets[src_curve],
Looks like this variable rename might not be necessary?