added doPhysics()

git-svn-id: svn://anubis/anaglym/trunk@48 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop committed 2009-10-05 19:06:42 +00:00
1 parent fccfb572e2
commit 6a52215247
4 files changed
+22 -21

No files matched your search

+6 -18
View File
@@ -24,10 +24,6 @@ namespace ag
{ "println", println },
{ "loadModel", loadModel },
{ "loadStaticModel", loadStaticModel },
#if 0
{ "videoStart", videoStart },
{ "videoStop", videoStop },
#endif
{ "sleep", sleep },
{ "startFrame", startFrame },
{ "endFrame", endFrame },
@@ -163,20 +159,6 @@ namespace ag
loadModelSpecify(L, true);
}
#if 0
int videoStart(lua_State * L)
{
g_engine->getVideo()->start();
return 0;
}
int videoStop(lua_State * L)
{
g_engine->getVideo()->stop();
return 0;
}
#endif
int sleep(lua_State * L)
{
int argc = lua_gettop(L);
@@ -218,6 +200,12 @@ namespace ag
return 1;
}
int doPhysics(lua_State * L)
{
g_engine->doPhysics();
return 0;
}
namespace object
{
static Engine::Object * getObject(lua_State * L, int index)
+1 -2
View File
@@ -11,13 +11,12 @@ namespace ag
int println(lua_State * L);
int loadModel(lua_State * L);
int loadStaticModel(lua_State * L);
int videoStart(lua_State * L);
int videoStop(lua_State * L);
int sleep(lua_State * L);
int startFrame(lua_State * L);
int endFrame(lua_State * L);
int setCamera(lua_State * L);
int elapsedTime(lua_State * L);
int doPhysics(lua_State * L);
namespace object
{
+14 -1
View File
@@ -267,7 +267,7 @@ Uint32 Engine::updateCallback(Uint32 interval)
void Engine::run()
{
/* register a screen redrawing SDL event */
SDL_AddTimer(20, &updateCallback, this);
SDL_AddTimer(25, &updateCallback, this);
SDL_Event event;
while (SDL_WaitEvent(&event))
@@ -333,3 +333,16 @@ void Engine::Object::getPosition(double * x, double * y, double * z)
*z = pos[2];
}
}
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;
}
+1
View File
@@ -41,6 +41,7 @@ class Engine
OdeWorld & getWorld() { return m_world; }
int addObject(WFObj * obj);
Object * getObject(int id);
void doPhysics();
/* lua services */
int startFrame(lua_State * L);