/*************************************************************************** File: PBMSimScene.cpp Created: 02/04/2002 Author: Maxim Garber Computer Science Department University of North Carolina - Chapel Hill garber@cs.unc.edu Description: Simulation scene file. ----------------------------------------------------------------------------. Copyright 2001 Maxim Garber UNC Motion Planning Research Group *****************************************************************************/ #include "PBMSimScene.h" #include /**************************************************************************** Function : PBMSimScene Description: Constructor ****************************************************************************/ PBMSimScene::PBMSimScene(){} /**************************************************************************** Function : ~PBMSimScene Description: Destructor ****************************************************************************/ PBMSimScene::~PBMSimScene() { std::list::iterator i = _objects.begin(); for(; i!= _objects.end(); i++) delete(*i); _objects.clear(); } /**************************************************************************** Function : Update Description: Updates the objects in the scene and cull inactive obejcts ****************************************************************************/ void PBMSimScene::Update(float timeStep) { // update all objects std::list::iterator j = _objects.begin(); for(; j!= _objects.end(); j++) (*j)->Update(timeStep); // cull inactive objects std::list::iterator newEnd = std::stable_partition(_objects.begin(), _objects.end(), PBMSimObjectActive); for(j = newEnd; j != _objects.end(); j++) { PBMSimObject *obj = *j; delete obj; } if (newEnd != _objects.end()) _objects.erase(newEnd, _objects.end()); } /**************************************************************************** Function : Draw Description: Draws all of the objects in the scene ****************************************************************************/ void PBMSimScene::Draw() { // draw all objects std::list::iterator i = _objects.begin(); for(; i!= _objects.end(); i++) (*i)->Draw(); }