GPv3: Envelope modifier implementation #118272
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
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#118272
Loading…
Reference in New Issue
No description provided.
Delete Branch "LukasTonne/blender:gp3-envelope-modifier"
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?
Ports the Envelope modifier from GPv2.
TODO
The GPv2 implementation of this modifier isn't well documented, so i took some time to try and understand what it does in detail, specifically for the generative Segments and Fills modes. The Deform mode is working as it is right now, even though the math is a little underexplained.
Expand wall of text
Segments mode
Lets start with a simple curve:
Segment mode creates simple 2-point lines between neighboring points. For a given spread
S
a line is created for every point pair(p-S+i, p+1+i)
. For example with a spreadS=3
around pointp
the new lines would be[p-3, p+]
,[p-2, p+2]
,[p-1, p+3]
.Most of these lines would be generated for neighboring points as well. In the example above, the line
[p-2, p+2]
would also be generated by the neighboring pointp-1
as[(p-1)-1, (p-1)+3]
and by pointp+1
as[(p+1)-3, (p+1)+2]
. Generally each point only needs to create one line, which drastically reduces the amount of redundant geometry.One caveat (possibly a bug?) is that lines at the end points of a curve would stray into negative index territory, so the indices get clamped (for non-cyclic curves). The result is that multiple curves between the same points get generated. For example, around
p=0
the generated lines[-3, +1]
,[-2, +2]
,[-1, +3]
are clamped to
[0, 1]
,[0, 2]
,[0, 3]
which overlaps with lines by point
p=1
:[0, 2]
,[0, 3]
,[0, 4]
.These lines are not deduplicated, which is the reason the modifier generates "thicker" lines at the end points:
Fills mode
This mode is more mysterious/buggy. Instead of creating individual 2-point lines for every envelope pair, it creates a closed curve of surrounding points:
The way it uses the Spread setting is a bit weird: adding +1 to the spread alternatingly expands the neighborhood left or right, but not symmetrically:
The curves also have gaps at the end points, which are probably a bug too.
The segments mode may not end up working exactly the same in GPv3.
Maybe @weasel as the author of the current modifier can help (https://archive.blender.org/developer/D14341).
WIP: GPv3: Envelope modifier implementationto GPv3: Envelope modifier implementation@blender-bot build
Overall this looks good. Just a have a small cleanup comment.
@ -0,0 +118,4 @@
const float diff_dir = p1_dir - p2_dir;
float u;
if (diff_dir != 0.0f) {
Maybe this could be a function? So that we can do:
or as a lambda
Will let @weasel check the math, but overall this looks good to me.
@blender-bot build
@ -0,0 +446,4 @@
const bool src_curve_cyclic,
const VArray<int> &src_material_indices,
const IndexRange dst_points,
const MutableSpan<int> curve_offsets,
const MutableSpan<int> curve_offsets
->MutableSpan<int> curve_offsets
There is no point in having a constant if the values themselves will change.
Oh? I've used this a lot before, pretty sure Hans wanted it this way in other reviews. The values are still mutable when the span itself is const. It's unlikely that anyone would accidentally change the span instead of accessing elements of it, but making it const can't hurt.
It took me a lot of thinking just to realize that this was data to be changed. I see a bunch of constants in parameters, and the void result, and my first thought is: what does this function even do?
@HooglyBoogly /
To me the more important is: https://developer.blender.org/docs/handbook/guidelines/c_cpp/#return-arguments since this is basically "returning" the result in these mutable spans.
So these should be named
r_curve_offsets
, etc.const
or noconst
. That will make it clear.Personally I don't use
const
in cases like this since visually it looks more separate. So I don't think I would have asked for it. But I think it's a very reasonable choice, and being more "strict" about const makes sense too! I don't really think a mutable span argument always needs ar_
prefix, it's often not helpful.@blender-bot build
Testing this, it seems to work exactly like the old code, except for the discussed bugfix on the end of fills. However I found a bug in the old version which is still there. Imo it is a bug, that in case the spread is higher than the length of the stroke, it keeps duplicating the end to end stroke. For non cyclic strokes, the spread should be clamped to
point_count-2
imo, such that the end to end stroke is never duplicated.Looking at the code I found no math errors. Just a minor performance regression in a weird special case.
@ -0,0 +180,4 @@
if (point == 0 || point >= point_num - 1) {
return unlimited_radius;
}
for (const int line_i : IndexRange(spread)) {
This loop is longer than in the original. Afaict it checks the same point multiple times at the boundaries, which does work, but is unecessary.
Clamping to relevant point spread now.
@blender-bot build