这是indexloc提供的服务,不要输入任何密码
Skip to content

Adds PlayAtlas and SnapToMultiple operators #428

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

Merged
merged 2 commits into from
May 12, 2024

Conversation

anosci
Copy link
Contributor

@anosci anosci commented May 10, 2024

An operator for turning Atlases into animations, for use with GIFs, sprite sheets, etc. For a better user experience, I've also included SnapToMultiple, which will return the lowest divisor of a number that has a modulus of 0.
playatlas

{
var v = Value.GetValue(context);
var mod = Mod.GetValue(context);
if (mod == 0){
Copy link
Contributor

Choose a reason for hiding this comment

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

this part is not needed, in this case the "end test" (second field) of the for statement will trigger before the first run, and the loop content won't be executed.

var mod = Mod.GetValue(context);
if (mod == 0){
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

keep indentation consistent for easier code maintenance (your ide can do that for you)

if (mod == 0){
return;
}
for(int goodvalue=mod;goodvalue>0;goodvalue--){
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be optimized starting from 0 until iterator==mod, as we want the minimal value, and the mod value can be huge.

also goodvalue is not a very good variable name.

Result.Value = goodvalue;
return;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto indent.

@ylmrx
Copy link
Contributor

ylmrx commented May 11, 2024

Thanks for this PR ! Thus it's working fine, there's a few cosmetic and optimization issues you can fix 👍

@ylmrx
Copy link
Contributor

ylmrx commented May 11, 2024

Regarding the PlayAtlas operator itself, there's a bunch of unbound operator you can dispose, and the ClampInt ops bound to FrameCount[X/Y] can be removed and replaced with the correct parameter settings (cf. screenshot, set "Min" to 1 in your case).
image

removed redundant check, changed indentation for consistency, clarified nextLowestMod variable name, adjusted clamping behavior
@anosci
Copy link
Contributor Author

anosci commented May 11, 2024

I went ahead and made all of the changes you mentioned, except for the loop optimization. I think what you proposed would always return the lowest possible modulo, whereas I'm looking for the next lowest modulo (at, or below, the given input for Mod).

Also, my "IDE" is notepad++, so it might not actually take care of the indentation for me. I'm not sure. 😅
I tried to make it consistent, at least.

@pixtur pixtur merged commit 77e48b3 into tixl3d:dev May 12, 2024
@pixtur
Copy link
Collaborator

pixtur commented May 12, 2024

Thanks for this awesome contribution!
And thanks to @ylmrx for going ahead and reviewing. This really helps a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants