Component Hooks, Quill UI Demo, and Procedural applications
2024-07-15
This week in Bevy we've got people making use of Observers and Hooks, first games, procedural generation and animation, and more.
The #rendering channel has been talking about technology like MaterialX. We'll see number of different UI showcases including bevy_ui, text-to-speech, and Quill. While other people are implementing papers and talks including destructible stress environment systems and water simulation.
Bevy game jam 5 theme voting is underway. You can sign up to participate here on Itch.io, vote on themes in the #jam-theme-voting Discord channel, and find a team to participate with in #jam-find-a-team.
The Bevy jam starts on the 20th so get your voting in if you want to and get ready to make a game!
Component Hooks
Bevy 0.14 introduced Component Hooks which enable upholding invariants when Components are added, inserted, and removed. Defining these hooks required forgoing the automatic deriving of the #[derive(Component)]
and using a manual implementation.
As of #14005, new attributes have been added to the Component
macro, which enable defining hooks as regular functions that are attached to an implementation using the new component
attribute.
#[derive(Component)]
#[component(on_add = my_on_add_hook)]
#[component(on_insert = my_on_insert_hook)]
struct ComponentA;
fn my_on_add_hook(world: DeferredWorld, entity: Entity, id: ComponentId) {
// ...
}
Uniform mesh sampling
#14071 enables random sampling from the surfaces of triangle meshes with a new Mesh::triangles
method. The implementation of UniformMeshSampler
caches the triangles' distribution of areas so that after its initial setup, sampling is allocation-free.
let triangles = my_mesh.triangles().unwrap();
let mut rng = StdRng::seed_from_u64(8765309);
let distribution = UniformMeshSampler::try_new(triangles).unwrap();
// 10000 random points from the surface of my_mesh:
let sample_points: Vec<Vec3> = distribution.sample_iter(&mut rng).take(10000).collect();
Fixed Timestep Movement
A new demo, physics_in_fixed_timestep
how to properly handle player input, advance a physics simulation in a fixed timestep, and display the results. The classic source for how and why this demo exists the way it does is Fix your Timestep! and more bevy-centric fixed-timestep information is available in the Bevy Cheatbook. One especially useful section is the "Should I put my systems in Update
or FixedUpdate
" section.
Virtual Geometry
Virtual Geometry work continues with mixed software/hardware rasterization. Its already much faster than hardware and there's plenty of opportunity for optimization. More information in the Discord thread
MaterialX
MaterialX is a rendering-related technology for well, materials. It recently got added to Blender's USD export (USD).
MaterialX has been getting a few mentions in the #rendering channel in the Bevy Discord lately, and an initial parser for the spec was created (discord link). The repo with the bevy loading example seen here lives on GitHub.
Whether or not MaterialX makes an impact on Bevy's Rendering implementation is yet to be seen, but for those that are interested there is some interesting development and discussion happening.
Automated feature testing
Testing all of the combinations of all of the different ways Bevy's features can be enabled or disabled in combination can be hard to do manually. Worked to automate this kind of testing can be found in the TheBevyFlock/flag-frenzy repo. This work-in-progress has already caught its first bug.
Showcase
Bevy work from the #showcase channel in Discord and around the internet. Use hashtag #bevyengine.
Scriptgrip's physics update
showcase
Scriptgrip is a ship physics based puzzle game that got some updates to its physics model this week resulting in smooth sliding on surfaces and no ghost collisions.
Quartz Spectral Delay
showcase
quartz v0.6.1 has rfft()
and ifft()
nodes (fourier transform) which enables spectral processing. In the video you hear the input signal analyzed, then each bin is delayed by a different time (spectral delay)
Rain World Kelp Creature
showcase
Rain World is known for its procedural animation. This demo recreates the kelp creature from Rain World using Avian physics.
Druid's Quest
showcase
This puzzle game is the author's first. Published after 6 month's of work, push crates around as a Druid to solve puzzles. Downloadable for Windows on Itch.io.
Procedural forest day/night cycles
showcase
This procedurally generated forest was built using Perlin noise from the noise crate and has a day/night cycle. It hosts 75k entities.
Waving Foliage for a Sandbox Voxel Game
showcase
Waving foliage implemented with a custom vertex shader that offsets the position over time. The code is on GitHub and the current build of the game is available in releases
destruction system and stress simulation
showcase
Destructible environment based on a 2011 GDC talk by one of the developers of Red Faction Armageddon called "Living in a Stressful World: Real-time Stress Calculation for Destroyable Environments". The "stress" system is what causes hanging pieces to fall off since they weigh too much for the supporting pieces to hold.
Menu text-to-speech
showcase
eerii/hello-bevy is a bevy game template that recently got key mappings and text-to-speech support. text-to-speech is powered by tts and works with keyboard and gamepad navigation. Navigation is powered by bevy-alt-ui-navigation-lite and a custom input system powered by leafwing-input-manager.
Water Simulation
showcase
More progress on the water simulation we saw last week. Including an implementation of the Phillips oceanographic spectrum in 2D using rustfft for the inverse fast-fourier transform on the CPU.
The diagnostics display on the shallower water is powered by iyes_perf_ui and more information available about the techniques used are available in the Discord thread.
Crates
New releases to crates.io and substantial updates to existing projects
bevy-translation-table
crate_release
Bevy Translation Tables is a crate for performing simple Key-Value translations with only the currently needed locale loaded into memory.
wgsl_ln
crate_release
Write wgsl in rust! With support for compile time error checking and global imports.
pub static MANHATTAN_DISTANCE: &str = wgsl!(
fn manhattan_distance(a: vec2<f32>, b: vec2<f32>) -> f32 {
return abs(a.x - b.x) + abs(a.y - b.y);
}
);
bevy-autoplay
crate_release
Automated integration testing based on recorded play-testing sessions.
This plugin allows you to record playtest sessions, save them to a file, and then write feature/integration tests that assert against that session. This allows you to perform automated testing on real play sessions, including being able to test for regressions in a CI for example. The sessions can also be played back at a multiplied speed
EmptyPathStream is only used in android/wasm32 authored by mockersf
meta: Add `Showcase` section to PR template authored by MrGVSV
disable gpu preprocessing on android with Adreno 730 GPU and earilier authored by Litttlefish
Optimize unnecessary normalizations for `Transform::local_{xyz}` authored by janhohenheim
bevy_input: allow use without bevy_reflect authored by torsteingrindvik
Fix state example urls authored by SpecificProtagonist
bevy_core: make bevy_reflect optional authored by torsteingrindvik
use Display for entity id in log_components authored by hymm
add entity to error message authored by hymm
Fix crash when an asset load failure event is processed after asset drop authored by brianreavis
impl Reflect + Clone for StateScoped authored by brandon-reinhart
Component Hook functions as attributes for Component derive macro authored by Jenya705
Use rust-lld on windows rustdoc in config_fast_builds.toml authored by SkiFire13
Optimize ui_layout_system authored by re0312
Add Mac OS tracy info to profiling docs authored by mweatherley
prepare next version: update regexes authored by mockersf
Created an EventMutator for when you want to mutate an event before reading authored by BobG1983
Bump Version after Release authored by github-actions[bot]
fix typo processed_dir authored by mockersf
Uniform mesh sampling authored by mweatherley
Make `bevy_math::common_traits` public authored by mweatherley
Moves smooth_follow to movement dir authored by Cioraz
Add an example for doing movement in fixed timesteps authored by janhohenheim
Fix doc list indentation authored by rparrett
fix: Possible NaN due to denormalised quaternions in AABB implementations for round shapes. authored by IQuick143
Fix intra-doc links and make CI test them authored by SkiFire13
Fixed #14248 and other URL issues authored by BlakeBedford
Want to contribute to Bevy?
Here you can find two types of potential contribution: Pull Requests that might need review and Issues that might need to be worked on.
Pull Requests Opened this week
Component Lifecycle Hook & Observer Trigger for replaced values authored by Pixelstormer
Rename `bevy_core::name::DebugName` to `bevy_core::name::DebugLabel` authored by GauravTalreja
Make initial `StateTransition` run before `PreStartup` authored by MiniaczQ
bevy_reflect: Improve `DynamicFunction` ergonomics authored by MrGVSV
Remove need for EventLoopProxy to be NonSend authored by hymm
Clean up UiSystem system sets authored by UkoeHB
update example low_power authored by mockersf
update gltf example to use type-safe `GltfAssetLabel::Scene` authored by johannesvollmer
Persistent Render World authored by Trashtalk217
Implement FromIterator/IntoIterator for dynamic types authored by SpecificProtagonist
Implement `Spawn` trait authored by MiniaczQ
Allow `Asset` to define hooks for `Handle<T>`. authored by mintlu8
Make state methods panic on missing `StatePlugin` authored by MiniaczQ
Fix inaccurate docs for `Commands::spawn_empty` authored by benfrankel
force field example authored by ChristopherBiscardi
Pack multiple vertex and index arrays together into growable buffers. authored by pcwalton
Prevent division by zero in HWBA to HSVA conversions authored by ickshonpe
Add some missing reflect attributes authored by mrchantey
Text2d misalignment fix authored by ickshonpe
Basic isometry types authored by mweatherley
Add support for skybox transformation authored by Soulghost
Fix overflow in `RenderLayers::iter_layers` authored by Azorlogh
feature: Derive Hash for KeyboardInput. authored by shanecelis
Fix incorrect function calls to hsv_to_rgb in render debug code. authored by Soulghost
Move `Msaa` to component authored by tychedelia
Improve camera clear behavior with viewports authored by tychedelia
remove iter_unsafe/iter_many_unsafe/iter_combinations_unsafe from Query authored by Victoronz
Remove second generic from `.add_before`, `.add_after` authored by benfrankel
Add custom cursors authored by eero-lehtinen
Add insert_by_id and try_insert_by_id to EntityCommands authored by SOF3
Time trackers authored by Brezak
Add support for environment map transformation authored by Soulghost
Skip batching for phase items from other pipelines authored by james-j-obrien
Clearer spatial bundle pub const docs authored by torsteingrindvik
Clarify GlobalTransform::transform_point authored by masonk
Issues Opened this week
Minimizing and then enlarging the window with GpuCulling leads to a crash authored by Lemonzyy
Resources inserted during `Startup` schedule are not available in `OnEnter` schedule. authored by CooCooCaCha
`OnEnter` schedule is not ran when calling `next_state.set()` in `Startup` system authored by CooCooCaCha
Access to Observer's EntityCommands in every registration method authored by MiniaczQ
Observers as part of bundle authored by MiniaczQ
Support alternate backends (like Unity, Unreal, Godot or Itch) to complement Bevy Assets / Marketplace authored by Doh09
Component Lifecycle Hook for replaced values authored by Pixelstormer
Good reposittu authored by MAFLIXD
0.13 to 0.14: 3-4 times higher CPU usage in empty project with DefaultPlugins due to wgpu 0.20 authored by perry-blueberry
Panic when `PbrPlugin.add_default_deferred_lighting_plugin = false` authored by eero-lehtinen
FPS Drop in 0.14.0 when moving mouse authored by andreypfau
Move FixedUpdate / fixed timestep behind a feature flag authored by alice-i-cecile
`low_power` example does not work on WASM authored by aevyrie
Wgpu error doesn't let my bevy 0.13.0 project that I updated to bevy 0.14.0 work authored by Silver-Sorbet
UI only visible for one frame when used with animated sprites authored by tsukinoko-kun
Support `EntityCommands::trigger` and `EntityWorldMut::trigger` authored by benfrankel
Use traits to make ECS APIs for working with entities more consistent authored by MiniaczQ
bevy_animation `0.14` is overly restrictive. authored by mintlu8
Make `Trigger::entity()` panic on `Entity::PLACEHOLDER` and add `Trigger::get_entity()` authored by MiniaczQ
State API should panic when missing `StatePlugin` authored by MiniaczQ
UI does not update in sync with window resizes authored by UkoeHB
Borders of `MaterialNodeBundle` are vanished authored by umut-sahin
Raspberry Pi 4 Performance Regression authored by s-mayrh
`embedded_asset!` is broken on Windows Wasm builds authored by janhohenheim
Don't use fixed time in breakout example authored by alice-i-cecile
Inconsistent API between observers and commands for entity-targetting authored by benfrankel
Rebuild thrashing when using Rust Analyzer in VSCode with fast build config authored by hintron
Various examples need their font sizes adjusted post-`cosmic-text` authored by rparrett
Add `PluginGroupBuilder::replace` helper method authored by benfrankel
Add `Configure` trait as a receiver-free alternative to `Plugin` authored by benfrankel
`JustifyText::Center` doesn't place a text in the center of `Text2dBounds` authored by m2ym
Second `Text2d` example explaining `Anchor`, `JustifyText` and `TextBounds/Text2dBounds` authored by ickshonpe
Add `EntityWorldMut::commands` method authored by benfrankel
UI nodes don't resize when toggling fullscreen authored by benfrankel
Our API suggests that panicking should be the default authored by janhohenheim
Competing naming conventions for types authored by benfrankel
Bevy 0.14 adds some very expensive debug assertions somewhere authored by SludgePhD
Extreme Bloom on non-emissive dark surface. WebGl2 & Linux only authored by paul-hansen
Improper batching of non-mesh phase items. authored by james-j-obrien