Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lottie: fix repeater transformation #2280

Closed
wants to merge 1 commit into from

Conversation

mgrudzinska
Copy link
Collaborator

Matrix multiplication order changed.

before:
Zrzut ekranu 2024-05-15 o 00 45 13

after:
Zrzut ekranu 2024-05-15 o 00 43 30

AE:
Zrzut ekranu 2024-05-15 o 00 44 49

@mgrudzinska mgrudzinska added bug Something isn't working lottie Lottie animation labels May 14, 2024
@mgrudzinska mgrudzinska requested a review from hermet as a code owner May 14, 2024 22:47
@mgrudzinska mgrudzinska self-assigned this May 14, 2024
@hermet hermet requested a review from tinyjin May 15, 2024 05:56
Copy link
Member

@hermet hermet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgrudzinska Hello, it would be nice if you share the test resource here.
Unfortunately, this breaks the existing resources: in examples/lottie:
5317-fireworkds.json, abstract_circle.json
Need to confirm all works correctly.

@mgrudzinska mgrudzinska force-pushed the mira/repeater_fix branch 2 times, most recently from 6d74348 to 552aa4d Compare May 19, 2024 23:34
@mgrudzinska
Copy link
Collaborator Author

It is a working solution, but I'm not entirely satisfied with the use of array repeaters.
From what I can see, repeaters, unlike other elements, do not overwrite the previous ones - instead, both are applied. This would justify using an array, but I would prefer to confirm this and discuss it further.

@mgrudzinska mgrudzinska marked this pull request as draft May 19, 2024 23:38
@mgrudzinska
Copy link
Collaborator Author

repeater.json

@@ -59,7 +60,7 @@ struct RenderContext
Shape* propagator = nullptr;
Shape* merging = nullptr; //merging shapes if possible (if shapes have same properties)
LottieObject** begin = nullptr; //iteration entry point
RenderRepeater* repeater = nullptr;
Array<RenderRepeater*> repeaters;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array<RenderRepeater> repeaters;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it

@@ -49,6 +49,7 @@ struct RenderRepeater
uint8_t endOpacity;
bool interpOpacity;
bool inorder;
bool external;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We strongly recommend adding a comment for this kind of ambiguous data.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the approach, since I've found nested examples. I need to know whether the level of repeater was greater or it was equal to the level of repeated shape

@@ -1082,7 +1096,7 @@ static void _updateChildren(LottieGroup* parent, float frameNo, Inlist<RenderCon
break;
}
case LottieObject::Repeater: {
_updateRepeater(parent, child, frameNo, contexts, ctx, exps);
_updateRepeater(parent, child, frameNo, contexts, ctx, exps, groupLevel == level);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, the level looks over-programmed. You might wanna just confirm whether the repeater is requested after the group.

Depending on whether the repeater is an element
of the shapes list or the shape layer, the repeater's
transformation should be applied either before or after
the shape's transformation, respectively.
@mgrudzinska
Copy link
Collaborator Author

samples:
r1.json
r2.json
s1.json
s2.json

main:
Zrzut ekranu 2024-05-23 o 14 55 29

this pr:
Zrzut ekranu 2024-05-23 o 14 56 02

currently there are no differences regardless of whether the repeater is inside the group (before the transformation) or outside (after the transformation):
Zrzut ekranu 2024-05-23 o 15 01 41
Zrzut ekranu 2024-05-23 o 15 01 38

Based on whether the repeater was called before or after the group, I cannot determine which transformation should be applied first. Only at the stage of updating the shape and cloning it, in the _repeat() can I decide, knowing the level values of both the shape and the repeater, the order in which to apply the transformations.
Zrzut ekranu 2024-05-23 o 15 07 05

regarding using an array to store all the repeaters:
I found an example, where there are two repeaters after each other and both have to be applied:
Zrzut ekranu 2024-05-23 o 13 59 45
Zrzut ekranu 2024-05-23 o 13 59 48
Zrzut ekranu 2024-05-23 o 13 59 52

@mgrudzinska mgrudzinska marked this pull request as ready for review May 23, 2024 13:36
@mgrudzinska mgrudzinska requested a review from hermet May 23, 2024 13:36
if (rhs.repeater) {
repeater = new RenderRepeater();
*repeater = *rhs.repeater;
if (!rhs.repeaters.empty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!rhs.repeaters.empty()) {
  ...
} 

->

repeaters.push(rhs.repeaters);

@@ -40,6 +40,7 @@
struct RenderRepeater
{
int cnt;
uint32_t level;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think if we put this uint16_t level in the RenderContext. I guess the code could be more compact & clean.

@mgrudzinska
Copy link
Collaborator Author

combined with #2311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lottie Lottie animation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants