Fix: Curves extrude with all points selected #117095

Merged
Hans Goudey merged 3 commits from laurynas/blender:fix-curves-extrude into main 2024-01-16 21:59:25 +01:00
Contributor

CurvesGeometry has no ".selection" attribute when all control points
are selected. The earlier code assumed that the attribute always exists.
Also Python tests are added for the "extrude" operator.

CurvesGeometry has no ".selection" attribute when all control points are selected. The earlier code assumed that the attribute always exists. Also Python tests are added for the "extrude" operator.
Laurynas Duburas added 1 commit 2024-01-13 18:02:48 +01:00
ef3ba6dfa2 Fix: Curves extrude with all points selected
CurvesGeometry has no ".selected" attribute when all control points are selected.
The earlier code assumed that ".selected" always exists.
Also Python test is added for "extrude" operator.
Laurynas Duburas requested review from Hans Goudey 2024-01-13 18:03:07 +01:00
Hans Goudey reviewed 2024-01-16 16:55:27 +01:00
Hans Goudey left a comment
Member

I wonder if a simpler solution is checking whether extruded_points.size() == curves.points_num(). Then the extrude code won't do anything I think, right?

I wonder if a simpler solution is checking whether `extruded_points.size() == curves.points_num()`. Then the extrude code won't do anything I think, right?
@ -277,3 +278,3 @@
const bke::AttributeAccessor src_attributes = curves.attributes();
const GVArraySpan src_selection = *src_attributes.lookup(".selection", bke::AttrDomain::Point);
const bool true_ = true;
Member

By passing CD_PROP_BOOL, the attribute will always be read as a boolean (using implicit conversions if necessary).

By passing `CD_PROP_BOOL`, the attribute will always be read as a boolean (using implicit conversions if necessary).
Author
Contributor

I wonder if a simpler solution is checking whether extruded_points.size() == curves.points_num(). Then the extrude code won't do anything I think, right?

No. It will append one point at both ends. And this also applies if there is more than one curve: each will get two new points.

What if to return back to always check extruded_points.size() == curves.points_num() and then either lookup(const AttributeIDRef &attribute_id, const AttrDomain domain) or GVArray::ForSingle(const CPPType &type, const int64_t size, const void *value) ?
Or maybe check if lookupreturns empty GAttributeReaderthen call GVArray::ForSingle

> I wonder if a simpler solution is checking whether `extruded_points.size() == curves.points_num()`. Then the extrude code won't do anything I think, right? No. It will append one point at both ends. And this also applies if there is more than one curve: each will get two new points. What if to return back to always check `extruded_points.size() == curves.points_num()` and then either `lookup(const AttributeIDRef &attribute_id, const AttrDomain domain)` or `GVArray::ForSingle(const CPPType &type, const int64_t size, const void *value)` ? Or maybe check if `lookup`returns empty `GAttributeReader`then call `GVArray::ForSingle`
Member

Ah, right, of course. That might work, but this seems a bit simpler maybe?

GVArray src_selection = *attributes.lookup(".selection", bke::AttrDomain::Point);
if (!src_selection) {
  src_selection = VArray<bool>::ForSingle(true, curves.points_num());
}
Ah, right, of course. That might work, but this seems a bit simpler maybe? ```cpp GVArray src_selection = *attributes.lookup(".selection", bke::AttrDomain::Point); if (!src_selection) { src_selection = VArray<bool>::ForSingle(true, curves.points_num()); }
Laurynas Duburas added 2 commits 2024-01-16 20:17:22 +01:00
Author
Contributor

Changed, but had to add conversion:

const GVArraySpan src_selection = src_selection_array;
Changed, but had to add conversion: ```c const GVArraySpan src_selection = src_selection_array; ```
Hans Goudey approved these changes 2024-01-16 21:58:08 +01:00
Hans Goudey merged commit a6fd1f5034 into main 2024-01-16 21:59:25 +01:00
Laurynas Duburas deleted branch fix-curves-extrude 2024-01-16 22:15:25 +01: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#117095
No description provided.