From ff08b8e1983016221967a024dab76799a3d75059 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Sun, 6 Dec 2009 05:26:23 +0000 Subject: [PATCH] Renamed Rect to Rectf SVN-Revision: 6180 --- src/badguy/badguy.cpp | 2 +- src/badguy/captainsnowball.cpp | 3 ++- src/badguy/igel.cpp | 4 ++-- src/badguy/mrtree.cpp | 8 ++++---- src/badguy/plant.cpp | 4 ++-- src/badguy/sspiky.cpp | 4 ++-- src/gui/menu.cpp | 22 ++++++++++----------- src/math/{rect.hpp => rectf.hpp} | 14 +++++++------- src/object/anchor_point.cpp | 6 +++--- src/object/anchor_point.hpp | 6 +++--- src/object/floating_image.cpp | 2 +- src/object/icecrusher.cpp | 4 ++-- src/object/infoblock.cpp | 2 +- src/object/ispy.cpp | 2 +- src/object/ispy.hpp | 2 +- src/object/moving_sprite.cpp | 2 +- src/object/particlesystem_interactive.cpp | 4 ++-- src/object/player.cpp | 6 +++--- src/object/text_object.cpp | 2 +- src/sprite/sprite.cpp | 4 ++-- src/sprite/sprite.hpp | 2 +- src/supertux/collision.cpp | 12 ++++++------ src/supertux/collision.hpp | 8 ++++---- src/supertux/info_box.cpp | 2 +- src/supertux/info_box_line.cpp | 2 +- src/supertux/info_box_line.hpp | 4 ++-- src/supertux/moving_object.hpp | 8 ++++---- src/supertux/sector.cpp | 32 +++++++++++++++---------------- src/supertux/sector.hpp | 18 ++++++++--------- src/supertux/textscroller.cpp | 2 +- src/supertux/tile.hpp | 6 +++--- src/supertux/tile_set_parser.cpp | 6 +++--- src/supertux/title_screen.cpp | 2 +- src/trigger/climbable.cpp | 2 +- src/trigger/climbable.hpp | 2 +- src/trigger/secretarea_trigger.cpp | 2 +- src/trigger/secretarea_trigger.hpp | 2 +- src/util/log.cpp | 4 ++-- src/util/log.hpp | 4 ++-- src/video/drawing_context.cpp | 4 ++-- src/video/drawing_context.hpp | 6 +++--- src/video/font.cpp | 6 +++--- src/video/font.hpp | 4 ++-- src/video/gl/gl_renderer.cpp | 2 +- src/video/lightmap.hpp | 2 +- src/video/renderer.hpp | 2 +- 46 files changed, 125 insertions(+), 124 deletions(-) rename src/math/{rect.hpp => rectf.hpp} (91%) diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index e14e81c47..09fba678f 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -484,7 +484,7 @@ BadGuy::might_fall(int height) x1 = bbox.p2.x + 1; x2 = bbox.p2.x + 1; } - return Sector::current()->is_free_of_statics(Rect(x1, y1, x2, y2)); + return Sector::current()->is_free_of_statics(Rectf(x1, y1, x2, y2)); } Player* diff --git a/src/badguy/captainsnowball.cpp b/src/badguy/captainsnowball.cpp index 34b287af2..d4826413e 100644 --- a/src/badguy/captainsnowball.cpp +++ b/src/badguy/captainsnowball.cpp @@ -61,7 +61,8 @@ CaptainSnowball::might_climb(int width, int height) x1 = bbox.p2.x + 1; x2 = bbox.p2.x + width; } - return ((!Sector::current()->is_free_of_statics(Rect(x1, y1a, x2, y2a))) && (Sector::current()->is_free_of_statics(Rect(x1, y1b, x2, y2b)))); + return ((!Sector::current()->is_free_of_statics(Rectf(x1, y1a, x2, y2a))) && + (Sector::current()->is_free_of_statics(Rectf(x1, y1b, x2, y2b)))); } void diff --git a/src/badguy/igel.cpp b/src/badguy/igel.cpp index 41c3543d5..2eaa0abff 100644 --- a/src/badguy/igel.cpp +++ b/src/badguy/igel.cpp @@ -60,8 +60,8 @@ Igel::turn_around() bool Igel::can_see(const MovingObject& o) { - Rect mb = get_bbox(); - Rect ob = o.get_bbox(); + Rectf mb = get_bbox(); + Rectf ob = o.get_bbox(); bool inReach_left = ((ob.p2.x < mb.p1.x) && (ob.p2.x >= mb.p1.x-((dir == LEFT) ? RANGE_OF_VISION : 0))); bool inReach_right = ((ob.p1.x > mb.p2.x) && (ob.p1.x <= mb.p2.x+((dir == RIGHT) ? RANGE_OF_VISION : 0))); diff --git a/src/badguy/mrtree.cpp b/src/badguy/mrtree.cpp index 9a04e6c31..65f81aa1e 100644 --- a/src/badguy/mrtree.cpp +++ b/src/badguy/mrtree.cpp @@ -71,8 +71,8 @@ MrTree::collision_squished(GameObject& object) } // spawn PoisonIvy - Vector leaf1_pos = Vector(stumpy_pos.x - POISONIVY_WIDTH - 1, stumpy_pos.y - POISONIVY_Y_OFFSET); - Rect leaf1_bbox = Rect(leaf1_pos.x, leaf1_pos.y, leaf1_pos.x + POISONIVY_WIDTH, leaf1_pos.y + POISONIVY_HEIGHT); + Vector leaf1_pos(stumpy_pos.x - POISONIVY_WIDTH - 1, stumpy_pos.y - POISONIVY_Y_OFFSET); + Rectf leaf1_bbox(leaf1_pos.x, leaf1_pos.y, leaf1_pos.x + POISONIVY_WIDTH, leaf1_pos.y + POISONIVY_HEIGHT); if (Sector::current()->is_free_of_movingstatics(leaf1_bbox, this)) { PoisonIvy* leaf1 = new PoisonIvy(leaf1_bbox.p1, LEFT); leaf1 = leaf1; @@ -81,8 +81,8 @@ MrTree::collision_squished(GameObject& object) } // spawn PoisonIvy - Vector leaf2_pos = Vector(stumpy_pos.x + sprite->get_current_hitbox_width() + 1, stumpy_pos.y - POISONIVY_Y_OFFSET); - Rect leaf2_bbox = Rect(leaf2_pos.x, leaf2_pos.y, leaf2_pos.x + POISONIVY_WIDTH, leaf2_pos.y + POISONIVY_HEIGHT); + Vector leaf2_pos(stumpy_pos.x + sprite->get_current_hitbox_width() + 1, stumpy_pos.y - POISONIVY_Y_OFFSET); + Rectf leaf2_bbox(leaf2_pos.x, leaf2_pos.y, leaf2_pos.x + POISONIVY_WIDTH, leaf2_pos.y + POISONIVY_HEIGHT); if (Sector::current()->is_free_of_movingstatics(leaf2_bbox, this)) { PoisonIvy* leaf2 = new PoisonIvy(leaf2_bbox.p1, RIGHT); leaf2 = leaf2; diff --git a/src/badguy/plant.cpp b/src/badguy/plant.cpp index a2276d3e7..9b98f63e1 100644 --- a/src/badguy/plant.cpp +++ b/src/badguy/plant.cpp @@ -76,8 +76,8 @@ Plant::active_update(float elapsed_time) { Player* player = this->get_nearest_player(); if (player) { - Rect mb = this->get_bbox(); - Rect pb = player->get_bbox(); + Rectf mb = this->get_bbox(); + Rectf pb = player->get_bbox(); bool inReach_left = (pb.p2.x >= mb.p2.x-((dir == LEFT) ? 256 : 0)); bool inReach_right = (pb.p1.x <= mb.p1.x+((dir == RIGHT) ? 256 : 0)); diff --git a/src/badguy/sspiky.cpp b/src/badguy/sspiky.cpp index 7f0fde9fd..8bef20056 100644 --- a/src/badguy/sspiky.cpp +++ b/src/badguy/sspiky.cpp @@ -68,8 +68,8 @@ SSpiky::active_update(float elapsed_time) { Player* player = this->get_nearest_player(); if (player) { - Rect mb = this->get_bbox(); - Rect pb = player->get_bbox(); + Rectf mb = this->get_bbox(); + Rectf pb = player->get_bbox(); bool inReach_left = (pb.p2.x >= mb.p2.x-((dir == LEFT) ? 256 : 0)); bool inReach_right = (pb.p1.x <= mb.p1.x+((dir == RIGHT) ? 256 : 0)); diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index f80569d22..2e1c17d5d 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -476,13 +476,13 @@ Menu::draw_item(DrawingContext& context, int index) if(active_item == index) { float blink = (sinf(real_time * M_PI * 1.0f)/2.0f + 0.5f) * 0.5f + 0.25f; - context.draw_filled_rect(Rect(Vector(pos_x - menu_width/2 + 10 - 2, y_pos - 12 - 2), - Vector(pos_x + menu_width/2 - 10 + 2, y_pos + 12 + 2)), + context.draw_filled_rect(Rectf(Vector(pos_x - menu_width/2 + 10 - 2, y_pos - 12 - 2), + Vector(pos_x + menu_width/2 - 10 + 2, y_pos + 12 + 2)), Color(1.0f, 1.0f, 1.0f, blink), 14.0f, LAYER_GUI-10); - context.draw_filled_rect(Rect(Vector(pos_x - menu_width/2 + 10, y_pos - 12), - Vector(pos_x + menu_width/2 - 10, y_pos + 12)), + context.draw_filled_rect(Rectf(Vector(pos_x - menu_width/2 + 10, y_pos - 12), + Vector(pos_x + menu_width/2 - 10, y_pos + 12)), Color(1.0f, 1.0f, 1.0f, 0.5f), 12.0f, LAYER_GUI-10); @@ -669,14 +669,14 @@ Menu::draw(DrawingContext& context) } /* Draw a transparent background */ - context.draw_filled_rect(Rect(Vector(pos_x - menu_width/2-4, pos_y - menu_height/2 - 10-4), - Vector(pos_x + menu_width/2+4, pos_y - menu_height/2 + 10 + menu_height+4)), + context.draw_filled_rect(Rectf(Vector(pos_x - menu_width/2-4, pos_y - menu_height/2 - 10-4), + Vector(pos_x + menu_width/2+4, pos_y - menu_height/2 + 10 + menu_height+4)), Color(0.2f, 0.3f, 0.4f, 0.8f), 20.0f, LAYER_GUI-10); - context.draw_filled_rect(Rect(Vector(pos_x - menu_width/2, pos_y - menu_height/2 - 10), - Vector(pos_x + menu_width/2, pos_y - menu_height/2 + 10 + menu_height)), + context.draw_filled_rect(Rectf(Vector(pos_x - menu_width/2, pos_y - menu_height/2 - 10), + Vector(pos_x + menu_width/2, pos_y - menu_height/2 + 10 + menu_height)), Color(0.6f, 0.7f, 0.8f, 0.5f), 16.0f, LAYER_GUI-10); @@ -686,13 +686,13 @@ Menu::draw(DrawingContext& context) int text_width = (int) Resources::normal_font->get_text_width(items[active_item]->help); int text_height = (int) Resources::normal_font->get_text_height(items[active_item]->help); - Rect text_rect(pos_x - text_width/2 - 8, + Rectf text_rect(pos_x - text_width/2 - 8, SCREEN_HEIGHT - 48 - text_height/2 - 4, pos_x + text_width/2 + 8, SCREEN_HEIGHT - 48 + text_height/2 + 4); - context.draw_filled_rect(Rect(text_rect.p1 - Vector(4,4), - text_rect.p2 + Vector(4,4)), + context.draw_filled_rect(Rectf(text_rect.p1 - Vector(4,4), + text_rect.p2 + Vector(4,4)), Color(0.2f, 0.3f, 0.4f, 0.8f), 16.0f, LAYER_GUI-10); diff --git a/src/math/rect.hpp b/src/math/rectf.hpp similarity index 91% rename from src/math/rect.hpp rename to src/math/rectf.hpp index 88480620d..f34bb43f7 100644 --- a/src/math/rect.hpp +++ b/src/math/rectf.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef HEADER_SUPERTUX_MATH_RECT_HPP -#define HEADER_SUPERTUX_MATH_RECT_HPP +#ifndef HEADER_SUPERTUX_MATH_RECTF_HPP +#define HEADER_SUPERTUX_MATH_RECTF_HPP #include @@ -26,20 +26,20 @@ * upper left and width/height here, because that makes the collision detection * a little bit more efficient. */ -class Rect +class Rectf { public: - Rect() : + Rectf() : p1(), p2() { } - Rect(const Vector& np1, const Vector& np2) + Rectf(const Vector& np1, const Vector& np2) : p1(np1), p2(np2) { } - Rect(float x1, float y1, float x2, float y2) + Rectf(float x1, float y1, float x2, float y2) : p1(x1, y1), p2(x2, y2) { assert(p1.x <= p2.x && p1.y <= p2.y); @@ -99,7 +99,7 @@ public: { return v.x >= p1.x && v.y >= p1.y && v.x < p2.x && v.y < p2.y; } - bool contains(const Rect& other) const + bool contains(const Rectf& other) const { if(p1.x >= other.p2.x || other.p1.x >= p2.x) return false; diff --git a/src/object/anchor_point.cpp b/src/object/anchor_point.cpp index ad7db404b..0c0519124 100644 --- a/src/object/anchor_point.cpp +++ b/src/object/anchor_point.cpp @@ -21,7 +21,7 @@ #include #include -#include "math/rect.hpp" +#include "math/rectf.hpp" #include "util/log.hpp" std::string anchor_point_to_string(AnchorPoint point) @@ -76,7 +76,7 @@ AnchorPoint string_to_anchor_point(const std::string& str) throw std::runtime_error(msg.str()); } -Vector get_anchor_pos(const Rect& rect, AnchorPoint point) +Vector get_anchor_pos(const Rectf& rect, AnchorPoint point) { Vector result; @@ -121,7 +121,7 @@ Vector get_anchor_pos(const Rect& rect, AnchorPoint point) return result; } -Vector get_anchor_pos(const Rect& destrect, float width, float height, +Vector get_anchor_pos(const Rectf& destrect, float width, float height, AnchorPoint point) { Vector result; diff --git a/src/object/anchor_point.hpp b/src/object/anchor_point.hpp index 99c2b9b7a..3030ca1dd 100644 --- a/src/object/anchor_point.hpp +++ b/src/object/anchor_point.hpp @@ -21,7 +21,7 @@ #include "math/vector.hpp" -class Rect; +class Rectf; enum AnchorPoint { ANCHOR_H_MASK = 0x00f0, @@ -40,8 +40,8 @@ enum AnchorPoint { std::string anchor_point_to_string(AnchorPoint point); AnchorPoint string_to_anchor_point(const std::string& str); -Vector get_anchor_pos(const Rect& rect, AnchorPoint point); -Vector get_anchor_pos(const Rect& destrect, float width, float height, +Vector get_anchor_pos(const Rectf& rect, AnchorPoint point); +Vector get_anchor_pos(const Rectf& destrect, float width, float height, AnchorPoint point); #endif diff --git a/src/object/floating_image.cpp b/src/object/floating_image.cpp index c7e586aa4..0d41354e9 100644 --- a/src/object/floating_image.cpp +++ b/src/object/floating_image.cpp @@ -96,7 +96,7 @@ FloatingImage::draw(DrawingContext& context) return; } - Vector spos = pos + get_anchor_pos(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), + Vector spos = pos + get_anchor_pos(Rectf(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), sprite->get_width(), sprite->get_height(), anchor); sprite->draw(context, spos, layer); diff --git a/src/object/icecrusher.cpp b/src/object/icecrusher.cpp index de27a7791..aef8dd517 100644 --- a/src/object/icecrusher.cpp +++ b/src/object/icecrusher.cpp @@ -153,8 +153,8 @@ IceCrusher::found_victim() Player* player = this->get_nearest_player(); if (!player) return false; - const Rect& pr = player->get_bbox(); - const Rect& br = get_bbox(); + const Rectf& pr = player->get_bbox(); + const Rectf& br = get_bbox(); if ((pr.p2.x > br.p1.x) && (pr.p1.x < br.p2.x) && (pr.p1.y >= br.p2.y)) { return true; } diff --git a/src/object/infoblock.cpp b/src/object/infoblock.cpp index 705d6636b..3d262dfb2 100644 --- a/src/object/infoblock.cpp +++ b/src/object/infoblock.cpp @@ -176,7 +176,7 @@ InfoBlock::draw(DrawingContext& context) break; } - lines[i]->draw(context, Rect(x1, y, x2, y), LAYER_GUI-50+1); + lines[i]->draw(context, Rectf(x1, y, x2, y), LAYER_GUI-50+1); y += lines[i]->get_height(); } diff --git a/src/object/ispy.cpp b/src/object/ispy.cpp index d69266ae4..b4461de7b 100644 --- a/src/object/ispy.cpp +++ b/src/object/ispy.cpp @@ -91,7 +91,7 @@ Ispy::line_intersects_line(Vector line1_start, Vector line1_end, Vector line2_st } bool -Ispy::intersects_line(Rect r, Vector line_start, Vector line_end) +Ispy::intersects_line(Rectf r, Vector line_start, Vector line_end) { Vector p1 = r.p1; Vector p2 = Vector(r.p2.x, r.p1.y); diff --git a/src/object/ispy.hpp b/src/object/ispy.hpp index 4e1e0ba49..beb107d25 100644 --- a/src/object/ispy.hpp +++ b/src/object/ispy.hpp @@ -34,7 +34,7 @@ public: private: bool line_intersects_line(Vector line1_start, Vector line1_end, Vector line2_start, Vector line2_end); - bool intersects_line(Rect r, Vector line_start, Vector line_end); + bool intersects_line(Rectf r, Vector line_start, Vector line_end); bool free_line_of_sight(Vector p1, Vector p2, const MovingObject* ignore_object); enum IspyState { diff --git a/src/object/moving_sprite.cpp b/src/object/moving_sprite.cpp index e71577b4d..a79759949 100644 --- a/src/object/moving_sprite.cpp +++ b/src/object/moving_sprite.cpp @@ -131,7 +131,7 @@ MovingSprite::set_action_centered(const std::string& action, int loops) void MovingSprite::set_action(const std::string& action, int loops, AnchorPoint anchorPoint) { - Rect old_bbox = bbox; + Rectf old_bbox = bbox; sprite->set_action(action, loops); float w = sprite->get_current_hitbox_width(); float h = sprite->get_current_hitbox_height(); diff --git a/src/object/particlesystem_interactive.cpp b/src/object/particlesystem_interactive.cpp index b31707172..331884bf3 100644 --- a/src/object/particlesystem_interactive.cpp +++ b/src/object/particlesystem_interactive.cpp @@ -76,7 +76,7 @@ ParticleSystem_Interactive::collision(Particle* object, Vector movement) int max_x = int(x2+1); int max_y = int(y2+1); - Rect dest = Rect(x1, y1, x2, y2); + Rectf dest(x1, y1, x2, y2); dest.move(movement); Constraints constraints; @@ -102,7 +102,7 @@ ParticleSystem_Interactive::collision(Particle* object, Vector movement) water = true; } } else { // normal rectangular tile - Rect rect(x*32, y*32, (x+1)*32, (y+1)*32); + Rectf rect(x*32, y*32, (x+1)*32, (y+1)*32); if(intersects(dest, rect)) { if(tile->getAttributes() & Tile::WATER) water = true; diff --git a/src/object/player.cpp b/src/object/player.cpp index 575113e3a..6e756f373 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -277,12 +277,12 @@ Player::do_scripting_controller(std::string control, bool pressed) bool Player::adjust_height(float new_height) { - Rect bbox2 = bbox; + Rectf bbox2 = bbox; bbox2.move(Vector(0, bbox.get_height() - new_height)); bbox2.set_height(new_height); if(new_height > bbox.get_height()) { - Rect additional_space = bbox2; + Rectf additional_space = bbox2; additional_space.set_height(new_height - bbox.get_height()); if(!Sector::current()->is_free_of_statics(additional_space, this, true)) return false; @@ -776,7 +776,7 @@ Player::handle_input() Vector pos = get_pos() + Vector(dir == LEFT ? -bbox.get_width()-1 : bbox.get_width()+1, bbox.get_height()*0.66666 - 32); - Rect dest(pos, pos + Vector(32, 32)); + Rectf dest(pos, pos + Vector(32, 32)); if(Sector::current()->is_free_of_movingstatics(dest)) { MovingObject* moving_object = dynamic_cast (grabbed_object); if(moving_object) { diff --git a/src/object/text_object.cpp b/src/object/text_object.cpp index ba4a98c01..d5ee81ca3 100644 --- a/src/object/text_object.cpp +++ b/src/object/text_object.cpp @@ -122,7 +122,7 @@ TextObject::draw(DrawingContext& context) float width = 500; float height = 70; - Vector spos = pos + get_anchor_pos(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), + Vector spos = pos + get_anchor_pos(Rectf(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), width, height, anchor); context.draw_filled_rect(spos, Vector(width, height), diff --git a/src/sprite/sprite.cpp b/src/sprite/sprite.cpp index b159c9792..7739a7566 100644 --- a/src/sprite/sprite.cpp +++ b/src/sprite/sprite.cpp @@ -192,10 +192,10 @@ Sprite::get_current_hitbox_height() const return action->hitbox_h; } -Rect +Rectf Sprite::get_current_hitbox() const { - return Rect(action->x_offset, action->y_offset, action->x_offset + action->hitbox_w, action->y_offset + action->hitbox_h); + return Rectf(action->x_offset, action->y_offset, action->x_offset + action->hitbox_w, action->y_offset + action->hitbox_h); } void diff --git a/src/sprite/sprite.hpp b/src/sprite/sprite.hpp index 6e90a8471..b2ec201e6 100644 --- a/src/sprite/sprite.hpp +++ b/src/sprite/sprite.hpp @@ -80,7 +80,7 @@ public: /** return height of current action's hitbox */ float get_current_hitbox_height() const; /** return current action's hitbox, relative to 0,0 */ - Rect get_current_hitbox() const; + Rectf get_current_hitbox() const; /** Set the angle of the sprite rotation in degree */ void set_angle(float angle); diff --git a/src/supertux/collision.cpp b/src/supertux/collision.cpp index 2718a0673..6729d0540 100644 --- a/src/supertux/collision.cpp +++ b/src/supertux/collision.cpp @@ -19,11 +19,11 @@ #include #include "math/aatriangle.hpp" -#include "math/rect.hpp" +#include "math/rectf.hpp" namespace collision { -bool intersects(const Rect& r1, const Rect& r2) +bool intersects(const Rectf& r1, const Rectf& r2) { if(r1.p2.x < r2.p1.x || r1.p1.x > r2.p2.x) return false; @@ -47,16 +47,16 @@ inline void makePlane(const Vector& p1, const Vector& p2, Vector& n, float& c) } -bool rectangle_aatriangle(Constraints* constraints, const Rect& rect, +bool rectangle_aatriangle(Constraints* constraints, const Rectf& rect, const AATriangle& triangle, const Vector& addl_ground_movement) { - if(!intersects(rect, (const Rect&) triangle)) + if(!intersects(rect, (const Rectf&) triangle)) return false; Vector normal; float c; Vector p1; - Rect area; + Rectf area; switch(triangle.dir & AATriangle::DEFORM_MASK) { case 0: area.p1 = triangle.p1; @@ -145,7 +145,7 @@ bool rectangle_aatriangle(Constraints* constraints, const Rect& rect, } void set_rectangle_rectangle_constraints(Constraints* constraints, - const Rect& r1, const Rect& r2, const Vector& addl_ground_movement) + const Rectf& r1, const Rectf& r2, const Vector& addl_ground_movement) { float itop = r1.get_bottom() - r2.get_top(); float ibottom = r2.get_bottom() - r1.get_top(); diff --git a/src/supertux/collision.hpp b/src/supertux/collision.hpp index ac365f7aa..a500a2b1e 100644 --- a/src/supertux/collision.hpp +++ b/src/supertux/collision.hpp @@ -21,7 +21,7 @@ #include class Vector; -class Rect; +class Rectf; class AATriangle; namespace collision { @@ -68,16 +68,16 @@ public: }; /** checks if 2 rectangle intersect each other */ -bool intersects(const Rect& r1, const Rect& r2); +bool intersects(const Rectf& r1, const Rectf& 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. */ -bool rectangle_aatriangle(Constraints* constraints, const Rect& rect, +bool rectangle_aatriangle(Constraints* constraints, const Rectf& rect, const AATriangle& triangle, const Vector& addl_ground_movement = Vector(0,0)); void set_rectangle_rectangle_constraints(Constraints* constraints, - const Rect& r1, const Rect& r2, const Vector& addl_ground_movement = Vector(0,0)); + const Rectf& r1, const Rectf& r2, const Vector& addl_ground_movement = Vector(0,0)); } // namespace collision diff --git a/src/supertux/info_box.cpp b/src/supertux/info_box.cpp index c5521c88a..0ba7f380d 100644 --- a/src/supertux/info_box.cpp +++ b/src/supertux/info_box.cpp @@ -72,7 +72,7 @@ InfoBox::draw(DrawingContext& context) break; } - lines[i]->draw(context, Rect(x1, y, x1+width, y), LAYER_GUI); + lines[i]->draw(context, Rectf(x1, y, x1+width, y), LAYER_GUI); y += lines[i]->get_height(); } diff --git a/src/supertux/info_box_line.cpp b/src/supertux/info_box_line.cpp index 23fb1a6b5..16a69d6f7 100644 --- a/src/supertux/info_box_line.cpp +++ b/src/supertux/info_box_line.cpp @@ -169,7 +169,7 @@ InfoBoxLine::split(const std::string& text, float width) } void -InfoBoxLine::draw(DrawingContext& context, const Rect& bbox, int layer) +InfoBoxLine::draw(DrawingContext& context, const Rectf& bbox, int layer) { Vector position = bbox.p1; switch (lineType) { diff --git a/src/supertux/info_box_line.hpp b/src/supertux/info_box_line.hpp index 350122927..d2b382173 100644 --- a/src/supertux/info_box_line.hpp +++ b/src/supertux/info_box_line.hpp @@ -25,7 +25,7 @@ class DrawingContext; class Font; -class Rect; +class Rectf; class Surface; /** @@ -39,7 +39,7 @@ public: InfoBoxLine(char format_char, const std::string& text); ~InfoBoxLine(); - void draw(DrawingContext& context, const Rect& bbox, int layer); + void draw(DrawingContext& context, const Rectf& bbox, int layer); float get_height(); static const std::vector split(const std::string& text, float width); diff --git a/src/supertux/moving_object.hpp b/src/supertux/moving_object.hpp index 422aee7bd..7642ac5d5 100644 --- a/src/supertux/moving_object.hpp +++ b/src/supertux/moving_object.hpp @@ -19,7 +19,7 @@ #include -#include "math/rect.hpp" +#include "math/rectf.hpp" #include "supertux/collision_hit.hpp" #include "supertux/game_object.hpp" @@ -110,7 +110,7 @@ public: } /** returns the bounding box of the Object */ - const Rect& get_bbox() const + const Rectf& get_bbox() const { return bbox; } @@ -164,7 +164,7 @@ protected: /** The bounding box of the object (as used for collision detection, this isn't necessarily the bounding box for graphics) */ - Rect bbox; + Rectf bbox; /** The movement that will happen till next frame */ Vector movement; @@ -178,7 +178,7 @@ private: This field holds the currently anticipated destination of the object during collision detection */ - Rect dest; + Rectf dest; }; #endif diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index 8d83f5b77..9f978d9d5 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -634,10 +634,10 @@ Sector::deactivate() _current = NULL; } -Rect +Rectf Sector::get_active_region() { - return Rect( + return Rectf( camera->get_translation() - Vector(1600, 1200), camera->get_translation() + Vector(1600, 1200) + Vector(SCREEN_WIDTH,SCREEN_HEIGHT)); } @@ -864,7 +864,7 @@ Sector::draw(DrawingContext& context) for(MovingObjects::iterator i = moving_objects.begin(); i != moving_objects.end(); ++i) { MovingObject* object = *i; - const Rect& rect = object->get_bbox(); + const Rectf& rect = object->get_bbox(); context.draw_filled_rect(rect, col, LAYER_FOREGROUND1 + 10); } @@ -879,7 +879,7 @@ Sector::draw(DrawingContext& context) /** r1 is supposed to be moving, r2 a solid object */ void check_collisions(collision::Constraints* constraints, - const Vector& movement, const Rect& r1, const Rect& r2, + const Vector& movement, const Rectf& r1, const Rectf& r2, GameObject* object = NULL, MovingObject* other = NULL, const Vector& addl_ground_movement = Vector(0,0)) { if(!collision::intersects(r1, r2)) @@ -952,7 +952,7 @@ void check_collisions(collision::Constraints* constraints, void Sector::collision_tilemap(collision::Constraints* constraints, - const Vector& movement, const Rect& dest) const + const Vector& movement, const Rectf& dest) const { // calculate rectangle where the object will move float x1 = dest.get_left(); @@ -992,7 +992,7 @@ Sector::collision_tilemap(collision::Constraints* constraints, collision::rectangle_aatriangle(constraints, dest, triangle, solids->get_movement()); } else { // normal rectangular tile - Rect rect(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset(), (x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset()); + Rectf rect(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset(), (x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset()); check_collisions(constraints, movement, dest, rect, NULL, NULL, solids->get_movement()); } } @@ -1001,7 +1001,7 @@ Sector::collision_tilemap(collision::Constraints* constraints, } uint32_t -Sector::collision_tile_attributes(const Rect& dest) const +Sector::collision_tile_attributes(const Rectf& dest) const { float x1 = dest.p1.x; float y1 = dest.p1.y; @@ -1032,7 +1032,7 @@ Sector::collision_tile_attributes(const Rect& dest) const } /** fills in CollisionHit and Normal vector of 2 intersecting rectangle */ -static void get_hit_normal(const Rect& r1, const Rect& r2, CollisionHit& hit, +static void get_hit_normal(const Rectf& r1, const Rectf& r2, CollisionHit& hit, Vector& normal) { float itop = r1.get_bottom() - r2.get_top(); @@ -1066,8 +1066,8 @@ Sector::collision_object(MovingObject* object1, MovingObject* object2) const { using namespace collision; - const Rect& r1 = object1->dest; - const Rect& r2 = object2->dest; + const Rectf& r1 = object1->dest; + const Rectf& r2 = object2->dest; CollisionHit hit; if(intersects(object1->dest, object2->dest)) { @@ -1103,7 +1103,7 @@ Sector::collision_object(MovingObject* object1, MovingObject* object2) const void Sector::collision_static(collision::Constraints* constraints, - const Vector& movement, const Rect& dest, + const Vector& movement, const Rectf& dest, GameObject& object) { collision_tilemap(constraints, movement, dest); @@ -1132,7 +1132,7 @@ Sector::collision_static_constrains(MovingObject& object) Constraints constraints; Vector movement = object.get_movement(); - Rect& dest = object.dest; + Rectf& dest = object.dest; float owidth = object.get_bbox().get_width(); float oheight = object.get_bbox().get_height(); @@ -1340,7 +1340,7 @@ Sector::handle_collisions() } bool -Sector::is_free_of_tiles(const Rect& rect, const bool ignoreUnisolid) const +Sector::is_free_of_tiles(const Rectf& rect, const bool ignoreUnisolid) const { using namespace collision; @@ -1374,7 +1374,7 @@ Sector::is_free_of_tiles(const Rect& rect, const bool ignoreUnisolid) const } bool -Sector::is_free_of_statics(const Rect& rect, const MovingObject* ignore_object, const bool ignoreUnisolid) const +Sector::is_free_of_statics(const Rectf& rect, const MovingObject* ignore_object, const bool ignoreUnisolid) const { using namespace collision; @@ -1394,7 +1394,7 @@ Sector::is_free_of_statics(const Rect& rect, const MovingObject* ignore_object, } bool -Sector::is_free_of_movingstatics(const Rect& rect, const MovingObject* ignore_object) const +Sector::is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object) const { using namespace collision; @@ -1482,7 +1482,7 @@ Sector::get_total_badguys() } bool -Sector::inside(const Rect& rect) const +Sector::inside(const Rectf& rect) const { for(std::list::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) { TileMap* solids = *i; diff --git a/src/supertux/sector.hpp b/src/supertux/sector.hpp index 80d5c267b..996de3ef2 100644 --- a/src/supertux/sector.hpp +++ b/src/supertux/sector.hpp @@ -33,7 +33,7 @@ class Constraints; } class Vector; -class Rect; +class Rectf; class Sprite; class GameObject; class Player; @@ -102,7 +102,7 @@ public: * tests if a given rectangle is inside the sector * (a rectangle that is on top of the sector is considered inside) */ - bool inside(const Rect& rectangle) const; + bool inside(const Rectf& rectangle) const; void play_music(MusicType musictype); MusicType get_music_type(); @@ -128,27 +128,27 @@ public: } void collision_tilemap(collision::Constraints* constraints, - const Vector& movement, const Rect& dest) const; + const Vector& movement, const Rectf& dest) const; /** * Checks if the specified rectangle is free of (solid) tiles. * Note that this does not include static objects, e.g. bonus blocks. */ - bool is_free_of_tiles(const Rect& rect, const bool ignoreUnisolid = false) const; + bool is_free_of_tiles(const Rectf& rect, const bool ignoreUnisolid = false) const; /** * Checks if the specified rectangle is free of both * 1.) solid tiles and * 2.) MovingObjects in COLGROUP_STATIC. * Note that this does not include badguys or players. */ - bool is_free_of_statics(const Rect& rect, const MovingObject* ignore_object = 0, const bool ignoreUnisolid = false) const; + bool is_free_of_statics(const Rectf& rect, const MovingObject* ignore_object = 0, const bool ignoreUnisolid = false) const; /** * Checks if the specified rectangle is free of both * 1.) solid tiles and * 2.) MovingObjects in COLGROUP_STATIC, COLGROUP_MOVINGSTATIC or COLGROUP_MOVING. * This includes badguys and players. */ - bool is_free_of_movingstatics(const Rect& rect, const MovingObject* ignore_object = 0) const; + bool is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object = 0) const; /** * returns a list of players currently in the sector @@ -157,7 +157,7 @@ public: return std::vector(1, this->player); } - Rect get_active_region(); + Rectf get_active_region(); /** * returns the width (in px) of a sector) @@ -195,7 +195,7 @@ public: float get_gravity() const; private: - uint32_t collision_tile_attributes(const Rect& dest) const; + uint32_t collision_tile_attributes(const Rectf& dest) const; void before_object_remove(GameObject* object); bool before_object_add(GameObject* object); @@ -226,7 +226,7 @@ private: * (because of ABORT_MOVE in the collision response or no collisions) */ void collision_static(collision::Constraints* constraints, - const Vector& movement, const Rect& dest, GameObject& object); + const Vector& movement, const Rectf& dest, GameObject& object); void collision_static_constrains(MovingObject& object); diff --git a/src/supertux/textscroller.cpp b/src/supertux/textscroller.cpp index 61af4c600..e3a3d45b3 100644 --- a/src/supertux/textscroller.cpp +++ b/src/supertux/textscroller.cpp @@ -121,7 +121,7 @@ TextScroller::draw(DrawingContext& context) float y = SCREEN_HEIGHT - scroll; for(size_t i = 0; i < lines.size(); i++) { if (y + lines[i]->get_height() >= 0 && SCREEN_HEIGHT - y >= 0) { - lines[i]->draw(context, Rect(LEFT_BORDER, y, SCREEN_WIDTH - 2*LEFT_BORDER, y), LAYER_GUI); + lines[i]->draw(context, Rectf(LEFT_BORDER, y, SCREEN_WIDTH - 2*LEFT_BORDER, y), LAYER_GUI); } y += lines[i]->get_height(); diff --git a/src/supertux/tile.hpp b/src/supertux/tile.hpp index 9c8e7119d..690aef323 100644 --- a/src/supertux/tile.hpp +++ b/src/supertux/tile.hpp @@ -21,7 +21,7 @@ #include #include -#include "math/rect.hpp" +#include "math/rectf.hpp" #include "video/surface.hpp" #include "util/reader_fwd.hpp" @@ -83,12 +83,12 @@ public: }; struct ImageSpec { - ImageSpec(const std::string& newfile, const Rect& newrect) + ImageSpec(const std::string& newfile, const Rectf& newrect) : file(newfile), rect(newrect) { } std::string file; - Rect rect; + Rectf rect; }; private: diff --git a/src/supertux/tile_set_parser.cpp b/src/supertux/tile_set_parser.cpp index 255b27abe..5163901b0 100644 --- a/src/supertux/tile_set_parser.cpp +++ b/src/supertux/tile_set_parser.cpp @@ -168,7 +168,7 @@ TileSetParser::parse_tile_images(const Reader& images_lisp) { std::string file; cur->get(file); - imagespecs.push_back(Tile::ImageSpec(m_tiles_path + file, Rect(0, 0, 0, 0))); + imagespecs.push_back(Tile::ImageSpec(m_tiles_path + file, Rectf(0, 0, 0, 0))); } else if(cur->get_type() == lisp::Lisp::TYPE_CONS && cur->get_car()->get_type() == lisp::Lisp::TYPE_SYMBOL && @@ -186,7 +186,7 @@ TileSetParser::parse_tile_images(const Reader& 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(Tile::ImageSpec(m_tiles_path + file, Rect(x, y, x+w, y+h))); + imagespecs.push_back(Tile::ImageSpec(m_tiles_path + file, Rectf(x, y, x+w, y+h))); } else { @@ -277,7 +277,7 @@ TileSetParser::parse_tiles(const Reader& reader) std::vector imagespecs; for(std::vector::const_iterator j = images.begin(); j != images.end(); ++j) { - imagespecs.push_back(Tile::ImageSpec(m_tiles_path + *j, Rect(x, y, x + 32, y + 32))); + imagespecs.push_back(Tile::ImageSpec(m_tiles_path + *j, Rectf(x, y, x + 32, y + 32))); } std::auto_ptr tile(new Tile(m_tileset, imagespecs, diff --git a/src/supertux/title_screen.cpp b/src/supertux/title_screen.cpp index 0372be321..f9791bc19 100644 --- a/src/supertux/title_screen.cpp +++ b/src/supertux/title_screen.cpp @@ -89,7 +89,7 @@ TitleScreen::make_tux_jump() controller->press(Controller::RIGHT); // Check if we should press the jump button - Rect lookahead = tux->get_bbox(); + Rectf lookahead = tux->get_bbox(); lookahead.p2.x += 96; bool pathBlocked = !sector->is_free_of_statics(lookahead); if ((pathBlocked && jumpWasReleased) || !tux->on_ground()) { diff --git a/src/trigger/climbable.cpp b/src/trigger/climbable.cpp index dd8d944f0..5153bae37 100644 --- a/src/trigger/climbable.cpp +++ b/src/trigger/climbable.cpp @@ -42,7 +42,7 @@ Climbable::Climbable(const Reader& reader) : bbox.set_size(w, h); } -Climbable::Climbable(const Rect& area) : +Climbable::Climbable(const Rectf& area) : climbed_by(0), activate_try_timer() { diff --git a/src/trigger/climbable.hpp b/src/trigger/climbable.hpp index 3e454840e..f7b3616c2 100644 --- a/src/trigger/climbable.hpp +++ b/src/trigger/climbable.hpp @@ -30,7 +30,7 @@ class Climbable : public TriggerBase static Color text_color; public: Climbable(const Reader& reader); - Climbable(const Rect& area); + Climbable(const Rectf& area); ~Climbable(); void event(Player& player, EventType type); diff --git a/src/trigger/secretarea_trigger.cpp b/src/trigger/secretarea_trigger.cpp index 0f4aac818..8effd45a3 100644 --- a/src/trigger/secretarea_trigger.cpp +++ b/src/trigger/secretarea_trigger.cpp @@ -44,7 +44,7 @@ SecretAreaTrigger::SecretAreaTrigger(const Reader& reader) : message_displayed = false; } -SecretAreaTrigger::SecretAreaTrigger(const Rect& area, std::string fade_tilemap) : +SecretAreaTrigger::SecretAreaTrigger(const Rectf& area, std::string fade_tilemap) : message_timer(), message_displayed(), fade_tilemap(fade_tilemap) diff --git a/src/trigger/secretarea_trigger.hpp b/src/trigger/secretarea_trigger.hpp index e3d59168d..65fbf1b05 100644 --- a/src/trigger/secretarea_trigger.hpp +++ b/src/trigger/secretarea_trigger.hpp @@ -31,7 +31,7 @@ class SecretAreaTrigger : public TriggerBase static Color text_color; public: SecretAreaTrigger(const Reader& reader); - SecretAreaTrigger(const Rect& area, std::string fade_tilemap = ""); + SecretAreaTrigger(const Rectf& area, std::string fade_tilemap = ""); ~SecretAreaTrigger(); void event(Player& player, EventType type); diff --git a/src/util/log.cpp b/src/util/log.cpp index db49baffb..eafc99bfc 100644 --- a/src/util/log.cpp +++ b/src/util/log.cpp @@ -16,7 +16,7 @@ #include "util/log.hpp" -#include "math/rect.hpp" +#include "math/rectf.hpp" #include "supertux/console.hpp" #ifndef NDEBUG @@ -61,7 +61,7 @@ std::ostream& operator<<(std::ostream& out, const Vector& vector) return out; } -std::ostream& operator<<(std::ostream& out, const Rect& rect) +std::ostream& operator<<(std::ostream& out, const Rectf& rect) { out << "[" << rect.get_left() << "," << rect.get_top() << " " << rect.get_right() << "," << rect.get_bottom() << "]"; diff --git a/src/util/log.hpp b/src/util/log.hpp index 244c3f426..54bcb789a 100644 --- a/src/util/log.hpp +++ b/src/util/log.hpp @@ -48,8 +48,8 @@ std::ostream& log_fatal_f(); class Vector; std::ostream& operator<< (std::ostream& str, const Vector& vector); -class Rect; -std::ostream& operator<< (std::ostream& str, const Rect& rect); +class Rectf; +std::ostream& operator<< (std::ostream& str, const Rectf& rect); #endif diff --git a/src/video/drawing_context.cpp b/src/video/drawing_context.cpp index d94ab64d4..d5a5be12b 100644 --- a/src/video/drawing_context.cpp +++ b/src/video/drawing_context.cpp @@ -231,14 +231,14 @@ DrawingContext::draw_filled_rect(const Vector& topleft, const Vector& size, } void -DrawingContext::draw_filled_rect(const Rect& rect, const Color& color, +DrawingContext::draw_filled_rect(const Rectf& rect, const Color& color, int layer) { draw_filled_rect(rect, color, 0.0f, layer); } void -DrawingContext::draw_filled_rect(const Rect& rect, const Color& color, float radius, int layer) +DrawingContext::draw_filled_rect(const Rectf& rect, const Color& color, float radius, int layer) { DrawingRequest* request = new(obst) DrawingRequest(); diff --git a/src/video/drawing_context.hpp b/src/video/drawing_context.hpp index e37d28b64..684528846 100644 --- a/src/video/drawing_context.hpp +++ b/src/video/drawing_context.hpp @@ -23,7 +23,7 @@ #include #include -#include "math/rect.hpp" +#include "math/rectf.hpp" #include "math/vector.hpp" #include "video/color.hpp" #include "video/drawing_request.hpp" @@ -71,8 +71,8 @@ public: /// Fills a rectangle. void draw_filled_rect(const Vector& topleft, const Vector& size, const Color& color, int layer); - void draw_filled_rect(const Rect& rect, const Color& color, int layer); - void draw_filled_rect(const Rect& rect, const Color& color, float radius, int layer); + void draw_filled_rect(const Rectf& rect, const Color& color, int layer); + void draw_filled_rect(const Rectf& rect, const Color& color, float radius, int layer); void draw_inverse_ellipse(const Vector& pos, const Vector& size, const Color& color, int layer); diff --git a/src/video/font.cpp b/src/video/font.cpp index 86e524d5a..99b425e41 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -198,7 +198,7 @@ Font::loadFontSurface( glyph.surface_idx = surface_idx; if( glyph_width == FIXED ) { - glyph.rect = Rect(x, y, x + char_width, y + char_height); + glyph.rect = Rectf(x, y, x + char_width, y + char_height); glyph.offset = Vector(0, 0); glyph.advance = char_width; } @@ -211,9 +211,9 @@ Font::loadFontSurface( right -= 1; if (left <= right) - glyph.rect = Rect(left, y, right+1, y + char_height); + glyph.rect = Rectf(left, y, right+1, y + char_height); else // glyph is completely transparent - glyph.rect = Rect(x, y, x + char_width, y + char_height); + glyph.rect = Rectf(x, y, x + char_width, y + char_height); glyph.offset = Vector(0, 0); glyph.advance = glyph.rect.get_width() + 1; // FIXME: might be useful to make spacing configurable diff --git a/src/video/font.hpp b/src/video/font.hpp index 62b5d91c1..ffd89b80a 100644 --- a/src/video/font.hpp +++ b/src/video/font.hpp @@ -21,7 +21,7 @@ #include #include -#include "math/rect.hpp" +#include "math/rectf.hpp" #include "math/vector.hpp" #include "video/color.hpp" #include "video/surface.hpp" @@ -120,7 +120,7 @@ private: int surface_idx; /** Position of the glyph inside the surface */ - Rect rect; + Rectf rect; Glyph() : advance(), diff --git a/src/video/gl/gl_renderer.cpp b/src/video/gl/gl_renderer.cpp index fa153110b..b578977ad 100644 --- a/src/video/gl/gl_renderer.cpp +++ b/src/video/gl/gl_renderer.cpp @@ -300,7 +300,7 @@ GLRenderer::draw_filled_rect(const DrawingRequest& request) fillrectrequest->size.y/2)); // inner rectangle - Rect irect(request.pos.x + radius, + Rectf irect(request.pos.x + radius, request.pos.y + radius, request.pos.x + fillrectrequest->size.x - radius, request.pos.y + fillrectrequest->size.y - radius); diff --git a/src/video/lightmap.hpp b/src/video/lightmap.hpp index ab1acbe0c..905a237e1 100644 --- a/src/video/lightmap.hpp +++ b/src/video/lightmap.hpp @@ -24,7 +24,7 @@ #include #include -#include "math/rect.hpp" +#include "math/rectf.hpp" #include "math/vector.hpp" #include "video/color.hpp" #include "video/drawing_request.hpp" diff --git a/src/video/renderer.hpp b/src/video/renderer.hpp index 20204e136..8bb39c7ac 100644 --- a/src/video/renderer.hpp +++ b/src/video/renderer.hpp @@ -26,7 +26,7 @@ #include #include -#include "math/rect.hpp" +#include "math/rectf.hpp" #include "math/vector.hpp" #include "video/color.hpp" #include "video/font.hpp" -- 2.11.0