Geometry Nodes: Add a 'Group ID' input to the Fill Curve node #114048
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#114048
Loading…
Reference in New Issue
No description provided.
Delete Branch "Douglas-Paul/blender:group-id-for-fill-curve-node"
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 adds a "Group ID" input to the Fill Curve node, per #102285.
The curve filling operation is performed separately for each group, so curves associated with different Group IDs do not intersect.
This implementation also supports Grease Pencil 3 curves.
The issue said to name the socket "Group Index", but I see that the preferred term has changed so I named it "Group ID" instead.
I have also attached a .blend file that exercises the new node input in a few different situations. (It includes a README text block that describes each test case.)
Very nice, thanks for the PR! I should have some time to review this in the coming days.
Looking good, I just have some suggestions for simplifications and performance improvements.
@ -32,2 +32,4 @@
b.add_input<decl::Geometry>("Curve").supported_type(
{GeometryComponent::Type::Curve, GeometryComponent::Type::GreasePencil});
b.add_input<decl::Int>("Group ID")
.default_value(0)
.default_value(0)
is unnecessary, that's the implicit default already.@ -78,0 +129,4 @@
data_evaluator.add(group_index_field);
data_evaluator.evaluate();
const VArray<int> curve_group_ids = data_evaluator.get_evaluated<int>(0);
This can have a special case for
curve_group_ids.is_single()
to avoid building selections.A simpler way to do this that will help optimization in the future is using a combination of
VectorSet<int>
andIndexMask::from_groups
. There are some examples of that already.Yeah, that had seemed like too much of a corner case to be worth adding special handling for, but I suppose it does make sense since it's low complexity.
Okay, I made the changes based off of how I see things being done in
node_geo_index_of_nearest.cc
. I'm not sure I agree it's simpler, but I understand how it's likely more efficient.Right, good point. Less so about simplicity I guess, more about making the pattern recognizable and making it use common code, so we can optimize them all at once at some point.
@ -113,2 +185,3 @@
static void curve_fill_calculate(GeometrySet &geometry_set, const GeometryNodeCurveFillMode mode)
/* Converts multiple CDT results into a single Mesh. */
static Mesh *cdts_to_mesh(const Vector<meshintersect::CDT_result<double>> &results)
We should try to avoid duplicating the logic in
cdt_to_mesh
.A better approach is probably creating the mesh, then filling each slice corresponding to a CDT result. Then the 1 mesh case is handled by that by default.
Also, you can pass
const Span<meshintersect::CDT_result
rather than a const reference to a vector.I definitely agree it's best to avoid duplicating the logic, but I don't see a way to combine them without a bit of a performance hit to the presumably much more common case of a single group.
Could you elaborate on what you mean by "filling each slice corresponding to a CDT result"? It sounds like you're talking about looping over the CDT results and adding each to the mesh, but that's what
cdts_to_mesh()
is already doing. I could eliminatecdt_to_mesh()
, but again I'm not sure if that's worth the added complexity for the simple cases.Ah, yes, thank you. It will be a while before things like that jump out at me.
Yes, I'd probably just remove
cdt_to_mesh
and make surecdts_to_mesh
isn't doing too much extra work in the 1 mesh case. But yeah, this can be changed later too.Just a few comments about parallelism and some simplification now. I'd still probably try to have less duplication in the mesh copying, but I'm already planning to change this a fair amount in #111061 later, so that can wait.
@ -78,0 +96,4 @@
input.face.reinitialize(mask.size());
int i_vert = 0;
int i_face = 0;
When writing this sort of code, we're always looking out for how we can make the serial part boil down to just integer addition. Here's my attempt at that:
Not tested, but I think it works logically. In #111061 I'm also refactoring the CDT code to use something more like the
OffsetIndices
format, which would remove the need for the "vector of vectors" approach which is much slower.Thank you, this makes a lot of sense. Just like "thinking with Portals", it will take some practice to get used to "thinking with offsets".
This inspired me to similarly re-implement
cdts_to_mesh()
using offsets.@ -78,0 +139,4 @@
const VArraySpan<int> group_ids_span(curve_group_ids);
const int domain_size = group_ids_span.size();
VectorSet<int> group_indexing;
This can be done in the constructor:
I was going to let you know these lines were copied from
node_geo_index_of_nearest.cc
so you could apply the same fix there, but I see you already did that.@ -172,12 +342,15 @@ static void curve_fill_calculate(GeometrySet &geometry_set, const GeometryNodeCu
static void node_geo_exec(GeoNodeExecParams params)
{
GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve");
ValueOrField<int> group_index_value_or_field = params.extract_input<ValueOrField<int>>(
I think this can be a bit simpler. Just
Field
should be fine here:The field evaluation should be basically free when the field just outputs a single value, then the other code should just fall back on the
groups.size()==1
case already.Thanks, that looks great! I made some tweaks to small style things, but other than that this is ready IMO.