From d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Mon, 21 Dec 2020 01:22:15 +0100 Subject: Add previously missing docs where appropriate --- src/map/polygon_room.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/map/polygon_room.rs') diff --git a/src/map/polygon_room.rs b/src/map/polygon_room.rs index 65eeaab..fd4122e 100644 --- a/src/map/polygon_room.rs +++ b/src/map/polygon_room.rs @@ -1,13 +1,18 @@ +//! Polygon rooms are the standard rooms in graf karto. They can take the form of anything that a +//! [Polygon](crate::math::Polygon) can have. + use super::Mappable; use crate::colours::DEFAULT_COLOURS; use crate::math::{self, Polygon, Rect, Triangle}; use crate::transform::Transform; use crate::transformable::NonRigidTransformable; -use raylib::drawing::{RaylibDraw, RaylibDrawHandle}; use nalgebra::{Matrix3, Point2}; +use raylib::drawing::{RaylibDraw, RaylibDrawHandle}; +/// Data type for the Polygon room. pub type PolygonRoomData = Polygon; +/// A polygon room, which can be placed and modified in the world. pub struct PolygonRoom { data: PolygonRoomData, // The polygon shape, but in triangles, so the polygon does not have to be triangulated every frame. @@ -16,6 +21,7 @@ pub struct PolygonRoom { } impl PolygonRoom { + /// Create a room from the given polygon data. pub fn from_data(data: PolygonRoomData) -> Self { Self { data: data.clone(), @@ -24,6 +30,8 @@ impl PolygonRoom { } } + // When the internal polygon changes, it must be retriangulated to be drawn on the screen + // properly, so this function must be called any time that happens. fn retriangulate(&mut self) { self.triangulated = math::triangulate(self.data.clone()); } -- cgit v1.2.3-70-g09d2