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

Refactor: use glyph_brush_layout and add text alignment support #765

Merged
merged 29 commits into from
Nov 13, 2020

Conversation

AlisCode
Copy link
Contributor

@AlisCode AlisCode commented Nov 1, 2020

Context

The current state of bevy_text is :

  • ab_glyph for font loading
  • A custom, hand-made implementation of text layout with some of the code coming out of the ab_glyph examples
  • No standard way to measure text

Content

This PR introduces a dependency to glyph_brush_layout in bevy_text, and replaces the current implementation of text layout (which is done in the DrawableText's implementation of Drawable) with a more robust solution (e.g. using a crate that's meant to do that).

Since we're using glyph_brush_layout, we get text alignment for free in bevy_ui, so that's implemented also :) more on that later.

I'm exposing a TextPipeline. It is a public abstraction that allows to launch all text-related operations on a GlyphBrush, where GlyphBrush has been reimplemented for bevy's specific needs. Operation on a TextPipeline could potentially be launched from different threads, and include :

  • Queing text
  • Pre-rendering text in the queue (so, computing its layout)
  • Measuring text

The idea is that TextPipeline should be the public interface and encapsulates operations on the GlyphBrush, making sure we dont require a breaking change when we refactor it in the future for some reason (namely to add caching).

Goal

In short, this PR allows for standardized text layout and text measurement implemented in bevy_text. It would then be usable in the whole bevy ecosystem. I see two main use cases here :

  • Alternative UI system (imgui, iced are two examples that comes to mind)
  • In-game text

Caveats

No caching

We'd have to see if caching is something worth doing or not : right now, whenever the text or its style changes, its layout is recomputed. This is awful for things such as animating the color of a text. I originally thought TextAlignment would be worth storing in the text style, but a change of text style might not need a whole text layout recompute, while a change of text alignment definitely would.

The fact that we're adding a field to the TextStyle component effectively makes this PR a breaking change; It might be worth refactoring TextAlignment to use its own component. But the problem remains for the text size which is contained in TextStyle. Changing a text size will of course require to recompute all its glyphs.

bevy_ui's Val::Percent variant

Right now, the usage a Val::Percent to apply a constraint on the size of a textblock in min_size, size or max_size will be ... Ignored. We might need to use the parent's constraint to compute the percentage, I'm not exactly sure how to handle that.

Rationale

It's also possible to use another text engine like Fontdue or something. But since bevy currently uses ab_glyph it only makes sense to use glyph_brush_layout since it's based off ab_glyph, and actually written and maintained by the same author.

Thanks ❤️

@tigregalis for doing most of the work on glyph positioning
@verzuz for the help in debugging this

@karroffel karroffel added C-Code-Quality A section of code that is hard to understand or change C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Nov 1, 2020
@AlisCode AlisCode force-pushed the refactor/glyph_brush branch 2 times, most recently from 13d0753 to 3e6b3b1 Compare November 3, 2020 12:17
@cart
Copy link
Member

cart commented Nov 4, 2020

Lazy question that I could answer myself when I eventually review this pr: does this approach resolve #283?

@mockersf
Copy link
Member

mockersf commented Nov 4, 2020

yes, yes it does
Screenshot 2020-11-04 at 23 44 13

@enfipy
Copy link
Contributor

enfipy commented Nov 6, 2020

Hey, I tried to rebase this PR branch on bevy master and now it just doesn't show any text. Maybe you have some ideas?

@AlisCode
Copy link
Contributor Author

AlisCode commented Nov 6, 2020

@enfipy I rebased on master, fixed the problem and force-pushed.

CI is broken but that seems to come from bevy_ecs ? Not sure there's anything I can do for that.

@cart
Copy link
Member

cart commented Nov 6, 2020

Hmm yeah that's a problem. I'll fix that now.

@cart
Copy link
Member

cart commented Nov 6, 2020

Reviewing now btw!

@cart
Copy link
Member

cart commented Nov 6, 2020

(master build is fixed)

Cargo.toml Outdated
@@ -329,3 +329,7 @@ crate-type = ["cdylib"]
build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"]
target_sdk_version = 29
min_sdk_version = 16

[[example]]
Copy link
Member

Choose a reason for hiding this comment

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

can we move this alongside the rest of the ui examples? i like to keep these sorted

@@ -42,6 +42,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: TextStyle {
font_size: 60.0,
color: Color::WHITE,
..Default::default()
Copy link
Member

Choose a reason for hiding this comment

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

It looks like text now has a small amount of extra "left-padding" now (master on top, this pr on bottom)

image

Any clue why that is?

Copy link
Member

Choose a reason for hiding this comment

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

Here is how it renders in firefox, which makes me think the first one is correct (red bounds are a div container):
image

Copy link
Contributor

Choose a reason for hiding this comment

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

It's the side bearing that has been subtracted from min_x making the total text rectangle larger as well as increasing the distance from the left, because (if ab_glyph uses the same methodology), the origin already "includes" the side bearing so this has doubled up:

taken from: http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/Text/Text-186.html

i.e. for any glyph:

// left edge
min_x = origin_x;
// right edge
max_x = origin_x + advance;
// top edge
min_y = origin_y + ascent; // because down is positive in ab_glyph, this becomes `origin_y - ascent`
// bottom edge
max_y = origin_y - descent; // down is positive in ab_glyph, so this would be `origin_y + descent`, however, descent is already provided as a negative value in ab_glyph, so it would be `origin_y + -descent`

Simply removing - scaled_font.h_side_bearing(glyph.id) from glyph_brush.rs and pipeline.rs appears to fix it.


Before:
image

After:
image

48px font (bevy/ab_glyph) equivalent to 40px font / 30pt font (CSS/Word)
400% zoom
background image is bevy with white text
foreground image is Word with red text (confirmed behaves the same in Firefox)

}

impl FontAtlasSet {
pub fn new() -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

lets just remove new() here in favor of default()

Copy link
Contributor Author

@AlisCode AlisCode Nov 7, 2020

Choose a reason for hiding this comment

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

I removed new since you're in charge of the style of this codebase so I'm assuming that we should keep it symetrical with other bevy APIs. I would like to mention this though :

https://rust-lang.github.io/api-guidelines/interoperability.html?highlight=expected#types-eagerly-implement-common-traits-c-common-traits

Note that it is common and expected for types to implement both Default and an empty new constructor. new is the constructor convention in Rust, and users expect it to exist, so if it is reasonable for the basic constructor to take no arguments, then it should, even if it is functionally identical to default.

Copy link
Member

Choose a reason for hiding this comment

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

This is one of the few places where my opinions diverge from the api guidelines. I prefer "default only" because:

  • it means theres "one way" to instantiate the type (a good thing ... lowers cognitive load)
  • less code (easier to read, easier to maintain, marginally faster to compile)

@@ -88,6 +88,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, mut state: ResM
style: TextStyle {
font_size: 60.0,
color: Color::WHITE,
..Default::default()
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't work how it used to. It stops adding new glyphs to the atlas after a certain (random) point in time. Probably because it hits a random character that breaks part of the the glyph generation process?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This example was breaking because the size field of the text component's style was set to be [250px, 60px].

The size is being used to limit the bounds that glyph_brush_layout generates the glyphs in, and its behavior in this case is to ... Not generate glyphs that are out of bounds (probably by early returning btw, I haven't checked the sources).

I fixed the example by removing the size of the component, I do not think that this is a bug per se.

Copy link
Member

Choose a reason for hiding this comment

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

yeah that that seems like a desirable property. carry on!

@@ -0,0 +1,178 @@
use std::sync::Mutex;
Copy link
Member

Choose a reason for hiding this comment

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

bevy uses parking_lot mutexes elsewhere. can we switch to that?

Comment on lines 59 to 65
let first_glyph = section_glyphs.first().unwrap();
let mut min_x: f32 =
first_glyph.glyph.position.x - scaled_font.h_side_bearing(first_glyph.glyph.id);
let mut min_y: f32 = first_glyph.glyph.position.y - scaled_font.ascent();
let mut max_x: f32 =
first_glyph.glyph.position.x + scaled_font.h_advance(first_glyph.glyph.id);
let mut max_y: f32 = first_glyph.glyph.position.y - scaled_font.descent();
Copy link
Member

Choose a reason for hiding this comment

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

we can remove redundant code here by replacing this section with f32::MAX/MIN values:

let mut min_x = std::f32::MAX;
let mut min_y = std::f32::MAX;
let mut max_x = std::f32::MIN;
let mut max_y = std::f32::MIN;

};

pub struct TextPipeline {
pub brush: GlyphBrush,
Copy link
Member

Choose a reason for hiding this comment

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

do these fields need to be public? otherwise its probably better to make them private to prevent accidental misuse.

}

#[derive(Debug, Clone)]
pub struct TextVertex {
Copy link
Member

Choose a reason for hiding this comment

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

It seems like "vertex" isn't the right name for this. Vertices are points that make up a mesh, but this seems more like a PositionedGlyph.

}
Ok(vertices)
})
.collect::<Result<Vec<_>, TextError>>()?
Copy link
Member

Choose a reason for hiding this comment

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

Not necessarily something we need to do in this pr, but it would be interesting to try to remove allocations here entirely and just walk through each glyph + render it directly

Copy link
Contributor Author

@AlisCode AlisCode Nov 7, 2020

Choose a reason for hiding this comment

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

I do not think that this is feasible with the new design: we essentially store the TextGlyphs inside an entity now, and iterate over them when rendering. Collection needs to happen at some point, I believe.

false
}
}

pub fn add_char(
Copy link
Member

Choose a reason for hiding this comment

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

i think we can remove this function (and get_char_index() and glyph_to_index)

@razaamir
Copy link

razaamir commented Nov 7, 2020 via email

@AlisCode
Copy link
Contributor Author

AlisCode commented Nov 7, 2020

@cart Thanks for taking the time to review this :)

All comments are adressed.

I have one concern regarding the Mutex on section_queue in glyph_brush : it is essentially useless for now. We need to determine whether queing text from different threads is a goal or not (but I dont think it is, at least for now).

In my opinion :

  • Measuring text shouldn't require mutable access to the TextPipeline since it is done "in one go" and cannot possibly collide with an operation coming from an other thread.
  • Queuing text and processing it using the TextPipeline should require mutable access, because we must not have two threads queuing sections in parellel, that would likely be no bueno.

If we agree on that, I'll make it so.

@enfipy
Copy link
Contributor

enfipy commented Nov 9, 2020

@AlisCode There's sometimes the error NoSuchFont when the font not loaded before render. This error appeared only on this PR's fork. When loading font on the resource stage - everything works.

@tigregalis
Copy link
Contributor

@AlisCode There's sometimes the error NoSuchFont when the font not loaded before render. This error appeared only on this PR's fork. When loading font on the resource stage - everything works.

I ran into this as well on the first run for the text_debug example, but wasn't able to reproduce it in subsequent runs.

@AlisCode
Copy link
Contributor Author

AlisCode commented Nov 9, 2020

@enfipy @tigregalis

