Commit graph

1113 commits

Author SHA1 Message Date
Yoh Deadfall
a404eb2acf Removed redundant visibility check (#2311)
Since `visible_entities_system` already checks `Visiblie::is_visible` for each entity and requires it to be `true`, there's no reason to verify visibility in `PassNode::prepare` which consumes entities produced by the system.
2021-06-07 19:02:02 +00:00
Nathan Ward
27d809fd23 [assets] remove unnecessary temporary strong handles (#2304)
# Objective

- When creating an asset, the `update_asset_storage` function was unnecessarily creating an extraneous `Handle` to the created asset via calling `set`. This has some overhead as the `RefChange::Increment/Decrement` event was being sent.  
- A similar exteraneous handle is also created in `load_async` when loading dependencies. 

## Solution

- Have the implementation use `Assets::set_untracked` and `AssetServer::load_untracked` so no intermediate handle is created.
2021-06-07 18:32:57 +00:00
MinerSebas
4fed2ee858 Use cfg attribute to filter supported extensions (#2297)
When implementing `AssetLoader ` you need to specify which File extensions are supported by that loader.
Currently, Bevy always says it supports extensions that actually require activating a Feature beforehand.

This PR adds cf attributes, so Bevy only tries to load those Extensions whose Features were activated.

This prevents Bevy from Panicking and reports such a warning:
```
Jun 02 23:05:57.139  WARN bevy_asset::asset_server: no `AssetLoader` found for the following extension: ogg
```

This also fixes the Bug, that the `png Feature had to be activated even if you wanted to load a different image format.

Fixes #640
2021-06-03 19:58:08 +00:00
Nathan Ward
19db1e402b [ecs] implement is_empty for queries (#2271)
## Problem
- The `Query` struct does not provide an easy way to check if it is empty. 
- Specifically, users have to use `.iter().peekable()` or `.iter().next().is_none()` which is not very ergonomic. 
- Fixes: #2270 

## Solution
- Implement an `is_empty` function for queries to more easily check if the query is empty.
2021-06-02 20:50:06 +00:00
Carter Anderson
a20dc36c8c Add new SystemState and rename old SystemState to SystemMeta (#2283)
This enables `SystemParams` to be used outside of function systems. Anything can create and store `SystemState`, which enables efficient "param state cached" access to `SystemParams`.

It adds a `ReadOnlySystemParamFetch` trait, which enables safe `SystemState::get` calls without unique world access.

I renamed the old `SystemState` to `SystemMeta` to enable us to mirror the `QueryState` naming convention (but I'm happy to discuss alternative names if people have other ideas). I initially pitched this as `ParamState`, but given that it needs to include full system metadata, that doesn't feel like a particularly accurate name.

```rust
#[derive(Eq, PartialEq, Debug)]
struct A(usize);

#[derive(Eq, PartialEq, Debug)]
struct B(usize);

let mut world = World::default();
world.insert_resource(A(42));
world.spawn().insert(B(7));

// we get nice lifetime elision when declaring the type on the left hand side
let mut system_state: SystemState<(Res<A>, Query<&B>)> = SystemState::new(&mut world);
let (a, query) = system_state.get(&world);
assert_eq!(*a, A(42), "returned resource matches initial value");
assert_eq!(
    *query.single().unwrap(),
    B(7),
    "returned component matches initial value"
);

// mutable system params require unique world access
let mut system_state: SystemState<(ResMut<A>, Query<&mut B>)> = SystemState::new(&mut world);
let (a, query) = system_state.get_mut(&mut world);

// static lifetimes are required when declaring inside of structs
struct SomeContainer {
  state: SystemState<(Res<'static, A>, Res<'static, B>)>
}

// this can be shortened using type aliases, which will be useful for complex param tuples
type MyParams<'a> = (Res<'a, A>, Res<'a, B>);
struct SomeContainer {
  state: SystemState<MyParams<'static>>
}

// It is the user's responsibility to call SystemState::apply(world) for parameters that queue up work   
let mut system_state: SystemState<(Commands, Query<&B>)> = SystemState::new(&mut world);
{
  let (mut commands, query) = system_state.get(&world);
  commands.insert_resource(3.14);
}
system_state.apply(&mut world);
```

## Future Work

* Actually use SystemState inside FunctionSystem. This would be trivial, but it requires FunctionSystem to wrap SystemState in Option in its current form (which complicates system metadata lookup). I'd prefer to hold off until we adopt something like the later designs linked in #1364, which enable us to contruct Systems using a World reference (and also remove the need for `.system`).
* Consider a "scoped" approach to automatically call SystemState::apply when systems params are no longer being used (either a container type with a Drop impl, or a function that takes a closure for user logic operating on params).
2021-06-02 19:57:38 +00:00
thebluefish
f45dbe5bac Fixes dropping empty BlobVec (#2295)
When dropping the data, we originally only checked the size of an individual item instead of the size of the allocation. However with a capacity of 0, we attempt to deallocate a pointer which was not the result of allocation. That is, an item of `Layout { size_: 8, align_: 8 }` produces an array of `Layout { size_: 0, align_: 8 }` when `capacity = 0`.

Fixes #2294
2021-06-02 19:08:39 +00:00
François
6301b728ea remove commented code and TODO as it's not actually possible (#2289)
Fixing it was tried in #2069 and deemed not possible (https://github.com/bevyengine/bevy/pull/2069#issuecomment-841775844)

Other possibility would be to change the TODO to note the dependency on chalk integration.
2021-06-02 02:30:15 +00:00
Nathan Ward
0b67084e10 [assets] fix Assets being set as 'changed' each frame (#2280)
## Objective
- Fixes: #2275 
- `Assets` were being flagged as 'changed' each frame regardless of if the assets were actually being updated. 

## Solution
- Only have `Assets` change detection be triggered when the collection is actually modified. 
- This includes utilizing `ResMut` further down the stack instead of a `&mut Assets` directly.
2021-06-02 02:30:14 +00:00
Paweł Grabarz
1214ddabb7 drop overwritten component data on double insert (#2227)
Continuing the work on reducing the safety footguns in the code, I've removed one extra `UnsafeCell` in favour of safe `Cell` usage inisde `ComponentTicks`. That change led to discovery of misbehaving component insert logic, where data wasn't properly dropped when overwritten. Apart from that being fixed, some method names were changed to better convey the "initialize new allocation" and "replace existing allocation" semantic.

Depends on #2221, I will rebase this PR after the dependency is merged. For now, review just the last commit.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-30 20:15:40 +00:00
Nathan Ward
173bb48d78 Refactor ResMut/Mut/ReflectMut to remove duplicated code (#2217)
`ResMut`, `Mut` and `ReflectMut` all share very similar code for change detection.
This PR is a first pass at refactoring these implementation and removing a lot of the duplicated code.

Note, this introduces a new trait `ChangeDetectable`.

Please feel free to comment away and let me know what you think!
2021-05-30 19:29:31 +00:00
François
08e5939fd7 Despawn with children doesn't need to remove entities from parents children when parents are also removed (#2278)
Fixes #2274 

When calling `despawn_recursive`, the recursive loop doesn't need to remove the entity from the children list of its parent when the parent will also be deleted

Upside:
* Removes two entity lookup per entity being recursively despawned

Downside:
* The change detection on the `Children` component of a deleted entity in the despawned hierarchy will not be triggered
2021-05-30 18:39:32 +00:00
dependabot[bot]
016b60a790 Update rodio requirement from 0.13 to 0.14 (#2244)
Updates the requirements on [rodio](https://github.com/RustAudio/rodio) to permit the latest version.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/RustAudio/rodio/blob/master/CHANGELOG.md">rodio's changelog</a>.</em></p>
<blockquote>
<h1>Version 0.14.0 (2021-05-21)</h1>
<ul>
<li>Re-export <code>cpal</code> in full.</li>
<li>Replace panics when calling <code>OutputStream::try_default</code>, <code>OutputStream::try_from_device</code> with new
<code>StreamError</code> variants.</li>
<li><code>OutputStream::try_default</code> will now fallback to non-default output devices if an <code>OutputStream</code>
cannot be created from the default device.</li>
</ul>
<h1>Version 0.13.1 (2021-03-28)</h1>
<ul>
<li>Fix panic when no <code>pulseaudio-alsa</code> was installed.</li>
</ul>
<h1>Version 0.13.0 (2020-11-03)</h1>
<ul>
<li>Update <code>cpal</code> to <a href="https://github.com/RustAudio/cpal/blob/master/CHANGELOG.md#version-0130-2020-10-28">0.13</a>.</li>
<li>Add Android support.</li>
</ul>
<h1>Version 0.12.0 (2020-10-05)</h1>
<ul>
<li>Breaking: Update <code>cpal</code> to <a href="https://github.com/RustAudio/cpal/blob/master/CHANGELOG.md#version-0120-2020-07-09">0.12</a>.</li>
<li>Breaking: Rework API removing global &quot;rodio audio processing&quot; thread &amp; adapting to the upstream cpal API changes.</li>
<li>Add new_X format specific methods to Decoder.</li>
<li>Fix resampler dependency on internal <code>Vec::capacity</code> behaviour.</li>
</ul>
<h1>Version 0.11.0 (2020-03-16)</h1>
<ul>
<li>Update <code>lewton</code> to <a href="https://github.com/RustAudio/lewton/blob/master/CHANGELOG.md#release-0100---january-30-2020">0.10</a>.</li>
<li>Breaking: Update <code>cpal</code> to <a href="https://github.com/RustAudio/cpal/blob/master/CHANGELOG.md#version-0110-2019-12-11">0.11</a></li>
</ul>
<h1>Version 0.10.0 (2019-11-16)</h1>
<ul>
<li>Removal of nalgebra in favour of own code.</li>
<li>Fix a bug that switched channels when resuming after having paused.</li>
<li>Attempt all supported output formats if the default format fails in <code>Sink::new</code>.</li>
<li>Breaking: Update <code>cpal</code> to <a href="https://github.com/RustAudio/cpal/blob/master/CHANGELOG.md#version-0100-2019-07-05">0.10</a>.</li>
</ul>
<h1>Version 0.9.0 (2019-06-08)</h1>
<ul>
<li>Remove exclusive <code>&amp;mut</code> borrow requirements in <code>Sink</code> &amp; <code>SpatialSink</code> setters.</li>
<li>Use <code>nalgebra</code> instead of <code>cgmath</code> for <code>Spatial</code> source.</li>
</ul>
<h1>Version 0.8.1 (2018-09-18)</h1>
<ul>
<li>Update <code>lewton</code> dependency to <a href="https://github.com/RustAudio/lewton/blob/master/CHANGELOG.md#release-090---august-16-2018">0.9</a></li>
<li>Change license from <code>Apache-2.0</code> only to <code>Apache-2.0 OR MIT</code></li>
</ul>
<h1>Version 0.8.0 (2018-06-22)</h1>
<ul>
<li>Add mp3 decoding capabilities via <code>minimp3</code></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/RustAudio/rodio/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>
2021-05-29 01:08:58 +00:00
Paweł Grabarz
052094757a reduce tricky unsafety and simplify table structure (#2221)
I've noticed that we are overusing interior mutability of the Table data, where in many cases we already own a unique reference to it. That prompted a slight refactor aiming to reduce number of safety constraints that must be manually upheld. Now the majority of those are just about avoiding bound checking, which is relatively easy to prove right.

Another aspect is reducing the complexity of Table struct. Notably, we don't ever use archetypes stored there, so this whole thing goes away. Capacity and grow amount were mostly superficial, as we are already using Vecs inside anyway, so I've got rid of those too. Now the overall table capacity is being driven by the internal entity Vec capacity. This has a side effect of automatically implementing exponential growth pattern for BitVecs reallocations inside Table, which to my measurements slightly improves performance in tests that are heavy on inserts. YMMV, but I hope that those tests were at least remotely correct.
2021-05-24 23:21:19 +00:00
Jonathan Behrens
4b1d47da99 Enable downcasting of RenderContext (#2240)
Related to https://github.com/bevyengine/bevy/discussions/2210. This may make it possible to have external `wgpu` libraries work with `bevy`.
2021-05-24 19:38:33 +00:00
Yoh Deadfall
653c10371e Use bevy_reflect as path in case of no direct references (#1875)
Fixes #1844


Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-19 19:03:36 +00:00
Nathan Ward
a42343d847 Optimize Events::extend and impl std::iter::Extend (#2207)
The previous implementation of `Events::extend` iterated through each event and manually `sent` it via `Events:;send`.
However, this could be a minor performance hit since calling `Vec::push` in a loop is not optimal.
This refactors the code to use `Vec::extend`.
2021-05-19 18:41:46 +00:00
Nathan Ward
29bc4e3657 Fix Events::<drain/clear> bug (#2206)
Taken from #2145

On draining and clearing, dangling `EventReaders` would not read into the correct event offset.
2021-05-19 03:41:28 +00:00
Nathan Ward
9eb1aeee48 Expose set_changed() on ResMut and Mut (#2208)
This new api stems from this [discord conversation](https://discord.com/channels/691052431525675048/742569353878437978/844057268172357663).

This exposes a public facing `set_changed` method on `ResMut` and `Mut`.

As a side note: `ResMut` and `Mut` have a lot of duplicated code, I have a PR I may put up later that refactors these commonalities into a trait.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-18 19:25:58 +00:00
Paweł Grabarz
93cc7219bc small ecs cleanup and remove_bundle drop bugfix (#2172)
- simplified code around archetype generations a little bit, as the special case value is not actually needed
- removed unnecessary UnsafeCell around pointer value that is never updated through shared references
- fixed and added a test for correct drop behaviour when removing sparse components through remove_bundle command
2021-05-18 19:25:57 +00:00
Nathan Ward
4563e69e06 Update glam (0.15.1) and hexasphere (3.4) (#2199)
This is a version of #2195 which addresses the `glam` breaking changes.
Also update hexasphere to ensure versions of `glam` are matching
2021-05-18 18:56:15 +00:00
Gregory Oakes
2fcac67712 Bump winit to 0.25 (#2186)
winit v0.25 includes support for propagating mouse motion events in the HTML canvas to the winit window.
2021-05-18 18:36:36 +00:00
Daniel Burrows
d4ffa3f490 Document what Config is and how to use it. (#2185)
While trying to figure out how to implement a `SystemParam`, I spent a
long time looking for a feature that would do exactly what `Config`
does.  I ignored it at first because all the examples I could find used
`()` and I couldn't see a way to modify it.

This is documented in other places, but `Config` is a logical place to
include some breadcrumbs.  I've added some text that gives a brief
overview of what `Config` is for, and links to the existing docs on
`FunctionSystem::config` for more details.

This would have saved me from embarrassing myself by filing https://github.com/bevyengine/bevy/issues/2178.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-18 00:10:18 +00:00
Federico Rinaldi
1f0988be87 Improve legibility of RunOnce::run_unsafe param (#2181)
During PR #2046 @cart suggested that the `(): ()` notation is less legible than `_input: ()`. The first notation still managed to slip in though. This PR applies the second writing.
2021-05-18 00:10:17 +00:00
Paweł Grabarz
a81fb7aa7e Add a method iter_combinations on query to iterate over combinations of query results (#1763)
Related to [discussion on discord](https://discord.com/channels/691052431525675048/742569353878437978/824731187724681289)

With const generics, it is now possible to write generic iterator over multiple entities at once.

This enables patterns of query iterations like

```rust
for [e1, e2, e3] in query.iter_combinations() {
   // do something with relation of all three entities
}
```

The compiler is able to infer the correct iterator for given size of array, so either of those work
```rust
for [e1, e2] in query.iter_combinations()  { ... }
for [e1, e2, e3] in query.iter_combinations()  { ... }
```

This feature can be very useful for systems like collision detection.

When you ask for permutations of size K of N entities:
- if K == N, you get one result of all entities
- if K < N, you get all possible subsets of N with size K, without repetition
- if K > N, the result set is empty (no permutation of size K exist)

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-17 23:33:47 +00:00
Andre Popovitch
cb98d31b27 Impl AsRef+AsMut for Res, ResMut, and Mut (#2189)
This can save users from having to type `&*X` all the time at the cost of some complexity in the type signature. For instance, this allows me to accommodate @jakobhellermann's suggestion in #1799 without requiring users to type `&*windows` 99% of the time.
2021-05-17 23:07:19 +00:00
Aevyrie
85b17294b9 Fix PBR regression for unlit materials (#2197)
Fixes the frag shader for unlit materials by correcting the scope of the `#ifndef` to include the light functions. Closes #2190, introduced in #2112.

Tested by changing materials in the the `3d_scene` example to be unlit. Unsure how to prevent future regressions without creating a test case scene that will catch these runtime panics.
2021-05-17 22:45:07 +00:00
Paweł Grabarz
189df30a83 use bytemuck crate instead of Byteable trait (#2183)
This gets rid of multiple unsafe blocks that we had to maintain ourselves, and instead depends on library that's commonly used and supported by the ecosystem. We also get support for glam types for free.

There is still some things to clear up with the `Bytes` trait, but that is a bit more substantial change and can be done separately. Also there are already separate efforts to use `crevice` crate, so I've just added that as a TODO.
2021-05-17 22:29:10 +00:00
Nathan Ward
071965996b revert supporting generics for deriving TypeUuid (#2204)
This reverts some of the changes made in #2044 as supporting generics for a `#[derive(TypeUuid)]` should not work as each generic instantiation would have the same uuid.

Stems from [this conversation](https://github.com/bevyengine/bevy/pull/2044#issuecomment-841743135)
2021-05-17 20:28:50 +00:00
Paweł Grabarz
3cf10e2ef2 prevent memory leak when dropping ParallelSystemContainer (#2176)
`ParallelSystemContainer`'s `system` pointer was extracted from box, but it was never deallocated. This change adds missing drop implementation that cleans up that memory.
2021-05-17 20:01:25 +00:00
bjorn3
1d652941ea Some cleanups (#2170)
The first commit monomorphizes `add_system_inner` which I think was intended to be monomorphized anyway. The second commit moves the type argument of `GraphNode` to an associated type.
2021-05-17 19:06:05 +00:00
dependabot[bot]
b8c98a9065 Update gltf requirement from 0.15.2 to 0.16.0 (#2196)
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>[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 extension</code>.</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>
<h3>Changed</h3>
<ul>
<li><code>base64</code> updated to <code>0.11</code>.</li>
<li><code>byteorder</code> updated to <code>1.3</code>.</li>
<li><code>image</code> updated to <code>0.23.0</code>.</li>
<li><code>Format</code> has additional variants for 16-bit pixel formats.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Off-by-one error when reading whole files incurring a gratuitous reallocation.</li>
</ul>
<h2>[0.15.0] - 2020-01-18</h2>
<h3>Added</h3>
<ul>
<li>Support for the <code>KHR_materials_unlit</code> extension, which adds an <code>unlit</code> field</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>
2021-05-17 18:44:04 +00:00
MsK`
73f4a9d18f Directional light (#2112)
This PR adds a `DirectionalLight` component to bevy_pbr.
2021-05-14 20:37:34 +00:00
Jonas Matser
d1f40148fd Allows a number of clippy lints and fixes 2 (#1999)
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-14 20:37:32 +00:00
François
739224f981 fix diagnostic length for asset count (#2165)
fixes #2156 
limit the diagnostic name to `MAX_DIAGNOSTIC_NAME_WIDTH` length
2021-05-14 19:31:36 +00:00
Federico Rinaldi
b4f80c29ee Add module level documentation for collide_aabb (#2152)
Related to #2105.

Doc comments are present on the `collide` function, but not on the module level.
2021-05-14 18:45:31 +00:00
Nathan Ward
883abbb27a [bevy_ecs] Cleanup SparseSetIndex impls (#2099)
Problem:
- SparseSetIndex trait implementations had a lot of duplicated code.

Solution:
- Utilize a macro to implement the trait for a generic type.
2021-05-07 00:46:54 +00:00
Jonas Matser
bfd15d2d4b Fixes incorrect PipelineCompiler::compile_pipeline() step_mode (#2126)
There's what might be considered a proper bug in `PipelineCompiler::compile_pipeline()`, where it overwrites the `step_mode` for the passed in `VertexBufferLayout` with `InputStepMode::Vertex`. Due to this some ugly workarounds are needed to do any kind of instancing.

In the somewhat longer term, `PipelineCompiler::compile_pipeline()` should probably also handle a `Vec<VertexBufferLayout>`, but that would be a (slightly) larger PR, rather than a bugfix. And I'd love to have this fix in sooner than we can deal with a bigger PR.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-07 00:28:35 +00:00
Nathan Ward
1690a9db97 [bevy_derive] Refactor modules for better error message. (#2059)
Problem:
- When using the 'as_crate' attribute, if 'as_crate' was empty, the only
  error you would get is 'integer underflow'.

Solution:
- Provide an explicit check for the 'as_crate' attribute's token stream
  to ensure the formatting is correct.

Note:
- Also reworked 'get_meta' by not making it call 'Manifest::find' twice.
2021-05-06 23:45:23 +00:00
Carter Anderson
ce6dda2d4e fix new "inconsistent struct constructor" lint (#2127)
Not super sold on the rationale behind this one, but we can revisit if it ever becomes painful.
2021-05-06 23:25:16 +00:00
Denis Laprise
7d0e98f34c Implement rotation for Text2d (#2084)
Fixes https://github.com/bevyengine/bevy/issues/2080

![CleanShot 2021-05-02 at 22 50 09](https://user-images.githubusercontent.com/11653/116844876-373ca780-ab99-11eb-8f61-8d93d929bff0.gif)


Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: Denis Laprise <nside@users.noreply.github.com>
2021-05-06 03:55:55 +00:00
Felipe Jorge
41d9122740 Mesh vertex attributes for skinning and animation (#1831)
Required by #1429,

- Adds the `Ushort4` vertex attribute for joint indices
- `Mesh::ATTRIBUTE_JOINT_WEIGHT` and `Mesh::ATTRIBUTE_JOINT_INDEX` to import vertex attributes related to skinning from GLTF
- impl `Default` for `Mesh` a empty triangle mesh is created (needed by reflect)
- impl `Reflect` for `Mesh` all attributes are ignored (needed by the animation system)
2021-05-06 03:31:20 +00:00
Jakob Hellermann
cf8ef7660c load zeroed UVs as fallback in gltf loader (#1803)
fixes a lot of gltf loading failures (see https://github.com/bevyengine/bevy/issues/1802)
2021-05-06 03:08:53 +00:00
Mika
73ae6af6ef Add inline documentation to bevy code (#1404)
For review, first iteration of bevy code documentation.

I can continue submitting docs every now and then for relevant parts.

Some challenges I found:
* plugins example had to be commented out, as adding bevy_internal (where plugins reside) would pull in too many dependencies

Co-authored-by: Mika <1299457+blaind@users.noreply.github.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-06 02:26:54 +00:00
Patrik Buhring
4e524841a1 Bump glam and hexasphere versions (#2111)
Also fixes typo "feautres" in smallvec dependency.
2021-05-06 00:41:18 +00:00
TheRawMeatball
ce6889b9a8 Implement direct mutable dereferencing (#2100)
This PR adds a way to get the underlying mutable reference for it's full lifetime.

Context:
https://discord.com/channels/691052431525675048/692572690833473578/839255317287796796
2021-05-05 19:35:07 +00:00
TheRawMeatball
81279f3090 Move to smallvec v1.6 (#2074) 2021-05-05 19:14:39 +00:00
jak6jak
809877ade6 official 2D examples linked in rustdoc (#2081)
I linked to examples within the rustdoc for the 2d examples as per issue #1934
2021-05-05 18:45:49 +00:00
François
4f0499b91f Asset re-loading while it's being deleted (#2011)
fixes #824
fixes #1956 

* marked asset loading methods as `must_use`
* fixed asset re-loading while asset is still loading to work as comment is describing code
* introduced a 1 frame delay between unused asset marking and actual asset removal
2021-05-04 20:34:22 +00:00
dependabot[bot]
2390bee647 Update rectangle-pack requirement from 0.3 to 0.4 (#2086)
Updates the requirements on [rectangle-pack](https://github.com/chinedufn/rectangle-pack) to permit the latest version.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/chinedufn/rectangle-pack/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>
2021-05-03 21:20:35 +00:00
François
afaf4ad3da update for wgpu 0.8 (#1959)
Changes to get Bevy to compile with wgpu master.

With this, on a Mac:
* 2d examples look fine
* ~~3d examples crash with an error specific to metal about a compilation error~~
* 3d examples work fine after enabling feature `wgpu/cross`


Feature `wgpu/cross` seems to be needed only on some platforms, not sure how to know which. It was introduced in https://github.com/gfx-rs/wgpu-rs/pull/826
2021-05-02 20:45:25 +00:00