[395] | 1 | // Copyright (C) 2012-2015 ChaosForge Ltd
|
---|
[53] | 2 | // http://chaosforge.org/
|
---|
| 3 | //
|
---|
[395] | 4 | // This file is part of Nova libraries.
|
---|
| 5 | // For conditions of distribution and use, see copying.txt file in root folder.
|
---|
[53] | 6 |
|
---|
| 7 | #include "nv/lua/lua_glm.hh"
|
---|
[85] | 8 |
|
---|
| 9 | #include "nv/lua/lua_raw.hh"
|
---|
[319] | 10 | #include "nv/core/random.hh"
|
---|
[385] | 11 | #include "nv/stl/type_traits/common.hh"
|
---|
[53] | 12 |
|
---|
[406] | 13 | static int nlua_swizzel_lookup[256];
|
---|
[53] | 14 |
|
---|
[207] | 15 | using nv::lua::detail::is_vec;
|
---|
| 16 | using nv::lua::detail::to_vec;
|
---|
| 17 | using nv::lua::detail::to_pvec;
|
---|
| 18 | using nv::lua::detail::push_vec;
|
---|
| 19 |
|
---|
[406] | 20 | inline bool nlua_is_swizzel( const unsigned char* str, int max )
|
---|
[53] | 21 | {
|
---|
| 22 | while (*str)
|
---|
| 23 | {
|
---|
| 24 | if (nlua_swizzel_lookup[*str] > max) return false;
|
---|
| 25 | str++;
|
---|
| 26 | }
|
---|
| 27 | return true;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | template < typename T, size_t k >
|
---|
| 31 | struct nlua_vec_constructor {
|
---|
[177] | 32 | static inline T unit() { return T(); }
|
---|
[121] | 33 | static inline T construct( lua_State*, int ) {
|
---|
[53] | 34 | return T();
|
---|
| 35 | }
|
---|
| 36 | };
|
---|
| 37 |
|
---|
| 38 | template < typename T > struct nlua_vec_constructor< T, 1 > {
|
---|
[177] | 39 | static inline T unit() { return T( 1 ); }
|
---|
[53] | 40 | static inline T construct( lua_State* L, int index ) {
|
---|
| 41 | return T( lua_tonumber( L, index ) );
|
---|
| 42 | }
|
---|
| 43 | };
|
---|
| 44 |
|
---|
| 45 | template < typename T > struct nlua_vec_constructor< T, 2 > {
|
---|
[177] | 46 | static inline T unit() { return T( 1, 1 ); }
|
---|
[53] | 47 | static inline T construct( lua_State* L, int index ) {
|
---|
| 48 | if ( lua_type( L, index ) == LUA_TUSERDATA )
|
---|
[207] | 49 | return to_vec<T>( L, index );
|
---|
[53] | 50 | else
|
---|
| 51 | return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ) );
|
---|
| 52 | }
|
---|
| 53 | };
|
---|
| 54 |
|
---|
| 55 | template < typename T > struct nlua_vec_constructor< T, 3 > {
|
---|
[177] | 56 | static inline T unit() { return T( 1, 1, 1 ); }
|
---|
[53] | 57 | static inline T construct( lua_State* L, int index ) {
|
---|
[397] | 58 | typedef nv::tvec2<typename T::value_type> vec2;
|
---|
[53] | 59 | if ( lua_type( L, index ) == LUA_TUSERDATA )
|
---|
| 60 | {
|
---|
[207] | 61 | if ( is_vec<T>( L, index ) )
|
---|
| 62 | return to_vec<T>( L, index );
|
---|
[53] | 63 | else
|
---|
[207] | 64 | return T( to_vec<vec2>( L, index ), lua_tonumber( L, index + 1 ) );
|
---|
[53] | 65 | }
|
---|
| 66 | else
|
---|
| 67 | {
|
---|
| 68 | if ( lua_type( L, index+1 ) == LUA_TUSERDATA )
|
---|
[207] | 69 | return T( lua_tonumber( L, index ), to_vec<vec2>( L, index+1 ) );
|
---|
[53] | 70 | else
|
---|
| 71 | return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ), lua_tonumber( L, index + 2 ) );
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 | };
|
---|
| 75 |
|
---|
| 76 | template < typename T > struct nlua_vec_constructor< T, 4 > {
|
---|
[177] | 77 | static inline T unit() { return T( 1, 1, 1, 1 ); }
|
---|
[53] | 78 | static inline T construct( lua_State* L, int index ) {
|
---|
[397] | 79 | typedef nv::tvec2<typename T::value_type> vec2;
|
---|
| 80 | typedef nv::tvec3<typename T::value_type> vec3;
|
---|
[53] | 81 | if ( lua_type( L, index ) == LUA_TUSERDATA )
|
---|
| 82 | {
|
---|
[207] | 83 | if ( is_vec<T>( L, index ) )
|
---|
| 84 | return to_vec<T>( L, index );
|
---|
[53] | 85 | else
|
---|
| 86 | {
|
---|
[207] | 87 | if ( is_vec<vec3>( L, index ) )
|
---|
| 88 | return T( to_vec<vec3>( L, index ), lua_tonumber( L, index + 1 ) );
|
---|
[53] | 89 | else
|
---|
| 90 | {
|
---|
| 91 | if ( lua_type( L, index+1 ) == LUA_TUSERDATA )
|
---|
[207] | 92 | return T( to_vec<vec2>( L, index ), to_vec<vec2>( L, index + 1 ) );
|
---|
[53] | 93 | else
|
---|
[207] | 94 | return T( to_vec<vec2>( L, index ), lua_tonumber( L, index + 1 ), lua_tonumber( L, index + 2 ) );
|
---|
[53] | 95 | }
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 | else
|
---|
| 99 | {
|
---|
| 100 | if ( lua_type( L, index+1 ) == LUA_TUSERDATA )
|
---|
| 101 | {
|
---|
[207] | 102 | if ( is_vec<vec3>( L, index+1 ) )
|
---|
| 103 | return T( lua_tonumber( L, index ), to_vec<vec3>( L, index+1 ) );
|
---|
[53] | 104 | else
|
---|
[207] | 105 | return T( lua_tonumber( L, index ), to_vec<vec2>( L, index+1 ), lua_tonumber( L, index + 2 ) );
|
---|
[53] | 106 | }
|
---|
| 107 | else
|
---|
| 108 | {
|
---|
| 109 | if ( lua_type( L, index+2 ) == LUA_TUSERDATA )
|
---|
[207] | 110 | return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ), to_vec<vec2>( L, index+2 ) );
|
---|
[53] | 111 | else
|
---|
| 112 | return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ), lua_tonumber( L, index + 2 ), lua_tonumber( L, index + 3 ) );
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 | };
|
---|
| 117 |
|
---|
| 118 | template< typename T >
|
---|
| 119 | int nlua_vec_new( lua_State* L )
|
---|
| 120 | {
|
---|
[207] | 121 | push_vec<T>( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 1 ) );
|
---|
[53] | 122 | return 1;
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | template< typename T >
|
---|
[177] | 126 | int nlua_vec_random( lua_State* L )
|
---|
| 127 | {
|
---|
[207] | 128 | push_vec<T>( L, nv::random::get().range( to_vec<T>( L, 1 ), to_vec<T>( L, 2 ) ) );
|
---|
[177] | 129 | return 1;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | template< typename T >
|
---|
[174] | 133 | int nlua_vec_clone( lua_State* L )
|
---|
| 134 | {
|
---|
[207] | 135 | push_vec<T>( L, to_vec<T>( L, 1 ) );
|
---|
[174] | 136 | return 1;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | template< typename T >
|
---|
[53] | 140 | int nlua_vec_call( lua_State* L )
|
---|
| 141 | {
|
---|
[207] | 142 | push_vec<T>( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 2 ) );
|
---|
[53] | 143 | return 1;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | template< typename T >
|
---|
| 147 | static int nlua_vec_unm( lua_State* L )
|
---|
| 148 | {
|
---|
[207] | 149 | push_vec<T>( L, -to_vec<T>( L, 1 ) );
|
---|
[53] | 150 | return 1;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | template< typename T >
|
---|
| 154 | int nlua_vec_add( lua_State* L )
|
---|
| 155 | {
|
---|
| 156 | if ( lua_type( L, 1 ) == LUA_TNUMBER )
|
---|
[406] | 157 | push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) + to_vec<T>( L, 2 ) );
|
---|
[53] | 158 | else
|
---|
| 159 | if ( lua_type( L, 2 ) == LUA_TNUMBER )
|
---|
[406] | 160 | push_vec<T>( L, to_vec<T>( L, 1 ) + static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
|
---|
[53] | 161 | else
|
---|
[207] | 162 | push_vec<T>( L, to_vec<T>( L, 1 ) + to_vec<T>( L, 2 ) );
|
---|
[53] | 163 | return 1;
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | template< typename T >
|
---|
| 167 | int nlua_vec_sub( lua_State* L )
|
---|
| 168 | {
|
---|
| 169 | if ( lua_type( L, 1 ) == LUA_TNUMBER )
|
---|
[406] | 170 | push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) - to_vec<T>( L, 2 ) );
|
---|
[53] | 171 | else
|
---|
| 172 | if ( lua_type( L, 2 ) == LUA_TNUMBER )
|
---|
[406] | 173 | push_vec<T>( L, to_vec<T>( L, 1 ) - static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
|
---|
[53] | 174 | else
|
---|
[207] | 175 | push_vec<T>( L, to_vec<T>( L, 1 ) - to_vec<T>( L, 2 ) );
|
---|
[53] | 176 | return 1;
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 | template< typename T >
|
---|
| 180 | int nlua_vec_mul( lua_State* L )
|
---|
| 181 | {
|
---|
| 182 | if ( lua_type( L, 1 ) == LUA_TNUMBER )
|
---|
[406] | 183 | push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) * to_vec<T>( L, 2 ) );
|
---|
[53] | 184 | else
|
---|
| 185 | if ( lua_type( L, 2 ) == LUA_TNUMBER )
|
---|
[406] | 186 | push_vec<T>( L, to_vec<T>( L, 1 ) * static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
|
---|
[53] | 187 | else
|
---|
[207] | 188 | push_vec<T>( L, to_vec<T>( L, 1 ) * to_vec<T>( L, 2 ) );
|
---|
[53] | 189 | return 1;
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | template< typename T >
|
---|
| 193 | int nlua_vec_div( lua_State* L )
|
---|
| 194 | {
|
---|
| 195 | if ( lua_type( L, 1 ) == LUA_TNUMBER )
|
---|
[406] | 196 | push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) / to_vec<T>( L, 2 ) );
|
---|
[53] | 197 | else
|
---|
| 198 | if ( lua_type( L, 2 ) == LUA_TNUMBER )
|
---|
[406] | 199 | push_vec<T>( L, to_vec<T>( L, 1 ) / static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
|
---|
[53] | 200 | else
|
---|
[207] | 201 | push_vec<T>( L, to_vec<T>( L, 1 ) / to_vec<T>( L, 2 ) );
|
---|
[53] | 202 | return 1;
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | template< typename T >
|
---|
| 206 | int nlua_vec_eq( lua_State* L )
|
---|
| 207 | {
|
---|
[207] | 208 | lua_pushboolean( L, to_vec<T>( L, 1 ) == to_vec<T>( L, 2 ) );
|
---|
[53] | 209 | return 1;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | template< typename T >
|
---|
| 213 | int nlua_vec_get( lua_State* L )
|
---|
| 214 | {
|
---|
[207] | 215 | T v = to_vec<T>( L, 1 );
|
---|
[397] | 216 | for ( int i = 0; i < v.length(); ++i )
|
---|
[53] | 217 | {
|
---|
| 218 | lua_pushnumber( L, v[i] );
|
---|
| 219 | }
|
---|
| 220 | return v.length();
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | template< typename T >
|
---|
| 224 | int nlua_vec_index( lua_State* L )
|
---|
| 225 | {
|
---|
[207] | 226 | T* v = to_pvec<T>( L, 1 );
|
---|
[53] | 227 | size_t len = 0;
|
---|
[406] | 228 | int vlen = v->length();
|
---|
| 229 | const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
|
---|
| 230 | int idx = 255;
|
---|
[53] | 231 |
|
---|
[85] | 232 | if ( len == 1 )
|
---|
[53] | 233 | {
|
---|
| 234 | idx = nlua_swizzel_lookup[ key[ 0 ] ];
|
---|
| 235 | if ( idx < vlen )
|
---|
| 236 | {
|
---|
| 237 | lua_pushnumber( L, (*v)[idx] );
|
---|
| 238 | return 1;
|
---|
| 239 | }
|
---|
| 240 | }
|
---|
| 241 | else if ( len < 4 && nlua_is_swizzel(key,vlen-1) )
|
---|
| 242 | {
|
---|
| 243 | switch (len) {
|
---|
[397] | 244 | case 2 : push_vec( L, nv::tvec2<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]] ) ); return 1;
|
---|
| 245 | case 3 : push_vec( L, nv::tvec3<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]] ) ); return 1;
|
---|
| 246 | case 4 : push_vec( L, nv::tvec4<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]], (*v)[nlua_swizzel_lookup[key[3]]] ) ); return 1;
|
---|
[53] | 247 | default: break;
|
---|
| 248 | }
|
---|
| 249 | }
|
---|
| 250 |
|
---|
[174] | 251 | luaL_getmetafield( L, 1, "__functions" );
|
---|
[75] | 252 | lua_pushvalue( L, 2 );
|
---|
[53] | 253 | lua_rawget( L, -2 );
|
---|
| 254 | return 1;
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | template< typename T >
|
---|
| 258 | int nlua_vec_newindex( lua_State* L )
|
---|
| 259 | {
|
---|
[397] | 260 | typedef nv::tvec2<typename T::value_type> vec2;
|
---|
| 261 | typedef nv::tvec3<typename T::value_type> vec3;
|
---|
| 262 | typedef nv::tvec4<typename T::value_type> vec4;
|
---|
[53] | 263 |
|
---|
[207] | 264 | T* v = to_pvec<T>( L, 1 );
|
---|
[53] | 265 | size_t len = 0;
|
---|
[406] | 266 | int vlen = v->length();
|
---|
| 267 | const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
|
---|
| 268 | int idx = 255;
|
---|
[53] | 269 | if( len == 1 )
|
---|
| 270 | {
|
---|
| 271 | idx = nlua_swizzel_lookup[ key[ 0 ] ];
|
---|
| 272 | if ( idx < vlen )
|
---|
| 273 | {
|
---|
[406] | 274 | (*v)[idx] = static_cast<typename T::value_type>( luaL_checknumber( L, 3 ) );
|
---|
[53] | 275 | return 0;
|
---|
| 276 | }
|
---|
| 277 | }
|
---|
| 278 | else if ( len < 4 && nlua_is_swizzel(key,vlen-1) )
|
---|
| 279 | {
|
---|
| 280 | switch (len) {
|
---|
[406] | 281 | case 2 : { vec2 v2 = to_vec<vec2>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0;
|
---|
| 282 | case 3 : { vec3 v3 = to_vec<vec3>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0;
|
---|
| 283 | case 4 : { vec4 v4 = to_vec<vec4>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0;
|
---|
[53] | 284 | default: break;
|
---|
| 285 | }
|
---|
| 286 | }
|
---|
| 287 | return 0;
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | template< typename T >
|
---|
| 291 | static int nlua_vec_tostring( lua_State* L )
|
---|
| 292 | {
|
---|
[207] | 293 | T v = to_vec<T>( L, 1 );
|
---|
[378] | 294 | bool fl = nv::is_floating_point<typename T::value_type>::value;
|
---|
| 295 | switch ( v.length() )
|
---|
[53] | 296 | {
|
---|
[380] | 297 | case 1: lua_pushfstring( L, ( fl ? "(%f)" : "(%d)" ), v[0] ); break;
|
---|
| 298 | case 2: lua_pushfstring( L, ( fl ? "(%f,%f)" : "(%d,%d)" ), v[0], v[1] ); break;
|
---|
| 299 | case 3: lua_pushfstring( L, ( fl ? "(%f,%f,%f)" : "(%d,%d,%d)" ), v[0], v[1], v[2] ); break;
|
---|
| 300 | case 4: lua_pushfstring( L, ( fl ? "(%f,%f,%f,%f)" : "(%d,%d,%d,%d)" ), v[0], v[1], v[2], v[3] ); break;
|
---|
[385] | 301 | default:
|
---|
[378] | 302 | lua_pushliteral( L, "(vector?)" ); break;
|
---|
[53] | 303 | }
|
---|
| 304 | return 1;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | template< typename T >
|
---|
| 308 | int luaopen_vec( lua_State * L )
|
---|
| 309 | {
|
---|
[174] | 310 | static const struct luaL_Reg nlua_vec_sf [] = {
|
---|
| 311 | { "new", nlua_vec_new<T> },
|
---|
[177] | 312 | { "random", nlua_vec_random<T> },
|
---|
[174] | 313 | {NULL, NULL}
|
---|
| 314 | };
|
---|
| 315 |
|
---|
[53] | 316 | static const struct luaL_Reg nlua_vec_f [] = {
|
---|
[174] | 317 | { "clone", nlua_vec_clone<T> },
|
---|
[53] | 318 | { "get", nlua_vec_get<T> },
|
---|
[177] | 319 | { "tostring", nlua_vec_tostring<T> },
|
---|
[53] | 320 | {NULL, NULL}
|
---|
| 321 | };
|
---|
| 322 |
|
---|
[174] | 323 | static const struct luaL_Reg nlua_vec_sm [] = {
|
---|
[53] | 324 | { "__call", nlua_vec_call<T> },
|
---|
| 325 | {NULL, NULL}
|
---|
| 326 | };
|
---|
| 327 |
|
---|
| 328 | static const struct luaL_Reg nlua_vec_m [] = {
|
---|
| 329 | { "__add", nlua_vec_add<T> },
|
---|
| 330 | { "__sub", nlua_vec_sub<T> },
|
---|
| 331 | { "__unm", nlua_vec_unm<T> },
|
---|
| 332 | { "__mul", nlua_vec_mul<T> },
|
---|
| 333 | { "__div", nlua_vec_div<T> },
|
---|
| 334 | { "__eq", nlua_vec_eq<T> },
|
---|
| 335 | { "__index", nlua_vec_index<T> },
|
---|
| 336 | { "__newindex", nlua_vec_newindex<T> },
|
---|
| 337 | { "__tostring", nlua_vec_tostring<T> },
|
---|
| 338 | {NULL, NULL}
|
---|
| 339 | };
|
---|
| 340 |
|
---|
[207] | 341 | luaL_newmetatable( L, nv::lua::detail::glm_metatable_name<T>() );
|
---|
[85] | 342 | nlua_register( L, nlua_vec_m, -1 );
|
---|
| 343 | lua_createtable( L, 0, 0 );
|
---|
| 344 | nlua_register( L, nlua_vec_f, -1 );
|
---|
[174] | 345 | lua_setfield(L, -2, "__functions" );
|
---|
| 346 | lua_pop( L, 1 );
|
---|
| 347 |
|
---|
[85] | 348 | lua_createtable( L, 0, 0 );
|
---|
[174] | 349 | nlua_register( L, nlua_vec_sf, -1 );
|
---|
| 350 | lua_createtable( L, 0, 0 );
|
---|
| 351 | nlua_register( L, nlua_vec_sm, -1 );
|
---|
[53] | 352 | lua_setmetatable( L, -2 );
|
---|
[177] | 353 |
|
---|
[207] | 354 | nv::lua::detail::push_vec( L, T() );
|
---|
[177] | 355 | lua_setfield( L, -2, "ZERO" );
|
---|
[207] | 356 | nv::lua::detail::push_vec( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::unit() );
|
---|
[177] | 357 | lua_setfield( L, -2, "UNIT" );
|
---|
[53] | 358 | return 1;
|
---|
| 359 | }
|
---|
| 360 |
|
---|
[207] | 361 | void nv::lua::register_glm( lua_State* L )
|
---|
[53] | 362 | {
|
---|
| 363 | for (size_t i = 0; i < 256; ++i ) nlua_swizzel_lookup[i] = 255;
|
---|
[369] | 364 | using nv::uchar8;
|
---|
| 365 | nlua_swizzel_lookup[uchar8( 'x' )] = 0;
|
---|
| 366 | nlua_swizzel_lookup[uchar8( 'r' )] = 0;
|
---|
| 367 | nlua_swizzel_lookup[uchar8( 's' )] = 0;
|
---|
| 368 | nlua_swizzel_lookup[uchar8( '0' )] = 0;
|
---|
| 369 | nlua_swizzel_lookup[uchar8( 'y' )] = 1;
|
---|
| 370 | nlua_swizzel_lookup[uchar8( 'g' )] = 1;
|
---|
| 371 | nlua_swizzel_lookup[uchar8( 't' )] = 0;
|
---|
| 372 | nlua_swizzel_lookup[uchar8( '1' )] = 1;
|
---|
| 373 | nlua_swizzel_lookup[uchar8( 'z' )] = 2;
|
---|
| 374 | nlua_swizzel_lookup[uchar8( 'b' )] = 2;
|
---|
| 375 | nlua_swizzel_lookup[uchar8( 'u' )] = 0;
|
---|
| 376 | nlua_swizzel_lookup[uchar8( '2' )] = 2;
|
---|
| 377 | nlua_swizzel_lookup[uchar8( 'w' )] = 3;
|
---|
| 378 | nlua_swizzel_lookup[uchar8( 'a' )] = 3;
|
---|
| 379 | nlua_swizzel_lookup[uchar8( 'v' )] = 0;
|
---|
| 380 | nlua_swizzel_lookup[uchar8( '3' )] = 3;
|
---|
[74] | 381 | int stack = lua_gettop( L );
|
---|
[75] | 382 |
|
---|
[172] | 383 | luaL_requiref(L, "coord", luaopen_vec<nv::ivec2>, 1);
|
---|
[121] | 384 | luaL_requiref(L, "ivec2", luaopen_vec<nv::ivec2>, 1);
|
---|
| 385 | luaL_requiref(L, "ivec3", luaopen_vec<nv::ivec3>, 1);
|
---|
| 386 | luaL_requiref(L, "ivec4", luaopen_vec<nv::ivec4>, 1);
|
---|
| 387 | luaL_requiref(L, "vec2", luaopen_vec<nv::vec2>, 1);
|
---|
| 388 | luaL_requiref(L, "vec3", luaopen_vec<nv::vec3>, 1);
|
---|
| 389 | luaL_requiref(L, "vec4", luaopen_vec<nv::vec4>, 1);
|
---|
[74] | 390 | lua_settop( L, stack );
|
---|
[53] | 391 | }
|
---|
| 392 |
|
---|