Yep, thanks for noticing ; that would be because I removed the QueuedText local resource from text_system, thinking we did not need it anymore. Turns out I was wrong, and I now understand why. I'll re-add it. Re-scheduling the measurement/layout computing sounds like better error handling than the println! that's currently in the PR.

Any comment on the mutability concern around TextPipeline I mentioned ?

@tigregalis
Copy link
Contributor

because we must not have two threads queuing sections in parellel, that would likely be no bueno

@AlisCode Why is this? I'm not sure whether queuing text, and processing it, can't be done from multiple threads. At the entity/component level they shouldn't conflict, at least.

It's just that when you're queuing, you're touching the same resources, writing to the same atlases or potentially inserting to maps under the same keys. I don't think the order things get added matters, so that shouldn't be a concern.

Having said this, right now, it looks like, for any given entity, we're adding its text to the queue, then immediately removing it from the queue to process it, because we need to return the PositionedGlyphs specific to this entity. The queue isn't really doing anything. I think this is because the original intent was that the GlyphBrush would do the drawing, as that's what the original glyph_brush crate was for.

On that particular topic, we could combine the measure, queue_text and process_queued functions on TextPipeline into a single function (let's just call this queue_text), as we're effectively doing all of these operations sequentially without ever "yielding" so to speak. Additionally, we could let the TextPipeline/GlyphBrush end up handling the drawing at the end. Here's what I imagine:

  • in text_system in bevy_ui::stage::UI:
    • for each entity, TextPipeline::queue_text:
      • calculates the SectionGlyphs,
      • calculates the size,
      • builds the OutlineGlyphs,
      • constructs the *Atlases and Textures (ideally support this from multiple threads)
      • calculates the PositionedGlyphs
      • it inserts (overwriting) these onto a queue: HashMap<Entity, Vec<PositionedGlyph>> (ideally support this from multiple threads)
    • The only output from queue_text back into the ECS (text_system) is size, i.e.
      if let Ok(size) = text_pipeline.queue_text(entity, /* ... */) {
          calculated_size.size = size;
      }
    • Otherwise, all the state is held within the TextPipeline/GlyphBrush.
    • Within queue_text you could make extensive use of caching and memoisation.
  • in draw_text_system in bevy_render::stage::DRAW:
    • for each entity, run some new function e.g. TextPipeline::draw_text, and pass in all of:
      mut context: DrawContext,
      msaa: Res<Msaa>,
      mut render_resource_bindings: ResMut<RenderResourceBindings>,
      mut asset_render_resource_bindings: ResMut<AssetRenderResourceBindings>,
      as well as:
      entity: Entity,
      position: Vec3,
      draw: Draw,
      color: Color,
      i.e.
      let text_pipeline = text_pipeline.draw_text(
          &mut context,
          &msaa,
          &mut render_resource_bindings,
          &mut asset_render_resource_bindings,
          entity,
          position,
          &mut draw,
          color,
      );
      • This function would then
        • pull the PositionedGlyphs from its queue for that particular entity,
        • construct the DrawableText for the entity, and call the DrawableText::draw() method
    • You could probably change the order of this a bit and process it in a batch.

@AlisCode
Copy link
Contributor Author

AlisCode commented Nov 9, 2020

@tigregalis

I do agree with the first part, including this :

Additionally, we could let the TextPipeline/GlyphBrush end up handling the drawing at the end

While I agree with the concept of letting bevy_text's TextPipeline store the glyphs, the solution described afterwards would - in my opinion - work well for bevy_ui only. My intent with this PR was also to allow non-bevy_ui approaches to text rendering, such as iced and imgui, where using multiple Entities doesn't make sense (I have some ideas on how to integrate with an ECS for those framework, but that's beside the point).

If we want to go this way and make the TextPipeline modular, in my opinion, we should have bevy_text store in a HashMap (as you mentioned) any identifier for the text, as a generic, and the value would be the PositionedGlyph. That way bevy_ui can set this to be an Entity, and alternative UI backends can set this to be any kind of relevant information/identifier they want.

@tigregalis
Copy link
Contributor

tigregalis commented Nov 10, 2020

@AlisCode

If we want to go this way and make the TextPipeline modular, in my opinion, we should have bevy_text store in a HashMap (as you mentioned) any identifier for the text, as a generic, and the value would be the PositionedGlyph. That way bevy_ui can set this to be an Entity, and alternative UI backends can set this to be any kind of relevant information/identifier they want.

Yeah, I like it.

How straightforward do you think it would be to have "in-game" sprite text for 2d and 3d games?

@AlisCode
Copy link
Contributor Author

AlisCode commented Nov 10, 2020

I dont think it will exactly be straightforward : 2D text will indeed be very simple since it does not differ from rendering on the UI, we can essentially reuse DrawableText, while 3D text will require rendering to a texture.

I'm not sure if bevy supports that sort of thing out of the box (but I would assume not), I also dont know if there's a correct way of supporting this (maybe it's just as stupid as copying pixels to the render texture).

In any case, I'm not sure where this should go. Using a generic on TextPipeline means that any UI plugin (bevy_ui or other) will have to define their TextPipeline resource. Should the definition of in-game sprite lie in bevy_ui then ? In which case that means any user using bevy_whatever as their UI system would not benefit from in-game sprite ...

@tigregalis
Copy link
Contributor

tigregalis commented Nov 10, 2020

For rendering to a texture, I don't understand it 100% but I think that's what's already being done. I might be wildly off the mark, but if I understand correctly it's drawing to a texture which is applied to a quad mesh, and that's actually what gets rendered. On that same note, even in 2d, perhaps it would be useful to provide functionality to bake in certain text onto a newly spawned mesh*, and that mesh would act as any other sprite.
*Though I think this is technically what gets sent to DrawableText.

pub fn draw_text_system(
    mut context: DrawContext,
    msaa: Res<Msaa>,
    meshes: Res<Assets<Mesh>>, <----
    mut render_resource_bindings: ResMut<RenderResourceBindings>,
    mut asset_render_resource_bindings: ResMut<AssetRenderResourceBindings>,
    mut query: Query<(&mut Draw, &Text, &TextGlyphs, &Node, &GlobalTransform)>,
) {
    let font_quad = meshes.get(&QUAD_HANDLE).unwrap(); // <----
    let vertex_buffer_descriptor = font_quad.get_vertex_buffer_descriptor(); // <----

    for (mut draw, text, text_glyphs, node, global_transform) in query.iter_mut() {
        let position = global_transform.translation - (node.size / 2.0).extend(0.0);

        let mut drawable_text = DrawableText {
            render_resource_bindings: &mut render_resource_bindings,
            asset_render_resource_bindings: &mut asset_render_resource_bindings,
            position,
            msaa: &msaa,
            text_glyphs,
            font_quad_vertex_descriptor: &vertex_buffer_descriptor, // <----
            style: &text.style,
        };

        drawable_text.draw(&mut draw, &mut context).unwrap();
    }
}

I think it's fair that TextPipeline<Entity> is inserted in bevy_text::TextPlugin, since the Entity component is a core part of bevy_ecs which underpins the engine. Other plugins that want to make use of TextPipeline<SomeOtherKey> will have to insert their own resource.

As for in-game sprite text, that could be provided via an extra two systems that largely mimic what's in bevy_ui. Those systems could potentially be provided by bevy_text::TextPlugin, as bevy_text already depends on bevy_sprite, but conversely, in-game sprite text should have no requirement on bevy_ui.

@AlisCode
Copy link
Contributor Author

I dont think this is rendering to a target texture. I think the QUAD_HANDLE is just a handle to a Mesh that's inserted by default in the Mesh assets, and allows to draw .. well, a quad. Without re-allocating every time.

I'm done with the refactor, and found the API to be overall much simpler. Most notably :

  • The queue_text function does not return anything. It just computes the glyphs using the GlyphBrush (see below), and stores them in a HashMap owned by the TextPipeline.
  • Refactored GlyphBrush so that we now have :
    • compute_glyphs, which gives a Vec<SectionGlyph> (ab_glyph's specific types)
    • process_glyphs, which computes the Vec<PositionedGlyph> given a Vec<SectionGlyph>.
    • The TextPipeline then measures the size of the output, and stores it inside its HashMap, together with the glyphs, forming a TextLayoutInfo.
  • GlyphBrush logic is somewhat separated from the TextPipeline. The goal of having ab_glyph's implementation details being abstracted away is reached (the user of a TextPipeline does not need ab_glyph details) which sounds reasonable. I'm not sure where the caching - if we implement caching, that is - needs to be implemented. I suggest we keep that for a different PR. Caching will need benchmarks to show that it is indeed more performant. There's also a lot of possible work GlyphBrush-wise to avoid recomputing the whole layout of a text when we just change e.g. one letter.
  • Ho btw, when we fail to add a glyph to the text atlas, we switched from a panic in the font_atlas code to an error that flows to the user of the TextPipeline, who can now handle the error properly (though in most cases, such an error seems to indicate that something is going very wrong)

I still have two issues to tackle (but that should be fairly trivial now) :

  • The NoSuchFont error by re-implementing the QueuedText local resource (this is my next commit).
  • Right now, the TextPipeline needs to be mutably-borrowed to add text to it. As I previously mentioned, in all theory, we should be able to add text to the queue from multiple threads. This is as simple a refactor as using Mutexes, I believe.

@cart
Copy link
Member

cart commented Nov 11, 2020

These changes all sound good. For now lets not add mutexes. I add rather add them later when they have been shown to be measurably better for common use cases.

@AlisCode
Copy link
Contributor Author

@cart ack. I'll rebase on master now. Once this is done and since the NoSuchFont error has been fixed, I think this is good for another round of review if necessary :)

I tested that the error was gone by adding (0..10000000).for_each(|_| {}); in the FontLoader so that it takes time to load the font, and the behaviour is correct (No text is shown until the font is effectively loaded, and no crash).

@AlisCode
Copy link
Contributor Author

All good ! :)

@cart
Copy link
Member

cart commented Nov 11, 2020

Alrighty I think this is good to go! I pushed two small changes:

  • removed the unused glyph_to_index hashmap
  • removed declarations of text alignment from examples where the size isn't explicitly defined, which means size==text_bounds, which means alignment doesnt matter

@cart
Copy link
Member

cart commented Nov 11, 2020

Thanks for the awesome work! You've resolved a pretty major papercut here 😄

@AlisCode
Copy link
Contributor Author

Oops I forgot about those things... The minor tweaks are looking good to me :)

Glad I could contribute to something of use for the engine !

Feel free to merge :)

@cart cart merged commit 465c3d4 into bevyengine:master Nov 13, 2020
@Moxinilian Moxinilian mentioned this pull request Nov 23, 2020
bors bot pushed a commit that referenced this pull request Jan 20, 2022
# Objective

- Fixes #3562 

## Solution

- The outdated reference to `TextGlyphs` has been removed, and replaced with a more accurate docstring.

## What was `TextGlyphs`?
This is the real question of this Issue and PR. This is particulary interesting because not only is `TextGlyphs` not a type in bevy, but it _never was_. Indeed, this type never existed on main. Where did it come from?

`TextGlyphs` was originally a tuple struct wrapping a `Vec<PositionedGlyph>`. It was first introduced back in commit ec390ae in #765. At the time, position information was being stored on the text entities directly. However, after design review, [it was decided](#765 (comment)) to instead store the glyphs in a `HashMap` owned by the `TextPipeline`. When this was done, the original type was not only removed, but abstracted behind a few layers of the `TextPipeline` API. Obviously, the original docstring wasn't updated accordingly.

Later, as part of #1122, the incorrect docstring was swept up when copy/pasting `text_system` for `text2d`. (Although I don't blame @CleanCut for this; it took me like 3 hours to track all this down to find the original context.)
jleflang added a commit to jleflang/bevy that referenced this pull request Feb 11, 2022
commit 9a7852db0f22eb41f259a1afbb4926eb73863a10
Author: devjobe <contact@devjobe.com>
Date:   Tue Feb 8 23:18:11 2022 +0000

    Fix SetSpriteTextureBindGroup to use index (#3896)

    # Objective

    Fix `SetSpriteTextureBindGroup` to use index instead of hard coded 1.
    Fixes #3895

    ## Solution

    1 -> I

    Co-authored-by: devjobe <git@devjobe.com>

commit bdbf626341a35582350711f87fa17dea4ec129f6
Author: Alice Cecile <alice.i.cecile@gmail.com>
Date:   Tue Feb 8 23:04:19 2022 +0000

    Implement init_resource for `Commands` and `World` (#3079)

    # Objective

    - Fixes #3078
    - Fixes #1397

    ## Solution

    - Implement Commands::init_resource.
    - Also implement for World, for consistency and to simplify internal structure.
    - While we're here, clean up some of the docs for Command and World resource modification.

commit 38f6da5a85a8037de5eb4ea8531902ea1269ede1
Author: B-Janson <bjanson28@gmail.com>
Date:   Tue Feb 8 16:24:46 2022 +0000

    Add generic systems example (#2636)

    # Objective
    My attempt at fixing #2142. My very first attempt at contributing to Bevy so more than open to any feedback.
    I borrowed heavily from the [Bevy Cheatbook page](https://bevy-cheatbook.github.io/patterns/generic-systems.html?highlight=generic#generic-systems).

    ## Solution
    Fairly straightforward example using a clean up system to delete entities that are coupled with app state after exiting that state.

    Co-authored-by: B-Janson <brandon@canva.com>

commit 56b0e88b5331a2df31b757ff91b5ef30853bb5c5
Author: Loch Wansbrough <lochie@live.com>
Date:   Tue Feb 8 04:14:34 2022 +0000

    Add view transform to view uniform (#3885)

    (cherry picked from commit de943381bd2a8b242c94db99e6c7bbd70006d7c3)

    # Objective

    The view uniform lacks view transform information. The inverse transform is currently provided but this is not sufficient if you do not have access to an `inverse` function (such as in WGSL).

    ## Solution

    Grab the view transform, put it in the view uniform, use the same matrix to compute the inverse as well.

commit 1e049a651b13021653c31ec5903212936d585241
Author: Ryo Hirayama <ryo12redstone@gmail.com>
Date:   Tue Feb 8 04:14:33 2022 +0000

    Fix type mismatch error with latest winit (#3883)

    # Objective

    When I use the latest winit with bevy main, I got this error.
    ```
    error[E0308]: mismatched types
       --> /Users/ryo/.cargo/git/checkouts/bevy-f7ffde730c324c74/b13f238/crates/bevy_winit/src/lib.rs:191:5
        |
    191 |     event_loop.run_return(event_handler)
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `i32`
        |
    help: consider using a semicolon here
        |
    191 |     event_loop.run_return(event_handler);
        |                                         +
    help: try adding a return type
        |
    187 | -> i32 where
        | ++++++
    ```

    In [this commit](https://github.com/rust-windowing/winit/commit/a52f755ce8dfffe53329163364908937c780057d), the signature of `run_return` was changed in winit.

    ## Solution

    This tiny PR does not add support for exit code, but makes compilation successful.

commit 6615b7bf6439c9bcaf59982b2713e1c1564bf0f5
Author: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
Date:   Tue Feb 8 04:00:58 2022 +0000

    Deprecate `.system` (#3302)

    # Objective

    - Using `.system()` is no longer idiomatic.

    ## Solution

    - Give a warning when using it

commit 2f11c9dca84902423d37c887f941e835dad66ff7
Author: Gingeh <39150378+Gingeh@users.noreply.github.com>
Date:   Tue Feb 8 03:37:34 2022 +0000

    Add Query::contains (#3090)

    # Objective

    - Fixes #3089

commit 1468211e2bb91c528098fbe1c7f9c3d8bbb072c7
Author: François <mockersf@gmail.com>
Date:   Tue Feb 8 02:59:54 2022 +0000

    fix unreachable macro calls for rust 2021 (#3889)

    # Objective

    - It was decided in Rust 2021 to make macro like `panic` require a string literal to format instead of directly an object
    - `unreachable` was missed during the first pass but it was decided to go for it anyway now: https://github.com/rust-lang/rust/issues/92137#issuecomment-1019519285
    - this is making Bevy CI fail now: https://github.com/bevyengine/bevy/runs/5102586734?check_suite_focus=true

    ## Solution

    - Fix calls to `unreachable`

commit b3462428c9e65865499cd3739c0ab3459a2c30d9
Author: MinerSebas <scherthan_sebastian@web.de>
Date:   Tue Feb 8 00:03:50 2022 +0000

    Move the CoreStage::Startup to a seperate StartupSchedule label (#2434)

    # Objective

    - `CoreStage::Startup` is unique in the `CoreStage` enum, in that it represents a `Schedule` and not a `SystemStage`.
    - This can lead to confusion about how `CoreStage::Startup` and the `StartupStage` enum are related.
    - Beginners sometimes try `.add_system_to_stage(CoreStage::Startup, setup.system())` instead of `.add_startup_system(setup.system())`, which causes a Panic:
    ```
    thread 'main' panicked at 'Stage 'Startup' does not exist or is not a SystemStage', crates\bevy_ecs\src\schedule\mod.rs:153:13
    stack backtrace:
       0: std::panicking::begin_panic_handler
                 at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b\/library\std\src\panicking.rs:493
       1: std::panicking::begin_panic_fmt
                 at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b\/library\std\src\panicking.rs:435
       2: bevy_ecs::schedule::{{impl}}::add_system_to_stage::stage_not_found
                 at .\crates\bevy_ecs\src\schedule\mod.rs:153
       3: bevy_ecs::schedule::{{impl}}::add_system_to_stage::{{closure}}<tuple<bevy_ecs::system::function_system::IsFunctionSystem, tuple<bevy_ecs::system::commands::Commands, bevy_ecs::change_detection::ResMut<bevy_asset::assets::Assets<bevy_render::mesh::mesh::Me
                 at .\crates\bevy_ecs\src\schedule\mod.rs:161
       4: core::option::Option<mut bevy_ecs::schedule::stage::SystemStage*>::unwrap_or_else<mut bevy_ecs::schedule::stage::SystemStage*,closure-0>
                 at C:\Users\scher\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs:427
       5: bevy_ecs::schedule::Schedule::add_system_to_stage<tuple<bevy_ecs::system::function_system::IsFunctionSystem, tuple<bevy_ecs::system::commands::Commands, bevy_ecs::change_detection::ResMut<bevy_asset::assets::Assets<bevy_render::mesh::mesh::Mesh>>, bevy_ec
                 at .\crates\bevy_ecs\src\schedule\mod.rs:159
       6: bevy_app::app_builder::AppBuilder::add_system_to_stage<tuple<bevy_ecs::system::function_system::IsFunctionSystem, tuple<bevy_ecs::system::commands::Commands, bevy_ecs::change_detection::ResMut<bevy_asset::assets::Assets<bevy_render::mesh::mesh::Mesh>>, be
                 at .\crates\bevy_app\src\app_builder.rs:196
       7: 3d_scene::main
                 at .\examples\3d\3d_scene.rs:4
       8: core::ops::function::FnOnce::call_once<fn(),tuple<>>
                 at C:\Users\scher\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227
    ```

    ## Solution

    - Replace the `CoreStage::Startup` Label with the new `StartupSchedule` unit type.

    Resolves #2229

commit f7478f448ab1493986a4fcb60f7567c95a8dba4d
Author: dataphract <dataphract@gmail.com>
Date:   Mon Feb 7 22:07:43 2022 +0000

    doc: remove mention of void return type in entry_point docs (#3881)

    # Objective

    The docs for `{VertexState, FragmentState}::entry_point` stipulate that the entry point function in the shader must return void. This seems to be specific to GLSL; WGSL has no `void` type and its entry point functions return values that describe their output.

    ## Solution

    Remove the mention of the `void` return type.

commit 3d6e4893f66bec6e6cfba8c76cf28c81bf92ea17
Author: François <mockersf@gmail.com>
Date:   Mon Feb 7 21:50:52 2022 +0000

    reverse how diagnostic values are saved (#3056)

    # Objective

    - Currently, when getting a diagnostic value, the oldest value is returned. This is not the best for a diagnostic with a large history, as you could get a value from several frames away

    ## Solution

    - I changed the order in which the history is used to follow ["The “default” usage of this type as a queue is to use push_back to add to the queue, and pop_front to remove from the queue."](https://doc.rust-lang.org/std/collections/vec_deque/struct.VecDeque.html)

commit b13f238fc73692741ff87f804117770b1f42933c
Author: Delphine <delphine@lp0onfire.io>
Date:   Sun Feb 6 04:16:16 2022 +0000

    allow Entity to be deserialized with serde_json (#3873)

    # Objective

    - `serde_json` assumes that numbers being deserialized are either u64 or i64.
    - `Entity` serializes and deserializes as a u32.
    - Deserializing an `Entity` with `serde_json` fails with: `Error("invalid type: integer 10947, expected expected Entity"`

    ## Solution

    - Implemented a visitor for u64 that allows an `Entity` to be deserialized in this case.
    - While I was here, also fixed the redundant "expected expected Entity" in the error message
    - Tested the change in a local project which now correctly deserializes `Entity` structs with `serde_json` when it couldn't before

commit 75286b8540dc5795270465ed4584321f1a8dc3eb
Author: François <mockersf@gmail.com>
Date:   Sun Feb 6 01:07:56 2022 +0000

    check if resource for asset already exists before adding it (#3560)

    # Objective

    - Fix #3559
    - Avoid erasing existing resource `Assets<T>` when adding it twice

    ## Solution

    - Before creating a new `Assets<T>`, check if it has already been added to the world

    Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
    Co-authored-by: Aevyrie Roessler <aevyrie@gmail.com>

commit 59ee512292ab5e3b4be1ed6a32e6601413096857
Author: MinerSebas <scherthan_sebastian@web.de>
Date:   Sun Feb 6 01:07:55 2022 +0000

    Add TransformBundle (#3054)

    # Objective

    - Bevy currently has no simple way to make an "empty" Entity work correctly in a Hierachy.
      - The current Solution is to insert a Tuple instead:

    ```rs
    .insert_bundle((Transform::default(), GlobalTransform::default()))
    ```

    ## Solution

    * Add a `TransformBundle` that combines the Components:

    ```rs
    .insert_bundle(TransformBundle::default())
    ```

    * The code is based on #2331, except for missing the more controversial usage of `TransformBundle` as a Sub-bundle in preexisting Bundles.

    Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit 7604665880204e0aea79611c4ce0ff9d70a55755
Author: TheRawMeatball <therawmeatball@gmail.com>
Date:   Sun Feb 6 00:52:47 2022 +0000

    Implement AnyOf queries (#2889)

    Implements a new Queryable called AnyOf, which will return an item as long as at least one of it's requested Queryables returns something. For example, a `Query<AnyOf<(&A, &B, &C)>>` will return items with type `(Option<&A>, Option<&B>, Option<&C>)`, and will guarantee that for every element at least one of the option s is Some. This is a shorthand for queries like `Query<(Option<&A>, Option<&B>, Option<&C>), Or<(With<A>, With<B>, With&C>)>>`.

    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit a0af066af7dabf40457777504d2c5e323250b000
Author: Pocket7878 <poketo7878@gmail.com>
Date:   Sat Feb 5 17:21:00 2022 +0000

    fix typo in bevy_ecs/README.md (#3869)

    # Objective

    Fixes #3866

    ## Solution

    Fix comment in bevy_ecs/README.md

commit 385a2b189528d0c6c706f7d25969414b61450774
Author: François <mockersf@gmail.com>
Date:   Sat Feb 5 01:52:47 2022 +0000

    add examples on how to have a data source running in another thread / in a task pool thread (#2915)

    Add two examples on how to communicate with a task that is running either in another thread or in a thread from `AsyncComputeTaskPool`.

    Loosely based on https://github.com/bevyengine/bevy/discussions/1150

commit 865698548f23fa13a03202442bf114f5c01b8f46
Author: TheRawMeatball <therawmeatball@gmail.com>
Date:   Fri Feb 4 21:22:12 2022 +0000

    Fix HDR asset support (#3795)

    The HDR texture loader was never added to the app, this PR makes sure it is added when the relevant feature is enabled.

commit 3431335ee9a2e3cfda81485d8080f85c0bc50461
Author: Jakob Hellermann <jakob.hellermann@protonmail.com>
Date:   Fri Feb 4 03:37:45 2022 +0000

    add missing `into_inner` to `ReflectMut` (#3841)

    `Mut<T>`, `ResMut<T>` etc. have `.into_inner()` methods, but `ReflectMut` doesn't for some reason.

commit 1477765f626b39c4a52d42f567acfa9efb0e8123
Author: aloucks <aloucks@cofront.net>
Date:   Fri Feb 4 03:37:44 2022 +0000

    Replace VSync with PresentMode (#3812)

    # Objective

    Enable the user to specify any presentation modes (including `Mailbox`).

    Fixes #3807

    ## Solution

    I've added a new `PresentMode` enum in `bevy_window` that mirrors the `wgpu` enum 1:1. Alternatively, I could add a new dependency on `wgpu-types` if that would be preferred.

commit fe0e5580db9e32f344605f598f7e2b056f2afc96
Author: Mika <blaind@blaind.net>
Date:   Fri Feb 4 03:37:42 2022 +0000

    Fix node update (#3785)

    # Objective

    Fixes #3784

    ## Solution

    Check if the node size is actually different from previous

commit b11ee3ffb83864a989b329585e1f2ff5b368c1af
Author: Gwen <Gwen@Lofman.io>
Date:   Fri Feb 4 03:37:40 2022 +0000

    Remove duplicate call to set_vertex_buffer(0, ...) in shader_instancing example (#3738)

    ## Objective

    The [`DrawMeshInstanced`] command in the example sets vertex buffer 0 twice, with two identical calls to:

    ```rs
    pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..));
    ```

    ## Solution

    Remove the second call as it is unecessary.

    [`DrawMeshInstanced`]: https://github.com/bevyengine/bevy/blob/f3de12bc5e03c58a9b863943b8db84a321422bec/examples/shader/shader_instancing.rs#L217-L258

commit b7dfe1677fd8f92d3bbf0af658515e077b96cd1a
Author: Jakob Hellermann <jakob.hellermann@protonmail.com>
Date:   Fri Feb 4 03:37:38 2022 +0000

    include sources in shader validation error (#3724)

    ## Objective

    When print shader validation error messages, we didn't print the sources and error message text, which led to some confusing error messages.

    ```cs
    error:
       ┌─ wgsl:15:11
       │
    15 │     return material.color + 1u;
       │           ^^^^^^^^^^^^^^^^^^^^ naga::Expression [11]
    ```

    ## Solution

    New error message:
    ```cs
    error: Entry point fragment at Vertex is invalid
       ┌─ wgsl:15:11
       │
    15 │     return material.color + 1u;
       │           ^^^^^^^^^^^^^^^^^^^^ naga::Expression [11]
       │
       = Expression [11] is invalid
       = Operation Add can't work with [8] and [10]
    ```

commit aa7b15889303244ebb732e6f5663051a71d5555e
Author: Boutillier <boris.boutillier@gmail.com>
Date:   Fri Feb 4 03:21:33 2022 +0000

    Add a size method on Image. (#3696)

    # Objective

    Add a simple way for user to get the size of a loaded texture in an Image object.
    Aims to solve #3689

    ## Solution

    Add a `size() -> Vec2` method
    Add two simple tests for this method.

    Updates:
    . method named changed from `size_2d` to `size`

commit 142e7f3c5058f498f263c24d94604e5e6521d358
Author: TheRawMeatball <therawmeatball@gmail.com>
Date:   Fri Feb 4 03:21:31 2022 +0000

    Backport soundness fix (#3685)

    #3001 discovered a soundness bug in World::resource_scope, this PR backports the fix with a smaller PR to patch out the bug sooner.

    Fixes #3147

commit e928acb9ff12230893f696f1e2e6d5f6a17f69ac
Author: Robert Swain <robert.swain@gmail.com>
Date:   Fri Feb 4 03:21:29 2022 +0000

    bevy_asset: Add AssetServerSettings watch_for_changes member (#3643)

    # Objective

    - `asset_server.watch_for_changes().unwrap()` only watches changes for assets loaded **_after_** that call.
    - Technically, the `hot_asset_reloading` example is racey as the watch on the asset path is set up in an async task scheduled from the asset `load()`, but the filesystem watcher is only constructed in a call that comes **_after_** the call to `load()`.

    ## Solution

    -  It feels safest to allow enabling watching the filesystem for changes on the asset server from the point of its construction. Therefore, adding such an option to `AssetServerSettings` seemed to be the correct solution.
    - Fix `hot_asset_reloading` by inserting the `AssetServerSettings` resource with `watch_for_changes: true` instead of calling `asset_server.watch_for_changes().unwrap()`.
    - Document the shortcomings of `.watch_for_changes()`

commit ca83e8a6debce99656989df2656dd6e1926352d8
Author: dataphract <dataphract@gmail.com>
Date:   Fri Feb 4 03:07:22 2022 +0000

    fix: remove unneeded filter in check_light_mesh_visibility (#3861)

    # Objective

    The query for `VisiblePointLights` in `check_light_mesh_visibility` has a `Without<DirectionalLight>` filter. However, because `VisiblePointLights` is no longer an alias for `VisibleEntities`, the query won't conflict with the query for `DirectionalLight`s and thus the filter is unnecessary.

    ## Solution

    Remove the filter and the outdated comment explaining its purpose.

commit fe4a42a6485df4e441424dc6e66ae083dac52a3b
Author: Daniel Bearden <danbear0@gmail.com>
Date:   Fri Feb 4 03:07:21 2022 +0000

    Mut to immut impls (#3621)

    # Objective
    - Provide impls for mutable types to relevant immutable types.
    - Closes #2005

    ## Solution

    - impl From<ResMut> for Res
    - impl From<NonSendMut> for NonSend
    - Mut to &/&mut already impl'd in change_detection_impl! macro

commit 6b8d64cd019ad9a1dbe53752fed50c87c178af61
Author: JoJoJet <joe102000@gmail.com>
Date:   Fri Feb 4 03:07:20 2022 +0000

    impl more traits for bevy_core::Name (#3611)

    # Objective

    - `Name` component is missing some useful trait impls.

    ## Solution

    - Implement the missing traits. `Display`, `AsRef<str>`, and several other conversions to and from strings.

commit f00aec2454dff63a992dcef30256b8663c38ac5b
Author: MrGVSV <gino.valente.code@gmail.com>
Date:   Fri Feb 4 03:07:18 2022 +0000

    Added method to restart the current state (#3328)

    # Objective

    It would be useful to be able to restart a state (such as if an operation fails and needs to be retried from `on_enter`). Currently, it seems the way to restart a state is to transition to a dummy state and then transition back.

    ## Solution

    The solution is to add a `restart` method on `State<T>` that allows for transitioning to the already-active state.

    ## Context

    Based on [this](https://discord.com/channels/691052431525675048/742884593551802431/920335041756815441) question from the Discord.

    Closes #2385

    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit e2cce092d7d00d71c3643b02105e9c96879631dd
Author: rezural <rezural@protonmail.com>
Date:   Fri Feb 4 02:42:59 2022 +0000

    derive clone for Input (#3569)

    # Objective

    - As part of exploring input event suppression in bevy_egui here: https://github.com/mvlabat/bevy_egui/pull/50/commits/53c1773583f2dfc2a8f8bc2aa93de1c9c5fd05ec
    - I found that the only way to suppress events properly, is to allow to clone the relevant Input<Whatever>, and update with events manually from within the system. This cloned Input then is discarded, the Events<*> structs are cleared, and bevy_input's normal update of Input proceeds, without the events that have been suppressed.

    ## Solution

    - This enables Input to be cloned, allowing it to be manually updated with events.

commit ef65548fbaf104c7627c696a21843e41f6ca425e
Author: ickk <git@ickk.io>
Date:   Fri Feb 4 02:42:58 2022 +0000

    Change default window title to "app" (#3417)

    Implements the changes cart decided on in https://github.com/bevyengine/bevy/pull/3404#issuecomment-999806086

    > - The default title should be changed to app so we don't leak the "bevy context" by default. app is generic enough that most people building real games will probably want to change it, but also generic enough that if someone doesn't manually set it, users won't bat an eye. I prefer this to binary names because they won't be consistent on all platforms / setups. A user (or developer) renaming a binary would implicitly rename the window title, which feels odd to me.
    > - No debug info in the title by default. An opt in plugin for that would be nice though.

    closes #3404 ?

commit bb1538a13926327ad7996a1e7ba9c12c5784ac9a
Author: Kevin King <4kevinking@gmail.com>
Date:   Fri Feb 4 02:26:18 2022 +0000

    improve error message for attempting to add systems using add_system_to_stage (#3287)

    # Objective

    Fixes #3250

    ## Solution

    Since this panic occurs in bevy_ecs, and StartupStage is part of
    bevy_app, we really only have access to the Debug string of the
    `stage_label` parameter.  This led me to the hacky solution of
    comparing the debug output of the label the user provides with the known
    variants of StartupStage.

    An alternative would be to do this error handling further up in
    bevy_app, where we can access StartupStage's typeid, but I don't think
    it is worth having a panic in 2 places (_ecs, and _app).

commit f584e729537262cb0166586933396763f353784d
Author: James Beilby <jamesbeilby@gmail.com>
Date:   Fri Feb 4 02:09:24 2022 +0000

    Add Transform::rotate_around method (#3107)

    # Objective

    - Missing obvious way to rotate a transform around a point. This is popularly used for rotation of an object in world space ("orbiting" a point), or for local rotation of an object around a pivot point on that object.
    - Present in other (not to be named) game engines
    - Was question from user on Discord today (thread "object rotation")

    ## Solution

    - Added Transform::rotate_around method where point is specified in reference frame of the parent (if any) or in world space.

commit 37a7be56dbfcac13cede6df3c06c53ba79aedcb6
Author: François <mockersf@gmail.com>
Date:   Fri Feb 4 01:46:35 2022 +0000

    Make transform builder methods const (#3045)

    # Objective

    - Make transform builder methods `const`

    ## Solution

    - I made them `const`

commit 7d712406fe661c79c828753db6fb20210a3d93c1
Author: Charles <c.giguere42@gmail.com>
Date:   Fri Feb 4 01:24:47 2022 +0000

    Simplify sending empty events (#2935)

    # Objective

    When using empty events, it can feel redundant to have to specify the type of the event when sending it.

    ## Solution

    Add a new `fire()` function that sends the default value of the event. This requires that the event derives Default.

    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit 6f111136b9f2ebd5ab0975389f4c810242d1645d
Author: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
Date:   Thu Feb 3 23:56:57 2022 +0000

    Cleanup some things which shouldn't be components (#2982)

    # Objective

    - Using `Stopwatch` and `Timer` as raw components is a footgun.

    ## Solution

    - Stop them from being components

commit 1f99363de90cafc596f162e100511c2356cabd67
Author: bilsen <ivar.kallstrom@gmail.com>
Date:   Thu Feb 3 23:43:25 2022 +0000

    Add &World as SystemParam (#2923)

    # Objective
    Make it possible to use `&World` as a system parameter

    ## Solution
    It seems like all the pieces were already in place, very simple impl

    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit c216738b33d7a38aee08e885dc03f43f6b13a6f1
Author: Garett Cooper <garett@garettcooper.com>
Date:   Thu Feb 3 23:22:08 2022 +0000

    Implement len and is_empty for EventReaders (#2969)

    # Objective

    Provide a non-consuming method of checking if there are events in an `EventReader`.

    Fixes #2967

    ## Solution

    Implements the `len` and `is_empty` functions for `EventReader` and `ManualEventReader`, giving users the ability to check for the presence of new events without consuming any.

    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit af22cc1dc3713a24115e1cf8088cf7d4703f6d34
Author: bjorn3 <bjorn3@users.noreply.github.com>
Date:   Thu Feb 3 22:34:31 2022 +0000

    Use ManuallyDrop instead of forget in insert_resource_with_id (#2947)

    # Objective

    Calling forget would invalidate the data pointer before it is used.

    ## Solution

    Use `ManuallyDrop` to prevent the value from being dropped without moving it.

commit 6ac9d6876f7c0b71b1f84ec3e5df3460acba9449
Author: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
Date:   Thu Feb 3 22:34:29 2022 +0000

    Make ECS benchmark more representative (#2941)

    # Objective

    - The addition was being optimised out in the `for_each` loop, but not the `for` loop
    - Previously this meant that the `for_each` loop looked 3 times as fast - it's actually only 2 times as fast
    - Effectively, the addition take one unit of time, the for_each takes one unit of time, and the for loop version takes two units of time.

    ## Solution

    - `black_box` the count in each loop

    Note that this does not fix `for_each` being faster than `for`, unfortunately.

commit c44f8b2b68dfece1183c2ec7abb26b5fde746304
Author: Alice Cecile <alice.i.cecile@gmail.com>
Date:   Thu Feb 3 04:25:45 2022 +0000

    Run tests (including doc tests) in `cargo run -p ci` command (#3849)

    # Objective

    - Using the `cargo run -p ci` command locally is unreliable, as it does not run tests.
    - This is particularly unreliable for doc tests, as they are not run as part of `cargo test`.

    ## Solution

    - add more steps to the appropriate Rust file.

    ## Known Problems

    This duplicates work done to run tests when run on Github. @mockersf, suggestions on if we care / how we can mitigate it?

commit 19bd6b9c320c34d55f7e5f8bd16f51f0bb8831b2
Author: François <mockersf@gmail.com>
Date:   Thu Feb 3 04:25:44 2022 +0000

    Update rodio 0.15 (#3846)

    # Objective

    - Update rodio to 0.15
    - Replace #3828

commit 21ac4bc0ae24e519896f997bcfe9c215c5f78901
Author: Stefan Seemayer <stefan@seemayer.de>
Date:   Thu Feb 3 04:11:19 2022 +0000

    impl Command for <impl FnOnce(&mut World)> (#2996)

    This is my first contribution to this exciting project! Thanks so much for your wonderful work. If there is anything that I can improve about this PR, please let me know :)

    # Objective

    - Fixes #2899
    - If a simple one-off command is needed to be added within a System, this simplifies that process so that we can simply do `commands.add(|world: &mut World| { /* code here */ })` instead of defining a custom type implementing `Command`.

    ## Solution

    - This is achieved by `impl Command for F where F: FnOnce(&mut World) + Send + Sync + 'static` as just calling the function.

    I am not sure if the bounds can be further relaxed but needed the whole `Send`, `Sync`, and `'static` to get it to compile.

commit 69e9a47d92ff8599c270d77a6ce2917c97059d8c
Author: MinerSebas <scherthan_sebastian@web.de>
Date:   Thu Feb 3 03:32:02 2022 +0000

    SystemParam Derive fixes (#2838)

    # Objective

    A user on Discord couldn't derive SystemParam for this Struct:

    ```rs
    #[derive(SystemParam)]
    pub struct SpatialQuery<'w, 's, Q: WorldQuery + Send + Sync + 'static, F: WorldQuery + Send + Sync + 'static = ()>
    where
        F::Fetch: FilterFetch,
    {
        query: Query<'w, 's, (C, &'static Transform), F>,
    }
    ```

    ## Solution

    1. The `where`-clause is now also copied to the `SystemParamFetch` impl Block.
    2. The `SystemParamState` impl Block no longer gets any defaults for generics

    Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>

commit b506c30cd39742385e48e742ab464023ef3c6689
Author: dataphract <dataphract@gmail.com>
Date:   Thu Feb 3 00:43:37 2022 +0000

    fix: only init_resource() once for AmbientLight (#3853)

    # Objective

    `PbrPlugin` calls `app.init_resource::<AmbientLight>()` twice. The second call won't do anything.

    ## Solution

    Remove the second call.

commit 506642744c1839b76e3286b6885c467d80bdc71a
Author: KDecay <kdecaymusic@protonmail.com>
Date:   Wed Feb 2 21:47:29 2022 +0000

    docs: Fix private doc links and enable CI test (#3743)

    # Objective

    Fixes #3566

    ## Solution

    - [x] Fix broken links in private docs.
    - [x] Add the `--document-private-items` flag to the CI.

    ## Note

    The following was said by @killercup in #3566:

    > I don't have time to confirm this but I assume that linking to private items throws an error/warning when just running cargo doc, and --document-private-item might actually hide that warning. So to test this, you'd have to run it twice.

    I tested this and this is thankfully not the case. If you are linking to a private item you will get a warning no matter if you run `cargo doc` or `cargo doc --document-private-items`.

    ### Example

    I added `struct Test;` to `bevy_core/src/name.rs` and linked to it inside of a doc comment using ``[`Test`]``. After that I ran `cargo doc -p bevy_core --document-private-items` using `RUSTDOCFLAGS="-D warnings"` and got the following output (note the last sentence):

    ```rust
    error: public documentation for `Name` links to private item `Test`
      --> crates/bevy_core/src/name.rs:11:82
       |
    11 | /// Component used to identify an entity. Stores a hash for faster comparisons [`Test`]
       |                                                                                  ^^^^ this item is private
       |
       = note: `-D rustdoc::private-intra-doc-links` implied by `-D warnings`
       = note: this link resolves only because you passed `--document-private-items`, but will break without
    ```

commit 6cab36165f93fa240ae88298e897e687fee892aa
Author: Andrew Jackson <andrew.c.j1995@gmail.com>
Date:   Wed Feb 2 21:29:48 2022 +0000

    Update ClearColor Resource docs (#3842)

    # Objective
    - Update the `ClearColor` resource docs as described in #3837  so new users (like me) understand it better

    ## Solution
    - Update the docs to use what @alice-i-cecile described in #3837

    I took this one up because I got confused by it this weekend. I didn't understand why the  "background" was being set by a `ClearColor` resource.

commit f991c73bdf2b3fa9ec5987ac5ecce67edafb99dd
Author: jak6jak <jacobedie1@gmail.com>
Date:   Wed Feb 2 02:44:51 2022 +0000

    Add move sprite example.  (#2414)

    ## Objective
    There is no bevy example that shows how to transform a sprite. At least as its singular purpose. This creates an example of how to use transform.translate to move a sprite up and down. The last pull request had issues that I couldn't fix so I created a new one

    ### Solution
    I created move_sprite example.

    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit ce752d25228f2982546f02566ed5bdceb8fc3184
Author: TheRawMeatball <therawmeatball@gmail.com>
Date:   Wed Feb 2 02:29:33 2022 +0000

    Increment last event count on next instead of iter (#2382)

    # Objective

    Currently, simply calling `iter` on an event reader will mark all of it's events as read, even if the returned iterator is never used

    ## Solution

    With this, the cursor will simply move to the last unread, but available event when iter is called, and incremented by one per `next` call.

    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit 6a499b125bf2f37e2f95bf7936da382bc3571622
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed Feb 2 00:25:39 2022 +0000

    Update gltf requirement from 0.16.0 to 1.0.0 (#3826)

    Updates the requirements on [gltf](https://github.com/gltf-rs/gltf) to permit the latest version.
    <details>
    <summary>Changelog</summary>
    <p><em>Sourced from <a href="https://github.com/gltf-rs/gltf/blob/master/CHANGELOG.md">gltf's changelog</a>.</em></p>
    <blockquote>
    <h2>[1.0.0] - 2022-01-29</h2>
    <h3>Added</h3>
    <ul>
    <li>Support for the <code>KHR_materials_specular</code> extension.</li>
    <li>Support for the <code>KHR_materials_variants</code> extension.</li>
    <li>Support for the <code>KHR_materials_volume</code> extension.</li>
    <li><code>ExactSizeIterator</code> implementation for <code>Joints</code> iterator.</li>
    </ul>
    <h3>Changed</h3>
    <ul>
    <li>The <code>mesh.primitives</code> property is now always serialized.</li>
    </ul>
    <h3>Fixed</h3>
    <ul>
    <li>Incorrect implementation of <code>Normalize&lt;u16&gt;</code> and <code>Normalize&lt;f32&gt;</code> for <code>u16</code>.</li>
    </ul>
    <h2>[0.16.0] - 2021-05-13</h2>
    <h3>Added</h3>
    <ul>
    <li>Support for the <code>KHR_texture_transform</code> extension.</li>
    <li>Support for the <code>KHR_materials_transmission_ior</code> extension.</li>
    </ul>
    <h3>Changed</h3>
    <ul>
    <li><code>Material::alpha_cutoff</code> is now optional.</li>
    </ul>
    <h3>Fixed</h3>
    <ul>
    <li>URIs with embedded data failing to import when using <code>import_slice</code>.</li>
    <li>Serialization of empty primitives object being skipped.</li>
    </ul>
    <h2>[0.15.2] - 2020-03-29</h2>
    <h3>Changed</h3>
    <ul>
    <li>All features are now exposed in the <a href="http://docs.rs/gltf">online documentation</a>.</li>
    <li>Primary iterators now implement <code>Iterator::nth</code> explicitly for improved performance.</li>
    </ul>
    <h3>Fixed</h3>
    <ul>
    <li>Compiler warnings regarding deprecation of <code>std::error::Error::description</code>.</li>
    </ul>
    <h2>[0.15.1] - 2020-03-15</h2>
    <h3>Added</h3>
    <ul>
    <li>New feature <code>guess_mime_type</code> which, as the name suggests, attempts to guess
    the MIME type of an image if it doesn't exactly match the standard.</li>
    </ul>
    <!-- raw HTML omitted -->
    </blockquote>
    <p>... (truncated)</p>
    </details>
    <details>
    <summary>Commits</summary>
    <ul>
    <li>See full diff in <a href="https://github.com/gltf-rs/gltf/commits">compare view</a></li>
    </ul>
    </details>
    <br />

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

    [//]: # (dependabot-automerge-start)
    [//]: # (dependabot-automerge-end)

    ---

    <details>
    <summary>Dependabot commands and options</summary>
    <br />

    You can trigger Dependabot actions by commenting on this PR:
    - `@dependabot rebase` will rebase this PR
    - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
    - `@dependabot merge` will merge this PR after your CI passes on it
    - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
    - `@dependabot cancel merge` will cancel a previously requested merge and block automerging
    - `@dependabot reopen` will reopen this PR if it is closed
    - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

    </details>

commit c285a69f76d4ac9909d05f7956f2b1276512038a
Author: Horváth Bálint <horvbalint99@gmail.com>
Date:   Tue Feb 1 22:40:25 2022 +0000

    Add the Inside version to the Collision enum (#2489)

    # Objective
    I think the 'collide' function inside the 'bevy/crates/bevy_sprite/src/collide_aabb.rs' file should return 'Some' if the two rectangles are fully overlapping or one is inside the other. This can happen on low-end machines when a lot of time passes between two frames because of a stutter, so a bullet for example gets inside its target. I can also think of situations where this is a valid use case even without stutters.

    ## Solution
    I added an 'Inside' version to the Collision enum declared in the file. And I use it, when the two rectangles are overlapping, but we can't say from which direction it happened. I gave a 'penetration depth' of minus Infinity to these cases, so that this variant only appears, when the two rectangles overlap from each side fully. I am not sure if this is the right thing to do.

    Fixes #1980

    Co-authored-by: Carter Anderson <mcanders1@gmail.com>

commit 4134577e646e0d1017064780bca34bb3fa096216
Author: Carter Anderson <mcanders1@gmail.com>
Date:   Mon Jan 31 02:30:05 2022 +0000

    Fix Code of Conduct bolding in readme (#3822)

commit 33ef5b5039ce4bea9b33199c1e5649dc858a6d4c
Author: Robert Swain <robert.swain@gmail.com>
Date:   Mon Jan 31 01:22:17 2022 +0000

    bevy_render: Only auto-disable mappable primary buffers for discrete GPUs (#3803)

    # Objective

    - While it is not safe to enable mappable primary buffers for all GPUs, it should be preferred for integrated GPUs where an integrated GPU is one that is sharing system memory.

    ## Solution

    - Auto-disable mappable primary buffers only for discrete GPUs. If the GPU is integrated and mappable primary buffers are supported, use them.

commit ca029ef0ebf89dde45bf428110d2eb33d6585273
Author: sark <sarkahn@gmail.com>
Date:   Mon Jan 31 00:32:47 2022 +0000

    Naga export (#3714)

    # Objective

    In order to create a glsl shader, we must provide the `naga::ShaderStage` type which is not exported by bevy, meaning a user would have to manually include naga just to access this type.

    `pub fn from_glsl(source: impl Into<Cow<'static, str>>, stage: naga::ShaderStage) -> Shader {`

    ## Solution

    Re-rexport naga::ShaderStage from `render_resources`

commit 44d09dc46db356d22f3f232d16398c36db4e3d10
Author: François <mockersf@gmail.com>
Date:   Fri Jan 28 16:17:54 2022 +0000

    fix timer test to be less reliant on float precision (#3789)

    # Objective

    - Test is failing on nightly after the merge of https://github.com/rust-lang/rust/pull/90247
    - It was relying on the precision of the duration of `1.0 / 3.0`

    ## Solution

    - Fix the test to be less reliant on float precision to have the same result

commit 435fb7af4f983845d2fcc9e4221749f852431d11
Author: Charles Giguere <c.giguere42@gmail.com>
Date:   Wed Jan 26 18:52:54 2022 +0000

    Improve shader_material example documentation (#3601)

    # Objective

    While trying to learn how to use custom shaders, I had difficulty figuring out how to use a vertex shader. My confusion was mostly because all the other shader examples used a custom pipeline, but I didn't want a custom pipeline. After digging around I realised that I simply needed to add a function to the `impl Material` block. I also searched what was the default shader used, because it wasn't obvious to me where to find it.

    ## Solution

    Added a few comments explaining what is going on in the example and a link to the default shader.

commit ac63c491fb0d6bd8852e0d7e57280d4c3da35faa
Author: Cameron Hart <cameron.hart@gmail.com>
Date:   Tue Jan 25 22:10:11 2022 +0000

    Simple 2d rotation example (#3065)

    # Objective

    Some new bevy users are unfamiliar with quaternions and have trouble working with rotations in 2D.

    There has been an [issue](https://github.com/bitshifter/glam-rs/issues/226) raised with glam to add helpers to better support these users, however for now I feel could be better to provide examples of how to do this in Bevy as a starting point for new users.

    ## Solution

    I've added a 2d_rotation example which demonstrates 3 different rotation examples to try help get people started:

    - Rotating and translating a player ship based on keyboard input
    - An enemy ship type that rotates to face the player ship immediately
    - An enemy ship type that rotates to face the player at a fixed angular velocity

    I also have a standalone version of this example here https://github.com/bitshifter/bevy-2d-rotation-example but I think it would be more discoverable if it's included with Bevy.

commit 6d76229c384053e03683cc629a6c5ee7d0c4f690
Author: luke.biel <lukasz.p.biel@gmail.com>
Date:   Mon Jan 24 23:44:08 2022 +0000

    Fix a typo in shader_defs example (#3762)

    # Objective

    As in title, I'm already looking through these files so may as well rename `pipline` to `pipeline`

commit 514754d6503b2416e5266a24b39c884ab5d90d2f
Author: James Liu <contact@jamessliu.com>
Date:   Sun Jan 23 18:00:43 2022 +0000

    Add crate level docs to bevy_log and enable #![warn(missing_docs)] (#3520)

    This PR is part of the issue #3492.
    # Objective

      - Add crate level docs to the bevy_log documentation to achieve a 100% documentation coverage.
      - Add the #![warn(missing_docs)] lint to keep the documentation coverage for the future.

    # Solution

     - Add and update the bevy_log crate level docs
     - Add a note about panicking from multiple `LogPlugins` per process.
     - Add the #![warn(missing_docs)] lint.

commit f5039a476d48ec19bd74c94e83e10772565c68f1
Author: Alice Cecile <alice.i.cecile@gmail.com>
Date:   Sun Jan 23 14:24:37 2022 +0000

    Mark .id() methods which return an `Entity` as must_use (#3750)

    # Objective

    - Calling .id() has no purpose unless you use the Entity returned
    - This is an easy source of confusion for beginners.
    - This is easily missed during refactors.

    ## Solution

    - Mark the appropriate methods as #[must_use]

commit f3de12bc5e03c58a9b863943b8db84a321422bec
Author: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
Date:   Fri Jan 21 00:29:29 2022 +0000

    Add a warning when `watch_for_changes` has no effect (#3684)

    # Objective

    - Users can get confused when they ask for watching to be unsupported, then find it isn't supported
    - Fixes https://github.com/bevyengine/bevy/issues/3683

    ## Solution

    - Add a warning if the `watch_for_changes` call would do nothing

commit f1f6fd349a95059b031171021ff17251fde78456
Author: Michael Dorst <m@mdorst.net>
Date:   Fri Jan 21 00:12:32 2022 +0000

    Remove `ComponentsError` (#3716)

    # Objective
    `ComponentsError` is unused and should be removed.

    Fixes #3707

    ## Solution

    Remove `ComponentsError`.

commit e30d600dbf4ea76cf8bc4f87ce830202a8e741d2
Author: Rose Peck <olaf223224@gmail.com>
Date:   Thu Jan 20 19:32:16 2022 +0000

    Update docstrings for `text_system` and `text2d_system` (#3732)

    # Objective

    - Fixes #3562

    ## Solution

    - The outdated reference to `TextGlyphs` has been removed, and replaced with a more accurate docstring.

    ## What was `TextGlyphs`?
    This is the real question of this Issue and PR. This is particulary interesting because not only is `TextGlyphs` not a type in bevy, but it _never was_. Indeed, this type never existed on main. Where did it come from?

    `TextGlyphs` was originally a tuple struct wrapping a `Vec<PositionedGlyph>`. It was first introduced back in commit https://github.com/bevyengine/bevy/pull/765/commits/ec390aec4ebe7192e3470dddf1e8af36f10453e6 in #765. At the time, position information was being stored on the text entities directly. However, after design review, [it was decided](https://github.com/bevyengine/bevy/pull/765#issuecomment-725047186) to instead store the glyphs in a `HashMap` owned by the `TextPipeline`. When this was done, the original type was not only removed, but abstracted behind a few layers of the `TextPipeline` API. Obviously, the original docstring wasn't updated accordingly.

    Later, as part of #1122, the incorrect docstring was swept up when copy/pasting `text_system` for `text2d`. (Although I don't blame @CleanCut for this; it took me like 3 hours to track all this down to find the original context.)

commit cb2ba19d97ecb8f878c26357ade2ea7bcbd0cbc9
Author: François <mockersf@gmail.com>
Date:   Tue Jan 18 01:28:09 2022 +0000

    rename Texture to Image in doc of `from_buffer` function (#3713)

    This doc link was missed when changing the type name.

    Noticed in https://github.com/bevyengine/bevy/pull/3706 which will not be merged

commit 55da315432074e32a28b1ef0ad39b8eadf92467a
Author: Robert Swain <robert.swain@gmail.com>
Date:   Mon Jan 17 22:55:44 2022 +0000

    bevy_render: Provide a way to opt-out of the built-in frustum culling (#3711)

    # Objective

    - Allow opting-out of the built-in frustum culling for cases where its behaviour would be incorrect
    - Make use of the this in the shader_instancing example that uses a custom instancing method. The built-in frustum culling breaks the custom instancing in the shader_instancing example if the camera is moved to:

    ```rust
        commands.spawn_bundle(PerspectiveCameraBundle {
            transform: Transform::from_xyz(12.0, 0.0, 15.0)
                .looking_at(Vec3::new(12.0, 0.0, 0.0), Vec3::Y),
            ..Default::default()
        });
    ```

    ...such that the Aabb of the cube Mesh that is at the origin goes completely out of view. This incorrectly (for the purpose of the custom instancing) culls the `Mesh` and so culls all instances even though some may be visible.

    ## Solution

    - Add a `NoFrustumCulling` marker component
    - Do not compute and add an `Aabb` to `Mesh` entities without an `Aabb` if they have a `NoFrustumCulling` marker component
    - Do not apply frustum culling to entities with the `NoFrustumCulling` marker component

commit e88e394feb506d686b90b20090cc055f2c31baa9
Author: François <mockersf@gmail.com>
Date:   Mon Jan 17 22:38:05 2022 +0000

    Remove wasm specific examples (#3705)

    # Objective

    - There are wasm specific examples, which is misleading as now it works by default
    - I saw a few people on discord trying to work through those examples that are very limited

    ## Solution

    - Remove them and update the instructions

commit 836ffeda31e0b0c85666332cbe58221fbcce8a65
Author: Zhe Chen <me@zchen.im>
Date:   Mon Jan 17 22:22:16 2022 +0000

    Add missing dependencies for Fedora with Wayland (#3708)

    # Objective

    - The Linux dependencies document lacks packages for Fedora with Wayland.

    ## Solution

    - Add instructions to install packages for running Bevy apps in Fedora with Wayland.

commit a9f2817c49fcc8037293c5ff5add1d23d9f2d620
Author: Robert Swain <robert.swain@gmail.com>
Date:   Mon Jan 17 22:22:15 2022 +0000

    bevy_pbr: Do not panic when more than 256 point lights are added the scene (#3697)

    # Objective

    - Do not panic when mroe than 256 point lights are added the scene
    - Fixes https://github.com/bevyengine/bevy/issues/3682

    ## Solution

    - Only iterate the first `MAX_POINT_LIGHTS` lights instead of as many as there are

    ## Open questions

    - Should we warn that there are more than the maximum allowed number of point lights in the scene?

commit ef823d369ff69c626d94b4f4b20f6a22d8045136
Author: Robert Swain <robert.swain@gmail.com>
Date:   Mon Jan 17 22:03:14 2022 +0000

    bevy_render: Do not automatically enable MAPPABLE_PRIMARY_BUFFERS (#3698)

    # Objective

    - When using `WgpuOptionsPriority::Functionality`, which is the default, wgpu::Features::MAPPABLE_PRIMARY_BUFFERS would be automatically enabled. This feature can and does have a significant negative impact on performance for discrete GPUs where resizable bar is not supported, which is a common case. As such, this feature should not be automatically enabled.
    - Fixes the performance regression part of https://github.com/bevyengine/bevy/issues/3686 and at least some, if not all cases of https://github.com/bevyengine/bevy/issues/3687

    ## Solution

    - When using `WgpuOptionsPriority::Functionality`, use the adapter-supported features, enable `TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES` and disable `MAPPABLE_PRIMARY_BUFFERS`

commit a3e43b6abe4594b257fa7ff9d305b49a97b3ead6
Author: Igor Shaposhnik <ishaposhnik@icloud.com>
Date:   Mon Jan 17 21:43:44 2022 +0000

    Remove cargo-lipo from iOS ci job (#3671)

    # Objective

    `cargo-lipo` no more required since #3109 merged. Also remove unused `x11` feature from example.

commit 8139022ecde5c4bc0156af0f93d34287ad6e4425
Author: Chris J G <chris.j.gallo3@gmail.com>
Date:   Mon Jan 17 21:30:17 2022 +0000

    Change bevy_core::Name to implement Deref<Target = str> (#3681)

    # Objective
    Fixes #3613
    [Link to issue](https://github.com/bevyengine/bevy/issues/3613)

    ## Solution
    Changed the Deref Target to `str` and changed the `deref()` function body so that a `&str` is returned by using `as_ref() `.

commit e16ba80bd2929fff9da25b27a2d5c1e3dd8e7bff
Author: Weasy <weasy@hotmail.de>
Date:   Mon Jan 17 21:00:43 2022 +0000

    Add bevy_bird SVG for simpleicons.org (#3672)

    # Objective

    Add an icon to [simpleicons.org](https://simpleicons.org/), so that we can use it with [shields.io](https://shields.io/) to make some nice shields/badges.

    ## Solution

    Create a bevy bird SVG according to this guideline https://github.com/simple-icons/simple-icons/blob/develop/CONTRIBUTING.md#icon-guidelines, meaning i made [bevy_icon_dark.svg](https://github.com/bevyengine/bevy-website/blob/master/static/assets/bevy_icon_dark.svg) monochromatic and ran through all the steps in the icon-guideline. The result looks like this:

    ![grafik](https://user-images.githubusercontent.com/11967542/149509545-0748af23-ff52-42e6-a5bc-c1c7ce43e1fe.png)

    We still need to open a PR in the https://github.com/simple-icons/simple-icons repo.

commit d11cd6345229f1c2e0352e164bcbc0491c7cc319
Author: Linden Krouse <ztaticnull@gmail.com>
Date:   Mon Jan 17 20:44:22 2022 +0000

    Fixed doc comment with render Node input/output methods (#3642)

    Fixed doc comment where render Node input/output methods refered to using `RenderContext` for interaction instead of `RenderGraphContext`

    # Objective

    The doc comments for `Node` refer to `RenderContext` for slots instead of `RenderGraphContext`, which is only confusing because `Node::run` is passed both `RenderContext` and `RenderGraphContext`

    ## Solution

    Fixed the typo

commit 3fcdc5a4926dcad89a3346977d862c505993d265
Author: Wybe Westra <dev@wwestra.nl>
Date:   Sun Jan 16 21:09:15 2022 +0000

    Expanded Msaa documentation. (#3693)

    - Added default value.
    - Links to the explanation of Msaa on wikipedia.
    - Added a short example to show how to use the struct on an app.

    Fixes #3167.

commit 758fc5af6761d36c79115b93b5c20c03543646fa
Author: Aleksey Smirnov <debugger94@gmail.com>
Date:   Sun Jan 16 20:49:40 2022 +0000

    Remove a couple of unnecessary full paths (#3699)

commit e30199f7a9cf6429aed6c0b6f66fe76b791e90aa
Author: James Liu <contact@jamessliu.com>
Date:   Sun Jan 16 04:53:22 2022 +0000

    Document bevy_tasks and enable #![warn(missing_docs)] (#3509)

    This PR is part of the issue #3492.

    # Objective

    -  Add and update the bevy_tasks documentation to achieve a 100% documentation coverage (sans `prelude` module)
    -  Add the #![warn(missing_docs)] lint to keep the documentation coverage for the future.

    ## Solution

     -  Add and update the bevy_math documentation.
     -  Add the #![warn(missing_docs)] lint.
     - Added doctest wherever there should be in the missing docs.

commit 71814ca91bbd532a350db6dbcf2711fc7ce99ba5
Author: KDecay <kdecaymusic@protonmail.com>
Date:   Sun Jan 16 02:40:25 2022 +0000

    Added API guidelines to CONTRIBUTING.md (#3646)

    Closes #3497.

    I added the rust API guidelines (https://rust-lang.github.io/api-guidelines/about.html) to the `CONTRIBUTING.md` file.

    ## Note
    As noted in #3497 we should note any areas where we deliberately disagree as they arise. If we start adding these areas it might be a good idea to remove the mention of the `API guidelines` in the `CONTRIBUTING.md` file and move it to the `engine_style_guide.md`. That way we still have the connection between the `CONTRIBUTING.md` and the `API guidelines`, but we have more "space" to work with and can go into more detail about what we agree and disagree on.

    For now I would leave it this way, because it's one less click to get to the guidelines.

    Co-authored-by: KDecay <KDecayMusic@protonmail.com>

commit 8e1f660e1db77434d96626d3e40ecd0edfc71b54
Author: Ted Driggs <ted.driggs@outlook.com>
Date:   Sat Jan 15 22:14:43 2022 +0000

    Don't panic in macro shape validation (#3647)

    # Objective
    Emitting compile errors produces cleaner messages than panicking in a proc-macro.

    ## Solution
    - Replace match-with-panic code with call to new `bevy_macro_utils::get_named_struct_fields` function
    - Replace one use of match-with-panic for enums with inline match

    _Aside:_ I'm also the maintainer of [`darling`](https://docs.rs/darling), a crate which provides a serde-like API for parsing macro inputs. I avoided using it here because it seemed like overkill, but if there are plans to add lots more attributes/macros then that might be a good way of offloading macro error handling.

commit c16d0c5a39f384e45a3043b30f0aace2b408c6a1
Author: François <mockersf@gmail.com>
Date:   Sat Jan 15 20:29:58 2022 +0000

    do not set cursor grab on window creation if not asked for (#3617)

    # Objective

    - On Safari mobile, calling `winit_window.set_cursor_grab(true)` fails as the API is not implemented (as there is no cursor on Safari mobile, the api doesn't make sense there). I don't know about other mobile browsers
    ```
    [Error] Unhandled Promise Rejection: TypeError: getObject(arg0).exitPointerLock is not a function. (In 'getObject(arg0).exitPointerLock()', 'getObject(arg0).exitPointerLock' is undefined)
        (anonymous function) (rect.js:1089)
        wasm-stub
        <?>.wasm-function[web_sys::features::gen_Document::Document::exit_pointer_lock::h20ffc49be163fc45]
        <?>.wasm-function[winit::platform_impl::platform::backend::canvas::Canvas::set_cursor_grab::h6a9472cf55263e98]
        <?>.wasm-function[bevy_winit::winit_windows::WinitWindows::create_window::h9db5b3cbb24347c5]
        <?>.wasm-function[<bevy_winit::WinitPlugin as bevy_app::plugin::Plugin>::build::ha4a7c046b80c4280]
        <?>.wasm-function[bevy_app::plugin_group::PluginGroupBuilder::finish::h0e5bc78f71c37b2f]
        <?>.wasm-function[rect::main::h899852fd17f2d489]
        <?>.wasm-function[std::sys_common::backtrace::__rust_begin_short_backtrace::hfe38f282e8dda96b]
        <?>.wasm-function[std::rt::lang_start::{{closure}}::hc2f3b555ffc58618]
        <?>.wasm-function[std::rt::lang_start_internal::ha901ae30d88554f2]
        <?>.wasm-function[main]
        <?>.wasm-function[]
        wasm-stub
        21261
        (anonymous function) (rect.js:1664)
        asyncFunctionResume
        (anonymous function)
        promiseReactionJobWithoutPromise
        promiseReactionJob
    ```

    ## Solution

    - Do not call the api to release cursor grab on window creation, as the cursor is not grabbed anyway at this point

commit 2186eae89cd48f0e3606048b5463cbcf835079fb
Author: Robert Swain <robert.swain@gmail.com>
Date:   Sat Jan 15 20:10:33 2022 +0000

    bevy_crevice: Fix incorrect iterator usage in WriteStd430 impl for [T] (#3591)

    # Objective

    - Fix incorrect iterator usage in WriteStd430 impl for [T]
      - The first item was being written twice. This is correct in the WriteStd140 impl for [T].

    ## Solution

    - See the code.

commit 7c22f92ce42741610df2520f310dffa13287257f
Author: Federico Rinaldi <gisquerin@gmail.com>
Date:   Fri Jan 14 23:14:42 2022 +0000

    Document sub apps (#3403)

    Documentation added to:
    - `App::add_sub_app` (
    - `App::update` (mentions that sub apps are updated here)

    ### Future work
    - An example for `add_sub_app` would be good, but I wasn't able to come up with a simple one.
    - Since `SubApp` is private, maybe the concept of sub applications could be introduced in the `App` struct-level documentation.

commit f073b2d7f3d42561f081493e8a1c4bf337e1c7ae
Author: dataphract <dataphract@gmail.com>
Date:   Fri Jan 14 19:09:44 2022 +0000

    document more of bevy_reflect (#3655)

    This adds documentation for:

    - The trait methods of `Reflect` and its subtraits
    - The `partial_eq` and `apply` functions for `Map` et al.
    - `DynamicList` and `DynamicMap`
    - `TypeRegistry` and related types & traits
    - `GetPath`, including an explanation of path string syntax

    among other things.

    Still to be documented are the various macros and `bevy_reflect::serde`.

commit 3e8e6c56710a78216e0290bf194524429057f0c2
Author: François <mockersf@gmail.com>
Date:   Fri Jan 14 19:09:42 2022 +0000

    add an example using UI & states to create a game menu (#2960)

    adds an example using UI for something more related to a game than the current UI examples.

    Example with a game menu:
    * new game - will display settings for 5 seconds before returning to menu
    * preferences - can modify the settings, with two sub menus
    * quit - will quit the game

    I wanted a more complex UI example before starting the UI rewrite to have ground for comparison

    Co-authored-by: François <8672791+mockersf@users.noreply.github.com>

commit 39db8ecd03feebdef945048bab7e6551afd18735
Author: Troels Jessen <trojes@tuta.io>
Date:   Fri Jan 14 18:47:48 2022 +0000

    Added docs for bevy_transform (#3516)

    # Objective

    bevy_transform needed documentation and warn(missing_docs) as requested by #3492

    ## Solution

    warn(missing_docs) was activated and documentation was added to cover the crate

    Co-authored-by: Troels Jessen <kairyuka@gmail.com>

commit 17bb812d5df45c01529183bc8c6be21e3916fad0
Author: François <mockersf@gmail.com>
Date:   Fri Jan 14 18:21:22 2022 +0000

    Ignore clippy 1.58 (#3667)

    - Work around #3666 until a proper fix is done
    - Also update duplicate dependencies list

commit 7fd781e6703cc229ec5dae46ef9cc96ea6e7e52a
Author: Nicholas French <32023353+L-french@users.noreply.github.com>
Date:   Thu Jan 13 01:50:54 2022 +0000

    Fix documentation for QueryState::iter_manual (#3644)

    # Objective

    - Fixes #3616

    ## Solution

    - As described in the issue, documentation for `iter_manual` was copied from `iter_combinations` and did not reflect the behavior of the method. I've pulled some information from #2351 to create a more accurate description.

commit 84144c942992dedc200ccd9dae008acbfc2b767a
Author: Isse <isidornie@gmail.com>
Date:   Thu Jan 13 00:24:31 2022 +0000

    Remove documentation warning on EntityCommands::insert that is no longer necessary (#3653)

    # Objective

    - Removes warning about accidently inserting bundles with `EntityCommands::insert`, but since a component now needs to implement `Component` it is unnecessary.

commit bc499591c2d090e17c95d2c59bc6e16ba60a023d
Author: Pascal Hertleif <killercup@gmail.com>
Date:   Tue Jan 11 01:08:39 2022 +0000

    Use `use` instead of lots of full paths (#3564)

    Super tiny thing. Found this while reviewing #3479.

    # Objective

    - Simplify code
    - Fix the link in the doc comment

    ## Solution

    - Import a single item :)

    Co-authored-by: Pascal Hertleif <pascal@technocreatives.com>

commit fc0f15f11e3b327c65deaaccf722a8064a1a300b
Author: SuperSamus <tinozzo123@tutanota.com>
Date:   Mon Jan 10 17:05:13 2022 +0000

    Documentation: simplify NixOS dependencies (#3527)

    # Objective

    The description of NixOS dependencies is extremely long and spends entire paragraphs just for simple line changes.
    With this PR it should be much simpler.

    ## Solution

    - Linking Vulkan in `build.rs` is less effective than adding it in LD_LIBRARY_PATH, so I removed the former (related to #1992);
    - I put a simple comment explaining the line in the list of dependencies, instead of making entire paragraphs;
    - Clang is not in an absolute path in `.cargo/config_fast_builds` anymore, so that there is no need to specify it in `docs/linux_dependencies.md` (didn't test if this breaks other distros, though I doubt it. Also, maybe it could also be done on Darwin for consistency?);
    - Also added optional wayland dependencies.

    A few notes:
    - The x11 libraries will be linked only during the compilation phase. This means that if you use the `x11` feature without these libraries in the environment (for example because you forget to enter the nix shell before compiling), the program will still compile successfully but won't run. You'll have to `cargo clean` and recompile with the x11 libraries in the environment. I don't know if this is important enough to be added to the documentation, but it's not specified anywhere, though I don't think it's specific to NixOS;
    - The wayland dependencies need to be put in LD_LIBRARY_PATH only in certain conditions (IIRC, only if using the `dynamic` feature) and the text doesn't specify it. Because putting them there doesn't increase the number of dependencies (they are already in buildInputs) or alter the performance, I doubt anyone will care;
    - Should I comment out what isn't needed by default?
    - ~I removed `cargo` from buildInputs. Ignoring the fact that it should be in nativeBuildInputs, having it in `shell.nix` allows to use stable Rust in case it's not in the system environment, but maybe the user wanted to use the version that was already in the system environment and will be caught by surprise. In my opinion, if someone is looking at a Bevy's documentation on NixOS, that user will either have Rust already in the system environment (eg. via rustup) or is capable to add the toolchain they want on shell.nix by themselves. This isn't exactly the place to explain how this works.~ ~EDIT: I replaced `cargo` with Rust from the [Oxalica overlay](https://github.com/oxalica/rust-overlay) in order to have the latest nightly.~ EDIT: Removed `cargo` from dependencies. See comments for details.

commit 6bc5c609867908345f0b427cbd2725082883b31c
Author: Alice Cecile <alice.i.cecile@gmail.com>
Date:   Mon Jan 10 00:00:19 2022 +0000

    Remove tests from example style guide (#3582)

    # Objective

    - Consensus has emerged that examples shouldn't have tests.

    ## Solution

    - Discourage tests in examples.

commit 130953c717ffc1b05cf80d44dd82151b4c476555
Author: Michael Dorst <m@mdorst.net>
Date:   Sun Jan 9 23:20:13 2022 +0000

    Enable the `doc_markdown` clippy lint (#3457)

    # Objective

    CI should check for missing backticks in doc comments.

    Fixes #3435

    ## Solution

    `clippy` has a lint for this: `doc_markdown`. This enables that lint in the CI script.

    Of course, enabling this lint in CI causes a bunch of lint errors, so I've gone through and fixed all of them. This was a huge edit that touched a ton of files, so I split the PR up by crate.

    When all of the following are merged, the CI should pass and this can be merged.

    + [x] #3467
    + [x] #3468
    + [x] #3470
    + [x] #3469
    + [x] #3471
    + [x] #3472
    + [x] #3473
    + [x] #3474
    + [x] #3475
    + [x] #3476
    + [x] #3477
    + [x] #3478
    + [x] #3479
    + [x] #3480
    + [x] #3481
    + [x] #3482
    + [x] #3483
    + [x] #3484
    + [x] #3485
    + [x] #3486

commit 600ee7eee69aaf730bcf69f2f9fa83aaafb8a334
Author: François <mockersf@gmail.com>
Date:   Sun Jan 9 18:52:18 2022 +0000

    support all line endings in shader preprocessor (#3603)

    # Objective

    - Advance uses of shaders seems to often fail for Windows users
    - Bevy split lines on `'\n'` which messes with windows line endings

    ## Solution

    - Uses Rust built in https://doc.rust-lang.org/std/primitive.str.html#method.lines

commit e56685370ba82003af60a491667fac209a0f7897
Author: Michael Dorst <m@mdorst.net>
Date:   Sun Jan 9 11:09:46 2022 +0000

    Fix `doc_markdown` lints in `bevy_render` (#3479)

    #3457 adds the `doc_markdown` clippy lint, which checks doc comments to make sure code identifiers are escaped with backticks. This causes a lot of lint errors, so this is one of a number of PR's that will fix those lint errors one crate at a time.

    This PR fixes lints in the `bevy_render` crate.

commit 6f167aa3d60188952ea9bccad3b6725dd5085acc
Author: MiniaczQ <xnetroidpl@gmail.com>
Date:   Sun Jan 9 03:48:27 2022 +0000

    Documented `Events` (#3306)

    # Objective

    This PR extends the `Events` documentation by:
    - informing user about the possible race condition
    - explicitly explaining the unusual double buffer implementation

    Fixes #3305

    Co-authored-by: MiniaczQ <jakub.motyka.2000@gmail.com>
    Co-authored-by: MiniaczQ <MiniaczQ@gmail.com>

commit 8c81e816764e60df5b6f304709259433b734f35c
Author: Daniel Bearden <danbear0@gmail.com>
Date:   Sat Jan 8 22:36:33 2022 +0000

    Thread local example cleanup (#3586)

    # Objective

    Fixes #19…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants