forked from mirrors/principia
Deduplicate base LuaScript sprite verts
This commit is contained in:
parent
422e95b14c
commit
0ad08adab8
4 changed files with 26 additions and 44 deletions
|
|
@ -389,26 +389,6 @@ plua_foreach(lua_State *L, const int index, void (*cb)(lua_State*, int, void*),
|
|||
}
|
||||
}
|
||||
|
||||
static struct lua_vert base[4] = {
|
||||
{
|
||||
(tvec3){.5f,.5f,0.f},
|
||||
(tvec2){.5f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){-.5f,.5f,0.f},
|
||||
(tvec2){0.f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){-.5f,-.5f,0.f},
|
||||
(tvec2){0.f, .5f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){.5f,-.5f,0.f},
|
||||
(tvec2){.5f, .5f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}
|
||||
};
|
||||
|
||||
static int
|
||||
my_writer(lua_State *L, const void *contents, size_t size, void *ud)
|
||||
{
|
||||
|
|
@ -1561,7 +1541,7 @@ escript::add_static_sprite(float x, float y, float r, float w, float h, int bx,
|
|||
tmath_sincos(r, &sn, &cs);
|
||||
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n*4+ix] = base[ix];
|
||||
_b[n*4+ix] = sprite_base[ix];
|
||||
|
||||
_b[n*4+ix].pos.x *= w;
|
||||
_b[n*4+ix].pos.y *= h;
|
||||
|
|
@ -1585,7 +1565,7 @@ escript::add_static_sprite(float x, float y, float r, float w, float h, int bx,
|
|||
}
|
||||
} else {
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n*4+ix] = base[ix];
|
||||
_b[n*4+ix] = sprite_base[ix];
|
||||
|
||||
_b[n*4+ix].pos.x *= w;
|
||||
_b[n*4+ix].pos.y *= h;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,25 @@
|
|||
#include "lua.hh"
|
||||
|
||||
struct lua_vert sprite_base[4] = {
|
||||
{
|
||||
(tvec3){.5f,.5f,0.f},
|
||||
(tvec2){.5f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){-.5f,.5f,0.f},
|
||||
(tvec2){0.f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){-.5f,-.5f,0.f},
|
||||
(tvec2){0.f, .5f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){.5f,-.5f,0.f},
|
||||
(tvec2){.5f, .5f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}
|
||||
};
|
||||
|
||||
bool lua_push_stuff(lua_State *Lsrc, lua_State *Ldst, int pos)
|
||||
{
|
||||
if (lua_isnumber(Lsrc, pos)) {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ struct lua_vert {
|
|||
tvec4 color;
|
||||
};
|
||||
|
||||
extern struct lua_vert sprite_base[4];
|
||||
|
||||
/*
|
||||
* Recursive function to push stuff!
|
||||
* Can currently handle:
|
||||
|
|
|
|||
|
|
@ -2,26 +2,6 @@
|
|||
#include "escript.hh"
|
||||
#include "receiver.hh"
|
||||
|
||||
struct lua_vert base[4] = {
|
||||
{
|
||||
(tvec3){.5f,.5f,0.f},
|
||||
(tvec2){.5f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){-.5f,.5f,0.f},
|
||||
(tvec2){0.f, 1.f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){-.5f,-.5f,0.f},
|
||||
(tvec2){0.f, .5f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}, {
|
||||
(tvec3){.5f,-.5f,0.f},
|
||||
(tvec2){.5f, .5f},
|
||||
(tvec4){0.f, 0.f, 0.f, 0.f},
|
||||
}
|
||||
};
|
||||
|
||||
static uint32_t
|
||||
upper_power_of_two(uint32_t v)
|
||||
{
|
||||
|
|
@ -399,7 +379,7 @@ static int l_this_draw_sprite(lua_State *L)
|
|||
tmath_sincos(r, &sn, &cs);
|
||||
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n*4+ix] = base[ix];
|
||||
_b[n*4+ix] = sprite_base[ix];
|
||||
|
||||
_b[n*4+ix].pos.x *= w;
|
||||
_b[n*4+ix].pos.y *= h;
|
||||
|
|
@ -428,7 +408,7 @@ static int l_this_draw_sprite(lua_State *L)
|
|||
}
|
||||
} else {
|
||||
for (int ix=0; ix<4; ix++) {
|
||||
_b[n*4+ix] = base[ix];
|
||||
_b[n*4+ix] = sprite_base[ix];
|
||||
|
||||
_b[n*4+ix].pos.x *= w;
|
||||
_b[n*4+ix].pos.y *= h;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue