Skip to content

Commit

Permalink
Use higher geometry defaults for cone, add Y normal component
Browse files Browse the repository at this point in the history
Signed-off-by: Torstein Grindvik <torstein.grindvik@muybridge.com>
  • Loading branch information
Torstein Grindvik committed Nov 4, 2023
1 parent d3888b6 commit 3f1ef3f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/bevy_render/src/mesh/shape/cone.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::mesh::{Indices, Mesh};
use bevy_math::Vec3;
use wgpu::PrimitiveTopology;

/// A cone which stands on the XZ plane.
Expand Down Expand Up @@ -28,10 +29,10 @@ impl Default for Cone {
fn default() -> Self {
Self {
top_radius: 0.0,
bottom_radius: 1.0,
bottom_radius: 0.5,
height: 1.0,
resolution: 16,
segments: 1,
resolution: 64,
segments: 4,
}
}
}
Expand Down Expand Up @@ -70,7 +71,11 @@ impl From<Cone> for Mesh {
let (sin, cos) = theta.sin_cos();

positions.push([radius * cos, y, radius * sin]);
normals.push([cos, 0., sin]);
normals.push(
Vec3::new(cos, (c.bottom_radius - c.top_radius) / c.height, sin)
.normalize()
.to_array(),
);
uvs.push([
segment as f32 / c.resolution as f32,
ring as f32 / c.segments as f32,
Expand Down

0 comments on commit 3f1ef3f

Please sign in to comment.