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

Before bd00324c26, strip lengths were changed in
`rna_NlaStrip_frame_start_ui_set` and `rna_NlaStrip_frame_end_ui_set`
so as not to be shorter than NLASTRIP_MIN_LEN_THRESH.

This prevented `BKE_nlameta_flush_transforms` from working with
zero-length strips.

But now, in some cases, strip can be zero length.

Therefore, consider this case and avoid division by zero.

Pull Request: https://projects.blender.org/blender/blender/pulls/110121
This commit is contained in:
Germano Cavalcante
2023-10-16 16:46:47 +02:00
committed by Germano Cavalcante
parent 6dda18269c
commit 88a6df24aa

View File

@@ -1074,9 +1074,20 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
if (scaleChanged) {
float p1, p2;
/* compute positions of endpoints relative to old extents of strip */
p1 = (strip->start - oStart) / oLen;
p2 = (strip->end - oStart) / oLen;
if (oLen) {
/* Compute positions of endpoints relative to old extents of strip. */
p1 = (strip->start - oStart) / oLen;
p2 = (strip->end - oStart) / oLen;
}
else {
/* 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. */
p1 = 0.0f;
p2 = 1.0f;
}
/* Apply new strip endpoints using the proportions,
* then wait for second pass to flush scale properly. */