Changeset 503 for trunk/src/lua/lua_math.cc
- Timestamp:
- 06/28/16 21:09:19 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_math.cc
r490 r503 359 359 } 360 360 361 void nv::lua::register_math( lua_State* L ) 361 template < typename T > 362 void nlua_rtti_vec_push( nv::lua::state* state, const nv::type_entry*, void* object ) 363 { 364 T* value = reinterpret_cast<T*>( object ); 365 push_vec<T>( state->get_raw(), *value ); 366 } 367 368 template < typename T > 369 bool nlua_rtti_vec_read( nv::lua::state* state, const nv::type_entry*, void* object, int index ) 370 { 371 T* value = reinterpret_cast<T*>( object ); 372 int type = lua_type( state->get_raw(), index ); 373 if ( type == LUA_TUSERDATA ) 374 { 375 T* from = to_pvec<T>( state->get_raw(), index ); 376 if ( !from ) return false; 377 *value = *from; 378 } 379 // else if ( type == LUA_TTABLE ) 380 // { 381 // 382 // } 383 else 384 return false; 385 int todo; int table_constructor; 386 return true; 387 } 388 389 void nv::lua::register_math( lua::state* state ) 362 390 { 363 391 for (size_t i = 0; i < 256; ++i ) nlua_swizzel_lookup[i] = 255; … … 379 407 nlua_swizzel_lookup[uchar8( 'v' )] = 0; 380 408 nlua_swizzel_lookup[uchar8( '3' )] = 3; 409 410 lua_State* L = state->get_raw(); 381 411 int stack = lua_gettop( L ); 382 412 … … 389 419 nlua_requiref(L, "vec4", luaopen_vec<nv::vec4>, 1); 390 420 lua_settop( L, stack ); 391 } 392 421 422 state->register_rtti_type< nv::ivec2 >( nlua_rtti_vec_push<nv::ivec2>, nlua_rtti_vec_read<nv::ivec2> ); 423 state->register_rtti_type< nv::ivec3 >( nlua_rtti_vec_push<nv::ivec3>, nlua_rtti_vec_read<nv::ivec3> ); 424 state->register_rtti_type< nv::ivec4 >( nlua_rtti_vec_push<nv::ivec4>, nlua_rtti_vec_read<nv::ivec4> ); 425 state->register_rtti_type< nv::vec2 > ( nlua_rtti_vec_push<nv::vec2>, nlua_rtti_vec_read<nv::vec2> ); 426 state->register_rtti_type< nv::vec3 > ( nlua_rtti_vec_push<nv::vec3>, nlua_rtti_vec_read<nv::vec3> ); 427 state->register_rtti_type< nv::vec4 > ( nlua_rtti_vec_push<nv::vec4>, nlua_rtti_vec_read<nv::vec4> ); 428 } 429
Note: See TracChangeset
for help on using the changeset viewer.