Skip to content
Snippets Groups Projects
Commit 7256e9f2 authored by dg's avatar dg
Browse files

Particles can now return one more parameter to tell the engine to never stop...

Particles can now return one more parameter to tell the engine to never stop emitting them, even when they are all dead


git-svn-id: http://svn.net-core.org/repos/t-engine4@1321 51575b47-30f0-44d4-a5cc-537603b46e54
parent d4e1bac8
No related branches found
No related tags found
No related merge requests found
......@@ -48,18 +48,18 @@ function _M:cloned()
end
function _M:loaded()
local def, fct, max, gl
local def, fct, max, gl, no_stop
if type(self.def) == "string" then
if _M.particles_def[self.def] then
setfenv(_M.particles_def[self.def], setmetatable(self.args or {}, {__index=_G}))
def, fct, max, gl = _M.particles_def[self.def]()
def, fct, max, gl, no_stop = _M.particles_def[self.def]()
else
local odef = self.def
print("[PARTICLE] Loading from /data/gfx/particles/"..self.def..".lua")
local f, err = loadfile("/data/gfx/particles/"..self.def..".lua")
if not f and err then error(err) end
setfenv(f, setmetatable(self.args or {}, {__index=_G}))
def, fct, max, gl = f()
def, fct, max, gl, no_stop = f()
_M.particles_def[odef] = f
end
else error("unsupported particle type: "..type(self.def))
......@@ -70,5 +70,5 @@ function _M:loaded()
gl = self.__particles_gl[gl]
self.update = fct
self.ps = core.particles.newEmitter(max or 1000, def, gl)
self.ps = core.particles.newEmitter(max or 1000, no_stop, def, gl)
end
......@@ -116,4 +116,4 @@ function(self)
elseif self.nb == 32 then pause = false self.nb = 0
end
end,
4*(230)*tiles
4*(230)*tiles, nil, true
......@@ -65,7 +65,8 @@ static void getparticulefield(lua_State *L, const char *k, float *v)
static int particles_new(lua_State *L)
{
int nb = luaL_checknumber(L, 1);
GLuint *t = (GLuint*)auxiliar_checkclass(L, "gl{texture}", 3);
bool no_stop = lua_toboolean(L, 2);
GLuint *t = (GLuint*)auxiliar_checkclass(L, "gl{texture}", 4);
int t_ref = luaL_ref(L, LUA_REGISTRYINDEX);
int p_ref = luaL_ref(L, LUA_REGISTRYINDEX);
......@@ -75,6 +76,7 @@ static int particles_new(lua_State *L)
ps->nb = nb;
ps->texture = *t;
ps->texture_ref = t_ref;
ps->no_stop = no_stop;
ps->particles = calloc(nb, sizeof(particle_type));
......@@ -361,7 +363,7 @@ static int particles_to_screen(lua_State *L)
// Restore normal display
glColor4f(1, 1, 1, 1);
lua_pushboolean(L, alive);
lua_pushboolean(L, alive || ps->no_stop);
return 1;
}
......
......@@ -39,6 +39,7 @@ typedef struct {
int nb;
int texture_ref;
int generator_ref;
bool no_stop;
int base;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment