Skip to content

Commit 3f1ef3f

Browse files
author
Torstein Grindvik
committed
Use higher geometry defaults for cone, add Y normal component
Signed-off-by: Torstein Grindvik <[email protected]>
1 parent d3888b6 commit 3f1ef3f

File tree

1 file changed

+9
-4
lines changed
  • crates/bevy_render/src/mesh/shape

1 file changed

+9
-4
lines changed

crates/bevy_render/src/mesh/shape/cone.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::mesh::{Indices, Mesh};
2+
use bevy_math::Vec3;
23
use wgpu::PrimitiveTopology;
34

45
/// A cone which stands on the XZ plane.
@@ -28,10 +29,10 @@ impl Default for Cone {
2829
fn default() -> Self {
2930
Self {
3031
top_radius: 0.0,
31-
bottom_radius: 1.0,
32+
bottom_radius: 0.5,
3233
height: 1.0,
33-
resolution: 16,
34-
segments: 1,
34+
resolution: 64,
35+
segments: 4,
3536
}
3637
}
3738
}
@@ -70,7 +71,11 @@ impl From<Cone> for Mesh {
7071
let (sin, cos) = theta.sin_cos();
7172

7273
positions.push([radius * cos, y, radius * sin]);
73-
normals.push([cos, 0., sin]);
74+
normals.push(
75+
Vec3::new(cos, (c.bottom_radius - c.top_radius) / c.height, sin)
76+
.normalize()
77+
.to_array(),
78+
);
7479
uvs.push([
7580
segment as f32 / c.resolution as f32,
7681
ring as f32 / c.segments as f32,

0 commit comments

Comments
 (0)