Skip to content

Commit

Permalink
feat: Add gizmos regression test and fix original bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubba-64 committed Aug 5, 2024
1 parent 805a769 commit 3b45c3d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3002,6 +3002,14 @@ doc-scrape-examples = true
[package.metadata.example.ambiguity_detection]
hidden = true

[[example]]
name = "gizmos_regression"
path = "tests/gizmos/gizmos_sphere_regression.rs"
doc-scrape-examples = true

[package.metadata.example.gizmos_regression]
hidden = true

[[example]]
name = "resizing"
path = "tests/window/resizing.rs"
Expand Down
22 changes: 1 addition & 21 deletions crates/bevy_gizmos/src/circles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ where
gizmos: self,
radius,
position,
rotation,
rotation: rotation.normalize(),
color: color.into(),
resolution: DEFAULT_CIRCLE_RESOLUTION,
}
Expand Down Expand Up @@ -368,23 +368,3 @@ where
});
}
}

#[cfg(test)]
mod tests {
use bevy_app::{App, Update};
use bevy_color::Color;
use bevy_math::{Quat, Vec3};

use crate::{gizmos::Gizmos, GizmoPlugin};

#[test]
fn test_sphere_regression_14142() {
App::new()
.add_plugins(GizmoPlugin)
.add_systems(Update, |mut gizmos: Gizmos| {
let rot = Quat::from_array([5.0, 0.0, 0.0, 0.0]); //.normalize();
gizmos.sphere(Vec3::ZERO, rot, 1.0, Color::srgb(1.0, 0.0, 0.0));
})
.run();
}
}
16 changes: 16 additions & 0 deletions tests/gizmos/gizmos_sphere_regression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! A test to confirm that `bevy` doesn't regress on gizmos
//! This is run in CI.

use bevy::prelude::*;

/// A test to confirm that `bevy` doesn't regress on gizmos
/// #14142 is the latest issue where this occurred
pub fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Update, |mut gizmos: Gizmos| {
let rot = Quat::from_array([5.0, 0.0, 0.0, 0.0]); //.normalize();
gizmos.sphere(Vec3::ZERO, rot, 1.0, Color::srgb(1.0, 0.0, 0.0));
})
.run();
}

0 comments on commit 3b45c3d

Please sign in to comment.