Fix #117997: Crash trying to copy vertex group attributes as spans #119212

Merged
Lukas Tönne merged 6 commits from LukasTonne/blender:fix-curve-to-mesh-dvert-attributes into main 2024-03-11 20:52:24 +01:00
Member

Grease Pencil provides custom vertex group attributes as VArrays that
are a view on the MDeformVert buffer. These attributes are not spans,
which the curve conversion code was expecting. Non-span VArrays must be
materialized first.

Grease Pencil provides custom vertex group attributes as VArrays that are a view on the `MDeformVert` buffer. These attributes are not spans, which the curve conversion code was expecting. Non-span VArrays must be materialized first.
Lukas Tönne added 1 commit 2024-03-08 16:37:23 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
405d7adf94
Fix #117997: Crash trying to copy vertex group attributes as spans.
Grease Pencil provides custom vertex group attributes as VArrays that
are a view on the `MDeformVert` buffer. These attributes are not spans,
which the curve conversion code was expecting. Non-span VArrays must be
materialized first.
Lukas Tönne added this to the Grease Pencil project 2024-03-08 16:37:26 +01:00
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey requested changes 2024-03-08 16:42:17 +01:00
Dismissed
@ -381,0 +383,4 @@
buffer.reinitialize(curves.evaluated_points_num() * src.type().size());
GMutableSpan eval{src.type(), buffer.data(), curves.evaluated_points_num()};
curves.ensure_can_interpolate_to_evaluated();
Member

ensure_can_interpolate_to_evaluated should be called at some higher level before all this interpolation needs to happen

`ensure_can_interpolate_to_evaluated` should be called at some higher level before all this interpolation needs to happen
LukasTonne marked this conversation as resolved
@ -381,1 +388,4 @@
return eval;
}
GArray src_buffer(src.type(), src.size());
Member

GVArraySpan is a utility to do this

`GVArraySpan` is a utility to do this
Author
Member

I don't see how this would work: GVArraySpan can wrap the input src array but is not mutable (can't materialize into it). GVMutableArraySpan is mutable but can't be simply constructed from the immutable src buffer.

I don't see how this would work: `GVArraySpan` can wrap the input `src` array but is not mutable (can't materialize into it). `GVMutableArraySpan` is mutable but can't be simply constructed from the immutable `src` buffer.

But this is src buffer and should not be mutable, no?

But this is *src* buffer and should not be mutable, no?
Author
Member

Ok, looked into the constructor and it actually does a materialize internally. That wasn't clear to me.

Ok, looked into the constructor and it actually does a `materialize` internally. That wasn't clear to me.
LukasTonne marked this conversation as resolved
@ -381,1 +389,4 @@
}
GArray src_buffer(src.type(), src.size());
src.materialize_to_uninitialized(src_buffer.data());
Member

Seems worth also having a fast path for curves.is_single_type(CURVE_TYPE_POLY) here. The materialize can happen directly into the buffer.

Seems worth also having a fast path for `curves.is_single_type(CURVE_TYPE_POLY)` here. The `materialize` can happen directly into the `buffer`.
Author
Member

I don't think we can directly materialize into the output buffer because of the interpolate_to_evaluated call. The input array is per control point, the output is per evaluated point.

I don't think we can directly materialize into the output buffer because of the `interpolate_to_evaluated` call. The input array is per control point, the output is per evaluated point.
Member

When curves.is_single_type(CURVE_TYPE_POLY) is true, there is the same number of control point and evaluated points. That optimization is done just above, except that it requires is_span() there.

When `curves.is_single_type(CURVE_TYPE_POLY)` is true, there is the same number of control point and evaluated points. That optimization is done just above, except that it requires `is_span()` there.
Author
Member

Ok, makes sense. I'll add a comment though, because i don't think it's obvious why this works for poly curves.

Ok, makes sense. I'll add a comment though, because i don't think it's obvious why this works for poly curves.
LukasTonne marked this conversation as resolved
Lukas Tönne added 4 commits 2024-03-11 11:17:52 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
5524132763
Add back fast path for poly curves.
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2024-03-11 12:17:28 +01:00
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
84194aadb5
Merge branch 'main' into fix-curve-to-mesh-dvert-attributes
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey approved these changes 2024-03-11 19:35:36 +01:00
Lukas Tönne merged commit 054ef616ce into main 2024-03-11 20:52:24 +01:00
Lukas Tönne deleted branch fix-curve-to-mesh-dvert-attributes 2024-03-11 20:52:26 +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
3 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#119212
No description provided.