Fix #113552: NLA Markers do not reset when length reaches 0.0 #110121

Merged
Germano Cavalcante merged 2 commits from mano-wii/blender:fix_110108 into blender-v4.0-release 2023-10-16 16:46:56 +02:00

Caused by bd00324c26.

bd00324c26 allowed strip->start to have the same value as
strip->end (ignoring the NLASTRIP_MIN_LEN_THRESH).

So oLen can be 0.0f in BKE_nlameta_flush_transforms and create
nan when used in division.

This nan invalidates later transform operations.


I'm not sure if 0-length strips should be allowed. So maybe the fix should be extended to other places.

Caused by bd00324c26. bd00324c26 allowed `strip->start` to have the same value as `strip->end` (ignoring the `NLASTRIP_MIN_LEN_THRESH`). So `oLen` can be `0.0f` in `BKE_nlameta_flush_transforms` and create `nan` when used in division. This `nan` invalidates later transform operations. --- I'm not sure if 0-length strips should be allowed. So maybe the fix should be extended to other places.
Germano Cavalcante added the
Module
Animation & Rigging
label 2023-07-15 00:36:38 +02:00
Germano Cavalcante requested review from Sybren A. Stüvel 2023-07-15 00:37:09 +02:00
Germano Cavalcante requested review from Brad Clark 2023-07-15 00:37:10 +02:00
Author
Member

The change seems to have been made by Thibault de Villèle (thibaulltt) as we can see at https://archive.blender.org/developer/D14658, but he doesn't seem to be available anymore.

The change seems to have been made by Thibault de Villèle (thibaulltt) as we can see at https://archive.blender.org/developer/D14658, but he doesn't seem to be available anymore.
Nate Rupsis reviewed 2023-08-17 23:14:02 +02:00
@ -1067,2 +1066,2 @@
p1 = (strip->start - oStart) / oLen;
p2 = (strip->end - oStart) / oLen;
if (oLen) {
/* compute positions of endpoints relative to old extents of strip */
Member

Sentence should start with a capitol letter, and end with a period.

Sentence should start with a capitol letter, and end with a period.
Member

Will need to update with main, nla.c -> nla.cc

Will need to update with `main`, nla.c -> nla.cc
Germano Cavalcante force-pushed fix_110108 from 9815d5b4c2 to 42b192c227 2023-08-18 15:09:10 +02:00 Compare
Author
Member

Rebased on main.

While this fix fixes the transform bug (and possibly others), it is only a change for safeness.

Maybe it's good to check if it's really allowed to have a strip smaller than NLASTRIP_MIN_LEN_THRESH.

Rebased on main. While this fix fixes the transform bug (and possibly others), it is only a change for safeness. Maybe it's good to check if it's really allowed to have a strip smaller than `NLASTRIP_MIN_LEN_THRESH`.
Germano Cavalcante requested review from Nate Rupsis 2023-08-18 15:12:41 +02:00
Member

It doesnt look like this fixes the underlying issue of #110108 (which seems to be burried in the design if I look at createTransNlaData -- here we always transform both the start and end of the strip, if we then apply snapping, this can end up obscurely snapping either start and end to the same spot or in the case of Snap to Seconds gets even more funny)

It doesnt look like this fixes the underlying issue of #110108 (which seems to be burried in the design if I look at `createTransNlaData` -- here we always transform both the start and end of the strip, if we then apply snapping, this can end up obscurely snapping either start and end to the same spot or in the case of Snap to Seconds gets even more funny)

Thanks for the PR! Issue #110108 has been fixed by bd305c8d18, so I'll close this one.

Thanks for the PR! Issue #110108 has been fixed by bd305c8d18442ec056b84b889f604e0abeef8ea6, so I'll close this one.
Author
Member

Unfortunately the problem has not been fixed.
If you scale a strip and this scale reaches zero at some point, the cancellation is not restored.

The regression in issue #110108 is due to the fact that the transformation is not reset due to generated Nan values.

bd305c8d18 changed the existing (and old) snap behavior, but I wouldn't say it fixed #110108, as the issue confirmed there was resetting transformation.

I am considering apply this cosmetic change, as it is not disruptive.

But I still believe that oLen should never be 0.0.

Unfortunately the problem has not been fixed. If you scale a strip and this scale reaches zero at some point, the cancellation is not restored. The regression in issue #110108 is due to the fact that the transformation is not reset due to generated Nan values. bd305c8d18 changed the existing (and old) snap behavior, but I wouldn't say it fixed #110108, as the issue confirmed there was resetting transformation. I am considering apply this cosmetic change, as it is not disruptive. But I still believe that `oLen` should never be `0.0`.
Germano Cavalcante reopened this pull request 2023-10-11 17:15:18 +02:00
Germano Cavalcante changed title from Fix #110108: NLA Markers transform not resetting correctly to Fix #113552: NLA Markers do not reset when length reaches 0.0 2023-10-11 17:32:48 +02:00
Sybren A. Stüvel requested review from Nathan Vegdahl 2023-10-12 10:44:35 +02:00
Sybren A. Stüvel refused to review 2023-10-12 10:44:38 +02:00

I've added @nathanvegdahl as reviewer instead of me. He's been looking into the NLA's "no zero-length strips" thing recently, so his brain is more equipped than mine right now :)

I've added @nathanvegdahl as reviewer instead of me. He's been looking into the NLA's "no zero-length strips" thing recently, so his brain is more equipped than mine right now :)
Member

Although this certainly addresses the immediate symptom and prevents the divide by zero, it's not clear to me that this is the right fix. Specifically, the length of strips is never supposed to be zero in the first place.

Having said that, as discussed in #107030 (comment), the issues around actually ensuring non-zero strip length are a bit deep and tangled. So I think the fix in this PR is reasonable as a stop-gap, because it does address the symptom described in the bug report.

But before accepting, I think a comment needs to be added to the code explaining that this is a (possibly) stop-gap fix, and that the source of the zero-length strip needs to be tracked down for a proper fix. The comment should probably use the WORKAROUND tag.

Although this certainly addresses the immediate symptom and prevents the divide by zero, it's not clear to me that this is the right fix. Specifically, the length of strips is never supposed to be zero in the first place. Having said that, as discussed in https://projects.blender.org/blender/blender/issues/107030#issuecomment-1030437, the issues around actually ensuring non-zero strip length are a bit deep and tangled. So I think the fix in this PR is reasonable as a stop-gap, because it does address the symptom described in the bug report. But before accepting, I think a comment needs to be added to the code explaining that this is a (possibly) stop-gap fix, and that the source of the zero-length strip needs to be tracked down for a proper fix. The comment should probably use the [`WORKAROUND`](https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Comments) tag.
Germano Cavalcante force-pushed fix_110108 from 42b192c227 to 5d985cba2a 2023-10-13 21:30:46 +02:00 Compare
Author
Member

The patch was getting old, so I decided to rebase onto main and force push. (although the fix should go to blender-v4.0-release).

  • Improved comments
The patch was getting old, so I decided to rebase onto main and force push. (although the fix should go to `blender-v4.0-release`). - Improved comments
Member

Thanks @mano-wii !

I don't know if we need to (or should) mention specific functions in the comment in this case. To me, at least, it's not clear where the zero strip lengths are coming from here (e.g. it could be in the transform code). So I think this may be a better comment:

/* WORKAROUND: in theory, a strip should never be zero length. However,
 * zero-length strips are nevertheless showing up here (see issue #113552).
 * This is a stop-gap fix to handle that and prevent a divide by zero. A
 * proper fix will need to track down and fix the source(s) of these
 * zero-length strips. */

Sorry for the run-around! Just this one last change and then we can get it merged. :-)

