Commit graph

1875 commits

Author SHA1 Message Date
aloucks
294feeedc0 Add additional vertex formats (#1878)
- `Short2`
- `Short2Norm`
- `Ushort2`
- `Ushort2Norm`
- `Short4`
- `Short4Norm`
- `Ushort4`
- `Ushort4Norm`
- `Char2`
- `Char2Norm`
- `Uchar2`
- `Uchar2Norm`
- `Char4`
- `Char4Norm`
- `Uchar4`
2021-04-14 23:21:53 +00:00
therealstork
c86d490a20 More detailed errors when resource not found (#1864)
Fixes #1846

Got scared of the other "Requested resource does not exist" error at line 395 in `system_param.rs`, under `impl<'a, T: Component> SystemParamFetch<'a> for ResMutState<T> {`. Someone with better knowledge of the code might be able to go in and improve that one.
2021-04-14 22:52:43 +00:00
Yoh Deadfall
8aa22ba477 Removed frame rate updates from fixed step example (#1850)
Fixes #1751.

Output before:

```
...
update: 0.016478100000000495
update: 0.01955749999999945
fixed_update: 2.0052284
  overstep_percentage: 0.00946374999999966
update: 0.013902800000000326
update: 0.02283240000000042
...
```

Output after:

```
...
fixed_update: 2.0053731
  overstep_percentage: 0.0031439500000001175
fixed_update: 1.9976363
  overstep_percentage: 0.0019621000000002997
fixed_update: 2.0069121999999995
  overstep_percentage: 0.005418200000000262
...
```
2021-04-14 22:38:04 +00:00
TehPers
deb9f23667 Implement Byteable and RenderResource for [T; N] (#1872)
Implements `Byteable` and `RenderResource` for any array containing `Byteable` elements. This allows `RenderResources` to be implemented on structs with arbitrarily-sized arrays, among other things:

```rust
#[derive(RenderResources, TypeUuid)]
#[uuid = "2733ff34-8f95-459f-bf04-3274e686ac5f"]
struct Foo {
    buffer: [i32; 256],
}
```
2021-04-14 22:20:25 +00:00
Patrik Buhring
df3f40afd4 Fix IcoSphere UV coordinates (#1871)
Changes made:
- Swap Y/Z when calculating UV coordinates
- Correct mapping in the UV coordinates
- Fix typo in Azimuth
2021-04-14 22:20:24 +00:00
Saverio Miroddi
b80814681a Add g++ to the Ubuntu dependencies (#1874)
The g++ package may not be preinstalled.

Also, replaced the mention of "fast" compiles, with generic instructions about how to install clang; this is because on my test system, clang didn't make any difference, and it's likely not to do any in general, as it is a relatively small part of the build.

Closes #1294.
2021-04-14 22:02:52 +00:00
François
d868d07d0b run some examples on CI using swiftshader (#1826)
From suggestion from Godot workflows: https://github.com/bevyengine/bevy/issues/1730#issuecomment-810321110

* Add a feature `bevy_debug` that will make Bevy read a debug config file to setup some debug systems
  * Currently, only one that will exit after x frames
  * Could add option to dump screen to image file once that's possible
* Add a job in CI workflow that will run a few examples using [`swiftshader`](https://github.com/google/swiftshader)
  * This job takes around 13 minutes, so doesn't add to global CI duration

|example|number of frames|duration|
|-|-|-|
|`alien_cake_addict`|300|1:50|
|`breakout`|1800|0:44|
|`contributors`|1800|0:43|
|`load_gltf`|300|2:37|
|`scene`|1800|0:44|
2021-04-14 21:40:36 +00:00
Jakob Hellermann
d119c1ce14 gltf-loader: support data url for images (#1828)
This allows the `glTF-Embedded` variants in the [sample models](https://github.com/KhronosGroup/glTF-Sample-Models/) to be used.
The data url format is relatively small, so I didn't include a crate like [docs.rs/data-url](https://docs.rs/data-url/0.1.0/data_url/).

Also fixes the 'Box With Spaces' model as URIs are now percent-decoded.

cc #1802
2021-04-13 21:30:32 +00:00
Yoh Deadfall
04a37f722a Moved events to ECS (#1823)
Fixes #1809. It makes it also possible to use `derive` for `SystemParam` inside ECS and avoid manual implementation. An alternative solution to macro changes is to use `use crate as bevy_ecs;` in `event.rs`.
2021-04-13 20:36:37 +00:00
Aaron Winter
01142a137e Many Sprites Example Fix (#1897)
This example is supposed to use frustum culling, but doesn't. :P

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-04-13 20:18:56 +00:00
Alice Cecile
203c7c1aca Issue template for documentation improvements (#1732)
The existing issue templates don't fit well for "the docs are not very good" and are too high friction.

This is intended as a very-low friction tool to provide the basis for more thorough docs PRs.
2021-04-13 20:18:54 +00:00
follower
50df6b61f2 Typo fix: "wit" -> "with". (#1876) 2021-04-13 20:02:20 +00:00
François
dae8357057 markdown lint on CHANGELOG.md and examples/READE.md (#1906)
new lints after #1783, fixes current CI break
2021-04-13 17:18:47 +00:00
Jonas Matser
7342d463b8 Use a sorted Map for vertex buffer attributes (#1796)
The `VertexBufferLayout` returned by `crates\bevy_render\src\mesh\mesh.rs:308` was unstable, because `HashMap.iter()` has a random order. This caused the pipeline_compiler to wrongly consider a specialization to be different (`crates\bevy_render\src\pipeline\pipeline_compiler.rs:123`), causing each mesh changed event to potentially result in a different `PipelineSpecialization`. This in turn caused `Draw` to emit a `set_pipeline` much more often than needed.

This fix shaves off a `BindPipeline` and two `BindDescriptorSets` (for the Camera and for global renderresources) for every mesh after the first that can now use the same specialization, where it didn't before (which was random).

`StableHashMap` was not a good replacement, because it isn't `Clone`, so instead I replaced it with a `BTreeMap` which is OK in this instance, because there shouldn't be many insertions on `Mesh.attributes` after the mesh is created.
2021-04-13 03:31:29 +00:00
François
4c1099a77f add documentation on Input (#1781)
related to #1700 

This PR:
* documents all methods on `Input<T>`
* adds documentation on the struct about how to use it, and how to implement it for a new input type
* renames method `update` to a easier to understand `clear`
* adds two methods to check for state and clear it after, allowing easier use in the case of #1700 

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-04-13 03:13:48 +00:00
Jakob Hellermann
9e55d8dbb4 Error message improvements for shader compilation/gltf loading (#1786)
- prints glsl compile error message in multiple lines instead of `thread 'main' panicked at 'called Result::unwrap() on an Err value: Compilation("glslang_shader_parse:\nInfo log:\nERROR: 0:335: \'assign\' :  l-value required \"anon@7\" (can\'t modify a uniform)\nERROR: 0:335: \'\' : compilation terminated \nERROR: 2 compilation errors.  No code generated.\n\n\nDebug log:\n\n")', crates/bevy_render/src/pipeline/pipeline_compiler.rs:161:22`
- makes gltf error messages have more context

New error:
```rust
thread 'Compute Task Pool (5)' panicked at 'Shader compilation error:
glslang_shader_parse:
Info log:
ERROR: 0:12: 'assign' :  l-value required "anon@1" (can't modify a uniform)
ERROR: 0:12: '' : compilation terminated 
ERROR: 2 compilation errors.  No code generated.
', crates/bevy_render/src/pipeline/pipeline_compiler.rs:364:5
```


These changes are a bit unrelated. I can open separate PRs if someone wants that.
2021-04-13 02:56:30 +00:00
dependabot[bot]
73c8e9a596 Bump github/super-linter from v3.15.2 to v3.15.5 (#1783)
Bumps [github/super-linter](https://github.com/github/super-linter) from v3.15.2 to v3.15.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/github/super-linter/releases">github/super-linter's releases</a>.</em></p>
<blockquote>
<h2>Release v3.15.5</h2>
<p>No release notes provided.</p>
<h2>Release v3.15.3</h2>
<h2>Changelog</h2>
<ul>
<li>Updated Deployment scripts</li>
<li>Updated Security Scripts</li>
<li>Support <code>.env.*</code> for various <code>.env</code> files</li>
</ul>
<h2>Bugs</h2>
<ul>
<li>Various security bumps</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="286abe2b03"><code>286abe2</code></a> Updating action.yml with new release version</li>
<li><a href="1d0751b749"><code>1d0751b</code></a> cleanup (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1378">#1378</a>)</li>
<li><a href="be0e288e1e"><code>be0e288</code></a> Bump cljkondo/clj-kondo from 2021.03.03-alpine to 2021.03.22-alpine (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1379">#1379</a>)</li>
<li><a href="8ff48a47d3"><code>8ff48a4</code></a> Bump isort from 5.7.0 to 5.8.0 in /dependencies (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1382">#1382</a>)</li>
<li><a href="55cc19dbbc"><code>55cc19d</code></a> Bump immer from 8.0.3 to 9.0.1 in /dependencies (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1381">#1381</a>)</li>
<li><a href="a68b522bc1"><code>a68b522</code></a> Bump sql-lint from 0.0.15 to 0.0.16 in /dependencies (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1380">#1380</a>)</li>
<li><a href="701fd3b339"><code>701fd3b</code></a> Adding a11y eslint to npm dependencies (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1375">#1375</a>)</li>
<li><a href="4016de6222"><code>4016de6</code></a> Bump immer from 8.0.2 to 8.0.3 in /dependencies (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1376">#1376</a>)</li>
<li><a href="43e054faf7"><code>43e054f</code></a> Bump immer from 8.0.1 to 8.0.2 in /dependencies (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1374">#1374</a>)</li>
<li><a href="46d76783c7"><code>46d7678</code></a> Bump eslint-plugin-jest from 24.3.1 to 24.3.2 in /dependencies (<a href="https://github-redirect.dependabot.com/github/super-linter/issues/1372">#1372</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/github/super-linter/compare/v3.15.2...286abe2b0349da9c074c0fed8e8ec0a86cd13279">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-04-13 02:56:29 +00:00
Carter Anderson
5bccb67aa3 Remove unused material (#1898)
This doesn't do anything and complicates the example.
2021-04-13 02:39:50 +00:00
Jonas Matser
5c4f3554f9 Rename Light => PointLight and remove unused properties (#1778)
After an inquiry on Reddit about support for Directional Lights and the unused properties on Light, I wanted to clean it up, to hopefully make it ever so slightly more clear for anyone wanting to add additional light types.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-04-13 02:21:24 +00:00
Julian Heinken
8f1eaa6db5 glTF: added color attribute support (#1775) 2021-04-13 01:47:25 +00:00
MinerSebas
0fce6f0406 Override size_hint for all Iterators and add ExactSizeIterator where applicable (#1734)
After #1697 I looked at all other Iterators from Bevy and added overrides for `size_hint` where it wasn't done.
Also implemented `ExactSizeIterator` where applicable.
2021-04-13 01:28:14 +00:00
Guim Caballero
b060e16f62 Add synonyms for transform relative vectors (#1667)
Fixes #1663.

I think the directions are correct (same as [here](https://docs.godotengine.org/en/stable/classes/class_vector3.html?highlight=forward#constants)), but please double check because I might have mixed them up.

Co-authored-by: guimcaballero <guim.caballero@gmail.com>
Co-authored-by: Guim Caballero <guim.caballero@gmail.com>
2021-04-12 21:53:05 +00:00
Alessandro Re
6ce57c85d6 Example on how to draw using custom mesh and shader (#1565)
I was looking into "lower level" rendering and I saw no example on how to do that. Yet, I think it's something relevant to show, so I set up a simple example on how to do that. I hope it's welcome.

I'm not confident about the code and a review is definitely nice to have, especially because there are a few things that are not great.
Specifically, I think it would be nice to see how to render with a completely custom set of attributes (position and color, in this case), but I couldn't manage to get it working without normals and uv.

It makes sense if bevy Meshes need these two attributes, but I'm not sure about it.

Co-authored-by: Alessandro Re <ale@ale-re.net>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-04-12 19:47:12 +00:00
Mike
9186c4c8d2 Change breakout to use fixed timestamp (#1541)
This PR fixes https://github.com/bevyengine/bevy/issues/1240, where the ball is escaping the playing field at low framerates.  I did this by moving the movement and physics system into a Fixed Timestep system set and changing the movement steps to a constant.  So we lose the example use of delta_time for changing position, but gain a use of FixedTimestep.

If this is accepted https://github.com/bevyengine/bevy-website/pull/102 will need to be updated to match.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-04-12 19:29:08 +00:00
Nathan Stocks
60f286d56d Update linters.md with info about cargo ci xtask (#1507)
Update `linters.md` with info about `cargo ci` xtask as per https://github.com/bevyengine/bevy/pull/1463#pullrequestreview-593747890

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-04-12 19:11:40 +00:00
Jakob Hellermann
ed36c21e7e fix 'attempted to subtract with overflow' for State::inactives (#1668) 2021-04-10 16:33:35 +00:00
bjorn3
6a4051be3a Make some asset loading functions monomorphic (#1861)
This reduces the size of executables when using bevy as dylib by
ensuring that they get codegened in bevy_assets instead of the game
itself. This by extension avoids pulling in parts of bevy_tasks and
async_task.

Before this change the breakout example was 923k big after this change
it is only 775k big for cg_clif. For cg_llvm in release mode breakout
shrinks from 356k to 316k. For cg_llvm in debug mode breakout shrinks
from 3814k to 3057k.
2021-04-10 16:17:32 +00:00
Alice Cecile
100e516014 Release Checklist (#1834)
To help make the process easier and more fool-proof, aid delegation and document institutional knowledge.

I'm not entirely sure where this belongs.
2021-04-08 21:33:46 +00:00
Grindv1k
9ac9088933 Remove leftover pbr_textures example (#1845)
`examples/3d/pbr_textures.rs` was missing in both `Cargo.toml` and in the examples
`README.md`.
2021-04-08 17:42:15 +00:00
r00ster
bc13d11c78 Update old docs mentioning Camera2dBundle (#1836)
This replaces some outdated mentions of the `Camera2dBundle` that is removed now with 0.5.
2021-04-06 21:05:08 +00:00
Carter Anderson
97d8e4e179 Release 0.5.0 (#1835) 2021-04-06 18:48:48 +00:00
Jakob Hellermann
aaf204cbac remove active camera entity when despawned (#1825)
fixes #1452

This should probably be in 0.5, as the previous workaround isn't possible after dd4a196329 because the hashmap is now private.
2021-04-06 17:09:28 +00:00
Carter Anderson
3118ebdfd3
update changelog (#1829) 2021-04-06 09:58:34 -07:00
François
3e285d5c0b allow deriving bundle for struct with generics with where clause (#1811)
fixes #1777 

Seems the `_where_clause` parameter to lost somewhere, adding it back
2021-04-03 23:30:30 +00:00
François
9098df3034 make pbr shader std140 compatible (#1798)
In shaders, `vec3` should be avoided for `std140` layout, as they take the size of a `vec4` and won't support manual padding by adding an additional `float`.

This change is needed for 3D to work in WebGL2. With it, I get PBR to render
<img width="1407" alt="Screenshot 2021-04-02 at 02 57 14" src="https://user-images.githubusercontent.com/8672791/113368551-5a3c2780-935f-11eb-8c8d-e9ba65b5ee98.png">

Without it, nothing renders... @cart Could this be considered for 0.5 release?

Also, I learned shaders 2 days ago, so don't hesitate to correct any issue or misunderstanding I may have

bevy_webgl2 PR in progress for Bevy 0.5 is here if you want to test: https://github.com/rparrett/bevy_webgl2/pull/1
2021-04-03 23:30:28 +00:00
François
276a81cc30 allow up to 16 parameters for systems (#1805)
fixes #1772 

1st commit: the limit was at 11 as the macro was not using a range including the upper end. I changed that as it feels the purpose of the macro is clearer that way.

2nd commit: as suggested in the `// TODO`, I added a `Config` trait to go to 16 elements tuples. This means that if someone has a custom system parameter with a config that is not a tuple or an `Option`, they will have to implement `Config` for it instead of the standard `Default`.
2021-04-03 23:13:54 +00:00
Jakob Hellermann
1df3b74d38 fix attempt to modify emissive uniform (#1771)
Previously loading the boom box gltf file panic'd with `ERROR: 0:335: 'assign' :  l-value required "anon@7" (can't modify a uniform)`
2021-04-03 22:51:52 +00:00
Carter Anderson
f520a341d5 flip resource scope order (#1793)
I think [collection, thing_removed_from_collection] is a more natural order than [thing_removed_from_collection, collection]. Just a small tweak that I think we should include in 0.5.
2021-04-01 02:24:42 +00:00
TheRawMeatball
b657a9b39f Add on_in_stack_update to SystemSet (#1792) 2021-03-31 20:24:04 +00:00
Carter Anderson
d6bc414bf0 check for duplicate archetypes in QueryState::new_archetype (#1789)
Fixes #1788

See discussion in that issue for details.
2021-03-30 21:21:47 +00:00
François
9193fc57d0 CI break: fix syn version (#1787)
This is a temporary fix for the CI (and anyone building for wasm) break until `wgpu` can update

* `syn` released a version that fixed a bug in how they parsed attributes
* `wasm_bindgen` released a version that uses that fix
* but we're stuck with old `wasm_bindgen` as `wgpu` uses a fixed version: c5ee9cd983/Cargo.toml (L118)

So, to fix this, either we update everyone to latest version of `wasm_bindgen` or we keep using old version of `syn`.

On Bevy side, it should be faster to fix the version of `syn` to one that works.

More details: https://github.com/rustwasm/wasm-bindgen/pull/2510 & https://github.com/rustwasm/wasm-bindgen/issues/2508
2021-03-30 18:34:53 +00:00
Carter Anderson
94c4184068 Text responds to scale factor changes (#1769)
Fixes #1768

If the scale factor changes, queue up all text to be drawn instead of just changed text.
2021-03-27 03:03:47 +00:00
Jonas Matser
9a78addff0 Add PBR textures (#1632)
This PR adds normal maps on top of PBR #1554. Once that PR lands, the changes should look simpler.

Edit: Turned out to be so little extra work, I added metallic/roughness texture too. And occlusion and emissive.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-03-26 21:00:34 +00:00
davier
0c374df712 Add insert_children and push_children to EntityMut (#1728)
The only API to add a parent/child relationship between existing entities is through commands, there is no easy way to do it from `World`. Manually inserting the components is not completely possible since `PreviousParent` has no public constructor.

This PR adds two methods to set entities as children of an `EntityMut`: `insert_children` and `push_children`. ~~The API is similar to the one on `Commands`, except that the parent is the `EntityMut`.~~ The API is the same as in #1703.
However, the `Parent` and `Children` components are defined in `bevy_transform` which depends on `bevy_ecs`, while `EntityMut` is defined in `bevy_ecs`, so the methods are added to the `BuildWorldChildren` trait instead.
If #1545 is merged this should be fixed too.

I'm aware cart was experimenting with entity hierarchies, but unless it's a coming soon this PR would be useful to have meanwhile.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-03-26 20:03:12 +00:00
François
d90d19f1c7 gltf: load normal and occlusion as linear textures (#1762)
Load textures from gltf as linear when needed.

This is for #1632, but can be done independently and won't have any visible impact before.

* during iteration over materials, register textures that need to be loaded as linear
* during iteration over textures
  * directly load bytes from external files instead of adding them as dependencies in the load context
  * configure the texture the same way for buffered and external textures
  * if the texture is linear rgb, set as linear rgb
2021-03-26 18:47:47 +00:00
Ixentus
80bd378aa0 Fix tiny state docs inconsistency (#1764)
@TheRawMeatball
2021-03-26 18:30:28 +00:00
Carter Anderson
7a511394ac Add register_component to AppBuilder and improve error message (#1750) 2021-03-26 04:15:07 +00:00
Alexander Sepity
500d7469e7 Fixed criteria-less systems being re-ran unnecessarily (#1754)
Fixes #1753.

The problem was introduced while reworking the logic around stages' own criteria. Before #1675 they used to be stored and processed inline with the systems' criteria, and systems without criteria used that of their stage. After, criteria-less systems think they should run, always. This PR more or less restores previous behavior; a less cludge solution can wait until after 0.5 - ideally, until stageless.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-03-26 00:31:58 +00:00
Carter Anderson
bf053218bf Disable frustum culling and add warning (#1761)
Frustum culling has some pretty major gaps right now (such as not supporting sprite transform scaling and not taking into account projections). It should be disabled by default until it provides a solid experience across all bevy use cases.
2021-03-25 22:05:28 +00:00
Jakob Hellermann
ad60046982 fix clippy lints (#1756) 2021-03-25 20:48:18 +00:00