crystal_ball 0.3.0

A path tracing library written in Rust.
Documentation
//! Geometric shapes that can be placed into the scene.

pub use bvh::BVH;
pub use mesh::Mesh;
pub use object::Object;
pub use sphere::Sphere;
pub use triangle::Triangle;
pub use triangle_mesh::TriangleMesh;

use crate::math::{Bounds3, Hit, Ray};

mod bvh;
mod mesh;
mod object;
mod sphere;
mod triangle;
mod triangle_mesh;

/// A general representation of shapes.
///
/// This allows performing ray intersections against them and accessing their bounding volumes.
pub trait Shape: Send + Sync {
    /// Return the corresponding hit, if self and ray intersect.
    /// Otherwise return [`None`].
    fn intersects(&self, ray: Ray) -> Option<Hit>;

    /// Return the shape's bounding volume.
    fn bounds(&self) -> Bounds3;
}