Skip to content

Commit

Permalink
sim.framerender function to simulate a certain number of frames
Browse files Browse the repository at this point in the history
also remove particle debugging lua function now that there are key shortcuts
  • Loading branch information
jacob1 committed Feb 7, 2015
1 parent 2c0287b commit 6cb7818
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/lua/LuaScriptInterface.cpp
Expand Up @@ -591,7 +591,7 @@ void LuaScriptInterface::initSimulationAPI()
{"photons", simulation_photons},
{"neighbours", simulation_neighbours},
{"neighbors", simulation_neighbours},
{"updateParticles", simulation_update_particles},
{"framerender", simulation_framerender},
{NULL, NULL}
};
luaL_register(l, "simulation", simulationAPIMethods);
Expand Down Expand Up @@ -1780,13 +1780,17 @@ int LuaScriptInterface::simulation_neighbours(lua_State * l)
return 1;
}

int LuaScriptInterface::simulation_update_particles(lua_State * l)
int LuaScriptInterface::simulation_framerender(lua_State * l)
{
int start = luaL_optint(l, 1, 0);
int end = luaL_optint(l, 2, luacon_sim->parts_lastActiveIndex);
if (start < 0 || end >= NPART || start > end)
return luaL_error(l, "Invalid start / end positions: (%d, %d)", start, end);
luacon_sim->UpdateParticles(start, end);
if (lua_gettop(l) == 0)
{
lua_pushinteger(l, luacon_sim->framerender);
return 1;
}
int frames = luaL_checkinteger(l, 1);
if (frames < 0)
return luaL_error(l, "Can't simulate a negative number of frames");
luacon_sim->framerender = frames;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lua/LuaScriptInterface.h
Expand Up @@ -99,7 +99,7 @@ class LuaScriptInterface: public CommandInterface
static int simulation_pmap(lua_State * l);
static int simulation_photons(lua_State * l);
static int simulation_neighbours(lua_State * l);
static int simulation_update_particles(lua_State * l);
static int simulation_framerender(lua_State * l);

//Renderer
void initRendererAPI();
Expand Down

0 comments on commit 6cb7818

Please sign in to comment.