Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ jobs:
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo clippy
run: cargo clippy --locked --all-targets
run: cargo clippy --locked --all-targets --features avian2d/test,avian3d/test
3 changes: 3 additions & 0 deletions crates/avian2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ diagnostic_ui = ["bevy_diagnostic", "bevy/bevy_ui"]
# Enables additional correctness checks and validation at the cost of worse performance.
validate = []

# Exposes internal testing utilities. Only intended for use by benchmarks.
test = []

[lib]
name = "avian2d"
path = "../../src/lib.rs"
Expand Down
3 changes: 3 additions & 0 deletions crates/avian3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ diagnostic_ui = ["bevy_diagnostic", "bevy/bevy_ui"]
# Enables additional correctness checks and validation at the cost of worse performance.
validate = []

# Exposes internal testing utilities. Only intended for use by benchmarks.
test = []

[lib]
name = "avian3d"
path = "../../src/lib.rs"
Expand Down
9 changes: 3 additions & 6 deletions crates/avian3d/benches/velocity_projection.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use bevy_math::{Dir3, Vec3};
use bevy_math::Dir3;
use core::hint::black_box;
use criterion::{BenchmarkId, Criterion, PlotConfiguration, criterion_group, criterion_main};

use avian3d::{
character_controller::move_and_slide::{
project_velocity, project_velocity_bruteforce, test::QuasiRandomDirection,
},
math::PI,
use avian3d::character_controller::move_and_slide::{
project_velocity, project_velocity_bruteforce, test::QuasiRandomDirection,
};

fn bench_velocity_projection(c: &mut Criterion) {
Expand Down
3 changes: 2 additions & 1 deletion src/character_controller/velocity_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,15 @@ impl SimplicialCone {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "test"))]
pub mod test {
//! Tests for velocity projection, notably the [`QuasiRandomDirection`] type used
//! in testing and benchmarking functions on uniformly distributed input directions.
//!
//! This is used because the velocity projection edge cases may show up for relatively small
//! subsets of input directions, both in terms of correctness and performance.

#[cfg(test)]
use super::DOT_EPSILON;
use crate::prelude::*;
use core::f32::consts::PI;
Expand Down
Loading