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

[Merged by Bors] - Add RegularPolygon and Circle meshes #3730

Closed
wants to merge 25 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1e2f715
Add RegularPolygon and Circle
rparrett Jan 20, 2022
fb6f09f
Add example to readme
rparrett Jan 20, 2022
2c137d7
Use usize for sides for consistency
rparrett Jan 20, 2022
03c7cc7
Preallocate vecs
rparrett Jan 20, 2022
08e366e
Minor cleanup
rparrett Jan 20, 2022
63fa48c
Generate mesh with fewer triangles
rparrett Jan 20, 2022
c6e7923
Add missing doc string
rparrett Feb 4, 2022
10b3f0f
Consolidate examples
rparrett Feb 4, 2022
630d9c5
Use new mesh attribute api
rparrett Feb 24, 2022
8dc3c72
Use new default shorthand
rparrett Mar 1, 2022
216b769
Update crates/bevy_render/src/mesh/shape/regular_polygon.rs
rparrett Mar 2, 2022
9cc7852
Update crates/bevy_render/src/mesh/shape/regular_polygon.rs
rparrett Mar 2, 2022
ea920b8
Update crates/bevy_render/src/mesh/shape/regular_polygon.rs
rparrett Mar 2, 2022
62ed3d4
Update crates/bevy_render/src/mesh/shape/regular_polygon.rs
rparrett Mar 2, 2022
f9d62b7
Optimize by calculating sin and cos simultaneously
rparrett Mar 2, 2022
4b68753
Add constructors for RegularPolygon and Circle
rparrett Mar 2, 2022
689c074
Fix unnecessary return
rparrett Mar 2, 2022
994c252
Remove accidental newline
rparrett Mar 2, 2022
880d4a2
Fix doc comment
rparrett Mar 3, 2022
d774e70
Vertices terminology seems more correct than subdivisions
rparrett Mar 4, 2022
40b925e
Fix extra garbage triangle
rparrett Mar 4, 2022
b02089e
Minor optimization
rparrett Mar 7, 2022
1e1ba1f
Friendlier panic when sides <= 2
rparrett Mar 7, 2022
0a76d2a
Slightly less ambiguous variable names
rparrett Mar 7, 2022
e0b04a6
Fix larger allocation for indices than necessary
rparrett Mar 7, 2022
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
Prev Previous commit
Next Next commit
Minor optimization
  • Loading branch information
rparrett committed Mar 7, 2022
commit b02089eb6d5d06afaf3554bcc9a2ecf0d6ef6185
3 changes: 2 additions & 1 deletion crates/bevy_render/src/mesh/shape/regular_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ impl From<RegularPolygon> for Mesh {
let mut normals = Vec::with_capacity(sides);
let mut uvs = Vec::with_capacity(sides);

let step = std::f32::consts::TAU / sides as f32;
for i in 0..sides {
let a = std::f32::consts::FRAC_PI_2 - i as f32 * std::f32::consts::TAU / (sides as f32);
let a = std::f32::consts::FRAC_PI_2 - i as f32 * step;

let (s, c) = a.sin_cos();
positions.push([c * radius, s * radius, 0.0]);
Expand Down