Ignore:
Timestamp:
06/28/16 21:09:19 (9 years ago)
Author:
epyon
Message:
  • nv::random - support for different rng sources
  • nv::types - fixes and better support
  • nv::mesh_creator - full range transform
  • nv::context - buffer mask as separate type
  • nv::lua - initializations from lua::state instead of lua_State
  • nv::lua - initial support for rtti
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_math.cc

    r490 r503  
    359359}
    360360
    361 void nv::lua::register_math( lua_State* L )
     361template < typename T >
     362void 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
     368template < typename T >
     369bool 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
     389void nv::lua::register_math( lua::state* state )
    362390{
    363391        for (size_t i = 0; i < 256; ++i ) nlua_swizzel_lookup[i] = 255;
     
    379407        nlua_swizzel_lookup[uchar8( 'v' )] = 0;
    380408        nlua_swizzel_lookup[uchar8( '3' )] = 3;
     409
     410        lua_State* L = state->get_raw();
    381411        int stack = lua_gettop( L );
    382412
     
    389419        nlua_requiref(L, "vec4", luaopen_vec<nv::vec4>, 1);
    390420        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.