2020-08-24 18:16:52 +00:00
name : CI
2020-05-29 03:48:18 +00:00
on :
2023-03-06 06:08:21 +00:00
merge_group :
2020-05-29 03:48:18 +00:00
pull_request :
2021-02-19 21:15:29 +00:00
push :
2023-03-07 21:42:53 +00:00
branches :
- main
2024-06-07 01:56:25 +00:00
- release-*
2020-05-29 03:48:18 +00:00
env :
CARGO_TERM_COLOR : always
2024-04-22 22:41:45 +00:00
# If nightly is breaking CI, modify this variable to target a specific nightly version.
2024-01-22 19:32:44 +00:00
NIGHTLY_TOOLCHAIN : nightly
2020-05-29 03:48:18 +00:00
2024-02-28 16:07:29 +00:00
concurrency :
group : ${{github.workflow}}-${{github.ref}}
cancel-in-progress : ${{github.event_name == 'pull_request'}}
2020-05-29 03:48:18 +00:00
jobs :
build :
2020-08-26 18:57:35 +00:00
strategy :
matrix :
2021-01-27 01:11:38 +00:00
os : [ windows-latest, ubuntu-latest, macos-latest]
2020-08-27 19:24:02 +00:00
runs-on : ${{ matrix.os }}
2023-02-01 15:08:31 +00:00
timeout-minutes : 30
2020-05-29 03:48:18 +00:00
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2024-01-28 09:59:48 +00:00
- uses : actions/cache@v4
2021-07-27 02:01:11 +00:00
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
2022-07-15 22:37:07 +00:00
key : ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }}
2022-10-31 17:36:23 +00:00
- uses : dtolnay/rust-toolchain@stable
2024-04-13 22:34:48 +00:00
- name : Install Linux dependencies
uses : ./.github/actions/install-linux-deps
2021-01-27 01:11:38 +00:00
- name : Build & run tests
2022-05-02 19:13:34 +00:00
# See tools/ci/src/main.rs for the commands this runs
run : cargo run -p ci -- test
2020-08-26 18:57:35 +00:00
env :
CARGO_INCREMENTAL : 0
RUSTFLAGS : "-C debuginfo=0 -D warnings"
2021-07-27 02:01:11 +00:00
ci :
runs-on : ubuntu-latest
2023-02-01 15:08:31 +00:00
timeout-minutes : 30
2021-07-27 02:01:11 +00:00
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2024-01-28 09:59:48 +00:00
- uses : actions/cache@v4
2021-07-27 02:01:11 +00:00
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key : ${{ runner.os }}-cargo-ci-${{ hashFiles('**/Cargo.toml') }}
2022-10-31 17:36:23 +00:00
- uses : dtolnay/rust-toolchain@stable
2021-07-27 02:01:11 +00:00
with :
components : rustfmt, clippy
2024-04-13 22:34:48 +00:00
- name : Install Linux dependencies
uses : ./.github/actions/install-linux-deps
with :
wayland : true
xkb : true
2021-07-27 02:01:11 +00:00
- name : CI job
# See tools/ci/src/main.rs for the commands this runs
2022-05-02 19:13:34 +00:00
run : cargo run -p ci -- lints
2021-07-27 02:01:11 +00:00
2022-03-25 00:26:07 +00:00
miri :
2024-11-10 06:34:34 +00:00
runs-on : macos-latest
2022-05-14 02:01:38 +00:00
timeout-minutes : 60
2022-03-25 00:26:07 +00:00
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2024-01-28 09:59:48 +00:00
- uses : actions/cache@v4
2022-07-01 13:19:39 +00:00
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key : ${{ runner.os }}-cargo-miri-${{ hashFiles('**/Cargo.toml') }}
2022-10-31 17:36:23 +00:00
- uses : dtolnay/rust-toolchain@master
2022-03-25 00:26:07 +00:00
with :
2022-07-15 22:37:07 +00:00
toolchain : ${{ env.NIGHTLY_TOOLCHAIN }}
2022-03-25 00:26:07 +00:00
components : miri
- name : CI job
2022-07-06 00:11:24 +00:00
# To run the tests one item at a time for troubleshooting, use
2024-09-19 21:41:19 +00:00
# cargo --quiet test --lib -- --list | sed 's/: test$//' | MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation" xargs -n1 cargo miri test -p bevy_ecs --lib -- --exact
2022-03-25 00:26:07 +00:00
run : cargo miri test -p bevy_ecs
env :
# -Zrandomize-layout makes sure we dont rely on the layout of anything that might change
RUSTFLAGS : -Zrandomize-layout
2022-07-01 13:19:39 +00:00
# https://github.com/rust-lang/miri#miri--z-flags-and-environment-variables
2022-03-25 00:26:07 +00:00
# -Zmiri-disable-isolation is needed because our executor uses `fastrand` which accesses system time.
2022-07-01 21:54:28 +00:00
# -Zmiri-ignore-leaks is necessary because a bunch of tests don't join all threads before finishing.
2024-09-19 21:41:19 +00:00
MIRIFLAGS : -Zmiri-ignore-leaks -Zmiri-disable-isolation
2022-03-25 00:26:07 +00:00
2022-05-02 19:13:34 +00:00
check-compiles :
2021-08-26 00:40:56 +00:00
runs-on : ubuntu-latest
2023-02-01 15:08:31 +00:00
timeout-minutes : 30
2021-08-26 00:40:56 +00:00
needs : ci
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2024-01-28 09:59:48 +00:00
- uses : actions/cache@v4
2021-08-26 00:40:56 +00:00
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
2022-05-02 19:13:34 +00:00
crates/bevy_ecs_compile_fail_tests/target/
2023-01-02 21:07:33 +00:00
crates/bevy_reflect_compile_fail_tests/target/
2022-05-02 19:13:34 +00:00
key : ${{ runner.os }}-cargo-check-compiles-${{ hashFiles('**/Cargo.toml') }}
2022-10-31 17:36:23 +00:00
- uses : dtolnay/rust-toolchain@stable
2021-08-26 00:40:56 +00:00
with :
toolchain : stable
2024-04-13 22:34:48 +00:00
- name : Install Linux dependencies
uses : ./.github/actions/install-linux-deps
2022-05-02 19:13:34 +00:00
- name : Check Compile
# See tools/ci/src/main.rs for the commands this runs
run : cargo run -p ci -- compile
2024-11-07 00:56:22 +00:00
2024-10-11 10:54:44 +00:00
check-compiles-no-std :
runs-on : ubuntu-latest
timeout-minutes : 30
needs : ci
steps :
- uses : actions/checkout@v4
- uses : actions/cache@v4
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
crates/bevy_ecs_compile_fail_tests/target/
crates/bevy_reflect_compile_fail_tests/target/
key : ${{ runner.os }}-cargo-check-compiles-no-std-${{ hashFiles('**/Cargo.toml') }}
- uses : dtolnay/rust-toolchain@stable
with :
targets : x86_64-unknown-none
- name : Install Linux dependencies
uses : ./.github/actions/install-linux-deps
- name : Check Compile
run : cargo run -p ci -- compile-check-no-std
2021-08-26 00:40:56 +00:00
2020-10-22 01:15:14 +00:00
build-wasm :
2022-07-15 22:37:07 +00:00
runs-on : ubuntu-latest
2023-02-01 15:08:31 +00:00
timeout-minutes : 30
2022-05-31 17:30:31 +00:00
needs : build
2020-10-22 01:15:14 +00:00
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2024-01-28 09:59:48 +00:00
- uses : actions/cache@v4
2021-07-27 02:01:11 +00:00
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
2022-07-15 22:37:07 +00:00
key : ubuntu-assets-cargo-build-wasm-stable-${{ hashFiles('**/Cargo.toml') }}
2022-10-31 17:36:23 +00:00
- uses : dtolnay/rust-toolchain@stable
2020-10-22 01:15:14 +00:00
with :
target : wasm32-unknown-unknown
2020-09-21 22:47:38 +00:00
- name : Check wasm
2022-10-31 17:36:23 +00:00
run : cargo check --target wasm32-unknown-unknown
2020-09-21 22:47:38 +00:00
2024-03-25 19:10:18 +00:00
build-wasm-atomics :
runs-on : ubuntu-latest
timeout-minutes : 30
needs : build
steps :
- uses : actions/checkout@v4
- uses : actions/cache@v4
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key : ubuntu-assets-cargo-build-wasm-nightly-${{ hashFiles('**/Cargo.toml') }}
- uses : dtolnay/rust-toolchain@master
with :
toolchain : ${{ env.NIGHTLY_TOOLCHAIN }}
targets : wasm32-unknown-unknown
components : rust-src
- name : Check wasm
run : cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort
env :
RUSTFLAGS : "-C target-feature=+atomics,+bulk-memory"
2021-02-22 04:50:05 +00:00
markdownlint :
runs-on : ubuntu-latest
2023-02-01 15:08:31 +00:00
timeout-minutes : 30
2023-03-07 21:42:53 +00:00
needs : check-missing-features-in-docs
2021-07-27 02:01:11 +00:00
if : always()
2021-02-22 04:50:05 +00:00
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2021-02-22 04:50:05 +00:00
with :
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth : 0
- name : Run Markdown Lint
2021-06-01 01:01:20 +00:00
uses : docker://ghcr.io/github/super-linter:slim-v4
2021-02-22 04:50:05 +00:00
env :
2022-07-05 15:49:11 +00:00
MULTI_STATUS : false
2021-02-22 04:50:05 +00:00
VALIDATE_ALL_CODEBASE : false
VALIDATE_MARKDOWN : true
2021-04-15 19:29:47 +00:00
DEFAULT_BRANCH : main
2021-04-14 21:40:36 +00:00
2023-11-21 01:04:14 +00:00
toml :
runs-on : ubuntu-latest
timeout-minutes : 30
steps :
- uses : actions/checkout@v4
2024-02-22 18:13:45 +00:00
- uses : dtolnay/rust-toolchain@stable
2023-11-21 01:04:14 +00:00
- name : Install taplo
2024-02-22 18:13:45 +00:00
run : cargo install taplo-cli --locked
2023-11-21 01:04:14 +00:00
- name : Run Taplo
id : taplo
run : taplo fmt --check --diff
- name : Taplo info
if : failure()
run : |
2024-11-11 18:47:51 +00:00
echo 'To fix toml fmt, please run `taplo fmt`.'
echo 'To check for a diff, run `taplo fmt --check --diff`.'
2024-02-22 18:13:45 +00:00
echo 'You can find taplo here : https://taplo.tamasfe.dev/'
2024-11-11 18:47:51 +00:00
echo 'Or if you use VSCode, use the `Even Better Toml` extension.'
2024-02-22 18:13:45 +00:00
echo 'You can find the extension here : https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml'
2023-11-21 01:04:14 +00:00
2024-02-26 16:19:40 +00:00
typos :
runs-on : ubuntu-latest
timeout-minutes : 30
steps :
- uses : actions/checkout@v4
- name : Check for typos
2024-11-11 07:04:10 +00:00
uses : crate-ci/typos@v1.27.3
2024-02-26 16:19:40 +00:00
- name : Typos info
if : failure()
run : |
echo 'To fix typos, please run `typos -w`'
echo 'To check for a diff, run `typos`'
echo 'You can find typos here : https://crates.io/crates/typos'
echo 'if you use VSCode, you can also install `Typos Spell Checker'
echo 'You can find the extension here : https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode'
2024-10-14 19:16:12 +00:00
run-examples-macos-metal :
2024-11-10 06:34:34 +00:00
runs-on : macos-latest
2024-10-14 19:16:12 +00:00
timeout-minutes : 30
steps :
- uses : actions/checkout@v4
- uses : dtolnay/rust-toolchain@stable
- name : Disable audio
# Disable audio through a patch. on github m1 runners, audio timeouts after 15 minutes
run : git apply --ignore-whitespace tools/example-showcase/disable-audio.patch
- name : Build bevy
# this uses the same command as when running the example to ensure build is reused
run : |
TRACE_CHROME=trace-alien_cake_addict.json CI_TESTING_CONFIG=.github/example-run/alien_cake_addict.ron cargo build --example alien_cake_addict --features "bevy_ci_testing,trace,trace_chrome"
- name : Run examples
run : |
for example in .github/example-run/*.ron; do
example_name=`basename $example .ron`
echo -n $example_name > last_example_run
echo "running $example_name - "`date`
time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example cargo run --example $example_name --features "bevy_ci_testing,trace,trace_chrome"
sleep 10
if [ `find ./ -maxdepth 1 -name 'screenshot-*.png' -print -quit` ]; then
mkdir screenshots-$example_name
mv screenshot-*.png screenshots-$example_name/
fi
done
mkdir traces && mv trace*.json traces/
mkdir screenshots && mv screenshots-* screenshots/
- name : save traces
uses : actions/upload-artifact@v4
with :
name : example-traces-macos
path : traces
2024-10-14 23:20:56 +00:00
- name : Save PR number
if : ${{ github.event_name == 'pull_request' }}
run : |
echo ${{ github.event.number }} > ./screenshots/PR
2024-10-14 19:16:12 +00:00
- name : save screenshots
uses : actions/upload-artifact@v4
with :
name : screenshots-macos
path : screenshots
- uses : actions/upload-artifact@v4
if : ${{ failure() && github.event_name == 'pull_request' }}
with :
name : example-run-macos
path : example-run/
2024-11-07 00:56:22 +00:00
2021-04-27 02:17:12 +00:00
check-doc :
2021-04-22 19:53:44 +00:00
runs-on : ubuntu-latest
2023-02-01 15:08:31 +00:00
timeout-minutes : 30
2021-04-22 19:53:44 +00:00
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2024-01-28 09:59:48 +00:00
- uses : actions/cache@v4
2022-05-02 19:13:34 +00:00
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key : ${{ runner.os }}-check-doc-${{ hashFiles('**/Cargo.toml') }}
2024-11-07 00:56:22 +00:00
- uses : dtolnay/rust-toolchain@master
with :
toolchain : ${{ env.NIGHTLY_TOOLCHAIN }}
2024-04-13 22:34:48 +00:00
- name : Install Linux dependencies
uses : ./.github/actions/install-linux-deps
with :
wayland : true
xkb : true
2021-04-27 02:17:12 +00:00
- name : Build and check doc
2022-05-02 19:13:34 +00:00
# See tools/ci/src/main.rs for the commands this runs
run : cargo run -p ci -- doc
env :
CARGO_INCREMENTAL : 0
2024-11-07 00:56:22 +00:00
RUSTFLAGS : "-C debuginfo=0 --cfg docsrs_dep"
2022-05-02 19:13:34 +00:00
# This currently report a lot of false positives
# Enable it again once it's fixed - https://github.com/bevyengine/bevy/issues/1983
# - name: Installs cargo-deadlinks
# run: cargo install --force cargo-deadlinks
# - name: Checks dead links
# run: cargo deadlinks --dir target/doc/bevy
# continue-on-error: true
2021-07-27 02:01:11 +00:00
2021-05-30 18:14:58 +00:00
check-missing-examples-in-docs :
runs-on : ubuntu-latest
2023-02-01 15:08:31 +00:00
timeout-minutes : 30
2021-05-30 18:14:58 +00:00
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2023-01-29 17:16:29 +00:00
- name : check for missing metadata
id : missing-metadata
2023-02-28 14:24:47 +00:00
run : cargo run -p build-templated-pages -- check-missing examples
2023-01-29 17:16:29 +00:00
- name : check for missing update
2023-02-28 14:24:47 +00:00
run : cargo run -p build-templated-pages -- update examples
2022-06-25 20:23:24 +00:00
- name : Check for modified files
2023-04-21 22:42:33 +00:00
id : missing-update
2022-06-25 20:23:24 +00:00
run : |
echo "if this step fails, run the following command and commit the changed file on your PR."
2023-02-28 14:24:47 +00:00
echo " > cargo run -p build-templated-pages -- update examples"
2022-06-25 20:23:24 +00:00
git diff --quiet HEAD --
2023-01-29 17:16:29 +00:00
- name : Save PR number
if : ${{ failure() && github.event_name == 'pull_request' }}
run : |
mkdir -p ./missing-examples
echo ${{ github.event.number }} > ./missing-examples/NR
- name : log failed task - missing metadata
if : ${{ failure() && github.event_name == 'pull_request' && steps.missing-metadata.conclusion == 'failure' }}
run : touch ./missing-examples/missing-metadata
- name : log failed task - missing update
if : ${{ failure() && github.event_name == 'pull_request' && steps.missing-update.conclusion == 'failure' }}
run : touch ./missing-examples/missing-update
2023-12-24 00:34:02 +00:00
- uses : actions/upload-artifact@v4
2023-01-29 17:16:29 +00:00
if : ${{ failure() && github.event_name == 'pull_request' }}
with :
name : missing-examples
path : missing-examples/
2022-07-02 00:55:52 +00:00
2023-02-28 14:24:47 +00:00
check-missing-features-in-docs :
runs-on : ubuntu-latest
timeout-minutes : 30
2023-03-07 21:42:53 +00:00
needs : check-missing-examples-in-docs
2023-02-28 14:24:47 +00:00
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2023-02-28 14:24:47 +00:00
- name : check for missing features
id : missing-features
run : cargo run -p build-templated-pages -- check-missing features
- name : check for missing update
run : cargo run -p build-templated-pages -- update features
- name : Check for modified files
2023-04-21 22:42:33 +00:00
id : missing-update
2023-02-28 14:24:47 +00:00
run : |
echo "if this step fails, run the following command and commit the changed file on your PR."
echo " > cargo run -p build-templated-pages -- update features"
git diff --quiet HEAD --
- name : Save PR number
if : ${{ failure() && github.event_name == 'pull_request' }}
run : |
mkdir -p ./missing-features
echo ${{ github.event.number }} > ./missing-features/NR
- name : log failed task - missing features
if : ${{ failure() && github.event_name == 'pull_request' && steps.missing-features.conclusion == 'failure' }}
run : touch ./missing-features/missing-features
- name : log failed task - missing update
if : ${{ failure() && github.event_name == 'pull_request' && steps.missing-update.conclusion == 'failure' }}
run : touch ./missing-features/missing-update
2023-12-24 00:34:02 +00:00
- uses : actions/upload-artifact@v4
2023-02-28 14:24:47 +00:00
if : ${{ failure() && github.event_name == 'pull_request' }}
with :
name : missing-features
path : missing-features/
2023-01-09 21:19:48 +00:00
msrv :
runs-on : ubuntu-latest
2023-02-01 15:08:31 +00:00
timeout-minutes : 30
2023-01-09 21:19:48 +00:00
needs : build
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2024-01-28 09:59:48 +00:00
- uses : actions/cache@v4
2023-01-09 21:19:48 +00:00
with :
path : |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key : ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.toml') }}
- name : get MSRV
2024-04-22 22:41:45 +00:00
id : msrv
2023-01-09 21:19:48 +00:00
run : |
msrv=`cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name=="bevy") | .rust_version'`
2024-04-22 22:41:45 +00:00
echo "msrv=$msrv" >> $GITHUB_OUTPUT
2023-01-09 21:19:48 +00:00
- uses : dtolnay/rust-toolchain@master
with :
2024-04-22 22:41:45 +00:00
toolchain : ${{ steps.msrv.outputs.msrv }}
2024-04-13 22:34:48 +00:00
- name : Install Linux dependencies
uses : ./.github/actions/install-linux-deps
2023-01-09 21:19:48 +00:00
- name : Run cargo check
2023-02-06 22:14:39 +00:00
id : check
2023-01-09 21:19:48 +00:00
run : cargo check
2023-01-29 17:16:29 +00:00
- name : Save PR number
2023-02-06 22:14:39 +00:00
if : ${{ failure() && github.event_name == 'pull_request' && steps.check.conclusion == 'failure' }}
2023-01-29 17:16:29 +00:00
run : |
mkdir -p ./msrv
echo ${{ github.event.number }} > ./msrv/NR
2023-12-24 00:34:02 +00:00
- uses : actions/upload-artifact@v4
2023-02-06 22:14:39 +00:00
if : ${{ failure() && github.event_name == 'pull_request' && steps.check.conclusion == 'failure' }}
2023-01-29 17:16:29 +00:00
with :
name : msrv
path : msrv/
2023-08-29 19:11:06 +00:00
check-bevy-internal-imports :
runs-on : ubuntu-latest
timeout-minutes : 30
steps :
2023-09-13 19:26:25 +00:00
- uses : actions/checkout@v4
2024-09-20 17:08:37 +00:00
- name : Check for internal Bevy imports
2023-08-29 19:11:06 +00:00
shell : bash
run : |
errors=""
for file in $(find examples tests -name '*.rs'); do
2024-09-20 17:08:37 +00:00
if grep -q "use bevy_" "$file"; then
errors+="ERROR: Detected internal Bevy import in $file\n"
2023-08-29 19:11:06 +00:00
fi
done
if [ -n "$errors" ]; then
echo -e "$errors"
2024-09-20 17:08:37 +00:00
echo " Avoid importing internal Bevy crates, they should not be used directly"
echo " Fix the issue by replacing 'bevy_*' with 'bevy'"
Migrate meshes and materials to required components (#15524)
# Objective
A big step in the migration to required components: meshes and
materials!
## Solution
As per the [selected
proposal](https://hackmd.io/@bevy/required_components/%2Fj9-PnF-2QKK0on1KQ29UWQ):
- Deprecate `MaterialMesh2dBundle`, `MaterialMeshBundle`, and
`PbrBundle`.
- Add `Mesh2d` and `Mesh3d` components, which wrap a `Handle<Mesh>`.
- Add `MeshMaterial2d<M: Material2d>` and `MeshMaterial3d<M: Material>`,
which wrap a `Handle<M>`.
- Meshes *without* a mesh material should be rendered with a default
material. The existence of a material is determined by
`HasMaterial2d`/`HasMaterial3d`, which is required by
`MeshMaterial2d`/`MeshMaterial3d`. This gets around problems with the
generics.
Previously:
```rust
commands.spawn(MaterialMesh2dBundle {
mesh: meshes.add(Circle::new(100.0)).into(),
material: materials.add(Color::srgb(7.5, 0.0, 7.5)),
transform: Transform::from_translation(Vec3::new(-200., 0., 0.)),
..default()
});
```
Now:
```rust
commands.spawn((
Mesh2d(meshes.add(Circle::new(100.0))),
MeshMaterial2d(materials.add(Color::srgb(7.5, 0.0, 7.5))),
Transform::from_translation(Vec3::new(-200., 0., 0.)),
));
```
If the mesh material is missing, previously nothing was rendered. Now,
it renders a white default `ColorMaterial` in 2D and a
`StandardMaterial` in 3D (this can be overridden). Below, only every
other entity has a material:
![Näyttökuva 2024-09-29
181746](https://github.com/user-attachments/assets/5c8be029-d2fe-4b8c-ae89-17a72ff82c9a)
![Näyttökuva 2024-09-29
181918](https://github.com/user-attachments/assets/58adbc55-5a1e-4c7d-a2c7-ed456227b909)
Why white? This is still open for discussion, but I think white makes
sense for a *default* material, while *invalid* asset handles pointing
to nothing should have something like a pink material to indicate that
something is broken (I don't handle that in this PR yet). This is kind
of a mix of Godot and Unity: Godot just renders a white material for
non-existent materials, while Unity renders nothing when no materials
exist, but renders pink for invalid materials. I can also change the
default material to pink if that is preferable though.
## Testing
I ran some 2D and 3D examples to test if anything changed visually. I
have not tested all examples or features yet however. If anyone wants to
test more extensively, it would be appreciated!
## Implementation Notes
- The relationship between `bevy_render` and `bevy_pbr` is weird here.
`bevy_render` needs `Mesh3d` for its own systems, but `bevy_pbr` has all
of the material logic, and `bevy_render` doesn't depend on it. I feel
like the two crates should be refactored in some way, but I think that's
out of scope for this PR.
- I didn't migrate meshlets to required components yet. That can
probably be done in a follow-up, as this is already a huge PR.
- It is becoming increasingly clear to me that we really, *really* want
to disallow raw asset handles as components. They caused me a *ton* of
headache here already, and it took me a long time to find every place
that queried for them or inserted them directly on entities, since there
were no compiler errors for it. If we don't remove the `Component`
derive, I expect raw asset handles to be a *huge* footgun for users as
we transition to wrapper components, especially as handles as components
have been the norm so far. I personally consider this to be a blocker
for 0.15: we need to migrate to wrapper components for asset handles
everywhere, and remove the `Component` derive. Also see
https://github.com/bevyengine/bevy/issues/14124.
---
## Migration Guide
Asset handles for meshes and mesh materials must now be wrapped in the
`Mesh2d` and `MeshMaterial2d` or `Mesh3d` and `MeshMaterial3d`
components for 2D and 3D respectively. Raw handles as components no
longer render meshes.
Additionally, `MaterialMesh2dBundle`, `MaterialMeshBundle`, and
`PbrBundle` have been deprecated. Instead, use the mesh and material
components directly.
Previously:
```rust
commands.spawn(MaterialMesh2dBundle {
mesh: meshes.add(Circle::new(100.0)).into(),
material: materials.add(Color::srgb(7.5, 0.0, 7.5)),
transform: Transform::from_translation(Vec3::new(-200., 0., 0.)),
..default()
});
```
Now:
```rust
commands.spawn((
Mesh2d(meshes.add(Circle::new(100.0))),
MeshMaterial2d(materials.add(Color::srgb(7.5, 0.0, 7.5))),
Transform::from_translation(Vec3::new(-200., 0., 0.)),
));
```
If the mesh material is missing, a white default material is now used.
Previously, nothing was rendered if the material was missing.
The `WithMesh2d` and `WithMesh3d` query filter type aliases have also
been removed. Simply use `With<Mesh2d>` or `With<Mesh3d>`.
---------
Co-authored-by: Tim Blackbird <justthecooldude@gmail.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2024-10-01 21:33:17 +00:00
echo " Example: 'use bevy::sprite::Mesh2d;' instead of 'bevy_internal::sprite::Mesh2d;'"
2023-08-29 19:11:06 +00:00
exit 1
2024-02-25 15:19:27 +00:00
fi