mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Eliminate LUA_FLOAT4_VECTORS. LUA_VECTOR_SIZE is enough for the few remaining cases.
This commit is contained in:
parent
06a94fb097
commit
3ed5b6313c
10 changed files with 12 additions and 18 deletions
|
@ -157,7 +157,7 @@ LUA_API void lua_pushnil(lua_State* L);
|
|||
LUA_API void lua_pushnumber(lua_State* L, double n);
|
||||
LUA_API void lua_pushinteger(lua_State* L, int n);
|
||||
LUA_API void lua_pushunsigned(lua_State* L, unsigned n);
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
LUA_API void lua_pushvector(lua_State* L, float x, float y, float z, float w);
|
||||
#else
|
||||
LUA_API void lua_pushvector(lua_State* L, float x, float y, float z);
|
||||
|
|
|
@ -123,12 +123,6 @@
|
|||
long l; \
|
||||
}
|
||||
|
||||
#define LUA_FLOAT4_VECTORS
|
||||
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#define LUA_VECTOR_SIZE 4
|
||||
#else
|
||||
#define LUA_VECTOR_SIZE 3
|
||||
#endif
|
||||
#define LUA_VECTOR_SIZE 3 /* must be 3 or 4 */
|
||||
|
||||
#define LUA_EXTRA_SIZE LUA_VECTOR_SIZE - 2
|
||||
|
|
|
@ -550,7 +550,7 @@ void lua_pushunsigned(lua_State* L, unsigned u)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
void lua_pushvector(lua_State* L, float x, float y, float z, float w)
|
||||
{
|
||||
setvvalue(L->top, x, y, z, w);
|
||||
|
|
|
@ -462,7 +462,7 @@ LUALIB_API const char* luaL_tolstring(lua_State* L, int idx, size_t* len)
|
|||
case LUA_TVECTOR:
|
||||
{
|
||||
const float* v = lua_tovector(L, idx);
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
lua_pushfstring(L, LUA_NUMBER_FMT ", " LUA_NUMBER_FMT ", " LUA_NUMBER_FMT ", " LUA_NUMBER_FMT, v[0], v[1], v[2], v[3]);
|
||||
#else
|
||||
lua_pushfstring(L, LUA_NUMBER_FMT ", " LUA_NUMBER_FMT ", " LUA_NUMBER_FMT, v[0], v[1], v[2]);
|
||||
|
|
|
@ -1018,7 +1018,7 @@ static int luauF_tunpack(lua_State* L, StkId res, TValue* arg0, int nresults, St
|
|||
|
||||
static int luauF_vector(lua_State* L, StkId res, TValue* arg0, int nresults, StkId args, int nparams)
|
||||
{
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
if (nparams >= 4 && nresults <= 1 && ttisnumber(arg0) && ttisnumber(args) && ttisnumber(args + 1) && ttisnumber(args + 2))
|
||||
#else
|
||||
if (nparams >= 3 && nresults <= 1 && ttisnumber(arg0) && ttisnumber(args) && ttisnumber(args + 1))
|
||||
|
@ -1029,7 +1029,7 @@ static int luauF_vector(lua_State* L, StkId res, TValue* arg0, int nresults, Stk
|
|||
double z = nvalue(args + 1);
|
||||
double w = 0.0;
|
||||
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
w = nvalue(args + 2);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#define ABISWITCH(x64, ms32, gcc32) (sizeof(void*) == 8 ? x64 : ms32)
|
||||
#endif
|
||||
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
static_assert(sizeof(TValue) == ABISWITCH(24, 24, 24), "size mismatch for value");
|
||||
static_assert(sizeof(LuaNode) == ABISWITCH(48, 48, 48), "size mismatch for table entry");
|
||||
#else
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
inline bool luai_veceq(const float* a, const float* b)
|
||||
{
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3];
|
||||
#else
|
||||
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2];
|
||||
|
@ -27,7 +27,7 @@ inline bool luai_veceq(const float* a, const float* b)
|
|||
|
||||
inline bool luai_vecisnan(const float* a)
|
||||
{
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
return a[0] != a[0] || a[1] != a[1] || a[2] != a[2] || a[3] != a[3];
|
||||
#else
|
||||
return a[0] != a[0] || a[1] != a[1] || a[2] != a[2];
|
||||
|
|
|
@ -105,7 +105,7 @@ typedef struct lua_TValue
|
|||
i_o->tt = LUA_TNUMBER; \
|
||||
}
|
||||
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
#define setvvalue(obj, x, y, z, w) \
|
||||
{ \
|
||||
TValue* i_o = (obj); \
|
||||
|
|
|
@ -113,7 +113,7 @@ static LuaNode* hashvec(const Table* t, const float* v)
|
|||
// Optimized Spatial Hashing for Collision Detection of Deformable Objects
|
||||
unsigned int h = (i[0] * 73856093) ^ (i[1] * 19349663) ^ (i[2] * 83492791);
|
||||
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
i[3] = (i[3] == 0x8000000) ? 0 : i[3];
|
||||
i[3] ^= i[3] >> 17;
|
||||
h ^= i[3] * 39916801;
|
||||
|
|
|
@ -601,7 +601,7 @@ static void luau_execute(lua_State* L)
|
|||
const char* name = getstr(tsvalue(kv));
|
||||
int ic = (name[0] | ' ') - 'x';
|
||||
|
||||
#ifdef LUA_FLOAT4_VECTORS
|
||||
#if LUA_VECTOR_SIZE == 4
|
||||
// 'w' is before 'x' in ascii, so ic is -1 when indexing with 'w'
|
||||
if (ic == -1)
|
||||
ic = 3;
|
||||
|
|
Loading…
Add table
Reference in a new issue