Skip to content

Commit

Permalink
New circular primitives: Arc2d, CircularSector, CircularSegment (
Browse files Browse the repository at this point in the history
…#13482)

# Objective

Adopted #11748

## Solution

I've rebased on main to fix the merge conflicts. ~~Not quite ready to
merge yet~~

* Clippy is happy and the tests are passing, but...
* ~~The new shapes in `examples/2d/2d_shapes.rs` don't look right at
all~~ Never mind, looks like radians and degrees just got mixed up at
some point?
* I have updated one doc comment based on a review in the original PR.

---------

Co-authored-by: Alexis "spectria" Horizon <spectria.limina@gmail.com>
Co-authored-by: Alexis "spectria" Horizon <118812919+spectria-limina@users.noreply.github.com>
Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Ben Harper <ben@tukom.org>
  • Loading branch information
6 people committed May 23, 2024
1 parent da1e6e6 commit ec01c2d
Show file tree
Hide file tree
Showing 11 changed files with 1,485 additions and 16 deletions.
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,17 @@ description = "Renders a 2d mesh"
category = "2D Rendering"
wasm = true

[[example]]
name = "mesh2d_arcs"
path = "examples/2d/mesh2d_arcs.rs"
doc-scrape-examples = true

[package.metadata.example.mesh2d_arcs]
name = "Arc 2D Meshes"
description = "Demonstrates UV-mapping of the circular segment and sector primitives"
category = "2D Rendering"
wasm = true

[[example]]
name = "mesh2d_manual"
path = "examples/2d/mesh2d_manual.rs"
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ approx = { version = "0.5", optional = true }
rand = { version = "0.8", features = [
"alloc",
], default-features = false, optional = true }
smallvec = { version = "1.11" }

[dev-dependencies]
approx = "0.5"
Expand All @@ -26,6 +27,8 @@ rand = "0.8"
rand_chacha = "0.3"
# Enable the approx feature when testing.
bevy_math = { path = ".", version = "0.14.0-dev", features = ["approx"] }
glam = { version = "0.27", features = ["approx"] }


[features]
default = ["rand"]
Expand Down
417 changes: 413 additions & 4 deletions crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions crates/bevy_math/src/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl std::ops::Mul<Dir2> for Rotation2d {
}
}

#[cfg(feature = "approx")]
#[cfg(any(feature = "approx", test))]
impl approx::AbsDiffEq for Dir2 {
type Epsilon = f32;
fn default_epsilon() -> f32 {
Expand All @@ -245,7 +245,7 @@ impl approx::AbsDiffEq for Dir2 {
}
}

#[cfg(feature = "approx")]
#[cfg(any(feature = "approx", test))]
impl approx::RelativeEq for Dir2 {
fn default_max_relative() -> f32 {
f32::EPSILON
Expand All @@ -256,7 +256,7 @@ impl approx::RelativeEq for Dir2 {
}
}

#[cfg(feature = "approx")]
#[cfg(any(feature = "approx", test))]
impl approx::UlpsEq for Dir2 {
fn default_max_ulps() -> u32 {
4
Expand Down

0 comments on commit ec01c2d

Please sign in to comment.