Nilirad/bevy_prototype_lyon

Rough curves with fixed camera scaling mode

Pascualex opened this issue · 2 comments

I'm currently configuring my camera with ScalingMode::FixedVertical, like so:

commands.spawn(Camera2dBundle {
    projection: OrthographicProjection {
        scaling_mode: ScalingMode::FixedVertical(20.0),
        ..default()
    },
    ..default()
});

I do this because I want to use distance units for my transforms and not pixels. It also makes the experience more consistent between screens with different pixel densities.

The problem is that bevy_prototype_lyon doesn't seem to support this configuration. Now, when I spawn a circle with radius 1 the edges are so rough that I can even count the number of edges (8).

let shape = shapes::Circle {
    radius: 1.0,
    ..default()
};
commands.spawn(GeometryBuilder::build_as(
    &shape,
    DrawMode::Fill(FillMode::color(Color::BLACK)),
    Transform::default(),
));

You can configure lyon to work better with your scale with FillOptions and StrokeOptions.

let shape = shapes::Circle {
    radius: 1.0,
    ..default()
};
commands.spawn(GeometryBuilder::build_as(
    &shape,
    DrawMode::Fill(FillMode {
        options: FillOptions::tolerance(0.01),
        color: Color::BLACK,
    }),
    Transform::default(),
));

Sounds great, thanks for the pointer.

The ideal solution would be dynamic based on the viewport size. But my understanding is that the path generated by the circle is defined at creation and static.

At least this will mitigate the issue.