From 1aa0de39a5f87bda1e74d0992848ad5142a850bc Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 5 May 2005 13:28:54 +0000 Subject: [PATCH] =?utf8?q?renamed=20Rectangle=20to=20Rect=20because=20of?= =?utf8?q?=20=C2=A7%$?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit SVN-Revision: 2405 --- src/collision.cpp | 10 +++++----- src/collision.h | 8 ++++---- src/collision_grid.cpp | 14 +++++++------- src/collision_grid.h | 2 +- src/collision_grid_iterator.h | 4 ++-- src/math/aatriangle.h | 6 +++--- src/math/{rectangle.h => rect.h} | 14 +++++++------- src/moving_object.h | 6 +++--- src/object/particlesystem.h | 2 +- src/sector.cpp | 16 ++++++++-------- src/sector.h | 6 +++--- src/tile.cpp | 4 ++-- src/tile.h | 6 +++--- src/trigger/secretarea_trigger.cpp | 2 +- src/trigger/secretarea_trigger.h | 2 +- src/trigger/trigger_base.h | 2 +- 16 files changed, 52 insertions(+), 52 deletions(-) rename src/math/{rectangle.h => rect.h} (86%) diff --git a/src/collision.cpp b/src/collision.cpp index aa0631a04..cce522d5d 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -28,14 +28,14 @@ #include #include "math/vector.h" #include "math/aatriangle.h" -#include "math/rectangle.h" +#include "math/rect.h" #include "collision_hit.h" static const float DELTA = .0001; bool -Collision::rectangle_rectangle(CollisionHit& hit, const Rectangle& r1, - const Vector& movement, const Rectangle& r2) +Collision::rectangle_rectangle(CollisionHit& hit, const Rect& r1, + const Vector& movement, const Rect& r2) { if(r1.p2.x < r2.p1.x || r1.p1.x > r2.p2.x) return false; @@ -98,10 +98,10 @@ static void makePlane(const Vector& p1, const Vector& p2, Vector& n, float& c) } bool -Collision::rectangle_aatriangle(CollisionHit& hit, const Rectangle& rect, +Collision::rectangle_aatriangle(CollisionHit& hit, const Rect& rect, const Vector& movement, const AATriangle& triangle) { - if(!rectangle_rectangle(hit, rect, movement, (const Rectangle&) triangle)) + if(!rectangle_rectangle(hit, rect, movement, (const Rect&) triangle)) return false; Vector normal; diff --git a/src/collision.h b/src/collision.h index 2c65c488f..d4f58825a 100644 --- a/src/collision.h +++ b/src/collision.h @@ -22,7 +22,7 @@ #define __COLLISION_H__ class Vector; -class Rectangle; +class Rect; class AATriangle; class CollisionHit; @@ -32,13 +32,13 @@ public: /** does collision detection between 2 rectangles. Returns true in case of * collision and fills in the hit structure then. */ - static bool rectangle_rectangle(CollisionHit& hit, const Rectangle& r1, - const Vector& movement, const Rectangle& r2); + static bool rectangle_rectangle(CollisionHit& hit, const Rect& r1, + const Vector& movement, const Rect& r2); /** does collision detection between a rectangle and an axis aligned triangle * Returns true in case of a collision and fills in the hit structure then. */ - static bool rectangle_aatriangle(CollisionHit& hit, const Rectangle& rect, + static bool rectangle_aatriangle(CollisionHit& hit, const Rect& rect, const Vector& movement, const AATriangle& triangle); }; diff --git a/src/collision_grid.cpp b/src/collision_grid.cpp index 660ea8784..6ed8e4cc3 100644 --- a/src/collision_grid.cpp +++ b/src/collision_grid.cpp @@ -69,7 +69,7 @@ CollisionGrid::add_object(MovingObject* object) objects.push_back(wrapper); wrapper->id = objects.size()-1; - const Rectangle& bbox = object->bbox; + const Rect& bbox = object->bbox; for(float y = bbox.p1.y; y < bbox.p2.y; y += cell_height) { for(float x = bbox.p1.x; x < bbox.p2.x; x += cell_width) { int gridx = int(x / cell_width); @@ -107,7 +107,7 @@ CollisionGrid::remove_object(MovingObject* object) } #endif - const Rectangle& bbox = wrapper->dest; + const Rect& bbox = wrapper->dest; for(float y = bbox.p1.y; y < bbox.p2.y; y += cell_height) { for(float x = bbox.p1.x; x < bbox.p2.x; x += cell_width) { int gridx = int(x / cell_width); @@ -129,7 +129,7 @@ CollisionGrid::move_object(ObjectWrapper* wrapper) { // FIXME not optimal yet... should leave the gridcells untouched that don't // need to be changed. - const Rectangle& obbox = wrapper->dest; + const Rect& obbox = wrapper->dest; for(float y = obbox.p1.y; y < obbox.p2.y; y += cell_height) { for(float x = obbox.p1.x; x < obbox.p2.x; x += cell_width) { int gridx = int(x / cell_width); @@ -143,7 +143,7 @@ CollisionGrid::move_object(ObjectWrapper* wrapper) } } - const Rectangle& nbbox = wrapper->object->bbox; + const Rect& nbbox = wrapper->object->bbox; for(float y = nbbox.p1.y; y < nbbox.p2.y; y += cell_height) { for(float x = nbbox.p1.x; x < nbbox.p2.x; x += cell_width) { int gridx = int(x / cell_width); @@ -204,7 +204,7 @@ CollisionGrid::collide_object(ObjectWrapper* wrapper) { iterator_timestamp++; - const Rectangle& bbox = wrapper->object->bbox; + const Rect& bbox = wrapper->object->bbox; for(float y = bbox.p1.y - cell_height; y < bbox.p2.y + cell_height; y += cell_height) { for(float x = bbox.p1.x - cell_width; x < bbox.p2.x + cell_width; x += cell_width) { int gridx = int(x / cell_width); @@ -240,9 +240,9 @@ CollisionGrid::collide_object_object(ObjectWrapper* wrapper, MovingObject* object1 = wrapper->object; MovingObject* object2 = wrapper2->object; - Rectangle dest1 = object1->get_bbox(); + Rect dest1 = object1->get_bbox(); dest1.move(object1->get_movement()); - Rectangle dest2 = object2->get_bbox(); + Rect dest2 = object2->get_bbox(); dest2.move(object2->get_movement()); Vector movement = object1->get_movement() - object2->get_movement(); diff --git a/src/collision_grid.h b/src/collision_grid.h index d206c8c1d..abb2ef168 100644 --- a/src/collision_grid.h +++ b/src/collision_grid.h @@ -46,7 +46,7 @@ private: struct ObjectWrapper { MovingObject* object; - Rectangle dest; + Rect dest; /** (pseudo) timestamp. When reading from the grid the timestamp is * changed so that you can easily avoid reading an object multiple times * when it is in several cells that you check. diff --git a/src/collision_grid_iterator.h b/src/collision_grid_iterator.h index fd3350beb..3d5666161 100644 --- a/src/collision_grid_iterator.h +++ b/src/collision_grid_iterator.h @@ -20,14 +20,14 @@ #ifndef __COLLISION_GRID_ITERATOR_H__ #define __COLLISION_GRID_ITERATOR_H__ -#include "math/rectangle.h" +#include "math/rect.h" class CollisionGrid; class CollisionGridIterator { public: - CollisionGridIterator(CollisionGrid& newgrid, const Rectangle& bbox) + CollisionGridIterator(CollisionGrid& newgrid, const Rect& bbox) : grid(newgrid) { start_x = int(bbox.p1.x / grid.cell_width) - 2; diff --git a/src/math/aatriangle.h b/src/math/aatriangle.h index 4a2d81ac2..5f8537cd9 100644 --- a/src/math/aatriangle.h +++ b/src/math/aatriangle.h @@ -1,13 +1,13 @@ #ifndef __AATRIANGLE_H__ #define __AATRIANGLE_H__ -#include "rectangle.h" +#include "rect.h" /** * An axis aligned triangle (ie. a triangle where 2 sides are parallel to the x- * and y-axis. */ -class AATriangle : public Rectangle +class AATriangle : public Rect { public: /** Directions: @@ -38,7 +38,7 @@ public: { } AATriangle(const Vector& v1, const Vector& v2, int newdir) - : Rectangle(v1, v2), dir(newdir) + : Rect(v1, v2), dir(newdir) { } diff --git a/src/math/rectangle.h b/src/math/rect.h similarity index 86% rename from src/math/rectangle.h rename to src/math/rect.h index f6be7a5e4..a338054c9 100644 --- a/src/math/rectangle.h +++ b/src/math/rect.h @@ -1,5 +1,5 @@ -#ifndef __RECTANGLE_H__ -#define __RECTANGLE_H__ +#ifndef __RECT_H__ +#define __RECT_H__ #include #include "vector.h" @@ -9,18 +9,18 @@ * upper left and width/height here, because that makes the collision dectection * a little bit efficienter. */ -class Rectangle +class Rect { public: - Rectangle() + Rect() { } - Rectangle(const Vector& np1, const Vector& np2) + Rect(const Vector& np1, const Vector& np2) : p1(np1), p2(np2) { } - Rectangle(float x1, float y1, float x2, float y2) + Rect(float x1, float y1, float x2, float y2) : p1(x1, y1), p2(x2, y2) { assert(p1.x <= p2.x && p1.y <= p2.y); @@ -64,7 +64,7 @@ public: { return v.x >= p1.x && v.y >= p1.y && v.x < p2.x && v.y < p2.y; } - bool inside(const Rectangle& other) const + bool inside(const Rect& other) const { if(p1.x >= other.p2.x || other.p1.x >= p2.x) return false; diff --git a/src/moving_object.h b/src/moving_object.h index cd6850ca6..973595304 100644 --- a/src/moving_object.h +++ b/src/moving_object.h @@ -22,7 +22,7 @@ #include "game_object.h" #include "collision_hit.h" #include "math/vector.h" -#include "math/rectangle.h" +#include "math/rect.h" class Sector; class CollisionGrid; @@ -48,7 +48,7 @@ public: } /** returns the bounding box of the Object */ - const Rectangle& get_bbox() const + const Rect& get_bbox() const { return bbox; } @@ -74,7 +74,7 @@ protected: /** The bounding box of the object (as used for collision detection, this * isn't necessarily the bounding box for graphics) */ - Rectangle bbox; + Rect bbox; /** The movement that will happen till next frame */ Vector movement; diff --git a/src/object/particlesystem.h b/src/object/particlesystem.h index 526fbdd55..23d9e293c 100644 --- a/src/object/particlesystem.h +++ b/src/object/particlesystem.h @@ -37,7 +37,7 @@ class DisplayManager; * layer where it should be drawn and a texture. * The coordinate system used here is a virtual one. It would be a bad idea to * populate whole levels with particles. So we're using a virtual rectangle - * here that is tiled onto the level when drawing. This rectangle has the size + * here that is tiled onto the level when drawing. This rect.has the size * (virtual_width, virtual_height). We're using modulo on the particle * coordinates, so when a particle leaves left, it'll reenter at the right * side. diff --git a/src/sector.cpp b/src/sector.cpp index 1470654e2..b7884fdee 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -46,7 +46,7 @@ #include "collision_grid_iterator.h" #include "object_factory.h" #include "collision.h" -#include "math/rectangle.h" +#include "math/rect.h" #include "math/aatriangle.h" #include "object/coin.h" #include "object/block.h" @@ -422,10 +422,10 @@ Sector::activate(const Vector& player_pos) camera->reset(player->get_pos()); } -Rectangle +Rect Sector::get_active_region() { - return Rectangle( + return Rect( camera->get_translation() - Vector(1600, 1200), camera->get_translation() + Vector(1600, 1200)); } @@ -590,7 +590,7 @@ Sector::collision_tilemap(MovingObject* object, int depth) int max_y = int(y2+1); CollisionHit temphit, hit; - Rectangle dest = object->get_bbox(); + Rect dest = object->get_bbox(); dest.move(object->movement); hit.time = -1; // represents an invalid value for(int x = starttilex; x*32 < max_x; ++x) { @@ -615,7 +615,7 @@ Sector::collision_tilemap(MovingObject* object, int depth) hit = temphit; } } else { // normal rectangular tile - Rectangle rect(x*32, y*32, (x+1)*32, (y+1)*32); + Rect rect(x*32, y*32, (x+1)*32, (y+1)*32); if(Collision::rectangle_rectangle(temphit, dest, object->movement, rect)) { if(temphit.time > hit.time) @@ -647,9 +647,9 @@ void Sector::collision_object(MovingObject* object1, MovingObject* object2) { CollisionHit hit; - Rectangle dest1 = object1->get_bbox(); + Rect dest1 = object1->get_bbox(); dest1.move(object1->get_movement()); - Rectangle dest2 = object2->get_bbox(); + Rect dest2 = object2->get_bbox(); dest2.move(object2->get_movement()); Vector movement = object1->get_movement() - object2->get_movement(); @@ -803,7 +803,7 @@ Sector::get_total_badguys() } bool -Sector::inside(const Rectangle& rect) const +Sector::inside(const Rect& rect) const { if(rect.p1.x > solids->get_width() * 32 || rect.p1.y > solids->get_height() * 32 diff --git a/src/sector.h b/src/sector.h index 2067e0916..c2a8f3c47 100644 --- a/src/sector.h +++ b/src/sector.h @@ -32,7 +32,7 @@ class Lisp; class Writer; } -class Rectangle; +class Rect; class Sprite; class GameObject; class Player; @@ -86,7 +86,7 @@ public: { return name; } /// tests if a given rectangle is inside the sector - bool inside(const Rectangle& rectangle) const; + bool inside(const Rect& rectangle) const; void play_music(MusicType musictype); MusicType get_music_type(); @@ -140,7 +140,7 @@ public: // TODO make this private again typedef std::vector SpawnPoints; SpawnPoints spawnpoints; - Rectangle get_active_region(); + Rect get_active_region(); private: void fix_old_tiles(); diff --git a/src/tile.cpp b/src/tile.cpp index 20835fbd9..7fef75255 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -105,7 +105,7 @@ Tile::parse_images(const lisp::Lisp& images_lisp) if(cur->get_type() == lisp::Lisp::TYPE_STRING) { std::string file; cur->get(file); - imagespecs.push_back(ImageSpec(file, Rectangle(0, 0, 0, 0))); + imagespecs.push_back(ImageSpec(file, Rect(0, 0, 0, 0))); } else if(cur->get_type() == lisp::Lisp::TYPE_CONS && cur->get_car()->get_type() == lisp::Lisp::TYPE_SYMBOL) { const lisp::Lisp* ptr = cur->get_cdr(); @@ -117,7 +117,7 @@ Tile::parse_images(const lisp::Lisp& images_lisp) ptr->get_car()->get(y); ptr = ptr->get_cdr(); ptr->get_car()->get(w); ptr = ptr->get_cdr(); ptr->get_car()->get(h); - imagespecs.push_back(ImageSpec(file, Rectangle(x, y, x+w, y+h))); + imagespecs.push_back(ImageSpec(file, Rect(x, y, x+w, y+h))); } else { std::cerr << "Expected string or list in images tag.\n"; continue; diff --git a/src/tile.h b/src/tile.h index a9ea335a7..cfddd0217 100644 --- a/src/tile.h +++ b/src/tile.h @@ -22,7 +22,7 @@ #include #include "video/surface.h" -#include "math/rectangle.h" +#include "math/rect.h" #include "lisp/lisp.h" /** @@ -72,12 +72,12 @@ private: unsigned int id; struct ImageSpec { - ImageSpec(const std::string& newfile, const Rectangle& newrect) + ImageSpec(const std::string& newfile, const Rect& newrect) : file(newfile), rect(newrect) { } std::string file; - Rectangle rect; + Rect rect; }; std::vector imagespecs; std::vector images; diff --git a/src/trigger/secretarea_trigger.cpp b/src/trigger/secretarea_trigger.cpp index 72c88f867..3b59368d4 100644 --- a/src/trigger/secretarea_trigger.cpp +++ b/src/trigger/secretarea_trigger.cpp @@ -42,7 +42,7 @@ SecretAreaTrigger::SecretAreaTrigger(const lisp::Lisp& reader) message_displayed = false; } -SecretAreaTrigger::SecretAreaTrigger(const Rectangle& area) +SecretAreaTrigger::SecretAreaTrigger(const Rect& area) { bbox = area; message = "You found a secret area!"; diff --git a/src/trigger/secretarea_trigger.h b/src/trigger/secretarea_trigger.h index bbc3641af..0dba229d9 100644 --- a/src/trigger/secretarea_trigger.h +++ b/src/trigger/secretarea_trigger.h @@ -30,7 +30,7 @@ class SecretAreaTrigger : public TriggerBase, public Serializable { public: SecretAreaTrigger(const lisp::Lisp& reader); - SecretAreaTrigger(const Rectangle& area); + SecretAreaTrigger(const Rect& area); ~SecretAreaTrigger(); void write(lisp::Writer& writer); diff --git a/src/trigger/trigger_base.h b/src/trigger/trigger_base.h index 3f8fdc476..9038a55ee 100644 --- a/src/trigger/trigger_base.h +++ b/src/trigger/trigger_base.h @@ -20,7 +20,7 @@ #define SUPERTUX_TRIGGER_BASE_H #include "moving_object.h" -#include "math/rectangle.h" +#include "math/rect.h" #include "sprite/sprite.h" class Player; -- 2.11.0