(Edit: changed comment to reference the issue.)

Thanks @mano-wii ! I don't know if we need to (or should) mention specific functions in the comment in this case. To me, at least, it's not clear where the zero strip lengths are coming from here (e.g. it could be in the transform code). So I think this may be a better comment: ```c /* WORKAROUND: in theory, a strip should never be zero length. However, * zero-length strips are nevertheless showing up here (see issue #113552). * This is a stop-gap fix to handle that and prevent a divide by zero. A * proper fix will need to track down and fix the source(s) of these * zero-length strips. */ ``` Sorry for the run-around! Just this one last change and then we can get it merged. :-) (Edit: changed comment to reference the issue.)
Member

so I decided to rebase onto main

Oh! Also, please rebase onto and change the PR to merge to blender-v4.0-release, because we'll merge there first.

> so I decided to rebase onto main Oh! Also, please rebase onto and change the PR to merge to `blender-v4.0-release`, because we'll merge there first.
Germano Cavalcante changed title from Fix #113552: NLA Markers do not reset when length reaches 0.0 to Fix #113552: NLA Markers do not reset when length reaches 0.0 2023-10-16 14:52:02 +02:00
mano-wii changed target branch from main to blender-v4.0-release 2023-10-16 14:52:05 +02:00
Germano Cavalcante force-pushed fix_110108 from 4773eaa7de to 79cc6ba238 2023-10-16 15:05:40 +02:00 Compare
Nathan Vegdahl approved these changes 2023-10-16 16:37:10 +02:00
Nathan Vegdahl left a comment
Member

Looks good to me!

Looks good to me!
Germano Cavalcante merged commit 88a6df24aa into blender-v4.0-release 2023-10-16 16:46:56 +02:00
Germano Cavalcante deleted branch fix_110108 2023-10-16 16:47:01 +02:00
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
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
5 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#110121
No description provided.