diff options
| author | Arne Dußin | 2020-12-21 01:22:15 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-12-21 21:15:55 +0100 |
| commit | d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 (patch) | |
| tree | e5633f4d3b18472922c943d759e9f58722ba4405 /src/map/polygon_room.rs | |
| parent | 48f321a80970ebeb8374072b1d2e0a4d297aa348 (diff) | |
| download | graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.tar.gz graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.zip | |
Add previously missing docs where appropriate
Diffstat (limited to 'src/map/polygon_room.rs')
| -rw-r--r-- | src/map/polygon_room.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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<f64>; +/// 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()); } |
