40#ifndef GEOGRAM_LUA_LUA_VEC_MAT
41#define GEOGRAM_LUA_LUA_VEC_MAT
44#include <geogram/lua/lua.h>
69 lua_State* L,
int index, T& result
77 template<>
inline bool lua_toveccomp<double>(
78 lua_State* L,
int index,
double& result
80 if(lua_type(L,index) == LUA_TNUMBER) {
81 result = lua_tonumber(L,index);
87 template<>
inline bool lua_toveccomp<float>(
88 lua_State* L,
int index,
float& result
90 if(lua_type(L,index) == LUA_TNUMBER) {
91 result = float(lua_tonumber(L,index));
97 template<>
inline bool lua_toveccomp<Numeric::int32>(
100 if(lua_type(L,index) == LUA_TNUMBER && lua_isinteger(L,index)) {
120 template<
unsigned int N,
class T>
inline bool lua_tovec(
123 if(!lua_istable(L,index)) {
130 for(lua_Integer i=1; lua_geti(L,index,i) != LUA_TNIL; ++i) {
140 return(ok && cur ==
index_t(N));
154 template<
unsigned int N,
class T>
inline bool lua_tomat(
158 if(!lua_istable(L,index)) {
165 for(lua_Integer i=1; lua_geti(L,index,i) != LUA_TNIL; ++i) {
170 result(cur,j) = row[j];
182 return(ok && cur ==
index_t(N));
201 lua_pushnumber(L, val);
205 lua_pushnumber(L,
double(val));
211 lua_pushinteger(L, lua_Integer(val));
219 template <
unsigned int N,
class T>
inline void lua_push(
220 lua_State* L, const ::GEO::vecng<N,T>& V
222 lua_createtable(L,
int(N), 0);
225 lua_seti(L,-2,lua_Integer(i+1));
234 template <
unsigned int N,
class T>
inline void lua_push(
235 lua_State* L, const ::GEO::Matrix<N,T>& M
237 lua_createtable(L,
int(N), 0);
239 lua_createtable(L,
int(N), 0);
242 lua_seti(L,-2,lua_Integer(j+1));
244 lua_seti(L,-2,lua_Integer(i+1));
A function to suppress unused parameters compilation warnings.
Assertion checking mechanism.
#define geo_assert_not_reached
Sets a non reachable point in the program.
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
bool lua_tomat(lua_State *L, int index, ::GEO::Matrix< N, T > &result)
Converts a Lua object into a Geogram mat2, mat3 or mat4.
void geo_argused(const T &)
Suppresses compiler warnings about unused parameters.
void lua_push(lua_State *L, const ::GEO::vecng< N, T > &V)
Pushes a vector onto the Lua stack.
geo_index_t index_t
The type for storing and manipulating indices.
bool lua_toveccomp(lua_State *L, int index, T &result)
Converts a lua object into a value.
bool lua_tovec(lua_State *L, int index, ::GEO::vecng< N, T > &result)
Converts a lua object into a Geogram vec2,vec3 or vec4.
void lua_pushveccomp(lua_State *L, T val)
Pushes a vector component onto the Lua stack.
Types and functions for numbers manipulation.
Generic implementation of geometric vectors.