From bb4f0a1ac81da867dbe57bfaea364b69fb02d68a Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 13 Nov 2009 22:05:59 +0100 Subject: Add translating constructor to circle_def. --- crawl-ref/source/coord-circle.cc | 13 +++++++++++++ crawl-ref/source/coord-circle.h | 3 +++ 2 files changed, 16 insertions(+) (limited to 'crawl-ref') diff --git a/crawl-ref/source/coord-circle.cc b/crawl-ref/source/coord-circle.cc index a4d98ad505..d43f41cfd1 100644 --- a/crawl-ref/source/coord-circle.cc +++ b/crawl-ref/source/coord-circle.cc @@ -33,6 +33,14 @@ circle_def::circle_def() init(LOS_MAX_RADIUS, C_ROUND); } +circle_def::circle_def(const coord_def& origin_, const circle_def& bds) + : los_radius(bds.los_radius), shape(bds.shape), + origin(origin_), radius(bds.radius), radius_sq(bds.radius_sq) +{ + // Set up bounding box. + init_bbox(); +} + circle_def::circle_def(int param, circle_type ctype) : los_radius(false), origin(coord_def(0,0)) { @@ -69,6 +77,11 @@ void circle_def::init(int param, circle_type ctype) radius = param; radius_sq = radius * radius; } + init_bbox(); +} + +void circle_def::init_bbox() +{ bbox = rect_def(origin - coord_def(radius, radius), origin + coord_def(radius, radius)); if (!origin.origin()) diff --git a/crawl-ref/source/coord-circle.h b/crawl-ref/source/coord-circle.h index 9a8dc088d2..c9fc3f7263 100644 --- a/crawl-ref/source/coord-circle.h +++ b/crawl-ref/source/coord-circle.h @@ -48,6 +48,8 @@ class circle_def public: // Circle around (0,0) with radius that tracks global LOS radius. circle_def(); + // Circle around origin with shape of given circle. + circle_def(const coord_def &origin_, const circle_def &bds); // Circle around (0,0) of specified shape and size. explicit circle_def(int param, circle_type ctype = C_SQUARE); // Circle around given origin of specified shape and size. @@ -61,6 +63,7 @@ public: private: void init(int param, circle_type ctype); + void init_bbox(); }; #endif -- cgit v1.2.3-54-g00ecf