Transform: support properly transforming implicitly shared positions #120631

Closed
Jacques Lucke wants to merge 1 commits from JacquesLucke/blender:transform-data-copy into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

There seems to be a fairly fundamental problem with transforming points in curves edit mode right now. The transform code keeps non-const pointers into potentially shared (and therefore immutable) position arrays. This is not possible allowed with implicitly-shared data. Instead, the transform code should work on a local copy of the data that it actually owns and then copy the changes back into the geometry.

I don't know the transform code all that well, so it's possible that this has been fixed in a different way elsewhere already. Some feedback would be welcome.

There seems to be a fairly fundamental problem with transforming points in curves edit mode right now. The transform code keeps non-const pointers into potentially shared (and therefore immutable) position arrays. This is not possible allowed with implicitly-shared data. Instead, the transform code should work on a local copy of the data that it actually owns and then copy the changes back into the geometry. I don't know the transform code all that well, so it's possible that this has been fixed in a different way elsewhere already. Some feedback would be welcome.
Jacques Lucke added 1 commit 2024-04-14 12:07:10 +02:00
Jacques Lucke requested review from Germano Cavalcante 2024-04-14 12:09:51 +02:00
Jacques Lucke requested review from Hans Goudey 2024-04-14 12:09:52 +02:00

I'm not a big fan of the idea of increasing the size of TransData (with the float loc_copy[3] member). It would be better if we could shorten this struct. To give you an idea, when we transform a mesh with Proportional Editing enabled, the number of TransData is equal to the number of vertices which causes memory usage to be greater than that of the mesh itself.

If we really need a copy with the curve locations. We could allocate an array and reference it in tc->custom.type.data. This member is customizable for each type of "transform_convert". It can be created and set within the transform_convert_curves.cc file.


(More information that might be useful:)

  • To update positions during transformation. Just edit the recalcData_curves function.
  • If it is useful to call a function at the end of the transformation, simply create a callback and set it to the special_aftertrans_update member of TransConvertTypeInfo.
I'm not a big fan of the idea of increasing the size of `TransData` (with the `float loc_copy[3]` member). It would be better if we could shorten this struct. To give you an idea, when we transform a mesh with Proportional Editing enabled, the number of `TransData` is equal to the number of vertices which causes memory usage to be greater than that of the mesh itself. If we really need a copy with the curve locations. We could allocate an array and reference it in `tc->custom.type.data`. This member is customizable for each type of "transform_convert". It can be created and set within the `transform_convert_curves.cc` file. --- (More information that might be useful:) - To update positions during transformation. Just edit the `recalcData_curves` function. - If it is useful to call a function at the end of the transformation, simply create a callback and set it to the `special_aftertrans_update` member of `TransConvertTypeInfo`.
Member

I agree that keeping pointers to mutable shared data is problematic. I've removed them from a fair amount of sculpt code for the same reasons.

I think a better long term solution would be to completely replace the TransData::iloc pointer. The only thing the transform system should need to store per element is an index (or a BMVert pointer for BMesh). Instead the transform system should retrieve the data on-demand and write it back to the geometry as a separate step.

I agree that keeping pointers to mutable shared data is problematic. I've removed them from a fair amount of sculpt code for the same reasons. I think a better long term solution would be to completely replace the `TransData::iloc` pointer. The only thing the transform system should need to store per element is an index (or a `BMVert` pointer for BMesh). Instead the transform system should retrieve the data on-demand and write it back to the geometry as a separate step.
Contributor

I like array in tc->custom.type.data solution more too.
Maybe I could implement it in #120222, because in any case I'll have to add Bezier handles to the solution?

I like array in `tc->custom.type.data` solution more too. Maybe I could implement it in #120222, because in any case I'll have to add Bezier handles to the solution?
Author
Member

@laurynas it would be very helpful if you could look into fixing this issue properly. I'd recommend doing it separate from your existing patch though, as the problem exists in main already.

@laurynas it would be very helpful if you could look into fixing this issue properly. I'd recommend doing it separate from your existing patch though, as the problem exists in `main` already.
Member
#120824
Hans Goudey closed this pull request 2024-04-22 17:14:27 +02:00

Pull request closed

Sign in to join this conversation.
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
4 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#120631
No description provided.