pub struct SurfaceMesh {
pub vertices: Vec<SurfaceVertex>,
pub indices: Vec<TriangleIndex>,
pub resolution_u: usize,
pub resolution_v: usize,
pub aabb_min: Vec3,
pub aabb_max: Vec3,
}Expand description
A tessellated mesh of a parametric surface.
Fields§
§vertices: Vec<SurfaceVertex>§indices: Vec<TriangleIndex>§resolution_u: usize§resolution_v: usize§aabb_min: Vec3Axis-aligned bounding box: (min, max).
aabb_max: Vec3Implementations§
Source§impl SurfaceMesh
impl SurfaceMesh
Sourcepub fn tessellate(
surface: &dyn Surface,
resolution_u: usize,
resolution_v: usize,
) -> Self
pub fn tessellate( surface: &dyn Surface, resolution_u: usize, resolution_v: usize, ) -> Self
Tessellate a surface at the given resolution.
resolution_u and resolution_v define the number of subdivisions along
each parameter axis. The resulting mesh has (res_u + 1) * (res_v + 1) vertices
and 2 * res_u * res_v triangles.
Sourcepub fn tessellate_adaptive(
surface: &dyn Surface,
base_resolution_u: usize,
base_resolution_v: usize,
curvature_threshold: f32,
) -> Self
pub fn tessellate_adaptive( surface: &dyn Surface, base_resolution_u: usize, base_resolution_v: usize, curvature_threshold: f32, ) -> Self
Tessellate with adaptive resolution that places more samples where curvature is higher.
Sourcepub fn recompute_smooth_normals(&mut self)
pub fn recompute_smooth_normals(&mut self)
Recompute vertex normals by averaging adjacent face normals.
Sourcepub fn recompute_tangents(&mut self)
pub fn recompute_tangents(&mut self)
Recompute tangent vectors using UV-aligned tangent calculation (MikkTSpace-style).
Sourcepub fn transform(&mut self, scale: f32, offset: Vec3)
pub fn transform(&mut self, scale: f32, offset: Vec3)
Transform all vertices by a 4x4-like operation (scale + translate).
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Total number of triangles in the mesh.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Total number of vertices in the mesh.
Sourcepub fn surface_area(&self) -> f32
pub fn surface_area(&self) -> f32
Compute the surface area of the mesh by summing triangle areas.
Sourcepub fn make_flat_shaded(&mut self)
pub fn make_flat_shaded(&mut self)
Generate flat normals (each face gets its own normal, vertices are duplicated).
Sourcepub fn subdivide(&mut self)
pub fn subdivide(&mut self)
Subdivide each triangle into 4 triangles (Loop-style without smoothing).
Sourcepub fn positions_flat(&self) -> Vec<f32>
pub fn positions_flat(&self) -> Vec<f32>
Extract positions as a flat array of f32 triples (for GPU upload).
Sourcepub fn normals_flat(&self) -> Vec<f32>
pub fn normals_flat(&self) -> Vec<f32>
Extract normals as a flat array of f32 triples.
Sourcepub fn indices_flat(&self) -> Vec<u32>
pub fn indices_flat(&self) -> Vec<u32>
Extract indices as a flat array of u32.
Sourcepub fn wireframe_edges(&self) -> Vec<(u32, u32)>
pub fn wireframe_edges(&self) -> Vec<(u32, u32)>
Generate wireframe edges (deduplicated edge list).
Source§impl SurfaceMesh
impl SurfaceMesh
Trait Implementations§
Source§impl Clone for SurfaceMesh
impl Clone for SurfaceMesh
Source§fn clone(&self) -> SurfaceMesh
fn clone(&self) -> SurfaceMesh
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SurfaceMesh
impl RefUnwindSafe for SurfaceMesh
impl Send for SurfaceMesh
impl Sync for SurfaceMesh
impl Unpin for SurfaceMesh
impl UnsafeUnpin for SurfaceMesh
impl UnwindSafe for SurfaceMesh
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.