bevy
bevy copied to clipboard
Lighting Should Only hold Vec<Entity> instead of TypeId<Vec<Entity>>
Objective
- After #13894, I noticed the performance of
many_lightsdropped from 120+ to 60+. I reviewed the PR but couldn't identify any mistakes. After profiling, I discovered thatHashmap::Clonewas very slow when its not empty, causingextract_lightto increase from 3ms to 8ms. - Lighting only checks visibility for 3D Meshes. We don't need to maintain a TypeIdMap for this, as it not only impacts performance negatively but also reduces ergonomics.
Solution
- use VisibleMeshEntities for lighint visibility checking.
Performance
cargo run --release --example many_lights --features bevy/trace_tracy
name="bevy_pbr::light::check_point_light_mesh_visibility"}
system{name="bevy_pbr::render::light::extract_lights"}
Migration Guide
now
SpotLightBundle,CascadesVisibleEntitiesandCubemapVisibleEntitiesuse VisibleMeshEntities instead ofVisibleEntities