osudroid / osu-droid

http://osudroid.moe
Apache License 2.0
529 stars 79 forks source link

Follow point rendering not matching stable #115

Closed Beyley closed 5 days ago

Beyley commented 3 years ago

This has been an issue for awhile and has only been slightly fixed by capping the amount to 30 and distributing it (previously it would render hundreds if the follow point image was too small)

For those who arent up to spec on how follow points are rendered in stable and droid droid: calculate the amount to fill the distance (cap to 30) then distribute evenly stable: place a follow point every 32 pixels(?) until you reach the end

In the following code block it shows how stable renders its follow points

    internal void AddFollowPoints(int startIndex = 0, int endIndex = -1) {
            if (endIndex == -1) endIndex = this.hitObjectsCount - 1;

            pTexture[] fptextures = TextureManager.LoadAll(@"followpoint");

            int followPointIndex = 0;
            for (int i = startIndex + 1; i <= endIndex; i++) {
                HitObject currHitObject = this.hitObjects[i];

                //Draw connection lines
                if (!currHitObject.NewCombo && !this.hitObjects[i - 1].IsType(HitObjectType.Spinner) && !this.hitObjects[i].IsType(HitObjectType.Spinner)) {
                    Vector2 pos1 = this.hitObjects[i - 1].EndPosition;
                    int time1 = this.hitObjects[i - 1].EndTime;
                    Vector2 pos2 = currHitObject.Position;
                    int time2 = currHitObject.StartTime;

                    int distance = (int)Vector2.Distance(pos1, pos2);
                    Vector2 distanceVector = pos2 - pos1;
                    int length = time2 - time1;

                    float angle = (float)Math.Atan2(pos2.Y - pos1.Y, pos2.X - pos1.X);

                    for (int j = (int)(FollowLineDistance * 1.5); j < distance - FollowLineDistance; j += FollowLineDistance) {
                        float fraction = (float)j / distance;
                        Vector2 posStart = pos1 + (fraction - 0.1f) * distanceVector;
                        Vector2 pos = pos1 + fraction * distanceVector;
                        int fadein = (int)(time1 + fraction * length) - FollowLinePreEmpt;
                        int fadeout = (int)(time1 + fraction * length);

                        pAnimation dot;
                        if (followPointIndex < this.followPoints.Count) {
                            dot = this.followPoints[followPointIndex];
                            dot.Position = pos;

                            foreach (Transformation t in dot.Transformations) {
                                if (t.Type == TransformationType.Fade && t.EndFloat == 0) {
                                    t.Time1 = fadeout;
                                    t.Time2 = fadeout + FadeIn;
                                }
                                else {
                                    t.Time1 = fadein;
                                    t.Time2 = fadein + FadeIn;
                                }

                                if (t.Type == TransformationType.Movement) {
                                    t.StartVector = posStart;
                                    t.EndVector = pos;
                                }

                            }

                            dot.ResetAnimation();
                        }
                        else {
                            dot = new pAnimation(fptextures, Fields.Gamefield, Origins.Centre, Clocks.Audio, pos, 0, false, Color.White, null);
                            dot.SetFramerateFromSkin();
                            dot.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, fadein, fadein + FadeIn));
                            if (SkinManager.IsDefault && GameBase.NewGraphicsAvailable) {
                                dot.Transformations.Add(new Transformation(TransformationType.Scale, 1.5f, 1, fadein, fadein + FadeIn, EasingTypes.Out));
                                dot.Transformations.Add(new Transformation(TransformationType.Movement, posStart, pos, fadein, fadein + FadeIn, EasingTypes.Out));
                            }

                            dot.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, fadeout, fadeout + FadeIn));

                            if (GameBase.Mode == OsuModes.Edit) this.followPoints.Add(dot);

                        }

                        dot.Rotation = angle;
                        this.spriteManager.Add(dot);

                        followPointIndex++;
                    }
                }
            }
        }