WIP: Geometry Nodes: Curve intersections #109393
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109393
Loading…
Reference in New Issue
No description provided.
Delete Branch "CharlieJolly/blender:gn-curve-intersections"
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?
PR updating my old patch D15624 to the new development site.
https://archive.blender.org/developer/D15624
Outputs curve intersections as a collection of points.
Three modes:
Self - checks a spline for self intersections only
All - checks all spline edges for intersections
Plane - checks all spline edges for intersections with a plane
Inspired by this post in stackexchange:
https://blender.stackexchange.com/questions/264070/geometrynodes-curve-intersections
Finally had some time to port over some of my old patches to the new development site.
I think this is a nice feature, and it's been through a lot already, so it should be worth finishing!
My only larger comment is that I think this node should propagate attributes from the source curves. That probably adds a fair amount of complexity to the code, but I think it's fairly essential for the node to work as expected. Let me know if you'd like advice for that part in chat.
@ -675,3 +675,2 @@
classes = (
NODE_MT_geometry_node_add_all,
classes = (NODE_MT_geometry_node_add_all,
Unrelated formatting changes in this file
@ -290,6 +290,8 @@ class CurvesGeometry : public ::CurvesGeometry {
Span<float3> evaluated_tangents() const;
Span<float3> evaluated_normals() const;
Span<float3> evaluated_positions_for_curve(int curve_index) const;
We decided to avoid adding functions like this, and just rely on the combination of local variables
OffsetIndices
andSpan<float3>
in calling functions. (See uses ofevaluated_points_by_curve
)@ -0,0 +26,4 @@
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Geometry>(N_("Curve")).supported_type(GeometryComponent::Type::Curve);
The
N_
translation markers are unnecessary now actually :)They were made automatic a few weeks ago
@ -0,0 +38,4 @@
.subtype(PROP_DISTANCE)
.make_available(
[](bNode &node) { node_storage(node).mode = GEO_NODE_CURVE_INTERSECT_PLANE; })
.description(N_("Plane offset"));
The description shouldn't be the same as the input name :P
For these offset inputs, I'm not sure what they do right now-- the descriptions should probably say in which direction the offset is.
Removed description. This is like Offset used in Set Position.
Hmm, so can the offset be achieved by using a set position node afterwards?
@ -0,0 +92,4 @@
bool intersects;
};
struct CurveInfo {
I think this
CurveInfo
array is unnecessary. With the indices in the BVH tree, the raw data can be accessed directly, andprocess
could be a separate boolean array or bit vector.When the patch started it was using the old spline api. I think this is a hangover from that way of thinking.
@ -0,0 +169,4 @@
for (const int64_t curve_i : src_curves.curves_range()) {
const CurveInfo &curveinfo = curve_data[curve_i];
const int totpoints = curveinfo.positions.size() - 1;
const int loopcount = curveinfo.cyclic ? totpoints + 1 : totpoints;
This can use the function
curves::segments_num
@ -0,0 +189,4 @@
}
/* Based on isect_line_plane_v3 with check that lines cross between start and end points. */
static bool isect_line_plane_crossing(const float3 point_1,
This sort of function shouldn't be specific to this node IMO. There's a precedent for including utilities like this in the newer BLI math headers. See
isect_seg_seg
. Maybe this could beisect_seg_plane
?Will add to BLI math if patch is accepted. Easier to keep with patch whilst it is in development.
The function is based on isect_line_plane_v3 with an additional check that lines cross between start and end points. It also stores the lambda.
@ -0,0 +265,4 @@
continue;
}
curve_plane_intersections_to_points(
Looks like multiple threads are appending to the same vector here, which isn't thread-safe. Maybe it would work to accumulate the intersections per thread with
EnumerableThreadSpecific
and then combine them at the end?@ -0,0 +306,4 @@
BVHTree *bvhtree = create_curve_segment_bvhtree(src_curves, &curve_segments);
const int max_segments = curve_segments.size() + 1;
Array<Vector<OutputData>> intersection_output_data;
Maybe this array wouldn't have to be so big with the
EnumerableThreadSpecific
suggestion from above.@ -0,0 +313,4 @@
Vector<OutputData> output_data;
Vector<int> curve_ids;
Vector<int> bvh_indices;
bvh_indices.reserve(max_segments);
Allocating something
curve_segments
in size for every segment and then freeing it seems a bit inefficient, maybe that's not right?@ -0,0 +367,4 @@
});
for (int64_t i : intersection_output_data.index_range()) {
const Vector<OutputData> data = intersection_output_data[i];
Careful, this line copies the
Vector
without a&
@ -0,0 +387,4 @@
AnonymousAttributeIDPtr curve_index_attr_id = params.get_output_anonymous_attribute_id_if_needed(
"Curve Index");
lazy_threading::send_hint();
Most code shouldn't need to do this manually,
parallel_for
calls that end up using threading do that already@ -0,0 +434,4 @@
Vector<float3> r_position;
Vector<int> r_curve_id;
for (auto begin = std::make_move_iterator(r_data.begin()),
Should be fine to write directly to the attributes, without the temporary
r_position
andr_curve_id
vectors.WIP: D15624 Curve intersectionsto WIP: Geometry Nodes: Curve intersectionsIs it really necessary to have a plane mode?
@HooglyBoogly for attributes are you thinking the same as for the Curve to Points node e.g. Normal, Tangent etc?
No, I don't think so, just the attributes stored on the curves.
16e55403d7
to9d8f6edf5b
Forced push commit because I had squashed and amended commits locally.
Last commit:
Still need to look at passing attributes etc
Trim curves between first and last intersections provides a way to Trim Loose Ends.
If you point out the fact that this node is very similar to the Closest Neighbors node (#110675), then it turns out that this is not a real practical application node, but just a way to output the intersection factors array field on curve domains as a point cloud. All the other operations look like just working with data arrays.
At least i don't see other case to use this points. But as you have shown (#109393 (comment)), this data may be relevant a lot. But not in the form of outgoing geometry and group id fields, ... .
A similar concept a year ago i considered as an implementation of the output of topology data arrays (devtalk: Access to geometry data. Post 7, point 2). A useful experiment, but it seems to break how we want to represent this kind of data (as array attribute).
@mod_moder the comment about the closest neighbour node was only to reference the use of
EnumerableThreadSpecific
to make it thread safe and to address some comments from Hans.This patch is WIP so what data and how the data is exposed is still to be decided. Since intersections can occur between points, that data is exposed by the Factor and Length. It's useful to have this available for testing etc. Offset mode which was proposed on the old system could be replaced by using the Direction data for example. Curve index provides data to determine which curve the intersection belongs to.
Checkout
From your project repository, check out a new branch and test the changes.