From a9fd726a0dabcfa3ecd6066b04768a8be48f24ec Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 22 Mar 2020 00:42:37 +0100 Subject: [PATCH] library: document shape module --- src/shape/mod.rs | 3 +++ src/shape/triangle.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/shape/mod.rs b/src/shape/mod.rs index c8b79cd..7f799f6 100644 --- a/src/shape/mod.rs +++ b/src/shape/mod.rs @@ -1,3 +1,5 @@ +//! Various shape implementations + use super::{Point, Point2D, Vector}; use bvh::{ aabb::{Bounded, AABB}, @@ -8,6 +10,7 @@ use serde::Deserialize; /// All the existing `Shape` implementation. #[serde(tag = "type")] #[serde(rename_all = "lowercase")] +#[allow(missing_docs)] #[enum_dispatch::enum_dispatch] #[derive(Debug, PartialEq, Deserialize)] pub enum ShapeEnum { diff --git a/src/shape/triangle.rs b/src/shape/triangle.rs index a1a8fd5..a78af0e 100644 --- a/src/shape/triangle.rs +++ b/src/shape/triangle.rs @@ -13,6 +13,22 @@ pub struct Triangle { } impl Triangle { + /// Creates a new `Triangle` from 3 [`Point`]s. + /// + /// [`Point`]: ../../type.Point.html + /// + /// # Examples + /// + /// ``` + /// # use pathtracer::shape::Triangle; + /// # use pathtracer::Point; + /// # + /// let t = Triangle::new( + /// Point::new(1.0, 0.0, 0.0), + /// Point::new(0.0, 1.0, 0.0), + /// Point::new(0.0, 0.0, 1.0), + /// ); + /// ``` pub fn new(c0: Point, c1: Point, c2: Point) -> Self { Triangle { c0,