moved Engine::Object::draw() into .cc file as it got bigger

git-svn-id: svn://anubis/anaglym/trunk@50 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-10-05 20:03:14 +00:00
parent 4b34a2e565
commit 452b8fe3f3
2 changed files with 23 additions and 11 deletions

View File

@ -314,6 +314,21 @@ void Engine::update()
m_drawing = false; m_drawing = false;
} }
void Engine::doPhysics()
{
static Uint32 last_updated = 0;
Uint32 current_ticks = SDL_GetTicks();
if (last_updated > 0)
{
Uint32 msec_steps = current_ticks - last_updated;
for (int i = 0; i < msec_steps; i++)
m_world.step();
}
last_updated = current_ticks;
}
void Engine::Object::loadPhy(const std::string & path, bool static_data) void Engine::Object::loadPhy(const std::string & path, bool static_data)
{ {
geoms = g_engine->m_world.loadPhy(path, &body, static_data); geoms = g_engine->m_world.loadPhy(path, &body, static_data);
@ -338,15 +353,12 @@ void Engine::Object::getPosition(double * x, double * y, double * z)
} }
} }
void Engine::doPhysics() void Engine::Object::draw()
{ {
static Uint32 last_updated = 0; if (body != 0)
Uint32 current_ticks = SDL_GetTicks(); OdeWorld::pushTransform(dBodyGetPosition(body),
if (last_updated > 0) dBodyGetRotation(body));
{ glCallList(display_list);
Uint32 msec_steps = current_ticks - last_updated; if (body != 0)
for (int i = 0; i < msec_steps; i++) glPopMatrix();
m_world.step();
}
last_updated = current_ticks;
} }

View File

@ -23,7 +23,7 @@ class Engine
std::vector<dGeomID> geoms; std::vector<dGeomID> geoms;
dBodyID body; dBodyID body;
void draw() { glCallList(display_list); } void draw();
void loadPhy(const std::string & path, void loadPhy(const std::string & path,
bool static_data = false); bool static_data = false);
void setPosition(double x, double y, double z); void setPosition(double x, double y, double z);