Fixed windings on map.
[poopmup2.git] / poopmup / map / object.cpp
blobc9c9ac7c78969a0f3d19c90804149ceb48fcd3ae
1 /**
2 * @file poopmup/map/object.cpp
3 * The private implemntation file for the map object class.
5 * Copyright Stephen M. Webb <bregma@poopmup.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <poopmup/map/object.h>
23 #include <iostream>
26 namespace Poopmup
28 namespace Map
32 namespace
34 Core::BoundingSphere calculateBS(float west, float south, float east, float north, float top, float bottom)
36 float width = (east - west) / 2.0f;
37 float length = (north - south) / 2.0f;
38 float height = (top - bottom) / 2.0f;
40 return Core::BoundingSphere(Core::Vector(west+width, bottom+height, south+length),
41 Core::Vector(width, height, length).length2());
43 } // anonymous namespace
46 Object::Object(float west, float south, float east, float north, float top, float bottom)
47 : Collideable(calculateBS(west, south, east, north, top, bottom))
48 , m_north(north)
49 , m_south(south)
50 , m_east(east)
51 , m_west(west)
52 , m_top(top)
53 , m_bottom(bottom)
54 , m_displayList(glGenLists(1))
59 /**
60 * Destroys a map/object object.
62 Object::~Object()
64 glDeleteLists(1, m_displayList);
68 bool Object::lessThan(const Object* rhs) const
70 if (m_north < rhs->m_north)
71 return true;
73 if (m_west < rhs->m_west)
74 return true;
76 return false;
80 bool Object::intersects(const Collideable& rhs) const
82 return false;
86 ObjectList::ObjectList()
91 ObjectList::~ObjectList()
93 for (iterator it = begin(); it != end(); ++it)
95 delete *it;
100 } // namespace Map
101 } // namespace Poopmup