changed m_objects to use an IDSet
git-svn-id: svn://anubis/anaglym/trunk@265 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
4757223088
commit
ab4d6a82b8
20
Engine.cc
20
Engine.cc
@ -88,7 +88,6 @@ static void checkGLErrorLine(const char * function, int line)
|
|||||||
Engine::Engine(const string & path, AV & av)
|
Engine::Engine(const string & path, AV & av)
|
||||||
: m_av(av)
|
: m_av(av)
|
||||||
{
|
{
|
||||||
m_next_object_index = 1;
|
|
||||||
m_eye[0] = 0;
|
m_eye[0] = 0;
|
||||||
m_eye[1] = -1;
|
m_eye[1] = -1;
|
||||||
m_eye[2] = 0;
|
m_eye[2] = 0;
|
||||||
@ -279,20 +278,18 @@ bool Engine::fileExists(const string & path)
|
|||||||
int Engine::addObject(WFObj * obj, bool is_static, bool is_reference,
|
int Engine::addObject(WFObj * obj, bool is_static, bool is_reference,
|
||||||
float scale)
|
float scale)
|
||||||
{
|
{
|
||||||
int id = m_next_object_index++;
|
|
||||||
Object * o = new Object(is_static, is_reference, m_world, obj, scale);
|
Object * o = new Object(is_static, is_reference, m_world, obj, scale);
|
||||||
|
int id = m_objects.add(o);
|
||||||
o->setID(id);
|
o->setID(id);
|
||||||
m_objects[id] = o;
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Engine::addObject(bool is_static, bool is_reference,
|
int Engine::addObject(bool is_static, bool is_reference,
|
||||||
OdeWorld::GeomType geom_type, refptr< vector<float> > args)
|
OdeWorld::GeomType geom_type, refptr< vector<float> > args)
|
||||||
{
|
{
|
||||||
int id = m_next_object_index++;
|
|
||||||
Object * o = new Object(is_static, is_reference, m_world, geom_type, args);
|
Object * o = new Object(is_static, is_reference, m_world, geom_type, args);
|
||||||
|
int id = m_objects.add(o);
|
||||||
o->setID(id);
|
o->setID(id);
|
||||||
m_objects[id] = o;
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,16 +403,15 @@ void Engine::removeObject(int id)
|
|||||||
|
|
||||||
int Engine::cloneObject(const Engine::Object * obj)
|
int Engine::cloneObject(const Engine::Object * obj)
|
||||||
{
|
{
|
||||||
int id = m_next_object_index++;
|
|
||||||
Object * o = new Object(*obj);
|
Object * o = new Object(*obj);
|
||||||
|
int id = m_objects.add(o);
|
||||||
o->setID(id);
|
o->setID(id);
|
||||||
m_objects[id] = o;
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Object * Engine::getObject(int id)
|
Engine::Object * Engine::getObject(int id)
|
||||||
{
|
{
|
||||||
return m_objects.find(id) != m_objects.end() ? m_objects[id] : NULL;
|
return m_objects.contains(id) ? m_objects[id] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::startFrame()
|
void Engine::startFrame()
|
||||||
@ -654,8 +650,7 @@ void Engine::clearWorld()
|
|||||||
{
|
{
|
||||||
while (!m_objects.empty())
|
while (!m_objects.empty())
|
||||||
{
|
{
|
||||||
std::map<int, Object *>::iterator it = m_objects.begin();
|
removeObject(m_objects.begin()->first);
|
||||||
removeObject(it->first);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1141,8 +1136,9 @@ void Engine::doPhysics()
|
|||||||
|
|
||||||
void Engine::drawObjects()
|
void Engine::drawObjects()
|
||||||
{
|
{
|
||||||
std::map<int, Object *>::iterator it;
|
for (std::map<int, Object *>::const_iterator it = m_objects.begin();
|
||||||
for (it = m_objects.begin(); it != m_objects.end(); it++)
|
it != m_objects.end();
|
||||||
|
it++)
|
||||||
{
|
{
|
||||||
it->second->draw();
|
it->second->draw();
|
||||||
}
|
}
|
||||||
|
3
Engine.h
3
Engine.h
@ -264,10 +264,9 @@ class Engine
|
|||||||
std::string m_program_directory;
|
std::string m_program_directory;
|
||||||
std::string m_engine_path;
|
std::string m_engine_path;
|
||||||
OdeWorld m_world;
|
OdeWorld m_world;
|
||||||
std::map<int, Object *> m_objects;
|
IDSet<Object *> m_objects;
|
||||||
IDSet< refptr<AV::Sound> > m_sounds;
|
IDSet< refptr<AV::Sound> > m_sounds;
|
||||||
IDSet<dJointID> m_joints;
|
IDSet<dJointID> m_joints;
|
||||||
int m_next_object_index;
|
|
||||||
GLdouble m_eye[3];
|
GLdouble m_eye[3];
|
||||||
GLdouble m_center[3];
|
GLdouble m_center[3];
|
||||||
GLdouble m_up[3];
|
GLdouble m_up[3];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user