#include using namespace std; #include "entity.h" void box::add (const box &o) { a.x = min (a.x, o.a.x); a.y = min (a.y, o.a.y); a.z = min (a.z, o.a.z); b.x = max (b.x, o.b.x); b.y = max (b.y, o.b.y); b.z = max (b.z, o.b.z); } void entity_base::update_bbox () { if (parent) parent->update_bbox (); } void entity_base::hide () { for (vector::iterator i = o.end (); i-- != o.begin (); ) (*i)->remove (this); o.clear (); } void entity_filter::update_bbox () { bbox = e->bbox; entity_base::update_bbox (); } void entity_filter::show (const sector &sec) { e->show (sec); } void entity_filter::draw () { e->draw (); } entity_filter::~entity_filter () { delete e; } void entity::show (const sector &sec) { e->show (this->sec); } void entity::draw () { //TODO setup matrix etc. e->draw (); } void entity_container::update_bbox () { bbox.reset (); for (iterator i = end (); i-- != begin (); ) { (*i)->update_bbox (); bbox.add ((*i)->bbox); } } void entity_container::show (const sector &sec) { for (iterator i = end (); i-- != begin (); ) (*i)->show (sec); } void entity_container::draw () { for (iterator i = end (); i-- != begin (); ) (*i)->draw (); } entity_container::~entity_container () { hide (); for (iterator i = end (); i-- != begin (); ) delete *i; clear (); }