Fix #103068: Link insert offset not working when rotating/scaling nodes #107460

Merged
Leon Schittek merged 1 commits from lone_noel/blender:fix-103068-node-link-insert-offset into blender-v3.6-release 2023-06-03 12:30:03 +02:00
Member

Fix node link insertion during transform not working properly for
rotation and scale.
Inserting nodes by rotating or scaling...

  • ...didn't offset the attached nodes.
  • ...could lead to unfreed memory.

This commit fixes that by always calling the NODE_OT_insert_offset
operator at the end of the node transform operator rather than having
to explicitly append it into a macro operator for each transform
operator.


Comparison
Note how in main the nodes are only offset when moving nodes after the
insertion happened. If this isn't done it causes unfreed memory.

fix main
fix_insert-offset.mp4 main_insert-offset.mp4

Issue
Nodes can be inserted on links during transform. This is set up in
the transform operator for nodes (regardless of which type of
transform is used) by storing NodeInsertOfsData in the node space.

This data is then used by the modal callback of the operator
NODE_OT_insert_offset which handles moving the nodes out of the way
after which the data is freed.

The issue is that NODE_OT_insert_offset is only invoked, when it is
explicitly put in an operator macro after the transform operators. This
has only been done for a few variants of the translate operator so
the link insertion offset is currently unhandled after rotating or
scaling nodes.

This leads to a few issues:

  • The nodes are not offset after insertion through rotating/scaling.
    (The offset can still happen delayed when moving a node without
    inserting it after the rotation/scaling, see [video])
  • There can be unfreed memory as described in #103068
  • In a debug build it triggers this assert in node_relationships.cc:
    BLI_assert(snode.runtime->iofsd == nullptr);

Proposed Fix
Rather than relying on the insert offset operator being chained after
each variation of the transform operator, this patch calls it in
special_aftertrans_update__node, which removes the need to create
macro operators with NODE_OT_insert_offset.

I'm not sure it's really necessary to keep NODE_OT_insert_offset
around as an operator and it might not be necessary to store the
NodeInsertOfsData in the node space anymore but this seems like a
minimal fix for now.

Alternative
Another quick way to fix this is to just skip the rotation/scale
transform completely, when only one node is selected. Rotating/scaling
a single node doesn't do anything and since node link insertion only
works when transfoming a single node that would avoid the issues.

It would however come up again in case we wanted to enable link
insertion for multiple nodes (see D14185)

Fix node link insertion during transform not working properly for rotation and scale. Inserting nodes by rotating or scaling... * ...didn't offset the attached nodes. * ...could lead to unfreed memory. This commit fixes that by always calling the `NODE_OT_insert_offset` operator at the end of the node transform operator rather than having to explicitly append it into a macro operator for each transform operator. --- **Comparison** Note how in main the nodes are only offset when moving nodes after the insertion happened. If this isn't done it causes unfreed memory. |fix|main| |---|---| |[fix_insert-offset.mp4](/attachments/2cd854c0-3871-4c0b-a4cf-77142ed9b90b)|[main_insert-offset.mp4](/attachments/1ead6db3-82f4-4481-8487-117cac1ac166)| **Issue** Nodes can be inserted on links during transform. This is set up in the transform operator for nodes (regardless of which type of transform is used) by storing `NodeInsertOfsData` in the node space. This data is then used by the modal callback of the operator `NODE_OT_insert_offset` which handles moving the nodes out of the way after which the data is freed. The issue is that `NODE_OT_insert_offset` is only invoked, when it is explicitly put in an operator macro after the transform operators. This has only been done for a few variants of the translate operator so the link insertion offset is currently unhandled after rotating or scaling nodes. This leads to a few issues: * The nodes are not offset after insertion through rotating/scaling. (The offset can still happen delayed when moving a node without inserting it after the rotation/scaling, see [video]) * There can be unfreed memory as described in #103068 * In a debug build it triggers this assert in `node_relationships.cc`: `BLI_assert(snode.runtime->iofsd == nullptr);` **Proposed Fix** Rather than relying on the insert offset operator being chained after each variation of the transform operator, this patch calls it in `special_aftertrans_update__node`, which removes the need to create macro operators with `NODE_OT_insert_offset`. I'm not sure it's really necessary to keep `NODE_OT_insert_offset` around as an operator and it might not be necessary to store the `NodeInsertOfsData` in the node space anymore but this seems like a minimal fix for now. **Alternative** Another quick way to fix this is to just skip the rotation/scale transform completely, when only one node is selected. Rotating/scaling a single node doesn't do anything and since node link insertion only works when transfoming a single node that would avoid the issues. It would however come up again in case we wanted to enable link insertion for multiple nodes (see [D14185](https://archive.blender.org/developer/D14185))
Iliya Katushenock added this to the Nodes & Physics project 2023-04-29 10:00:32 +02:00
Iliya Katushenock added the
Interest
Modeling
Interest
User Interface
labels 2023-04-29 10:00:39 +02:00
Hans Goudey approved these changes 2023-05-31 22:44:56 +02:00
Hans Goudey left a comment
Member

I guess at this point the fact that NODE_OT_insert_offset is an operator just gives us a simple way to make the timer work. That seems fine to me. I do agree that NodeInsertOfsData probably doesn't need to be stored in the editor's runtime data anymore. But that could be changed separately.

I guess at this point the fact that `NODE_OT_insert_offset` is an operator just gives us a simple way to make the timer work. That seems fine to me. I do agree that `NodeInsertOfsData` probably doesn't need to be stored in the editor's runtime data anymore. But that could be changed separately.
Leon Schittek changed title from Fix #103068: Link insert offset not working when rotating/scaling nodes to Fix #103068: Link insert offset not working when rotating/scaling nodes 2023-06-03 11:32:21 +02:00
lone_noel changed target branch from main to blender-v3.6-release 2023-06-03 11:32:26 +02:00
Leon Schittek force-pushed fix-103068-node-link-insert-offset from aba9b5ca32 to d90f3b3bfc 2023-06-03 12:22:46 +02:00 Compare
Leon Schittek merged commit cc9c720aae into blender-v3.6-release 2023-06-03 12:30:03 +02:00
Leon Schittek deleted branch fix-103068-node-link-insert-offset 2023-06-03 12:30:06 +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 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#107460
No description provided.