Skip to content

Vector based sprites #2184

Description

@einarf
  • Resolve lingering issues related to pyglet vectors (whatever that is)
  • Possibly issues with implementation details in pyglet
  • Possibly we should revert parts of Name scale properties on Sprites to things that make sense #2021
  • If we end up using Vec2 in sprites we must do performance testing. Moving rotating and scaling 3400 sprites per frame (the current 60fps limit) will cause over 1 million calls to the sprite properties. It's the hottest path we have in arcade.

Likely it's simpler to keep the old float scale for now because most users rely only on uniform scale. We can get more fancy about these properties in the future, but only when we have vectors sorted out. Only scale being a vec2 doesn't really make sense right now.

New issue should be created for sorting out vectors.

Activity

  1. added this to the 3.0 mandatory milestone on Jul 3, 2024
  2. DigiDuncan commented on Jul 3, 2024

    @DigiDuncan
    Collaborator

    Can I ask why the request for reverting aspect of #2021? I agree Vecs behavior isn't ideal, but I don't think returning anything but a Vec2 makes sense for scale; the issue lies with Vec.

  3. einarf commented on Jul 6, 2024

    @einarf
    MemberAuthor

    Can I ask why the request for reverting aspect of #2021? I agree Vecs behavior isn't ideal, but I don't think returning anything but a Vec2 makes sense for scale; the issue lies with Vec.

    Technically you are 100% right that scale is a vec2. However, after looking at a lot of code I'm not entirely convinced this is the right path. Likely in 99% of cases users want uniform scale. The sprite initializer also take a float scale so we already have an inconsistency. Looking at existing libraries out there we can see that scale appears as both float and vec2. There isn't really a right or wrong solution here. Even pyglet sprites are using float scale.

    However.. if we fix all the issues with vec2, use it consistently and the performance testing is promising it might be the way to go. There is a lot of work that needs to go in there to ensure that we have a future proof api. Also remember that sprite properties are the hottest path in the arcade code base. They can be called hundreds of thousands of times per second. Almost every system interacts with them.

    Right now I don't see that we have the time to attack this problem. We already have way too much on our plate and need to get this release out as soon as possible. If we can take our time and design some new sprites in future or experimental in 3.x.x that would likely be a more realistic path.

    I would suggest making a new issue for starting this experimentation. Introducing new sprite types and see how they play out is a much safer option.

  4. einarf commented on Jul 8, 2024

    @einarf
    MemberAuthor

    Put 10+ hours into fixing up pyglet vectors with complete unit tests
    pyglet/pyglet#1151
    pyglet/pyglet#1154

  5. einarf commented on Jul 8, 2024

    @einarf
    MemberAuthor

    @pushfoo Created this branch Vecifying sprites fully. Is someone is able to performance test that vs the current sprites with good results it's possible we can get that in for 3.0. The work just needs to be done. https://github.com/pythonarcade/arcade/tree/scary-vecs-and-nice-sprites

    @DigiDuncan Is likely interested in this.
    @Cleptomania Might have something to say related to arcade-accelerate

  6. einarf commented on Jul 8, 2024

    @einarf
    MemberAuthor
  7. pushfoo commented on Jul 8, 2024

    @pushfoo
    Member

    Feel free to make optimizing PRs into #2219. It passes tests, but it does not try to be as fast as possible.

  8. changed the title [-]Resolve lingering issues with Vec2[/-] [+]Vector based sprites[/+] on Jul 28, 2024
  9. modified the milestones: 3.0 mandatory, 3.1 on Jul 28, 2024
  10. modified the milestones: 3.1, Future on Mar 29, 2025
  11. pvcraven commented on Oct 8, 2026

    @pvcraven
    Member

    Closing: the decision was to keep tuples for sprite positions and scale, and the prototype in #2219 was closed. A new issue is welcome if vector sprites come back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions