Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Aabbs and frustum culling by using default for RenderAssetUsages #251

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

rparrett
Copy link
Contributor

@rparrett rparrett commented Aug 9, 2024

Fixes #245

Tested with a modified example with a lot of shapes, most of which are offscreen. FPS before: 7, after: 40.

use bevy::{
    color::palettes::css::*,
    prelude::*,
    window::{PresentMode, WindowResolution},
};
use bevy_prototype_lyon::prelude::*;
use rand::Rng;

fn main() {
    App::new()
        .insert_resource(Msaa::Sample4)
        .add_plugins((
            DefaultPlugins.set(WindowPlugin {
                primary_window: Some(Window {
                    resolution: WindowResolution::new(1920.0, 1080.0)
                        .with_scale_factor_override(1.0),
                    present_mode: PresentMode::AutoNoVsync,
                    ..default()
                }),
                ..default()
            }),
            ShapePlugin,
        ))
        .add_systems(Startup, setup_system)
        .run();
}

fn setup_system(mut commands: Commands) {
    let shape = shapes::RegularPolygon {
        sides: 6,
        feature: shapes::RegularPolygonFeature::Radius(20.0),
        ..shapes::RegularPolygon::default()
    };

    commands.spawn(Camera2dBundle::default());

    for _ in 0..100000 {
        commands.spawn((
            ShapeBundle {
                spatial: SpatialBundle::from_transform(Transform::from_xyz(
                    (rand::thread_rng().gen::<f32>() - 0.5) * 4000.,
                    (rand::thread_rng().gen::<f32>() - 0.5) * 4000.,
                    0.,
                )),
                path: GeometryBuilder::build_as(&shape),
                ..default()
            },
            Fill::color(DARK_CYAN),
            Stroke::new(BLACK, 10.0),
        ));
    }
}

Copy link
Contributor

@NEON725 NEON725 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We meet again, lol.

Adding a stranger's approval since the Contributing section didn't say I couldn't.

@Nilirad Nilirad merged commit fcd8712 into Nilirad:master Aug 19, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mesh2dHandle points to no asset
3 participants