Skip to content

Commit ec01c2d

Browse files
aristaeusspectria-liminaJondolfalice-i-cecileBen Harper
authored
New circular primitives: Arc2d, CircularSector, CircularSegment (#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>
1 parent da1e6e6 commit ec01c2d

File tree

11 files changed

+1485
-16
lines changed

11 files changed

+1485
-16
lines changed

Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,17 @@ description = "Renders a 2d mesh"
423423
category = "2D Rendering"
424424
wasm = true
425425

426+
[[example]]
427+
name = "mesh2d_arcs"
428+
path = "examples/2d/mesh2d_arcs.rs"
429+
doc-scrape-examples = true
430+
431+
[package.metadata.example.mesh2d_arcs]
432+
name = "Arc 2D Meshes"
433+
description = "Demonstrates UV-mapping of the circular segment and sector primitives"
434+
category = "2D Rendering"
435+
wasm = true
436+
426437
[[example]]
427438
name = "mesh2d_manual"
428439
path = "examples/2d/mesh2d_manual.rs"

crates/bevy_math/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ approx = { version = "0.5", optional = true }
1818
rand = { version = "0.8", features = [
1919
"alloc",
2020
], default-features = false, optional = true }
21+
smallvec = { version = "1.11" }
2122

2223
[dev-dependencies]
2324
approx = "0.5"
@@ -26,6 +27,8 @@ rand = "0.8"
2627
rand_chacha = "0.3"
2728
# Enable the approx feature when testing.
2829
bevy_math = { path = ".", version = "0.14.0-dev", features = ["approx"] }
30+
glam = { version = "0.27", features = ["approx"] }
31+
2932

3033
[features]
3134
default = ["rand"]

crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs

+413-4
Large diffs are not rendered by default.

crates/bevy_math/src/direction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl std::ops::Mul<Dir2> for Rotation2d {
234234
}
235235
}
236236

237-
#[cfg(feature = "approx")]
237+
#[cfg(any(feature = "approx", test))]
238238
impl approx::AbsDiffEq for Dir2 {
239239
type Epsilon = f32;
240240
fn default_epsilon() -> f32 {
@@ -245,7 +245,7 @@ impl approx::AbsDiffEq for Dir2 {
245245
}
246246
}
247247

248-
#[cfg(feature = "approx")]
248+
#[cfg(any(feature = "approx", test))]
249249
impl approx::RelativeEq for Dir2 {
250250
fn default_max_relative() -> f32 {
251251
f32::EPSILON
@@ -256,7 +256,7 @@ impl approx::RelativeEq for Dir2 {
256256
}
257257
}
258258

259-
#[cfg(feature = "approx")]
259+
#[cfg(any(feature = "approx", test))]
260260
impl approx::UlpsEq for Dir2 {
261261
fn default_max_ulps() -> u32 {
262262
4

0 commit comments

Comments
 (0)