Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New circular primitives: Arc2d, CircularSector, CircularSegment #13482

Merged
merged 23 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8813322
Add `Arc` and `CircularSector` math primitives.
spectria-limina Feb 15, 2024
d766ccb
Add `CircularSegment` primitve as well.
spectria-limina Feb 15, 2024
7b9b17b
Fix doc errors.
spectria-limina Feb 7, 2024
6d92312
Review feedback and other minor improvements.
spectria-limina Feb 15, 2024
045eaac
Change the orientation of arc primitives to vertically symmetrical.
spectria-limina Feb 13, 2024
e628cd5
Fix Circular{Sector,Segment} UV-mapping and add an example.
spectria-limina Feb 14, 2024
fb5011a
Allow the apothem to be negative to simplify much of the math.
spectria-limina Feb 15, 2024
b24a097
Some more small cleanups.
spectria-limina Feb 15, 2024
dea8e26
Update examples page.
spectria-limina Feb 15, 2024
80f55a8
Rename CircularShapeUvMode to CircularMeshUvMode.
spectria-limina Feb 15, 2024
fad57dd
Add tests to primitive math.
spectria-limina Feb 15, 2024
98f0922
Add tests for arc bounding shapes.
spectria-limina Feb 16, 2024
794a611
Add tests to bounding shapes for CircularSector.
spectria-limina Feb 16, 2024
6de1c72
Silence clippy and CI.
spectria-limina Feb 16, 2024
46e186b
Apply suggestions from code review
spectria-limina Mar 9, 2024
b73dd0d
Review changes
spectria-limina Mar 9, 2024
7e10ab9
More review comments
spectria-limina Mar 24, 2024
feda843
Fixups for review & compile fixes
spectria-limina Mar 26, 2024
8750c06
Fix failing build stuff
spectria-limina Mar 26, 2024
a077d52
final fixes after rebasing on main
May 23, 2024
7e280f7
update examples readme
May 23, 2024
90aeaca
fix shapes example
May 23, 2024
20b69ce
minor doc fix
May 23, 2024
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
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,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 @@ -233,7 +233,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 @@ -244,7 +244,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 @@ -255,7 +255,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
Loading