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

optimization, animtion.Render, less copying of arguments #17175

anvilvapre opened this issue Oct 4, 2019 · 0 comments


Copy link

commented Oct 4, 2019

In Animation.cs multiple function are called that have 4+ arguments that take the same arguments. With "shadow" all the 5 arguments are copied at 4+ times.

Please consider combine pos, offset, zoffset and pallete into one object. The single object can then be passed from Render to Render to SpriteRenderable. Less arguments need to be copied multiple times on the stack.

Or as an alternative remove the Render function without scale, set scale as default value to 1.


            public IEnumerable<IRenderable> Render(WPos pos, WVec offset, int zOffset, PaletteReference palette, float scale)
                    var imageRenderable = new SpriteRenderable(Image, pos, offset, CurrentSequence.ZOffset + zOffset, palette, scale, IsDecoration);
                    if (CurrentSequence.ShadowStart >= 0)                   
                            var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
                            var shadowRenderable = new SpriteRenderable(shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, scale, true);
                            return new IRenderable[] { shadowRenderable, imageRenderable };
                    return new IRenderable[] { imageRenderable };           
            public IEnumerable<IRenderable> Render(WPos pos, PaletteReference palette)
                    return Render(pos, WVec.Zero, 0, palette, 1f);          


@reaperrr reaperrr added the Performance label Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.