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

Drawing Primitives with Gizmos #11072

Merged
merged 38 commits into from
Feb 2, 2024

Commits on Feb 1, 2024

  1. feat(circles): generalize circles in gizmos to ellipses

    Since circles are just special cases of ellipses where both half width
    and half height are equal to the radius, this is an easy generalization.
    
    - Added capabilities to draw ellipses
    - all previously existing circle drawing mechanisms are derived from
      ellipses now
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    8448ab9 View commit details
    Browse the repository at this point in the history
  2. feat(primitives): first feature implementation

    implement the first few drawing methods for primitives on `Gizmos`
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    7ae9aa0 View commit details
    Browse the repository at this point in the history
  3. feat: add gizmo trait impl for all 2D primitives

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    5596ab6 View commit details
    Browse the repository at this point in the history
  4. feat: add gizmo trait impl for all 3D primitives

    (non-optimal?)
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    5462a1f View commit details
    Browse the repository at this point in the history
  5. chore: docs + self-review

    - added docs to all the new traits and structs
    - manually tested whether the visuals were ok
    - refactored the code a bit to prevent duplication
    - improved visuals of arc like parts (probably add 3D arc to gizmo in a
      follow up commit)
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    d7cab7c View commit details
    Browse the repository at this point in the history
  6. chore(gizmo-primitives): impl Default for new struct

    To ease the use of all the primitive details structs needed for
    rendering, implement `Default` for them.
    
    For some values it's kind of hard to pick good defaults. I tried to use
    values that'll hopefully work better with respect to performance.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    b50a5d6 View commit details
    Browse the repository at this point in the history
  7. fix(primitives): adjust segments to look more uniform

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    d4b6de6 View commit details
    Browse the repository at this point in the history
  8. feat(arc3d): explore different approach

    The new arc approach uses the same API as unity does
    
    https://docs.unity3d.com/ScriptReference/Handles.DrawWireArc.html
    
    This gets rid of the restriction of only drawing arcs with angles
    smaller than 180 degrees which was previously the case.
    
    This new arc3d API might also be included into the standard gizmos arc
    module.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    ef089f9 View commit details
    Browse the repository at this point in the history
  9. refactor(primitives): factor out common code

    A lot of the 3D primitives share similar base shapes in 3D. This commit
    factors out those base shapes into functions for easier reuse.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    bde2496 View commit details
    Browse the repository at this point in the history
  10. chore(primitives): cleanup

    - Remove notes and add new note about optimization which needs consensus
    - Implement minor circles of torus via four arcs to prevent weird
      rotation of minor circles
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    0f836e1 View commit details
    Browse the repository at this point in the history
  11. chore(examples): add gizmo primitives examples

    This commit implements the visualization of various 3d primitives. You
    can scroll through them with the UP/DOWN keys and for the ones that use
    segments for level of details you can increase/decrease precision with
    M/N keys.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    9d48eb5 View commit details
    Browse the repository at this point in the history
  12. refactor(primitives): builder pattern

    Use builder pattern that already exists for arcs and circles instead of
    extra details structs for supplying the details of the primitives.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    24a6fc8 View commit details
    Browse the repository at this point in the history
  13. refactor(primitives): builder pattern 3d

    Also implement the builder pattern for all 3D primitives. As it turns
    out, this approach doesn't really work yet due to lifetime bounds.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    aee01fd View commit details
    Browse the repository at this point in the history
  14. fix(lifetimes): fix lifetime issues

    So many thanks to nothy for helping me with the lifetimes ♥️
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    Co-Authored-by: nothendev <borodinov.ilya@gmail.com>
    RobWalt and nothendev committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    be378eb View commit details
    Browse the repository at this point in the history
  15. chore(cleanup): remove the nix stuff

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    90c660e View commit details
    Browse the repository at this point in the history
  16. fix(rebase): fixup gizmo changes after rebase

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    3e1848d View commit details
    Browse the repository at this point in the history
  17. refactor(arc3d): redesign arc3d API

    I noticed some flaws with the original implementation of the API while
    creating some examples:
    
    - The orientation via `from` and `rotation_axis` fields felt really
      wonky
    - The rotation seemed not to rotate around the center set by the user
    
    This is why I reimplemented the API. It now draws some kind of default
    arc in 3D which has properties which are documented in the doc strings.
    You can modify this default arc via builder methods which seems to be
    the most flexible approach in my eyes.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    2d2e556 View commit details
    Browse the repository at this point in the history
  18. chore(cleanup): cleanup arc changes

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    f46ac68 View commit details
    Browse the repository at this point in the history
  19. fix(review): make API consistent

    and also adjust:
    
    - docs
    - tests
    - examples
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    3b37891 View commit details
    Browse the repository at this point in the history
  20. fix(review): add rotation for ellipses

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    bfbf12c View commit details
    Browse the repository at this point in the history
  21. fix(review): apply review suggestions (see details)

    This includes:
    
    - remove builders for mandatory arguments
    - refactor the API to look more similar to the rest of the gizmo APIs
    - split primitives module into 2d and 3d
    
    Thanks for the thorough review Jondolf!
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    40df6d4 View commit details
    Browse the repository at this point in the history
  22. chore(cleanup): remove development comments

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    43c9e91 View commit details
    Browse the repository at this point in the history
  23. fix(gizmos): switch mental model from Z-up to Y-up

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    3bac10d View commit details
    Browse the repository at this point in the history
  24. fix(gizmos): center cone and conical frustrum rendering

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    12b4d2c View commit details
    Browse the repository at this point in the history
  25. fix(gizmo-examples): add user facing explanations

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    85d245f View commit details
    Browse the repository at this point in the history
  26. fix(cleanup): capsule3d changes

    Fix code after rebasing on main. The capsule primitive was split for 2d
    and 3d cases.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    10f3df0 View commit details
    Browse the repository at this point in the history
  27. chore(cleanup): implement minor review comments

    This includes:
    
    - just drawing one line for line segements (2D/3D)
    - use minimum length for directions in 2D to prevent 1 pixel lines
      - now: 50 pixel
    - changing the infinit-ness of lines by adding big constant scale
      factors now:
      - 2D infinite length: 100_000
      - 3D infinite length: 10_000
    - refactor plane (2D/3D) to use other primitives for simplicity and less
      repetition (they now use a combination of Direction + Segement
      rendering)
    - add configurable options to Plane3d (number + detail + size of hinting axis)
    - adjust examples in 2D/3D cases
    - use consistent variable names
    - clean up docs
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    1f68958 View commit details
    Browse the repository at this point in the history
  28. feat(capsule2d): add gizmo impl for capusle 2d

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    cf383e4 View commit details
    Browse the repository at this point in the history
  29. fix(prelude): auto export new gizmo traits in prelude

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    a6dd10e View commit details
    Browse the repository at this point in the history
  30. chore(exmaples): clean up examples

    The examples should probably be cleaner than the previous state. After
    all people are learning with these so we should implement best practices
    and keep systems small and decoupled.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    0fd2c46 View commit details
    Browse the repository at this point in the history
  31. fix(gizmos): implement review suggestions

    This commit implements a loose bunch of small polishing fixes:
    
    - use angles in radians instead of `Mat2` for rotation in 2D primitive
      case and ellipse case
    - use constants on `Direction2D` struct as much as possible
    - update key bindings in examples to be consistent
    - update user facing text in examples to reflect real key bindings
    - fix naming on configurating builder for `Plane3D`
    
    sorry should have added you earlier below 🙈
    
    Reviewed-by: Joona Aalto <jondolf.dev@gmail.com>
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    be9b746 View commit details
    Browse the repository at this point in the history
  32. fix(tests): fix doc tests + half_size consistency

    Since a `half_size` `Vec2` was used on a lot of primitives lately I
    thought that we should be consistent here with ellipses as well.
    
    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    15c68e1 View commit details
    Browse the repository at this point in the history
  33. chore(cleanup): rename and move systems around

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    edf5e4f View commit details
    Browse the repository at this point in the history
  34. chore(fix-docs): doc links were broken

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    30c620a View commit details
    Browse the repository at this point in the history
  35. chore(CI): fix error from bevy_internal CI lint

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    00aefe0 View commit details
    Browse the repository at this point in the history
  36. chore(typo): fixes via spell checking

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    7c64e9c View commit details
    Browse the repository at this point in the history
  37. chore(examples): consistent user facing texts

    Authored-by: RobWalt <robwalter96@gmail.com>
    RobWalt committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    d3df91f View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2024

  1. docs: increase amount of documentation

    Authored-by: Aviac <aviac@mailbox.org>
    RobWalt committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    1531339 View commit details
    Browse the repository at this point in the history