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>
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
))
54 , m_displayList(glGenLists(1))
60 * Destroys a map/object object.
64 glDeleteLists(1, m_displayList
);
68 bool Object::lessThan(const Object
* rhs
) const
70 if (m_north
< rhs
->m_north
)
73 if (m_west
< rhs
->m_west
)
80 bool Object::intersects(const Collideable
& rhs
) const
86 ObjectList::ObjectList()
91 ObjectList::~ObjectList()
93 for (iterator it
= begin(); it
!= end(); ++it
)
101 } // namespace Poopmup