Nilirad/bevy_prototype_lyon

Rectangle shapes have wrong origin

no-materials opened this issue · 0 comments

I'm running a slightly modified version of the path example where I render a rectangle shape of position (0.0, 0.0, 0.0) and origin RectangleOrigin::Center on a line path which traces the x axis. The result is a slightly offset rectangle:

Screenshot 2022-11-17 at 12 29 52

Relevant code:

use bevy::prelude::*;
use bevy_prototype_lyon::prelude::*;

fn main() {
    App::new()
        .insert_resource(Msaa { samples: 4 })
        .add_plugins(DefaultPlugins)
        .add_plugin(ShapePlugin)
        .add_startup_system(setup_system)
        .run();
}

fn setup_system(mut commands: Commands) {
    let mut path_builder = PathBuilder::new();
    path_builder.move_to(Vec2::new(-10000.0, 0.0));
    path_builder.line_to(Vec2::new(10000.0, 0.0));
    let line = path_builder.build();

    commands.spawn(Camera2dBundle::default());
    commands.spawn(GeometryBuilder::build_as(
        &line,
        DrawMode::Stroke(StrokeMode::new(Color::BLACK, 5.0)),
        Transform::default(),
    ));

    let shape = shapes::Rectangle {
        extents: Vec2::splat(15.0),
        origin: RectangleOrigin::Center,
    };
    let shape_bundle = GeometryBuilder::build_as(
        &shape,
        DrawMode::Outlined {
            fill_mode: FillMode::color(Color::BLUE),
            outline_mode: StrokeMode::new(Color::BLACK, 1.0),
        },
        Transform::from_xyz(0.0, 0.0, 0.0),
    );
    commands.spawn(shape_bundle);
}

This occurred after updating to bevy_prototype_lyon 0.7 and bevy 0.9.