aboutsummaryrefslogtreecommitdiff
path: root/src/map/polygon_room.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/polygon_room.rs')
-rw-r--r--src/map/polygon_room.rs10
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());
}