Skip to content

Commit

Permalink
chore: improved docstrings for Hitable
Browse files Browse the repository at this point in the history
  • Loading branch information
Walther committed Jun 9, 2024
1 parent b0f8464 commit c843f97
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions clovers/src/hitable.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! An abstraction for things that can be hit by [Rays](crate::ray::Ray).
#![allow(missing_docs)] // TODO: Lots of undocumented things for now

#[cfg(feature = "stl")]
use crate::objects::STL;
#[cfg(feature = "gl_tf")]
Expand Down Expand Up @@ -51,9 +49,10 @@ impl<'a> HitRecord<'a> {
}
}

/// An abstraction for things that can be hit by [Rays](crate::ray::Ray).
/// Enumeration of all runtime entities that can be intersected aka "hit" by a [Ray].
#[enum_dispatch(HitableTrait)]
#[derive(Debug, Clone)]
#[allow(missing_docs)]
pub enum Hitable<'scene> {
Boxy(Boxy<'scene>),
BVHNode(BVHNode<'scene>),
Expand All @@ -75,6 +74,7 @@ pub enum Hitable<'scene> {

// TODO: remove horrible hack
#[derive(Debug, Clone)]
/// Empty hitable. Cannot be hit. Exists only as an internal workaround.
pub struct Empty {}

impl HitableTrait for Empty {
Expand Down Expand Up @@ -109,8 +109,10 @@ impl HitableTrait for Empty {
}

#[enum_dispatch]
/// The main trait for entities that can be intersect aka "hit" by a [Ray].
pub trait HitableTrait {
#[must_use]
/// The main intersection method.
fn hit(
&self,
ray: &Ray,
Expand All @@ -120,9 +122,11 @@ pub trait HitableTrait {
) -> Option<HitRecord>;

#[must_use]
/// Returns the bounding box of the entity.
fn bounding_box(&self, t0: Float, t1: Float) -> Option<&AABB>;

#[must_use]
/// Probability density function value method, used for multiple importance sampling.
fn pdf_value(
&self,
origin: Position,
Expand All @@ -133,6 +137,7 @@ pub trait HitableTrait {
) -> Float;

#[must_use]
/// Random point on the entity, used for multiple importance sampling.
fn random(&self, origin: Position, rng: &mut SmallRng) -> Position;
}

Expand Down

0 comments on commit c843f97

Please sign in to comment.