Changeset 471


Ignore:
Timestamp:
09/21/15 19:13:26 (10 years ago)
Author:
epyon
Message:
  • full math library
  • GLM dependency removed
Location:
trunk
Files:
8 added
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv.lua

    r466 r471  
    106106-- injection!
    107107solution( solution().name )
    108         configuration "*"
    109                 includedirs { os.getenv("GLM_PATH") }
    110108        configuration "gmake"
    111109                if _ACTION == "gmake-clang" then
  • trunk/nv/base/capi.hh

    r442 r471  
    102102        inline void* nvmemcpy( void *dest, const void *src, size_t count )
    103103        {
     104                if ( dest == src || count == 0 ) return dest;
    104105                NV_ASSERT( dest && src, "Bad parameter to nvmemcpy!" );
    105                 if ( dest == src ) return dest;
    106106                return NV_CAPI_CALL( memcpy )( dest, src, count );
    107107        }
     
    109109        inline void* nvmemmove( void *dest, const void *src, size_t count )
    110110        {
     111                if ( dest == src || count == 0 ) return dest;
    111112                NV_ASSERT( dest && src, "Bad parameter to nvmemmove!" );
    112                 if ( dest == src ) return dest;
    113113                return NV_CAPI_CALL( memmove )( dest, src, count );
    114114        }
  • trunk/nv/base/cmath.hh

    r451 r471  
    1919
    2020#include <nv/base/common.hh>
    21 
    2221#include <math.h>
    2322
     23namespace nv
     24{
     25
     26        namespace detail
     27        {
     28                template< typename T >
     29                inline T pow_int( T x, int y )
     30                {
     31                        unsigned int n = static_cast<unsigned>( y >= 0 ? y : -y );
     32                        for ( T z = static_cast<T>( 1 ); ; x *= x )
     33                        {
     34                                if ( ( n & 1 ) != 0 )
     35                                        z *= x;
     36                                if ( ( n >>= 1 ) == 0 )
     37                                        return ( y < 0 ? static_cast<T>( 1 ) / z : z );
     38                        }
     39                }
     40
     41        }
     42
     43        inline double abs( double x )
     44        {
     45                return ( ::fabs( x ) );
     46        }
     47
     48        inline double pow( double x, int y )
     49        {
     50                return ( detail::pow_int( x, y ) );
     51        }
     52
     53        inline float abs( float x )
     54        {
     55                return ( ::fabsf( x ) );
     56        }
     57
     58        inline float acos( float x )
     59        {
     60                return ( ::acosf( x ) );
     61        }
     62
     63        inline float cosh( float x )
     64        {
     65                return ( ::coshf( x ) );
     66        }
     67
     68        inline float acosh( float x )
     69        {
     70                return ( ::acoshf( x ) );
     71        }
     72
     73        inline float asin( float x )
     74        {
     75                return ( ::asinf( x ) );
     76        }
     77
     78        inline float asinh( float x )
     79        {
     80                return ( ::asinhf( x ) );
     81        }
     82
     83        inline float atan( float x )
     84        {
     85                return ( ::atanf( x ) );
     86        }
     87
     88        inline float atanh( float x )
     89        {
     90                return ( ::atanhf( x ) );
     91        }
     92
     93        inline float atan2( float y, float x )
     94        {
     95                return ( ::atan2f( y, x ) );
     96        }
     97
     98        inline float cbrt( float x )
     99        {
     100                return ( ::cbrtf( x ) );
     101        }
     102
     103        inline float ceil( float x )
     104        {
     105                return ( ::ceilf( x ) );
     106        }
     107
     108        inline float cos( float x )
     109        {
     110                return ( ::cosf( x ) );
     111        }
     112
     113        inline float erf( float x )
     114        {
     115                return ( ::erff( x ) );
     116        }
     117
     118        inline float erfc( float x )
     119        {
     120                return ( ::erfcf( x ) );
     121        }
     122
     123        inline float exp( float x )
     124        {
     125                return ( ::expf( x ) );
     126        }
     127
     128        inline float exp2( float x )
     129        {
     130                return ( ::exp2f( x ) );
     131        }
     132
     133        inline float expm1( float x )
     134        {
     135                return ( ::expm1f( x ) );
     136        }
     137
     138        inline float fabs( float x )
     139        {
     140                return ( ::fabsf( x ) );
     141        }
     142
     143        inline float fdim( float x, float y )
     144        {
     145                return ( ::fdimf( x, y ) );
     146        }
     147
     148        inline float floor( float x )
     149        {
     150                return ( ::floorf( x ) );
     151        }
     152
     153        inline float fma( float x, float y, float z )
     154        {
     155                return ( ::fmaf( x, y, z ) );
     156        }
     157
     158        inline float fmax( float x, float y )
     159        {
     160                return ( ::fmaxf( x, y ) );
     161        }
     162
     163        inline float fmin( float x, float y )
     164        {
     165                return ( ::fminf( x, y ) );
     166        }
     167
     168        inline float fmodf( float x, float y )
     169        {
     170                return ( ::fmodf( x, y ) );
     171        }
     172
     173        inline float frexp( float x, int* y )
     174        {
     175                return ( ::frexpf( x, y ) );
     176        }
     177
     178        inline float hypot( float x, float y )
     179        {
     180                return ( ::hypotf( x, y ) );
     181        }
     182
     183        inline int ilogb( float x )
     184        {
     185                return ( ::ilogbf( x ) );
     186        }
     187
     188        inline float ldexp( float x, int y )
     189        {
     190                return ( ::ldexpf( x, y ) );
     191        }
     192
     193        inline float lgamma( float x )
     194        {
     195                return ( ::lgammaf( x ) );
     196        }
     197
     198        inline long long llrint( float x )
     199        {
     200                return ( ::llrintf( x ) );
     201        }
     202
     203        inline long long llround( float x )
     204        {
     205                return ( ::llroundf( x ) );
     206        }
     207
     208        inline float log( float x )
     209        {
     210                return ( ::logf( x ) );
     211        }
     212
     213        inline float log10( float x )
     214        {
     215                return ( ::log10f( x ) );
     216        }
     217
     218        inline float log1p( float x )
     219        {
     220                return ( ::log1pf( x ) );
     221        }
     222
     223        inline float log2( float x )
     224        {
     225                return ( ::log2f( x ) );
     226        }
     227
     228        inline float logb( float x )
     229        {
     230                return ( ::logbf( x ) );
     231        }
     232
     233        inline long lrint( float x )
     234        {
     235                return ( ::lrintf( x ) );
     236        }
     237
     238        inline long lround( float x )
     239        {
     240                return ( ::lroundf( x ) );
     241        }
     242
     243        inline float modf( float x, float* y )
     244        {
     245                return ( ::modff( x, y ) );
     246        }
     247
     248        inline float pow( float x, float y )
     249        {
     250                return ( ::powf( x, y ) );
     251        }
     252
     253        inline float pow( float x, int y )
     254        {
     255                return ( detail::pow_int( x, y ) );
     256        }
     257
     258        inline float remainder( float x, float y )
     259        {
     260                return ( ::remainderf( x, y ) );
     261        }
     262
     263        inline float rint( float x )
     264        {
     265                return ( ::rintf( x ) );
     266        }
     267
     268        inline float round( float x )
     269        {
     270                return ( ::roundf( x ) );
     271        }
     272
     273        inline float sin( float x )
     274        {
     275                return ( ::sinf( x ) );
     276        }
     277
     278        inline float sinh( float x )
     279        {
     280                return ( ::sinhf( x ) );
     281        }
     282
     283        inline float sqrt( float x )
     284        {
     285                return ( ::sqrtf( x ) );
     286        }
     287
     288        inline float tan( float x )
     289        {
     290                return ( ::tanf( x ) );
     291        }
     292
     293        inline float tanh( float x )
     294        {
     295                return ( ::tanhf( x ) );
     296        }
     297
     298        inline float tgamma( float x )
     299        {
     300                return ( ::tgammaf( x ) );
     301        }
     302
     303        inline float trunc( float x )
     304        {
     305                return ( ::truncf( x ) );
     306        }
     307
     308}
    24309
    25310#endif // NV_BASE_CMATH_HH
  • trunk/nv/base/common.hh

    r450 r471  
    207207#endif
    208208
     209        enum no_init_t
     210        {
     211                no_init
     212        };
     213
    209214        // Typedefs for fixed size types.
    210215        typedef signed   char      sint8;
     
    288293        void set_log_handler( log_handler_t );
    289294
     295        template < typename T >
     296        constexpr size_t size( const T& t )
     297        {
     298                return t.size();
     299        }
     300
     301        template < typename T, size_t N >
     302        constexpr size_t size( const T (&)[N] )
     303        {
     304                return N;
     305        }
     306
     307        template < typename T >
     308        constexpr bool empty( const T& t )
     309        {
     310                return t.empty();
     311        }
     312
     313        template < typename T, size_t N >
     314        constexpr bool empty( const T(&)[N] )
     315        {
     316                return N > 0;
     317        }
     318
     319        template < typename T >
     320        constexpr auto data( T& t ) -> decltype( t.data() )
     321        {
     322                return t.data();
     323        }
     324
     325        template < typename T >
     326        constexpr auto data( const T& t ) -> decltype( t.data() )
     327        {
     328                return t.data();
     329        }
     330
     331        template < typename T, size_t N >
     332        constexpr T* data( T(&array)[N] )
     333        {
     334                return array;
     335        }
     336
     337
    290338} // namespace nv
    291339
  • trunk/nv/interface/animated_mesh.hh

    r470 r471  
    3030                uint32 get_fps() const { return m_fps; }
    3131                // TODO : if loop +1?
    32                 uint32 get_frame_count() const { int todo;  return m_fend - m_fstart; }
     32                uint32 get_frame_count() const { return m_fend - m_fstart; }
    3333                uint32 get_start_frame() const { return m_fstart; }
    3434                uint32 get_end_frame() const  { return m_fend; }
  • trunk/nv/interface/interpolation_raw.hh

    r459 r471  
    5353        {
    5454                quat result;
    55                 memcpy(reinterpret_cast<float*>(&result), data, sizeof(quat));
     55                nvmemcpy(reinterpret_cast<float*>(&result), data, sizeof(quat));
    5656                return result;
    5757        }
  • trunk/nv/stl/math.hh

    r454 r471  
    44// This file is part of Nova libraries.
    55// For conditions of distribution and use, see copying.txt file in root folder.
    6 //
    7 // TODO: https://github.com/cinder/Cinder/commit/56fd3996be207ccca8063bc81648e199930c909d
    86
    97#ifndef NV_STL_MATH_HH
     
    119
    1210#include <nv/stl/math/common.hh>
     11#include <nv/stl/math/vec2.hh>
     12#include <nv/stl/math/vec3.hh>
     13#include <nv/stl/math/vec4.hh>
     14#include <nv/stl/math/mat3.hh>
     15#include <nv/stl/math/mat4.hh>
     16#include <nv/stl/math/mat2.hh>
     17#include <nv/stl/math/mat3.hh>
     18#include <nv/stl/math/mat4.hh>
    1319#include <nv/stl/math/constants.hh>
    1420#include <nv/stl/math/relational.hh>
     
    1622#include <nv/stl/math/geometric.hh>
    1723#include <nv/stl/math/exponential.hh>
     24#include <nv/stl/math/trigonometric.hh>
    1825#include <nv/stl/math/matrix_transform.hh>
    1926#include <nv/stl/math/angle.hh>
    2027#include <nv/stl/math/quaternion.hh>
    21 
     28#include <nv/stl/math/matrix.hh>
    2229#include <nv/stl/math/cast.hh>
    2330
  • trunk/nv/stl/math/angle.hh

    r454 r471  
    167167                        static_assert( is_floating_point<T>::value, "Type expected to be floating point!" );
    168168
    169                         const T result( acos( clamp( dot( a, b ), T( -1 ), T( 1 ) ) ) );
     169                        const T result( nv::acos( clamp( dot( a, b ), T( -1 ), T( 1 ) ) ) );
    170170                        return mix( result, -result, dot( ref, cross( a, b ) ) < T( 0 ) );
    171171                }
  • trunk/nv/stl/math/basic.hh

    r454 r471  
    7777                                inline static T call( const T& a, const T& b, const U& m )
    7878                                {
    79                                         T result( ctor::uninitialize );
    80                                         for ( component_count_t i = 0; i < component_count( a ); ++i )
     79                                        T result( no_init );
     80                                        for ( size_t i = 0; i < nv::size( a ); ++i )
    8181                                                result[i] = m[i] ? b[i] : a[i];
    8282                                        return result;
     
    102102                        };
    103103
    104                         template < typename T, typename U >
    105                         struct sign_helper< T, U, false, true >
     104                        template < typename T, bool IsFloating >
     105                        struct sign_helper< T, T, IsFloating, true >
    106106                        {
    107107                                inline static T call( const T& a )
    108108                                {
    109                                         typedef typename make_unsigned<T>::type UT;
    110                                         typedef typename make_unsigned<U>::type UU;
    111                                         const U shift( static_cast<U>( sizeof( U ) * 8 - 1 ) );
    112                                         const T y( UT( -a ) >> UU( shift ) );
    113                                         return ( a >> shift ) | y;
     109                                        return ( a > T(0) ? T(1) : ( a < T(0) ? T(-1) : T(0) ) );
    114110                                }
    115111                        };
     
    278274                }
    279275
     276                template < typename T, typename enable_if< !is_vec<T>::value >::type* = nullptr >
     277                constexpr T step( T edge, T x )
     278                {
     279                        return mix( static_cast<T>( 1 ), static_cast<T>( 0 ), less_than( x, edge ) );
     280                }
     281
     282                template < typename T, typename enable_if< is_vec<T>::value >::type* = nullptr >
     283                constexpr T step( const T& edge, const T& x )
     284                {
     285                        return mix( static_cast<T>( 1 ), static_cast<T>( 0 ), less_than( x, edge ) );
     286                }
     287
     288                template < typename T, typename enable_if< is_vec<T>::value >::type* = nullptr >
     289                constexpr T step( value_type_t<T> edge, const T& x )
     290                {
     291                        return mix( static_cast<T>( 1 ), static_cast<T>( 0 ), less_than( x, edge ) );
     292                }
     293
     294                template < typename T, typename enable_if< is_floating_point<T>::value >::type* = nullptr >
     295                constexpr T smoothstep( T edge0, T edge1, T x )
     296                {
     297                        T y( clamp( ( x - edge0 ) / ( edge1 - edge0 ), static_cast<T>( 0 ), static_cast<T>( 1 ) ) );
     298                        return y * y * ( static_cast<T>( 3 ) - static_cast<T>( 2 ) * y );
     299                }
     300
     301                template < typename T, typename enable_if< is_fp_vec<T>::value >::type* = nullptr >
     302                constexpr T smoothstep( const T& edge0, const T& edge1, const T& x )
     303                {
     304                        T y( clamp( ( x - edge0 ) / ( edge1 - edge0 ), static_cast<T>( 0 ), static_cast<T>( 1 ) ) );
     305                        return y * y * ( static_cast<T>( 3 ) - static_cast<T>( 2 ) * y );
     306                }
     307
     308                template < typename T, typename enable_if< is_fp_vec<T>::value >::type* = nullptr >
     309                constexpr T smoothstep( value_type_t<T> edge0, value_type_t<T> edge1, const T& x )
     310                {
     311                        T y( clamp( ( x - edge0 ) / ( edge1 - edge0 ), static_cast<T>( 0 ), static_cast<T>( 1 ) ) );
     312                        return y * y * ( static_cast<T>( 3 ) - static_cast<T>( 2 ) * y );
     313                }
     314
    280315        }
    281316}
  • trunk/nv/stl/math/cast.hh

    r451 r471  
    107107        inline math::tvec2<T> make_vec2( const T * const ptr )
    108108        {
    109                 math::tvec2<T> result( math::ctor::uninitialize );
     109                math::tvec2<T> result( no_init );
    110110                nvmemcpy( data_cast( result ), ptr, sizeof( math::tvec2<T> ) );
    111111                return result;
     
    115115        inline math::tvec3<T> make_vec3( const T * const ptr )
    116116        {
    117                 math::tvec3<T> result( math::ctor::uninitialize );
     117                math::tvec3<T> result( no_init );
    118118                nvmemcpy( data_cast( result ), ptr, sizeof( math::tvec3<T> ) );
    119119                return result;
     
    123123        inline math::tvec4<T> make_vec4( const T * const ptr )
    124124        {
    125                 math::tvec4<T> result( math::ctor::uninitialize );
     125                math::tvec4<T> result( no_init );
    126126                nvmemcpy( data_cast( result ), ptr, sizeof( math::tvec4<T> ) );
    127127                return result;
     
    131131        inline math::tmat2<T> make_mat2( const T * const ptr )
    132132        {
    133                 math::tmat2<T> result( math::ctor::uninitialize );
     133                math::tmat2<T> result( no_init );
    134134                nvmemcpy( data_cast( result ), ptr, sizeof( math::tmat2<T> ) );
    135135                return result;
     
    139139        inline math::tmat3<T> make_mat3( const T * const ptr )
    140140        {
    141                 math::tmat3<T> result( math::ctor::uninitialize );
     141                math::tmat3<T> result( no_init );
    142142                nvmemcpy( data_cast( result ), ptr, sizeof( math::tmat3<T> ) );
    143143                return result;
     
    147147        inline math::tmat4<T> make_mat4( const T * const ptr )
    148148        {
    149                 math::tmat4<T> result( math::ctor::uninitialize );
     149                math::tmat4<T> result( no_init );
    150150                nvmemcpy( data_cast( result ), ptr, sizeof( math::tmat4<T> ) );
    151151                return result;
     
    155155        inline math::tquat<T> make_quat( const T * const ptr )
    156156        {
    157                 math::tquat<T> result( math::ctor::uninitialize );
     157                math::tquat<T> result( no_init );
    158158                nvmemcpy( data_cast( result ), ptr, sizeof( math::tquat<T> ) );
    159159                return result;
  • trunk/nv/stl/math/common.hh

    r459 r471  
    2424
    2525#include <nv/base/cmath.hh>
    26 #include <glm/glm.hpp>
    2726
    2827namespace nv
     
    3130        namespace math
    3231        {
    33 
    34                 // TODO: Remove
    35                 using glm::inverse;
    36                 using glm::transpose;
    37 
    38                 using glm::detail::component_count_t;
    39                 using glm::detail::component_count;
    40 
    41                 using glm::ctor;
     32                template < typename T > struct tvec2;
     33                template < typename T > struct tvec3;
     34                template < typename T > struct tvec4;
     35
     36                template < typename T > struct tmat2;
     37                template < typename T > struct tmat3;
     38                template < typename T > struct tmat4;
     39
     40                template < typename T > struct tquat;
     41
     42                namespace detail
     43                {
     44                        template < typename T >
     45                        inline tmat2<T> compute_inverse( const tmat2<T> & );
     46                        template < typename T >
     47                        inline tmat3<T> compute_inverse( const tmat3<T> & );
     48                        template < typename T >
     49                        inline tmat4<T> compute_inverse( const tmat4<T> & );
     50                }
     51
    4252
    4353                using ::cos;
     
    5868                using ::round;
    5969
    60 #if 0
    61                 template < typename T > using tvec2 = ::glm::detail::tvec2<T, glm::precision::highp>;
    62                 template < typename T > using tvec3 = ::glm::detail::tvec3<T, glm::precision::highp>;
    63                 template < typename T > using tvec4 = ::glm::detail::tvec4<T, glm::precision::highp>;
    64                 template < typename T > using tmat2 = ::glm::detail::tmat2x2<T, glm::precision::highp>;
    65                 template < typename T > using tmat3 = ::glm::detail::tmat3x3<T, glm::precision::highp>;
    66                 template < typename T > using tmat4 = ::glm::detail::tmat4x4<T, glm::precision::highp>;
    67 #else
    68                 template < typename T > using tvec2 = ::glm::tvec2<T>;
    69                 template < typename T > using tvec3 = ::glm::tvec3<T>;
    70                 template < typename T > using tvec4 = ::glm::tvec4<T>;
    71                 template < typename T > using tmat2 = ::glm::tmat2x2<T>;
    72                 template < typename T > using tmat3 = ::glm::tmat3x3<T>;
    73                 template < typename T > using tmat4 = ::glm::tmat4x4<T>;
    74 #endif
    75 
    76                 template < typename T > struct is_vec : false_type {};
    77                 template < typename T > struct is_mat : false_type {};
     70                template < typename T > struct is_vec  : false_type {};
     71                template < typename T > struct is_mat  : false_type {};
     72                template < typename T > struct is_quat : false_type {};
    7873
    7974                template < typename T > struct is_fp : is_floating_point< T > {};
    8075                template < typename T > struct is_fp_vec : false_type {};
    8176                template < typename T > struct is_fp_mat : false_type {};
    82 
     77                template < typename T > struct is_fp_quat : false_type {};
    8378                template < typename T > struct is_bool_vec : false_type {};
    8479
     
    8681                template < typename T > struct is_vec < tvec3< T > > : true_type {};
    8782                template < typename T > struct is_vec < tvec4< T > > : true_type {};
     83
    8884                template < typename T > struct is_mat < tmat2< T > > : true_type {};
    8985                template < typename T > struct is_mat < tmat3< T > > : true_type {};
    9086                template < typename T > struct is_mat < tmat4< T > > : true_type {};
    9187
     88                template < typename T > struct is_quat < tquat< T > > : true_type {};
     89
    9290                template < typename T > struct is_fp     < tvec2< T > > : is_floating_point< T > {};
    9391                template < typename T > struct is_fp     < tvec3< T > > : is_floating_point< T > {};
    9492                template < typename T > struct is_fp     < tvec4< T > > : is_floating_point< T > {};
     93
    9594                template < typename T > struct is_fp_vec < tvec2< T > > : is_floating_point< T > {};
    9695                template < typename T > struct is_fp_vec < tvec3< T > > : is_floating_point< T > {};
    9796                template < typename T > struct is_fp_vec < tvec4< T > > : is_floating_point< T > {};
     97
    9898                template < typename T > struct is_fp_mat < tmat2< T > > : is_floating_point< T > {};
    9999                template < typename T > struct is_fp_mat < tmat3< T > > : is_floating_point< T > {};
    100100                template < typename T > struct is_fp_mat < tmat4< T > > : is_floating_point< T > {};
     101
     102                template < typename T > struct is_fp_quat< tquat< T > > : is_floating_point< T > {};
     103
     104                template < typename T > struct is_vec_or_quat : is_vec< T > {};
     105                template < typename T > struct is_vec_or_quat< tquat< T > > : true_type {};
    101106
    102107                template <> struct is_bool_vec < tvec2< bool > > : true_type {};
  • trunk/nv/stl/math/exponential.hh

    r454 r471  
    6868                inline T inversesqrt( const T& x )
    6969                {
    70                         return static_cast<T>( 1 ) / sqrt( x );
     70                        return static_cast<T>( 1 ) / nv::sqrt( x );
    7171                }
    7272
  • trunk/nv/stl/math/geometric.hh

    r469 r471  
    3434                                inline static T get( const tvec2<T>& a, const tvec2<T>& b )
    3535                                {
    36                                         tvec2<T, P> tmp( a * b );
     36                                        tvec2<T> tmp( a * b );
    3737                                        return tmp.x + tmp.y;
    3838                                }
     
    6969                inline value_type_t<T> length( const T& v )
    7070                {
    71                         return sqrt( dot( v, v ) );
     71                        return nv::sqrt( dot( v, v ) );
    7272                }
    7373
  • trunk/nv/stl/math/matrix_transform.hh

    r454 r471  
    3434                {
    3535                        T const a = angle;
    36                         T const c = math::cos( a );
    37                         T const s = math::sin( a );
     36                        T const c = nv::cos( a );
     37                        T const s = nv::sin( a );
    3838
    3939                        tvec3<T> axis( normalize( v ) );
    4040                        tvec3<T> temp( ( T( 1 ) - c ) * axis );
    4141
    42                         tmat4<T> Rotate( ctor::uninitialize );
     42                        tmat4<T> Rotate( no_init );
    4343                        Rotate[0][0] = c + temp[0] * axis[0];
    4444                        Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
     
    5353                        Rotate[2][2] = c + temp[2] * axis[2];
    5454
    55                         tmat4<T> result( ctor::uninitialize );
     55                        tmat4<T> result( no_init );
    5656                        result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
    5757                        result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
     
    6464                inline tmat4<T> scale( const tmat4<T>& m, const tvec3<T>& v )
    6565                {
    66                         tmat4<T> result( ctor::uninitialize );
     66                        tmat4<T> result( no_init );
    6767                        result[0] = m[0] * v[0];
    6868                        result[1] = m[1] * v[1];
     
    134134                        NV_ASSERT( abs( aspect - epsilon<T>() ) > static_cast<T>( 0 ), "bad parameters to math::perspective!" );
    135135
    136                         const T tan_half_fovy = math::tan( fovy / static_cast<T>( 2 ) );
     136                        const T tan_half_fovy = nv::tan( fovy / static_cast<T>( 2 ) );
    137137
    138138                        tmat4<T> result( static_cast<T>( 0 ) );
     
    153153
    154154                        const T rad = fov;
    155                         const T h = math::cos( static_cast<T>( 0.5 ) * rad ) / math::sin( static_cast<T>( 0.5 ) * rad );
     155                        const T h = nv::cos( static_cast<T>( 0.5 ) * rad ) / math::sin( static_cast<T>( 0.5 ) * rad );
    156156                        const T w = h * height / width;
    157157
  • trunk/nv/stl/math/quaternion.hh

    r462 r471  
    1818#include <nv/stl/math/geometric.hh>
    1919#include <nv/stl/math/angle.hh>
     20#include <nv/base/cmath.hh>
    2021
    2122namespace nv
     
    5253                                : x( q.x ), y( q.y ), z( q.z ), w( q.w ) {}
    5354                       
    54                         inline explicit tquat( ctor ) {}
     55                        inline explicit tquat( no_init_t ) {}
    5556                        constexpr explicit tquat( const T& s, const tvec3<T>& v )
    5657                                : x( v.x ), y( v.y ), z( v.z ), w( s ) {}
     
    113114                typedef tquat< f32 > quat;
    114115
    115                 template < typename T > struct is_fp_quat : false_type {};
    116                 template < typename T > struct is_quat : false_type {};
    117 
    118                 template < typename T > struct is_quat< tquat< T > > : true_type {};
    119                 template < typename T > struct is_fp_quat< tquat< T > > : is_floating_point< T > {};
    120 
    121116                namespace detail
    122117                {
     
    192187                        else
    193188                        {
    194                                 T angle = acos( cos_theta );
     189                                T angle = nv::acos( cos_theta );
    195190                                return ( sin( ( T( 1 ) - m ) * angle ) * a + sin( m * angle ) * b ) / sin( angle );
    196191                        }
     
    226221                        else
    227222                        {
    228                                 T angle = acos( cos_theta );
    229                                 return ( sin( ( T( 1 ) - m ) * angle ) * x + sin( m * angle ) * z ) / sin( angle );
     223                                T angle = nv::acos( cos_theta );
     224                                return ( nv::sin( ( T( 1 ) - m ) * angle ) * x + nv::sin( m * angle ) * z ) / nv::sin( angle );
    230225                        }
    231226                }
     
    332327                        }
    333328
    334                         T vmax = sqrt( fmax + T( 1 ) ) * T( 0.5 );
     329                        T vmax = nv::sqrt( fmax + T( 1 ) ) * T( 0.5 );
    335330                        T mult = static_cast<T>( 0.25 ) / vmax;
    336331
    337                         tquat<T> result( ctor::uninitialize );
     332                        tquat<T> result( no_init );
    338333                        switch ( imax )
    339334                        {
     
    392387                inline tquat<T> angle_axis( T angle, const tvec3<T>& v )
    393388                {
    394                         tquat<T> result( ctor::uninitialize );
    395                         T sina = sin( angle * static_cast<T>( 0.5 ) );
    396                         result.w = cos( angle * static_cast<T>( 0.5 ) );
     389                        tquat<T> result( no_init );
     390                        T sina = nv::sin( angle * static_cast<T>( 0.5 ) );
     391                        result.w = nv::cos( angle * static_cast<T>( 0.5 ) );
    397392                        result.x = v.x * sina;
    398393                        result.y = v.y * sina;
     
    402397
    403398                template < typename T >
    404                 inline tvec4<bool> less_than( const tquat<T>& lhs, const tquat<T>& rhs )
    405                 {
    406                         tvec4<bool> result( ctor::uninitialize );
    407                         for ( component_count_t i = 0; i < component_count( x ); ++i )
    408                                 result[i] = rhs[i] < lhs[i];
    409                         return result;
    410                 }
    411 
    412                 template < typename T >
    413                 inline tvec4<bool> less_than_equal( const tquat<T>& lhs, const tquat<T>& rhs )
    414                 {
    415                         tvec4<bool> result( ctor::uninitialize );
    416                         for ( component_count_t i = 0; i < component_count( x ); ++i )
    417                                 result[i] = rhs[i] <= lhs[i];
    418                         return result;
    419                 }
    420 
    421                 template < typename T >
    422                 inline tvec4<bool> greater_than( const tquat<T>& lhs, const tquat<T>& rhs )
    423                 {
    424                         tvec4<bool> result( ctor::uninitialize );
    425                         for ( component_count_t i = 0; i < component_count( x ); ++i )
    426                                 result[i] = rhs[i] > lhs[i];
    427                         return result;
    428                 }
    429 
    430                 template < typename T >
    431                 inline tvec4<bool> greater_than_equal( const tquat<T>& lhs, const tquat<T>& rhs )
    432                 {
    433                         tvec4<bool, P> result( ctor::uninitialize );
    434                         for ( component_count_t i = 0; i < component_count( x ); ++i )
    435                                 result[i] = rhs[i] >= lhs[i];
    436                         return result;
    437                 }
    438 
    439                 template < typename T >
    440                 inline tvec4<bool> equal( const tquat<T>& lhs, const tquat<T>& rhs )
    441                 {
    442                         tvec4<bool, P> result( ctor::uninitialize );
    443                         for ( component_count_t i = 0; i < component_count( x ); ++i )
    444                                 result[i] = rhs[i] == lhs[i];
    445                         return result;
    446                 }
    447 
    448                 template < typename T >
    449                 inline tvec4<bool> not_equal( const tquat<T>& lhs, const tquat<T>& rhs )
    450                 {
    451                         tvec4<bool> result( ctor::uninitialize );
    452                         for ( component_count_t i = 0; i < component_count( x ); ++i )
    453                                 result[i] = rhs[i] != lhs[i];
    454                         return result;
    455                 }
    456 
    457                 template < typename T >
    458399                inline tquat<T>::operator tmat3<T>()
    459400                {
  • trunk/nv/stl/math/relational.hh

    r454 r471  
    4545                        };
    4646
     47                        template < typename T >
     48                        struct make_bool_vec< tquat< T > >
     49                        {
     50                                typedef tvec4< bool > type;
     51                        };
    4752                }
    4853
     
    5055                using bool_vec_t = typename detail::make_bool_vec<T>::type;
    5156
    52                 template < typename T, typename enable_if< is_vec<T>::value >::type* = nullptr >
     57                template < typename T, typename enable_if< is_vec_or_quat<T>::value >::type* = nullptr >
    5358                inline bool_vec_t<T> less_than( const T& lhs, const T& rhs )
    5459                {
    55                         bool_vec_t<T> result( ctor::uninitialize );
    56                         for ( component_count_t i = 0; i < component_count( lhs ); ++i )
     60                        bool_vec_t<T> result( no_init );
     61                        for ( size_t i = 0; i < nv::size( lhs ); ++i )
    5762                                result[i] = lhs[i] < rhs[i];
    5863
     
    6065                }
    6166
    62                 template < typename T, typename enable_if< is_vec<T>::value >::type* = nullptr >
     67                template < typename T, typename enable_if< is_vec_or_quat<T>::value >::type* = nullptr >
    6368                inline bool_vec_t<T> less_than_equal( const T& lhs, const T& rhs )
    6469                {
    65                         bool_vec_t<T> result( ctor::uninitialize );
    66                         for ( component_count_t i = 0; i < component_count( lhs ); ++i )
     70                        bool_vec_t<T> result( no_init );
     71                        for ( size_t i = 0; i < nv::size( lhs ); ++i )
    6772                                result[i] = lhs[i] <= rhs[i];
    6873                        return result;
    6974                }
    7075
    71                 template < typename T, typename enable_if< is_vec<T>::value >::type* = nullptr >
     76                template < typename T, typename enable_if< is_vec_or_quat<T>::value >::type* = nullptr >
    7277                inline bool_vec_t<T> greater_than( const T& lhs, const T& rhs )
    7378                {
    74                         bool_vec_t<T> result( ctor::uninitialize );
    75                         for ( component_count_t i = 0; i < component_count( lhs ); ++i )
     79                        bool_vec_t<T> result( no_init );
     80                        for ( size_t i = 0; i < nv::size( lhs ); ++i )
    7681                                result[i] = lhs[i] > rhs[i];
    7782                        return result;
    7883                }
    7984
    80                 template < typename T, typename enable_if< is_vec<T>::value >::type* = nullptr >
     85                template < typename T, typename enable_if< is_vec_or_quat<T>::value >::type* = nullptr >
    8186                inline bool_vec_t<T> greater_than_equal( const T& lhs, const T& rhs )
    8287                {
    83                         bool_vec_t<T> result( ctor::uninitialize );
    84                         for ( component_count_t i = 0; i < component_count( lhs ); ++i )
     88                        bool_vec_t<T> result( no_init );
     89                        for ( size_t i = 0; i < nv::size( lhs ); ++i )
    8590                                result[i] = lhs[i] >= rhs[i];
    8691                        return result;
    8792                }
    8893
    89                 template < typename T, typename enable_if< is_vec<T>::value >::type* = nullptr >
     94                template < typename T, typename enable_if< is_vec_or_quat<T>::value >::type* = nullptr >
    9095                inline bool_vec_t<T> equal( const T& lhs, const T& rhs )
    9196                {
    92                         bool_vec_t<T> result( ctor::uninitialize );
    93                         for ( component_count_t i = 0; i < component_count( lhs ); ++i )
     97                        bool_vec_t<T> result( no_init );
     98                        for ( size_t i = 0; i < nv::size( lhs ); ++i )
    9499                                result[i] = lhs[i] == rhs[i];
    95100                        return result;
    96101                }
    97102
    98                 template < typename T, typename enable_if< is_vec<T>::value >::type* = nullptr >
     103                template < typename T, typename enable_if< is_vec_or_quat<T>::value >::type* = nullptr >
    99104                inline bool_vec_t<T> not_equal( const T& lhs, const T& rhs )
    100105                {
    101                         bool_vec_t<T> result( ctor::uninitialize );
    102                         for ( component_count_t i = 0; i < component_count( lhs ); ++i )
     106                        bool_vec_t<T> result( no_init );
     107                        for ( size_t i = 0; i < nv::size( lhs ); ++i )
    103108                                result[i] = lhs[i] != rhs[i];
    104109                        return result;
     
    109114                {
    110115                        bool result = false;
    111                         for ( component_count_t i = 0; i < component_count( v ); ++i )
     116                        for ( size_t i = 0; i < nv::size( v ); ++i )
    112117                                result = result || v[i];
    113118                        return result;
     
    118123                {
    119124                        bool result = true;
    120                         for ( component_count_t i = 0; i < component_count( v ); ++i )
     125                        for ( size_t i = 0; i < nv::size( v ); ++i )
    121126                                result = result && v[i];
    122127                        return result;
     
    126131                inline T not_( const T& v )
    127132                {
    128                         T result( ctor::uninitialize );
    129                         for ( component_count_t i = 0; i < component_count( v ); ++i )
     133                        T result( no_init );
     134                        for ( size_t i = 0; i < nv::size( v ); ++i )
    130135                                result[i] = !v[i];
    131136                        return result;
  • trunk/nv/stl/type_erasure.hh

    r460 r471  
    8383                constexpr pointer operator->() const { return reinterpret_cast<pointer>( m_current ); }
    8484
    85                 constexpr const_raw_data_iterator& operator++() { m_current += stride; return *this; }
    86                 constexpr const_raw_data_iterator operator++( int ) { const_raw_data_iterator ri( *this ); m_current += stride; return ri; }
    87                 constexpr const_raw_data_iterator& operator--() { m_current -= stride; return *this; }
    88                 constexpr const_raw_data_iterator operator--( int ) { const_raw_data_iterator ri( *this ); m_current -= stride; return ri; }
     85                inline const_raw_data_iterator& operator++() { m_current += stride; return *this; }
     86                inline const_raw_data_iterator operator++( int ) { const_raw_data_iterator ri( *this ); m_current += stride; return ri; }
     87                inline const_raw_data_iterator& operator--() { m_current -= stride; return *this; }
     88                inline const_raw_data_iterator operator--( int ) { const_raw_data_iterator ri( *this ); m_current -= stride; return ri; }
    8989
    9090                constexpr const_raw_data_iterator operator+( difference_type n ) const { return const_raw_data_iterator( m_current + n * m_stride, m_stride ); }
    91                 constexpr const_raw_data_iterator& operator+=( difference_type n ) { m_current += n * m_stride; return *this; }
     91                inline const_raw_data_iterator& operator+=( difference_type n ) { m_current += n * m_stride; return *this; }
    9292                constexpr const_raw_data_iterator operator-( difference_type n ) const { return const_raw_data_iterator( m_current - n * m_stride, m_stride ); }
    93                 constexpr const_raw_data_iterator& operator-=( difference_type n ) { m_current -= n * m_stride; return *this; }
     93                inline const_raw_data_iterator& operator-=( difference_type n ) { m_current -= n * m_stride; return *this; }
    9494                constexpr reference operator[]( difference_type n ) const { return *reinterpret_cast<pointer>( m_current + n * m_stride ); }
    9595
  • trunk/src/core/random.cc

    r454 r471  
    2121void random::mt_init( uint32 seed )
    2222{
    23         m_state[0] = static_cast<uint32_t>( seed & mt_full_mask );
     23        m_state[0] = static_cast<uint32>( seed & mt_full_mask );
    2424        for ( int i = 1; i < mersenne_n; i++ )
    2525        {
     
    111111{
    112112        f32 angle = frand( math::pi<f32>() * 2.f );
    113         return vec2( math::cos( angle ), math::sin( angle ) );
     113        return vec2( cos( angle ), sin( angle ) );
    114114}
    115115
     
    117117{
    118118        f32 cos_theta = frange( -1.0f, 1.0f );
    119         f32 sin_theta = math::sqrt( 1.0f - cos_theta * cos_theta );
     119        f32 sin_theta = sqrt( 1.0f - cos_theta * cos_theta );
    120120        f32 phi       = frand( 2 * math::pi<f32>() );
    121121        return vec3(
    122                 sin_theta * math::sin(phi),
    123                 sin_theta * math::cos(phi),
     122                sin_theta * sin(phi),
     123                sin_theta * cos(phi),
    124124                cos_theta
    125125                );
     
    132132        if ( r1 > r2 ) swap( r1, r2 );
    133133        f32 rf = 2* math::pi<f32>()*(r1/r2);
    134         return vec2( r2*math::cos( rf ), r2*math::sin( rf ) );
     134        return vec2( r2*cos( rf ), r2*sin( rf ) );
    135135}
    136136
    137137nv::vec2 nv::random::precise_disk_point()
    138138{
    139         f32 r = math::sqrt( frand() );
     139        f32 r = sqrt( frand() );
    140140        f32 rangle = frand( math::pi<f32>() );
    141         return vec2( r*math::cos( rangle ), r*math::sin( rangle ) );
     141        return vec2( r*cos( rangle ), r*sin( rangle ) );
    142142}
    143143
     
    146146        f32 rad     = frand();
    147147        f32 pi      = math::pi<f32>();
    148         f32 phi     = math::asin( frange( -1.0f, 1.0f ) ) + pi*.5f;
     148        f32 phi     = asin( frange( -1.0f, 1.0f ) ) + pi*.5f;
    149149        f32 theta   = frange( 0.0f, 2 * math::pi<f32>() );
    150         f32 sin_phi = math::sin( phi );
     150        f32 sin_phi = sin( phi );
    151151        return vec3(
    152                 rad * math::cos(theta) * sin_phi,
    153                 rad * math::sin(theta) * sin_phi,
    154                 rad * math::cos(phi)
     152                rad * cos(theta) * sin_phi,
     153                rad * sin(theta) * sin_phi,
     154                rad * cos(phi)
    155155        );
    156156}
     
    158158nv::vec3 nv::random::precise_sphere_point()
    159159{
    160         f32 radius = math::pow( frand(), 1.f/3.f );
     160        f32 radius = pow( frand(), 1.f/3.f );
    161161        f32 cos_theta = frange( -1.0f, 1.0f );
    162         f32 sin_theta = math::sqrt( 1.0f - cos_theta * cos_theta );
     162        f32 sin_theta = sqrt( 1.0f - cos_theta * cos_theta );
    163163        f32 phi       = frange( 0.0f, 2 * math::pi<f32>() );
    164164        return vec3(
    165                 radius * sin_theta * math::sin(phi),
    166                 radius * sin_theta * math::cos(phi),
     165                radius * sin_theta * sin(phi),
     166                radius * sin_theta * cos(phi),
    167167                radius * cos_theta
    168168                );
     
    203203        f32 idist2 = iradius * iradius;
    204204        f32 odist2 = oradius * oradius;
    205         f32 rdist  = math::sqrt( frange( idist2, odist2 ) );
     205        f32 rdist  = sqrt( frange( idist2, odist2 ) );
    206206        return rdist * precise_unit_vec2();
    207207}
     
    216216        f32 idist3 = iradius * iradius * iradius;
    217217        f32 odist3 = oradius * oradius * oradius;
    218         f32 rdist  = math::pow( frange( idist3, odist3 ), 1.f/3.f );
     218        f32 rdist  = pow( frange( idist3, odist3 ), 1.f/3.f );
    219219        return rdist * precise_unit_vec3();
    220220}
     
    237237        f32 idist2 = ((iradii2.x * iradii2.y) / low ) * odist2;
    238238
    239         f32 rdist     = math::sqrt( frange( idist2, odist2 ) );
     239        f32 rdist     = sqrt( frange( idist2, odist2 ) );
    240240        return odir * rdist;   
    241241}
     
    260260        f32 idist2 = ((iradii2.x * iradii2.y * iradii2.z) / low ) * odist2;
    261261
    262         f32 odist3 = odist2 * math::sqrt( odist2 );
    263         f32 idist3 = idist2 * math::sqrt( idist2 );
    264 
    265         f32 rdist     = math::pow( frange( idist3, odist3 ), 1.f/3.f );
     262        f32 odist3 = odist2 * sqrt( odist2 );
     263        f32 idist3 = idist2 * sqrt( idist2 );
     264
     265        f32 rdist     = pow( frange( idist3, odist3 ), 1.f/3.f );
    266266        return odir * rdist;   
    267267}
  • trunk/src/engine/particle_engine.cc

    r454 r471  
    231231        datap->plane_normal = normalize_safe( datap->plane_normal, vec3(0.0f,1.0f,0.0f) );
    232232        datap->bounce       = table->get<float>("bounce", 0.0f );
    233         datap->distance     = -math::dot( datap->plane_normal, datap->plane_point ) / math::sqrt( math::dot( datap->plane_normal, datap->plane_normal ) );
     233        datap->distance     = -math::dot( datap->plane_normal, datap->plane_point ) / sqrt( math::dot( datap->plane_normal, datap->plane_normal ) );
    234234        return true;
    235235}
     
    751751                                        {
    752752                                                float emission_angle = math::radians( edata.angle );
    753                                                 float cos_theta = r.frange( math::cos( emission_angle ), 1.0f );
    754                                                 float sin_theta = math::sqrt(1.0f - cos_theta * cos_theta );
     753                                                float cos_theta = r.frange( cos( emission_angle ), 1.0f );
     754                                                float sin_theta = sqrt(1.0f - cos_theta * cos_theta );
    755755                                                float phi       = r.frange( 0.0f, 2* math::pi<float>() );
    756756                                                pinfo.velocity  = orient *
    757                                                         ( edata.odir * ( math::cos(phi) * sin_theta ) +
    758                                                         edata.cdir * ( math::sin(phi)*sin_theta ) +
     757                                                        ( edata.odir * ( cos(phi) * sin_theta ) +
     758                                                        edata.cdir * ( sin(phi)*sin_theta ) +
    759759                                                        edata.dir  * cos_theta );
    760760                                        }
  • trunk/src/formats/assimp_loader.cc

    r470 r471  
    350350
    351351        uint16 frame_rate     = static_cast<uint16>( anim->mTicksPerSecond );
    352         int check_this;
    353352        uint16 duration       = static_cast<uint16>( anim->mDuration );
    354353        bool   flat           = false;
  • trunk/src/formats/md3_loader.cc

    r451 r471  
    246246                {
    247247                        float flat    = lat * convert;
    248                         float sin_lat = math::sin( flat );
    249                         float cos_lat = math::cos( flat );
     248                        float sin_lat = nv::sin( flat );
     249                        float cos_lat = nv::cos( flat );
    250250                        for ( int lng = 0; lng < 256; ++lng, ++n )
    251251                        {
    252252                                float flng    = lng * convert;
    253                                 float sin_lng = math::sin( flng );
    254                                 float cos_lng = math::cos( flng );
     253                                float sin_lng = nv::sin( flng );
     254                                float cos_lng = nv::cos( flng );
    255255                                s_normal_cache[n].x = cos_lat * sin_lng;
    256256//                              s_normal_cache[n].y = sin_lat * sin_lng;
  • trunk/src/gfx/mesh_creator.cc

    r470 r471  
    1717        if ( m_data->m_flat ) return;
    1818        merge_keys();
    19         uint32 max_frames = 0;
     19        uint16 max_frames = 0;
    2020
    2121        nv::vector< sint16 > ids;
     
    6565                size_t count     = ( keys ? keys->get_channel_size(0) : 0 );
    6666                size_t pcount    = ( pkeys ? pkeys->get_channel_size(0) : 0 );
    67                 max_frames = nv::max<uint32>( count, max_frames );
     67                max_frames = nv::max<uint16>( uint16( count ), max_frames );
    6868                if ( pkeys && pkeys->size() > 0 && keys && keys->size() > 0 )
    6969                {
  • trunk/src/gfx/skeletal_mesh.cc

    r470 r471  
    4848{
    4949        float  fframe   = ( a_ms_time * 0.001f ) * m_fps;
    50         uint32 frame    = math::floor( fframe );
     50        uint32 frame    = uint32( math::floor( fframe ) );
    5151        float  reminder = fframe - static_cast<float>( frame );
    5252        uint32 duration = get_frame_count();
  • trunk/src/gfx/texture_atlas.cc

    r398 r471  
    2222        region r ( ivec2(0,0), size );
    2323
    24         int best_height = INT_MAX;
     24        int best_height = nv::limits::si_max;
    2525        int best_index  = -1;
    26         int best_width  = INT_MAX;
     26        int best_width  = nv::limits::si_max;
    2727
    2828        for( size_t i=0; i < m_nodes.size(); ++i )
  • trunk/src/gfx/texture_font.cc

    r438 r471  
    172172                FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING);
    173173                slot = face->glyph;
    174                 g->advance = ivec2( slot->advance.x/64.0f, slot->advance.y/64.0f );
     174                g->advance = vec2( slot->advance.x/64.0f, slot->advance.y/64.0f );
    175175        }
    176176        generate_kerning();
  • trunk/src/gl/gl_device.cc

    r466 r471  
    7676        }
    7777        // TODO: BGR vs RGB, single channel
    78         assert( image->format->BytesPerPixel > 2 );
     78        NV_ASSERT( image->format->BytesPerPixel > 2, "bytes per pixel > 2!" );
    7979        image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
    8080        image_data* idata = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) );
  • trunk/src/gui/gui_gfx_renderer.cc

    r469 r471  
    215215        image_data* data = m_window->get_device()->create_image_data( filename );
    216216        // TODO: Repitching
    217         assert( data->get_depth() == 4 );
     217        NV_ASSERT( data->get_depth() == 4, "depth != 4" );
    218218        region r = m_atlas.get_region( data->get_size() );
    219219        m_atlas.set_region( r, data->get_data() );
     
    327327                                                position p2 = p + g->size + gp;
    328328                                                qvec.emplace_back( p + gp, p2, color, g->tl, g->br );
    329                                                 p += g->advance;
     329                                                p += ivec2( g->advance );
    330330                                        }
    331331                                }
  • trunk/src/lua/lua_math.cc

    r452 r471  
    214214{
    215215        T v = to_vec<T>( L, 1 );
    216         for ( int i = 0; i < v.length(); ++i )
     216        for ( size_t i = 0; i < v.size(); ++i )
    217217        {
    218218                lua_pushnumber( L, v[i] );
    219219        }
    220         return v.length();
     220        return v.size();
    221221}
    222222
     
    226226        T* v = to_pvec<T>( L, 1 );
    227227        size_t len  = 0;
    228         int vlen = v->length();
     228        size_t vlen = v->size();
    229229        const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
    230         int idx = 255;
     230        size_t idx = 255;
    231231
    232232        if ( len == 1 )
     
    264264        T* v = to_pvec<T>( L, 1 );
    265265        size_t len  = 0;
    266         int vlen = v->length();
     266        size_t vlen = v->size();
    267267        const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
    268         int idx = 255;
     268        size_t idx = 255;
    269269        if( len == 1 )
    270270        {
     
    293293        T v = to_vec<T>( L, 1 );
    294294        bool fl = nv::is_floating_point<typename T::value_type>::value;
    295         switch ( v.length() )
     295        switch ( v.size() )
    296296        {
    297297        case 1: lua_pushfstring( L, ( fl ? "(%f)"          : "(%d)" ),          v[0] ); break;
Note: See TracChangeset for help on using the changeset viewer.