GPv3: Curve to Points node #113634

Manually merged
Dalai Felinto merged 0 commits from dfelinto/blender:grease-nodes-curve-to-points into main 2023-10-16 11:51:33 +02:00

I would commit this as two commits:

  1. The propagation commit with all the related updates.
  2. The node using it.

Part of #113602.

I would commit this as two commits: 1. The propagation commit with all the related updates. 2. The node using it. Part of #113602.
Dalai Felinto added the
Interest
Geometry Nodes
Module
Grease Pencil
labels 2023-10-13 00:48:21 +02:00
Hans Goudey was assigned by Dalai Felinto 2023-10-13 00:48:22 +02:00
Jacques Lucke was assigned by Dalai Felinto 2023-10-13 01:28:18 +02:00
Author
Owner

My test file: grease-nodes.blend

My test file: [grease-nodes.blend](/attachments/8b82d720-5e66-4984-9572-43a179f12157)
Jacques Lucke was unassigned by Hans Goudey 2023-10-13 08:58:55 +02:00
Hans Goudey removed their assignment 2023-10-13 08:58:55 +02:00
Hans Goudey requested review from Jacques Lucke 2023-10-13 08:59:03 +02:00
Hans Goudey requested review from Hans Goudey 2023-10-13 08:59:03 +02:00
Hans Goudey reviewed 2023-10-13 10:08:44 +02:00
Hans Goudey left a comment
Member

Looking at it again, the call to geometry.replace_instances(pointcloud_instances); inside the modify_geometry_sets loop does seem suspect, since there might be sub-instances that will still be processed by the loop. It might be ugly, but I worry we'd have to add to the existing instances in the geometry set rather than replace them. @JacquesLucke may have a better idea too.

I would suggest making propagate_attributes_from_layer_to_instances into a free function that just takes the source and destination attribute accessors, to make it clearer what data it's using.

Looking at it again, the call to `geometry.replace_instances(pointcloud_instances);` inside the `modify_geometry_sets` loop does seem suspect, since there might be sub-instances that will still be processed by the loop. It might be ugly, but I worry we'd have to add to the existing instances in the geometry set rather than replace them. @JacquesLucke may have a better idea too. I would suggest making `propagate_attributes_from_layer_to_instances` into a free function that just takes the source and destination attribute accessors, to make it clearer what data it's using.
@ -608,0 +608,4 @@
void GeometrySet::propagate_attributes_from_layer_to_instances(
const AnonymousAttributePropagationInfo &propagation_info)
{
Map<AttributeIDRef, AttributeKind> attributes_to_propagate;
Member

I'd suggest a couple changes here, I wrote it out below just to make sure it would work

  • Avoid gather_attributes_for_propagation and work at a slightly lower abstraction level, since we're really just dealing with two attribute accessors here
  • Also handle the case where the source attribute doesn't have sharing info or isn't a span, just to avoid making that assumption in too many unnecessary places in case we want to change those things in the future
  const AttributeAccessor src_attributes = this->get_grease_pencil()->attributes();
  MutableAttributeAccessor dst_attributes =
      this->get_instances_for_write()->attributes_for_write();

  src_attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) {
    if (id.is_anonymous() && !propagation_info.propagate(id.anonymous_id())) {
      return true;
    }
    const GAttributeReader src = src_attributes.lookup(id, ATTR_DOMAIN_LAYER);
    if (src.sharing_info && src.varray.is_span()) {
      const AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info);
      if (dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, meta_data.data_type, init)) {
        return true;
      }
    }
    GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span(
        id, ATTR_DOMAIN_INSTANCE, meta_data.data_type);
    if (!dst) {
      return true;
    }
    array_utils::copy(src.varray, dst.span);
    dst.finish();
    return true;
  });
I'd suggest a couple changes here, I wrote it out below just to make sure it would work - Avoid `gather_attributes_for_propagation` and work at a slightly lower abstraction level, since we're really just dealing with two attribute accessors here - Also handle the case where the source attribute doesn't have sharing info or isn't a span, just to avoid making that assumption in too many unnecessary places in case we want to change those things in the future ```cpp const AttributeAccessor src_attributes = this->get_grease_pencil()->attributes(); MutableAttributeAccessor dst_attributes = this->get_instances_for_write()->attributes_for_write(); src_attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) { if (id.is_anonymous() && !propagation_info.propagate(id.anonymous_id())) { return true; } const GAttributeReader src = src_attributes.lookup(id, ATTR_DOMAIN_LAYER); if (src.sharing_info && src.varray.is_span()) { const AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info); if (dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, meta_data.data_type, init)) { return true; } } GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span( id, ATTR_DOMAIN_INSTANCE, meta_data.data_type); if (!dst) { return true; } array_utils::copy(src.varray, dst.span); dst.finish(); return true; }); ```
dfelinto marked this conversation as resolved
Dalai Felinto force-pushed grease-nodes-curve-to-points from 529f96a821 to c75ced06cb 2023-10-13 10:09:44 +02:00 Compare
Author
Owner

@HooglyBoogly I incorporated your changes (thanks for the code by the way), see if I got it right what you meant (I made the function static now).

As for the geometry.replace_instances this is what we do already (in main) for the curves. So if this is wrong I suspect it is wrong in main itself too.

~~@HooglyBoogly I incorporated your changes (thanks for the code by the way), see if I got it right what you meant (I made the function static now).~~ ~~As for the `geometry.replace_instances` this is what we do already (in main) for the curves. So if this is wrong I suspect it is wrong in main itself too.~~
Author
Owner

Ah I see the difference. For the curves we are not mingling with the instances.

Ah I see the difference. For the curves we are not mingling with the instances.
Dalai Felinto force-pushed grease-nodes-curve-to-points from 484ea907f4 to fc9652f591 2023-10-13 16:27:36 +02:00 Compare
Hans Goudey approved these changes 2023-10-13 16:29:08 +02:00
Dalai Felinto removed review request for Jacques Lucke 2023-10-13 16:29:52 +02:00
Dalai Felinto closed this pull request 2023-10-13 16:35:04 +02:00
Author
Owner

Committed as:

Committed as: * 1f680c38592b * 6853d787dbe4
Dalai Felinto reopened this pull request 2023-10-16 11:50:19 +02:00
Dalai Felinto manually merged commit 1f680c3859 into main 2023-10-16 11:51:33 +02:00
Dalai Felinto deleted branch grease-nodes-curve-to-points 2023-10-16 11:51:42 +02:00
Sign in to join this conversation.
No reviewers
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#113634
No description provided.