Changeset 503 for trunk


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
Location:
trunk
Files:
4 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/core/random.hh

    r487 r503  
    1515{
    1616
    17         class random
    18         {
    19         public:
    20                 static constexpr uint32 mersenne_n = 624;
    21                 static constexpr uint32 mersenne_m = 397;
    22                 static constexpr uint32 mersenne_static_seed = 5489;
    23 
    24                 typedef uint32 result_type; // mt19937::result_type
     17        class random_base
     18        {
     19        public:
     20                typedef uint32 result_type;
    2521                typedef uint32 seed_type;
    2622
    27                 random( seed_type seed = 0 );
    28                 seed_type randomize() { return set_seed( 0 ); }
    29                 seed_type set_seed( seed_type seed = 0 );
    30                 static random& get();
    31                 result_type rand();
    32                 uint32 urand( uint32 val );
     23                virtual seed_type set_seed( seed_type seed = 0 ) = 0;
     24                virtual result_type rand() = 0;
     25
     26                seed_type randomize()
     27                {
     28                        return set_seed( randomized_seed() );
     29                }
     30
     31                uint32 urand( uint32 val )
     32                {
     33                        uint32 x, max = 0xFFFFFFFFUL - ( 0xFFFFFFFFUL % val );
     34                        while ( ( x = rand() ) >= max );
     35                        return x / ( max / val );
     36                }
    3337
    3438                sint32 srand( sint32 val )
    3539                {
    3640                        NV_ASSERT( val >= 0, "Bad srand range!" );
    37                         return static_cast< sint32 >( urand( static_cast< uint32 >( val ) ) );
     41                        return static_cast<sint32>( urand( static_cast<uint32>( val ) ) );
    3842                }
    3943
     
    5357                        // this method probably reduces range //
    5458                        uint32 roll = urand( static_cast<uint32>( max - min ) + 1 );
    55                         return static_cast< sint32 >( roll ) + min;
     59                        return static_cast<sint32>( roll ) + min;
    5660                }
    5761
     
    8387                {
    8488                        return math::tvec2<T>(
    85                                 range_impl( min.x, max.x, is_floating_point<T>() ), 
     89                                range_impl( min.x, max.x, is_floating_point<T>() ),
    8690                                range_impl( min.y, max.y, is_floating_point<T>() )
    8791                                );
     
    9296                {
    9397                        return math::tvec3<T>(
    94                                 range_impl( min.x, max.x, is_floating_point<T>() ), 
     98                                range_impl( min.x, max.x, is_floating_point<T>() ),
    9599                                range_impl( min.y, max.y, is_floating_point<T>() ),
    96100                                range_impl( min.z, max.z, is_floating_point<T>() )
     
    102106                {
    103107                        return math::tvec4<T>(
    104                                 range_impl( min.x, max.x, is_floating_point<T>() ), 
     108                                range_impl( min.x, max.x, is_floating_point<T>() ),
    105109                                range_impl( min.y, max.y, is_floating_point<T>() ),
    106                                 range_impl( min.z, max.z, is_floating_point<T>() ), 
    107                                 range_impl( min.w, max.w, is_floating_point<T>() ) 
     110                                range_impl( min.z, max.z, is_floating_point<T>() ),
     111                                range_impl( min.w, max.w, is_floating_point<T>() )
    108112                                );
    109113                }
    110114
     115
     116
    111117                vec3 unit_vec3( bool = false )
    112118                {
    113119                        return precise_unit_vec3();
    114 //                      return precise ? precise_unit_vec3() : fast_unit_vec3();
     120                        //                      return precise ? precise_unit_vec3() : fast_unit_vec3();
    115121                }
    116122                vec2 unit_vec2( bool = false )
    117123                {
    118124                        return precise_unit_vec2();
    119 //                      return precise ? precise_unit_vec2() : fast_unit_vec2();
     125                        //                      return precise ? precise_unit_vec2() : fast_unit_vec2();
    120126                }
    121127
     
    174180                //vec3 fast_unit_vec3();
    175181                vec3 precise_unit_vec3();
    176        
     182
    177183                vec2 fast_disk_point();
    178184                vec2 precise_disk_point();
     
    203209                vec3 precise_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii );
    204210
    205 
    206         private:
     211        protected:
    207212                static seed_type randomized_seed();
    208213
     
    218223                        return srange( min, max );
    219224                }
     225        };
     226
     227        class random_mersenne : public random_base
     228        {
     229        public:
     230                static constexpr uint32 mersenne_n = 624;
     231                static constexpr uint32 mersenne_m = 397;
     232                static constexpr uint32 mersenne_static_seed = 5489;
     233
     234                explicit random_mersenne( seed_type seed = randomized_seed() );
     235                virtual seed_type set_seed( seed_type seed = 0 );
     236                virtual result_type rand();
    220237        private:
    221238                void mt_init( uint32 seed );
    222239                void mt_update();
    223                 f64 mt_double();
    224240                uint32 mt_uint32();
    225241
    226                 uint32  m_state[ mersenne_n ];
     242                uint32  m_state[mersenne_n];
    227243                uint32* m_next;
    228244                uint32  m_remaining;
    229245                uint32  m_seeded : 1;
    230246                uint32  m_static_system_seed : 1;
    231 
    232                 // temporary solution until we get rid of ::random
    233                 char m_data[16 * 1024];
     247        };
     248
     249        class random_xor128 : public random_base
     250        {
     251        public:
     252                explicit random_xor128( seed_type seed = randomized_seed() );
     253                virtual seed_type set_seed( seed_type seed = 0 );
     254                virtual result_type rand();
     255        private:
     256                uint32  m_state[4]; // xyzw
     257        };
     258
     259
     260        class random : public random_mersenne
     261        {
     262        public:
     263                explicit random( seed_type seed = randomized_seed() ) : random_mersenne( seed ) {};
     264                static random& get();
    234265        };
    235266
  • trunk/nv/core/types.hh

    r487 r503  
    7878                uint32      flags;    //!< flags
    7979                uint32      offset;   //!< offset into parent
    80                 type_field* control;  //!< pointer to field control (in unions)
     80                sint32      control;  //!< index to field control (in unions), -1 otherwise
    8181                sint32      enumidx;  //!< field index (in unions)
    8282        };
     
    9191        {
    9292                type_database*     type_db;     //!< Parent type database
     93                thash64            hash;        //!< type hash
    9394                shash64            name;        //!< Scoped C++ name of the type
    9495                constructor_t      constructor; //!< Pointers to the constructor
     
    9899                vector<type_field> field_list;  //!< Field list
    99100                vector<type_enum>  enum_list;   //!< Enum list
    100                 hash_store< shash64, type_field* > field_names;
    101                 hash_store< shash64, type_enum* > enum_names;
     101                hash_store< shash64, uint32 > field_names;
     102                hash_store< shash64, uint32 > enum_names;
    102103        };
    103104
     
    146147                        type_entry* i_type = new type_entry;
    147148                        i_type->type_db = this;
     149                        i_type->hash = thash64::create< TYPE >();
    148150                        i_type->name = m_names.insert( name );
    149151                        i_type->size = sizeof( TYPE );
     
    151153                        i_type->constructor = raw_construct_object < TYPE >;
    152154                        i_type->destructor  = raw_destroy_object < TYPE >;
    153                         m_index_by_type[ thash64::create< TYPE >() ] = i_type;
     155                        m_index_by_type[ i_type->hash ] = i_type;
    154156                        m_index_by_name[ i_type->name ] = i_type;
    155157                        m_type_list.push_back( i_type );
     
    176178                }
    177179
    178                 string_view resolve_name( shash64 name_hash )
     180                template< typename T >
     181                const type_entry* get_type() const
     182                {
     183                        auto it = m_index_by_type.find( thash64::create< T >() );
     184                        return it != m_index_by_type.end() ? it->second : nullptr;
     185                }
     186
     187                string_view resolve_name( shash64 name_hash ) const
    179188                {
    180189                        return m_names[name_hash];
     190                }
     191
     192                string_view resolve_name( const type_entry* entry ) const
     193                {
     194                        return m_names[entry->name];
    181195                }
    182196
     
    211225                        ( is_pod<field_type>::value ? TF_SIMPLETYPE : 0 );
    212226                f.offset = uint32( offset_of( field ) );
    213                 f.control = nullptr;
     227                f.control = -1;
    214228                f.enumidx = 0;
    215229                m_entry->field_list.push_back( f );
    216                 m_entry->field_names[f.name] = &m_entry->field_list.back();
     230                m_entry->field_names[f.name] = m_entry->field_list.size() - 1;
    217231                return *this;
    218232        }
     
    229243                        ( is_pod<TFIELD>::value ? TF_SIMPLETYPE : 0 );
    230244                f.offset = uint32( offset_of( field ) );
    231                 f.control = nullptr;
     245                f.control = -1;
    232246                f.enumidx = 0;
    233247                m_entry->field_list.push_back( f );
    234                 m_entry->field_names[f.name] = &m_entry->field_list.back();
     248                m_entry->field_names[f.name] = m_entry->field_list.size() - 1;
    235249                return *this;
    236250        }
     
    248262                        ( is_pod<field_type>::value ? TF_SIMPLETYPE : 0 );
    249263                f.offset = uint32( offset_of( field ) );
    250                 f.control = m_entry->field_names[ control_name ];
     264                f.control = sint32( m_entry->field_names[ control_name ] );
    251265                f.enumidx = static_cast< sint32 >( control_value );
    252266                m_entry->field_list.push_back( f );
    253                 m_entry->field_names[f.name] = &m_entry->field_list.back();
     267                m_entry->field_names[f.name] = m_entry->field_list.size() - 1;
    254268                return *this;
    255269        }
     
    266280                        ( is_pod<TFIELD>::value ? TF_SIMPLETYPE : 0 );
    267281                f.offset = uint32( offset_of( field ) );
    268                 f.control = m_entry->field_names[control_name];
     282                f.control = sint32( m_entry->field_names[control_name] );
    269283                f.enumidx = static_cast<sint32>( control_value );
    270284                m_entry->field_list.push_back( f );
    271                 m_entry->field_names[f.name] = &m_entry->field_list.back();
     285                m_entry->field_names[f.name] = m_entry->field_list.size() - 1;
    272286                return *this;
    273287        }
     
    280294                e.value = value;
    281295                m_entry->enum_list.push_back( e );
    282                 m_entry->enum_names[e.name] = &m_entry->enum_list.back();
    283                 return *this;
    284         }
     296                m_entry->enum_names[e.name] = m_entry->enum_list.size() - 1;
     297                return *this;
     298        }
     299
     300        void register_core_types( type_database* db );
    285301
    286302}
  • trunk/nv/gfx/mesh_creator.hh

    r482 r503  
    2424
    2525                // assumes that position and normal is vec3, tangent is vec4
    26                 void transform( float scale, const mat3& r33 );
     26                void transform( const vec3& pos, const mat3& r33, float scale = 1.0f );
     27                // assumes that position and normal is vec3, tangent is vec4
     28                void transform( const vec3& pos, const quat& r, float scale = 1.0f )
     29                {
     30                        transform( pos, mat3_cast(r), scale );
     31                }
     32                // assumes that position and normal is vec3, tangent is vec4
     33                void transform( const nv::transform& tr, float scale = 1.0f )
     34                {
     35                        transform( tr.get_position(), tr.get_orientation(), scale );
     36                }
     37                // assumes that position and normal is vec3, tangent is vec4
     38                void transform( float scale, const mat3& r33 )
     39                {
     40                        // remove this
     41                        transform( vec3(), r33, scale );
     42                }
    2743                // TODO: this could generate normals too
    2844                void generate_tangents();
  • trunk/nv/gl/gl_context.hh

    r502 r503  
    5353                virtual void set_draw_buffer( output_slot slot );
    5454                virtual void set_read_buffer( output_slot slot );
    55                 virtual void blit( framebuffer f, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 );
    56                 virtual void blit( framebuffer from, framebuffer to, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 );
     55                virtual void blit( framebuffer f, buffer_mask mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 );
     56                virtual void blit( framebuffer from, framebuffer to, buffer_mask mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 );
    5757
    5858                virtual void attach( framebuffer f, output_slot slot, texture t, int layer = -1 );
  • trunk/nv/gl/gl_enum.hh

    r499 r503  
    2424
    2525        unsigned int texture_type_to_enum( texture_type type );
    26         unsigned int clear_state_buffers_to_mask( clear_state::buffers_type type );
     26        unsigned int clear_state_buffers_to_mask( buffer_mask type );
    2727        unsigned int depth_state_function_to_enum( depth_test::function_type type );
    2828        unsigned int polygon_mode_fill_to_enum( polygon_mode::fill_type type );
  • trunk/nv/interface/clear_state.hh

    r395 r503  
    5353        };
    5454
     55        enum buffer_mask
     56        {
     57                NO_BUFFER = 0,
     58                COLOR_BUFFER = 1,
     59                DEPTH_BUFFER = 2,
     60                STENCIL_BUFFER = 4,
     61                COLOR_AND_DEPTH_BUFFER = COLOR_BUFFER | DEPTH_BUFFER,
     62                ALL_BUFFERS = COLOR_BUFFER | DEPTH_BUFFER | STENCIL_BUFFER
     63        };
     64
    5565        struct clear_state
    5666        {
    57                 enum buffers_type
    58                 {
    59                         NONE = 0,
    60                         COLOR_BUFFER = 1,
    61                         DEPTH_BUFFER = 2,
    62                         STENCIL_BUFFER = 4,
    63                         COLOR_AND_DEPTH_BUFFER = COLOR_BUFFER | DEPTH_BUFFER,
    64                         ALL = COLOR_BUFFER | DEPTH_BUFFER | STENCIL_BUFFER
    65                 };
    66 
    6767                nv::scissor_test scissor_test;
    6868                nv::color_mask color_mask;
     
    7171                uint32 back_stencil_mask;
    7272
    73                 buffers_type buffers;
     73                buffer_mask buffers;
    7474                vec4 color;
    7575                float depth;
     
    7979                        : scissor_test(), color_mask(), depth_mask( true ),
    8080                          front_stencil_mask( uint32(-1) ), back_stencil_mask( uint32(-1) ),
    81                           buffers( ALL ), color( vec4(0,0,0,1) ), depth( 1.0f ), stencil( 0 ) {}
     81                          buffers( ALL_BUFFERS ), color( vec4(0,0,0,1) ), depth( 1.0f ), stencil( 0 ) {}
    8282        };
    8383
    8484} // namespace nv
    8585
     86NV_RTTI_DECLARE( nv::color_mask )
     87NV_RTTI_DECLARE( nv::scissor_test )
     88NV_RTTI_DECLARE( nv::clear_state )
     89NV_RTTI_DECLARE( nv::buffer_mask )
     90
    8691
    8792#endif // NV_INTERFACE_CLEAR_STATE_HH
  • trunk/nv/interface/context.hh

    r502 r503  
    185185                virtual void set_draw_buffer( output_slot slot ) = 0;
    186186                virtual void set_read_buffer( output_slot slot ) = 0;
    187                 virtual void blit( framebuffer f, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ) = 0;
    188                 virtual void blit( framebuffer from, framebuffer to, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ) = 0;
     187                virtual void blit( framebuffer f, buffer_mask mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ) = 0;
     188                virtual void blit( framebuffer from, framebuffer to, buffer_mask mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ) = 0;
    189189
    190190                virtual void attach( framebuffer f, output_slot slot, texture t, int layer = -1 ) = 0;
  • trunk/nv/interface/render_state.hh

    r492 r503  
    206206} // namespace nv
    207207
     208NV_RTTI_DECLARE( nv::depth_test )
     209NV_RTTI_DECLARE( nv::depth_test::function_type )
     210NV_RTTI_DECLARE( nv::polygon_mode )
     211NV_RTTI_DECLARE( nv::polygon_mode::fill_type )
     212NV_RTTI_DECLARE( nv::blending )
     213NV_RTTI_DECLARE( nv::blending::factor )
     214NV_RTTI_DECLARE( nv::blending::equation )
     215NV_RTTI_DECLARE( nv::stencil_test_face )
     216NV_RTTI_DECLARE( nv::stencil_test_face::operation )
     217NV_RTTI_DECLARE( nv::stencil_test_face::function_type )
     218NV_RTTI_DECLARE( nv::stencil_test )
     219NV_RTTI_DECLARE( nv::culling )
     220NV_RTTI_DECLARE( nv::culling::face_type )
     221NV_RTTI_DECLARE( nv::culling::order_type )
     222NV_RTTI_DECLARE( nv::depth_range )
     223NV_RTTI_DECLARE( nv::render_state )
    208224
    209225#endif // NV_INTERFACE_RENDER_STATE_HH
  • trunk/nv/lua/lua_area.hh

    r452 r503  
    1818        namespace lua
    1919        {
    20                 void register_area( lua_State* L );
     20                void register_area( lua::state* state );
    2121
    2222                template<>
  • trunk/nv/lua/lua_aux.hh

    r395 r503  
    1414        namespace lua
    1515        {
    16                 void register_aux( lua_State* L );
     16                void register_aux( lua::state* state );
    1717        }
    1818}
  • trunk/nv/lua/lua_map_area.hh

    r395 r503  
    2020        namespace lua
    2121        {
    22                 void register_map_area( lua_State* L );
    23                 void register_map_area_interface( lua_State* L, int index );
    24                 void register_map_area_instance( lua_State* L, ref object_index, map_area* area );
     22                void register_map_area( lua::state* state );
     23                void register_map_area_interface( lua::state* state, int index );
     24                void register_map_area_instance( lua::state* state, ref object_index, map_area* area );
    2525
    2626                namespace detail
  • trunk/nv/lua/lua_map_tile.hh

    r395 r503  
    2020        namespace lua
    2121        {
    22                 void register_map_tile( lua_State* L );
     22                void register_map_tile( lua::state* state );
    2323        }
    2424}
  • trunk/nv/lua/lua_math.hh

    r452 r503  
    1010#include <nv/common.hh>
    1111#include <nv/stl/math.hh>
     12#include <nv/lua/lua_state.hh>
    1213#include <nv/lua/lua_values.hh>
    1314
     
    1617        namespace lua
    1718        {
    18                 void register_math( lua_State* L );
     19                void register_math( lua::state* state );
    1920
    2021                template<> struct pass_traits< vec2 >  : metatable_pass_traits< vec2 >  { static const char* metatable() { return "vec2"; } };
  • trunk/nv/lua/lua_state.hh

    r486 r503  
    1313
    1414#include <nv/common.hh>
     15#include <nv/core/types.hh>
    1516#include <nv/stl/flags.hh>
    1617#include <nv/stl/handle.hh>
     
    3435        namespace lua
    3536        {
     37
    3638                class state;
    3739
     40                using lua_rtti_read_function  = bool(*)( state*, const type_entry*, void*, int index );
     41                using lua_rtti_push_function  = void(*)( state*, const type_entry*, void* );
     42               
     43
     44                class type_data
     45                {
     46                        class entry
     47                        {
     48
     49                        };
     50                public:
     51                        explicit type_data( type_database* db ) : m_type_database( db )
     52                        {
     53                                register_standard_types();
     54                        }
     55                        const type_database* get_type_database() const { return m_type_database; }
     56
     57                        template < typename T >
     58                        void insert( lua_rtti_push_function p, lua_rtti_read_function r )
     59                        {
     60                                insert( thash64::create<T>(), p, r );
     61                        }
     62                        void insert( thash64 tid, lua_rtti_push_function p, lua_rtti_read_function r );
     63
     64                        template < typename T >
     65                        lua_rtti_read_function* get_push() const
     66                        {
     67                                return get_read( thash64::create<T>() );
     68                        }
     69
     70                        template < typename T >
     71                        lua_rtti_push_function* get_push() const
     72                        {
     73                                return get_push( thash64::create<T>() );
     74                        }
     75
     76                        const lua_rtti_read_function* get_read( thash64 h ) const
     77                        {
     78                                auto f = m_type_read.find( h );
     79                                return f != m_type_read.end() ? &f->second : nullptr;
     80                        }
     81                        const lua_rtti_push_function* get_push( thash64 h ) const
     82                        {
     83                                auto f = m_type_push.find( h );
     84                                return f != m_type_push.end() ? &f->second : nullptr;
     85                        }
     86                protected:
     87                        void register_standard_types();
     88
     89                        hash_store< thash64, lua_rtti_read_function >  m_type_read;
     90                        hash_store< thash64, lua_rtti_push_function >  m_type_push;
     91                        type_database*                                 m_type_database;
     92                };
     93
    3894                const int ret_multi = -1;
    3995
     
    4197                {
    4298                public:
    43                         state_wrapper( lua_State* a_state, bool a_owner ) : m_state( a_state ), m_owner( a_owner ), m_global( true ) {}
     99                        state_wrapper( lua_State* a_state, type_data* types, bool a_owner ) : m_state( a_state ), m_lua_types( types ), m_owner( a_owner ), m_global( true ) {}
    44100                        virtual ~state_wrapper();
    45101
     
    143199                                register_native_function( detail::object_method_wrapper< C, F, f >, name );
    144200                        }
     201
     202                        const type_data* get_type_data() const { return m_lua_types; }
    145203
    146204                protected:
     
    155213                protected:
    156214                        lua_State* m_state;
     215                        type_data* m_lua_types;
    157216                        bool m_owner;
    158217                        bool m_global;
     
    191250
    192251                public:
    193                         explicit state( bool load_libs = false );
    194                         explicit state( lua_State* state );
     252                        explicit state( bool load_libs = false, type_database* types = nullptr );
     253                        explicit state( lua_State* state, type_database* types = nullptr );
    195254                        bool do_string( string_view code, string_view name, int rvalues = 0 );
    196255                        bool do_file( string_view filename );
     
    279338                        }
    280339
     340                        virtual ~state();
     341
     342                        template < typename T >
     343                        void register_rtti_type( lua_rtti_push_function p, lua_rtti_read_function r )
     344                        {
     345                                register_rtti_type( thash64::create< T >(), p, r );
     346                        }
     347
    281348                private:
     349                        void register_rtti_type( thash64 tid, lua_rtti_push_function p, lua_rtti_read_function r );
    282350                        ref register_handle_component_impl( string_view id, bool empty );
    283351                        void unregister_handle_component_impl( string_view id );
     
    313381                        bool is_boolean( string_view element );
    314382                        bool is_string( string_view element );
     383                        template < typename T >
     384                        bool read( const string_view& element, T& t )
     385                        {
     386                                NV_ASSERT( m_lua_types, "table_guard::read - type database not created!" );
     387                                NV_ASSERT( m_lua_types->get_type_database(), "table_guard::read - type database not set!" );
     388                                const type_entry* entry = m_lua_types->get_type_database()->get_type<T>();
     389                                return read( element, entry, &t );
     390                        }
     391                        bool read( const string_view& element, const type_entry* entry, void* object );
     392
    315393                private:
     394                        state* m_parent;
    316395                        int m_level;
    317396                };
  • trunk/src/core/random.cc

    r487 r503  
    1919#define NV_MT_TWIST(u, v)  ( (NV_MT_MIXBITS(u, v) >> 1) ^ ( (v) & 1UL ? mt_matrix_a : 0UL) )
    2020
    21 void random::mt_init( uint32 seed )
     21nv::random& random::get()
     22{
     23        static random default_rng;
     24        return default_rng;
     25}
     26
     27void random_mersenne::mt_init( uint32 seed )
    2228{
    2329        m_state[0] = static_cast<uint32>( seed & mt_full_mask );
     
    3440
    3541
    36 void random::mt_update()
     42void random_mersenne::mt_update()
    3743{
    3844        uint32 *p = m_state;
     
    5157
    5258
    53 uint32 random::mt_uint32()
     59uint32 random_mersenne::mt_uint32()
    5460{
    5561        uint32 r;
     
    7076}
    7177
    72 random::random( random::seed_type seed /*= 0 */ )
     78random_mersenne::random_mersenne( random_mersenne::seed_type seed /*= 0 */ )
    7379        : m_next( nullptr ), m_remaining( 0 ), m_seeded( 0 )
    7480{
    75         mt_init( seed == 0 ? randomized_seed() : seed );
    76 }
    77 
    78 random::seed_type random::set_seed( random::seed_type seed /*= 0 */ )
    79 {
    80         if ( seed == 0 ) seed = randomized_seed();
     81        mt_init( seed );
     82}
     83
     84random_mersenne::seed_type random_mersenne::set_seed( random_mersenne::seed_type seed /*= 0 */ )
     85{
    8186        mt_init( seed );
    8287        return seed;
    8388}
    8489
    85 nv::random& random::get()
    86 {
    87         static random default_rng;
    88         return default_rng;
    89 }
    90 
    91 random::result_type random::rand()
     90random_mersenne::result_type random_mersenne::rand()
    9291{
    9392        return mt_uint32();
    9493}
    9594
    96 uint32 random::urand( uint32 val )
    97 {
    98         uint32 x, max = mt_full_mask - ( mt_full_mask % val );
    99         while ( ( x = rand() ) >= max );
    100         return x / ( max / val );
    101 }
    102 
    103 random::seed_type random::randomized_seed()
     95random_base::seed_type random_base::randomized_seed()
    10496{
    10597        // TODO: this seems off, as it might often seed the same, use general time
     
    108100}
    109101
    110 nv::vec2 nv::random::precise_unit_vec2()
     102nv::vec2 nv::random_base::precise_unit_vec2()
    111103{
    112104        f32 angle = frand( math::pi<f32>() * 2.f );
     
    114106}
    115107
    116 nv::vec3 nv::random::precise_unit_vec3()
     108nv::vec3 nv::random_base::precise_unit_vec3()
    117109{
    118110        f32 cos_theta = frange( -1.0f, 1.0f );
     
    126118}
    127119
    128 nv::vec2 nv::random::fast_disk_point()
     120nv::vec2 nv::random_base::fast_disk_point()
    129121{
    130122        f32 r1 = frand();
     
    135127}
    136128
    137 nv::vec2 nv::random::precise_disk_point()
     129nv::vec2 nv::random_base::precise_disk_point()
    138130{
    139131        f32 r = sqrt( frand() );
     
    142134}
    143135
    144 nv::vec3 nv::random::fast_sphere_point()
     136nv::vec3 nv::random_base::fast_sphere_point()
    145137{
    146138        f32 rad     = frand();
     
    156148}
    157149
    158 nv::vec3 nv::random::precise_sphere_point()
     150nv::vec3 nv::random_base::precise_sphere_point()
    159151{
    160152        f32 radius = pow( frand(), 1.f/3.f );
     
    169161}
    170162
    171 nv::vec2 nv::random::precise_ellipse_point( const vec2& radii )
     163nv::vec2 nv::random_base::precise_ellipse_point( const vec2& radii )
    172164{
    173165        vec2 p = range( -radii, radii );
     
    184176}
    185177
    186 nv::vec3 nv::random::precise_ellipsoid_point( const vec3& radii )
     178nv::vec3 nv::random_base::precise_ellipsoid_point( const vec3& radii )
    187179{
    188180        vec3 p = range( -radii, radii );
     
    199191}
    200192
    201 nv::vec2 nv::random::fast_hollow_disk_point( f32 iradius, f32 oradius )
     193nv::vec2 nv::random_base::fast_hollow_disk_point( f32 iradius, f32 oradius )
    202194{
    203195        f32 idist2 = iradius * iradius;
     
    207199}
    208200
    209 nv::vec2 nv::random::precise_hollow_disk_point( f32 iradius, f32 oradius )
     201nv::vec2 nv::random_base::precise_hollow_disk_point( f32 iradius, f32 oradius )
    210202{
    211203        return fast_hollow_disk_point( iradius, oradius );
    212204}
    213205
    214 nv::vec3 nv::random::fast_hollow_sphere_point( f32 iradius, f32 oradius )
     206nv::vec3 nv::random_base::fast_hollow_sphere_point( f32 iradius, f32 oradius )
    215207{
    216208        f32 idist3 = iradius * iradius * iradius;
     
    220212}
    221213
    222 nv::vec3 nv::random::precise_hollow_sphere_point( f32 iradius, f32 oradius )
     214nv::vec3 nv::random_base::precise_hollow_sphere_point( f32 iradius, f32 oradius )
    223215{
    224216        return fast_hollow_sphere_point( iradius, oradius );
     
    226218
    227219
    228 nv::vec2 nv::random::fast_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
     220nv::vec2 nv::random_base::fast_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
    229221{
    230222        vec2 iradii2 = iradii * iradii;
     
    241233}
    242234
    243 nv::vec2 nv::random::precise_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
     235nv::vec2 nv::random_base::precise_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
    244236{
    245237        return fast_hollow_ellipse_point( iradii, oradii );
    246238}
    247239
    248 nv::vec3 nv::random::fast_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
     240nv::vec3 nv::random_base::fast_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
    249241{
    250242        vec3 iradii2 = iradii * iradii;
     
    267259}
    268260
    269 nv::vec3 nv::random::precise_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
     261nv::vec3 nv::random_base::precise_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
    270262{
    271263        return fast_hollow_ellipsoid_point( iradii, oradii );
    272264}
    273265
     266nv::random_xor128::random_xor128( seed_type seed /*= randomized_seed() */ )
     267{
     268        set_seed( seed );
     269}
     270
     271nv::random_base::seed_type nv::random_xor128::set_seed( seed_type seed /*= 0 */ )
     272{
     273        uint32 s = 4294967296 - seed;
     274        m_state[0] = 123456789 * s;
     275        m_state[1] = 362436069 * s;
     276        m_state[2] = 521288629 * s;
     277        m_state[3] = 88675123 * s;
     278        return seed;
     279}
     280
     281nv::random_base::result_type nv::random_xor128::rand()
     282{
     283        uint32 t = m_state[0];
     284        t ^= t << 11;
     285        t ^= t >> 8;
     286        m_state[0] = m_state[1]; m_state[1] = m_state[2]; m_state[2] = m_state[3];
     287        m_state[3] ^= m_state[3] >> 19;
     288        m_state[3] ^= t;
     289        return m_state[3];
     290}
  • trunk/src/gfx/mesh_creator.cc

    r491 r503  
    8888
    8989
    90 void nv::mesh_data_creator::transform( float scale, const mat3& r33 )
    91 {
    92         vec3 vertex_offset     = vec3();
    93         mat3 vertex_transform  = scale * r33;
    94         mat3 normal_transform  = r33;
     90void nv::mesh_data_creator::transform( const vec3& pos, const mat3& r33, float scale /*= 1.0f */ )
     91{
     92        vec3 vertex_offset = pos;
     93        mat3 vertex_transform = scale * r33;
     94        mat3 normal_transform = r33;
    9595
    9696        for ( uint32 c = 0; c < m_data->size(); ++c )
    9797        {
    9898                raw_data_channel_access channel( m_data, c );
    99                 const data_descriptor&  desc    = channel.descriptor();
     99                const data_descriptor&  desc = channel.descriptor();
    100100                uint8* raw_data = channel.raw_data();
    101101                uint32 vtx_size = desc.element_size();
     
    103103                int n_offset = -1;
    104104                int t_offset = -1;
    105                 for ( const auto& cslot : desc  )
     105                for ( const auto& cslot : desc )
    106106                        switch ( cslot.vslot )
    107107                        {
    108                                 case slot::POSITION : if ( cslot.etype == FLOAT_VECTOR_3 ) p_offset = int( cslot.offset ); break;
    109                                 case slot::NORMAL   : if ( cslot.etype == FLOAT_VECTOR_3 ) n_offset = int( cslot.offset ); break;
    110                                 case slot::TANGENT  : if ( cslot.etype == FLOAT_VECTOR_4 ) t_offset = int( cslot.offset ); break;
    111                                 default             : break;
     108                        case slot::POSITION: if ( cslot.etype == FLOAT_VECTOR_3 ) p_offset = int( cslot.offset ); break;
     109                        case slot::NORMAL: if ( cslot.etype == FLOAT_VECTOR_3 ) n_offset = int( cslot.offset ); break;
     110                        case slot::TANGENT: if ( cslot.etype == FLOAT_VECTOR_4 ) t_offset = int( cslot.offset ); break;
     111                        default: break;
    112112                        }
    113113
    114114                if ( p_offset != -1 )
    115                         for ( uint32 i = 0; i < channel.size(); i++)
     115                        for ( uint32 i = 0; i < channel.size(); i++ )
    116116                        {
    117117                                vec3& p = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + p_offset );
     
    120120
    121121                if ( n_offset != -1 )
    122                         for ( uint32 i = 0; i < channel.size(); i++)
     122                        for ( uint32 i = 0; i < channel.size(); i++ )
    123123                        {
    124124                                vec3& n = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + n_offset );
     
    126126                        }
    127127                if ( t_offset != -1 )
    128                         for ( uint32 i = 0; i < channel.size(); i++)
    129                         {
    130                                 vec4& t = *reinterpret_cast<vec4*>(raw_data + vtx_size*i + t_offset );
    131                                 t = vec4( math::normalize( normal_transform * vec3(t) ), t[3] );
    132                         }
    133         }
    134 }
     128                        for ( uint32 i = 0; i < channel.size(); i++ )
     129                        {
     130                                vec4& t = *reinterpret_cast<vec4*>( raw_data + vtx_size*i + t_offset );
     131                                t = vec4( math::normalize( normal_transform * vec3( t ) ), t[3] );
     132                        }
     133        }
     134}
     135
    135136
    136137struct vertex_g
  • trunk/src/gl/gl_context.cc

    r502 r503  
    201201}
    202202
    203 void nv::gl_context::blit( framebuffer f, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 )
     203void nv::gl_context::blit( framebuffer f, buffer_mask mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 )
    204204{
    205205        gl_framebuffer_info* info  = m_framebuffers.get( f );
     
    207207        {
    208208                glBindFramebuffer( GL_FRAMEBUFFER, info->glid );
    209                 unsigned filter = mask == clear_state::COLOR_BUFFER ? GL_LINEAR : GL_NEAREST;
     209                unsigned filter = mask == buffer_mask::COLOR_BUFFER ? GL_LINEAR : GL_NEAREST;
    210210                glBlitFramebuffer( src1.x, src1.y, src2.x, src2.y, dst1.x, dst1.y, dst2.x, dst2.y, clear_state_buffers_to_mask( mask ), filter );
    211211        }
     
    213213
    214214
    215 void nv::gl_context::blit( framebuffer from, framebuffer to, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 )
     215void nv::gl_context::blit( framebuffer from, framebuffer to, buffer_mask mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 )
    216216{
    217217        gl_framebuffer_info* finfo = m_framebuffers.get( from );
     
    221221                glBindFramebuffer( GL_READ_FRAMEBUFFER, finfo->glid );
    222222                glBindFramebuffer( GL_DRAW_FRAMEBUFFER, tinfo ? tinfo->glid : 0 );
    223                 unsigned filter = mask == clear_state::COLOR_BUFFER ? GL_LINEAR : GL_NEAREST;
     223                unsigned filter = mask == buffer_mask::COLOR_BUFFER ? GL_LINEAR : GL_NEAREST;
    224224                glBlitFramebuffer( src1.x, src1.y, src2.x, src2.y, dst1.x, dst1.y, dst2.x, dst2.y, clear_state_buffers_to_mask( mask ), filter );
    225225                glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
  • trunk/src/gl/gl_enum.cc

    r500 r503  
    2828}
    2929
    30 unsigned int nv::clear_state_buffers_to_mask( clear_state::buffers_type type )
     30unsigned int nv::clear_state_buffers_to_mask( buffer_mask type )
    3131{
    3232        unsigned int mask = 0;
    33         if ( (type & clear_state::COLOR_BUFFER) != 0 )   mask |= GL_COLOR_BUFFER_BIT;
    34         if ( (type & clear_state::DEPTH_BUFFER) != 0 )   mask |= GL_DEPTH_BUFFER_BIT;
    35         if ( (type & clear_state::STENCIL_BUFFER) != 0 ) mask |= GL_STENCIL_BUFFER_BIT;
     33        if ( (type & buffer_mask::COLOR_BUFFER) != 0 )   mask |= GL_COLOR_BUFFER_BIT;
     34        if ( (type & buffer_mask::DEPTH_BUFFER) != 0 )   mask |= GL_DEPTH_BUFFER_BIT;
     35        if ( (type & buffer_mask::STENCIL_BUFFER) != 0 ) mask |= GL_STENCIL_BUFFER_BIT;
    3636        return mask;
    3737}
  • trunk/src/lua/lua_area.cc

    r491 r503  
    459459}
    460460
    461 void nv::lua::register_area( lua_State* L )
    462 {
    463         int stack = lua_gettop( L );
    464         nlua_requiref(L, "area", luaopen_area, 1);
    465         lua_settop( L, stack );
    466 }
    467 
     461void nv::lua::register_area( lua::state* state )
     462{
     463        int stack = lua_gettop( state->get_raw() );
     464        nlua_requiref( state->get_raw(), "area", luaopen_area, 1);
     465        lua_settop( state->get_raw(), stack );
     466}
     467
  • trunk/src/lua/lua_aux.cc

    r490 r503  
    137137};
    138138
    139 void nv::lua::register_aux( lua_State* L )
     139void nv::lua::register_aux( lua::state* state )
    140140{
    141         nlua_register( L, "table", nluaaux_table_aux_f );
    142         nlua_register( L, "math", nluaaux_math_aux_f );
     141        nlua_register( state->get_raw(), "table", nluaaux_table_aux_f );
     142        nlua_register( state->get_raw(), "math", nluaaux_math_aux_f );
    143143}
    144144
  • trunk/src/lua/lua_map_area.cc

    r490 r503  
    223223}
    224224
    225 void nv::lua::register_map_area_interface( lua_State* L, int index )
    226 {
    227         nlua_register( L, nlua_map_area_f, index );
    228 }
    229 
    230 void nv::lua::register_map_area( lua_State* L )
    231 {
    232         luaopen_map_area(L);
    233 }
    234 
    235 void nv::lua::register_map_area_instance( lua_State* L, ref object_index, map_area* area )
    236 {
     225void nv::lua::register_map_area_interface( lua::state* state, int index )
     226{
     227        nlua_register( state->get_raw(), nlua_map_area_f, index );
     228}
     229
     230void nv::lua::register_map_area( lua::state* state )
     231{
     232        luaopen_map_area( state->get_raw() );
     233}
     234
     235void nv::lua::register_map_area_instance( lua::state* state, ref object_index, map_area* area )
     236{
     237        lua_State* L = state->get_raw();
    237238        lua_rawgeti( L, LUA_REGISTRYINDEX, object_index.get() );
    238239        lua_pushliteral( L, "__map_area_ptr" );
  • trunk/src/lua/lua_map_tile.cc

    r490 r503  
    366366};
    367367
    368 void nv::lua::register_map_tile( lua_State * L )
     368void nv::lua::register_map_tile( lua::state* state )
    369369{
    370370        // TODO: check if __gc is used!
     371        lua_State* L = state->get_raw();
    371372        luaL_newmetatable( L, NLUA_MAP_TILE_METATABLE );
    372373        lua_pushvalue( L, -1 );
  • 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
  • trunk/src/lua/lua_state.cc

    r490 r503  
    99#include "nv/lua/lua_raw.hh"
    1010#include "nv/lua/lua_nova.hh"
     11#include "nv/lua/lua_types.hh"
    1112#include "nv/core/logging.hh"
    1213#include "nv/stl/string.hh"
     
    143144
    144145lua::table_guard::table_guard( lua::state* lstate, const path& p, bool global )
    145         : state_wrapper( lstate->get_raw(), false ), m_level(0)
     146        : state_wrapper( lstate->get_raw(), lstate->m_lua_types, false ), m_parent( lstate ), m_level(0)
    146147{
    147148        m_global = false;
     
    155156
    156157lua::table_guard::table_guard( const table_guard& parent, const path& p )
    157         : state_wrapper( parent.m_state, false ), m_level(0)
     158        : state_wrapper( parent.m_state, parent.m_lua_types, false ), m_parent( parent.m_parent ), m_level(0)
    158159{
    159160        m_global = false;
     
    350351
    351352
     353bool nv::lua::table_guard::read( const string_view& element, const type_entry* entry, void* object )
     354{
     355        NV_ASSERT_ALWAYS( m_lua_types->get_type_database() == entry->type_db, "Type database mismatch between Lua and entry!" );
     356        lua_getfield( m_state, -1, element.data() );
     357        if ( lua_type( m_state, -1 ) != LUA_TTABLE )
     358        {
     359                lua_pop( m_state, 1 );
     360                return false;
     361        }
     362        if ( !nv::lua::read_rtti_type( m_parent, entry, object, -1 ) )
     363        {
     364                lua_pop( m_state, 1 );
     365                return false;
     366        }
     367        lua_pop( m_state, 1 );
     368        return true;
     369}
     370
    352371// state
    353372
    354 lua::state::state( lua_State* state ) : state_wrapper( state, false )
    355 {
    356 
    357 }
    358 
    359 lua::state::state( bool load_libs /*= false*/ ) : state_wrapper( nullptr, true )
     373lua::state::state( lua_State* state, type_database* types )
     374        : state_wrapper( state, new type_data( types ), false )
     375{
     376
     377}
     378
     379lua::state::state( bool load_libs /*= false*/, type_database* types )
     380        : state_wrapper( nullptr, new type_data( types ), true )
    360381{
    361382        load_lua_library();
     
    575596}
    576597
     598void nv::lua::state::register_rtti_type( thash64 tid, lua_rtti_push_function p, lua_rtti_read_function r )
     599{
     600        m_lua_types->insert( tid, p, r );
     601}
     602
    577603nv::lua::ref nv::lua::state::register_handle_component_impl( string_view id, bool empty )
    578604{
     
    626652}
    627653
     654nv::lua::state::~state()
     655{
     656        delete m_lua_types;
     657        m_lua_types = nullptr;
     658}
     659
     660template < typename T >
     661void nlua_rtti_signed_push( nv::lua::state* state, const type_entry*, void* object )
     662{
     663        T* value = reinterpret_cast<T*>( object );
     664        lua_pushinteger( state->get_raw(), lua_Integer( *value ) );
     665}
     666
     667template < typename T >
     668void nlua_rtti_unsigned_push( nv::lua::state* state, const type_entry*, void* object )
     669{
     670        T* value = reinterpret_cast<T*>( object );
     671        lua_pushinteger( state->get_raw(), lua_Unsigned( *value ) );
     672}
     673
     674template < typename T >
     675void nlua_rtti_floating_push( nv::lua::state* state, const type_entry*, void* object )
     676{
     677        T* value = reinterpret_cast< T* >( object );
     678        lua_pushnumber( state->get_raw(), lua_Number( *value ) );
     679}
     680
     681static void nlua_rtti_boolean_push( nv::lua::state* state, const type_entry*, void* object )
     682{
     683        bool* value = reinterpret_cast<bool*>( object );
     684        lua_pushboolean( state->get_raw(), *value );
     685}
     686
     687template < typename T >
     688bool nlua_rtti_signed_read( nv::lua::state* state, const type_entry*, void* object, int index )
     689{
     690        T* value = reinterpret_cast<T*>( object );
     691        if ( lua_type( state->get_raw(), index ) == LUA_TNUMBER )
     692        {
     693                *value = T( lua_tointeger( state->get_raw(), index ) );
     694                return true;
     695        }
     696        return false;
     697}
     698
     699template < typename T >
     700bool nlua_rtti_unsigned_read( nv::lua::state* state, const type_entry*, void* object, int index )
     701{
     702        T* value = reinterpret_cast<T*>( object );
     703        if ( lua_type( state->get_raw(), index ) == LUA_TNUMBER )
     704        {
     705                *value = T( lua_tointeger( state->get_raw(), index ) );
     706                return true;
     707        }
     708        return false;
     709}
     710
     711template < typename T >
     712bool nlua_rtti_floating_read( nv::lua::state* state, const type_entry*, void* object, int index )
     713{
     714        T* value = reinterpret_cast<T*>( object );
     715        if ( lua_type( state->get_raw(), index ) == LUA_TNUMBER )
     716        {
     717                *value = T( lua_tonumber( state->get_raw(), index ) );
     718                return true;
     719        }
     720        return false;
     721}
     722
     723static bool nlua_rtti_boolean_read( nv::lua::state* state, const type_entry*, void* object, int index )
     724{
     725        bool* value = reinterpret_cast<bool*>( object );
     726        if ( lua_type( state->get_raw(), index ) == LUA_TBOOLEAN )
     727        {
     728                *value = bool( lua_toboolean( state->get_raw(), index ) );
     729                return true;
     730        }
     731        return false;
     732}
     733
     734
     735void nv::lua::type_data::insert( thash64 tid, lua_rtti_push_function p, lua_rtti_read_function r )
     736{
     737        m_type_read.assign( tid, r );
     738        m_type_push.assign( tid, p );
     739}
     740
     741void nv::lua::type_data::register_standard_types()
     742{
     743        insert<bool>( nlua_rtti_boolean_push, nlua_rtti_boolean_read );
     744        insert<nv::sint8> ( nlua_rtti_signed_push<nv::sint8>,    nlua_rtti_signed_read<nv::sint8> );
     745        insert<nv::sint16>( nlua_rtti_signed_push<nv::sint16>,   nlua_rtti_signed_read<nv::sint16> );
     746        insert<nv::sint32>( nlua_rtti_signed_push<nv::sint32>,   nlua_rtti_signed_read<nv::sint32> );
     747        insert<nv::uint8> ( nlua_rtti_unsigned_push<nv::uint8>,  nlua_rtti_unsigned_read<nv::uint8> );
     748        insert<nv::uint16>( nlua_rtti_unsigned_push<nv::uint16>, nlua_rtti_unsigned_read<nv::uint16> );
     749        insert<nv::uint32>( nlua_rtti_unsigned_push<nv::uint32>, nlua_rtti_unsigned_read<nv::uint32> );
     750        insert<nv::f32>   ( nlua_rtti_floating_push<nv::f32>,    nlua_rtti_floating_read<nv::f32> );
     751        insert<nv::f64>   ( nlua_rtti_floating_push<nv::f64>,    nlua_rtti_floating_read<nv::f64> );
     752//      insert<nv::sint64>( nlua_rtti_floating_push<nv::sint64>, nlua_rtti_floating_read<nv::sint64> );
     753//      insert<nv::uint64>( nlua_rtti_floating_push<nv::uint64>, nlua_rtti_floating_read<nv::uint64> );
     754}
Note: See TracChangeset for help on using the changeset viewer.