Ignore:
Timestamp:
10/03/16 17:45:46 (9 years ago)
Author:
epyon
Message:
  • ecs updates
  • animation updates
  • ragdoll manager
  • lua has own random engine
  • several minor fixes
  • particle engine/particle group
  • shitload of other stuff
  • bullet world
File:
1 edited

Legend:

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

    r503 r520  
    99#include "nv/lua/lua_raw.hh"
    1010#include "nv/core/random.hh"
     11
     12static nv::random lua_rng;
    1113
    1214static int nluaaux_table_copy( lua_State* L )
     
    9496        if ( dice < 1 )  luaL_argerror( L, 1, "die count lower than 1!" );
    9597        if ( sides < 1 ) luaL_argerror( L, 2, "side count lower than 1!" );
    96         lua_pushnumber( L, nv::random::get().dice( static_cast< nv::uint32 >( dice ), static_cast< nv::uint32 >( sides ) ) );
     98        lua_pushnumber( L, lua_rng.dice( static_cast< nv::uint32 >( dice ), static_cast< nv::uint32 >( sides ) ) );
    9799        return 1;
    98100}
     
    102104        if ( lua_gettop( L ) == 0 )
    103105        {
    104                 lua_pushnumber( L, nv::random::get().frand(1.0f) );
     106                lua_pushnumber( L, lua_rng.frand(1.0f) );
    105107        }
    106108        else
     
    110112                        lua_Integer arg1 = luaL_checkinteger( L, 1 );
    111113                        if ( arg1 < 1 ) arg1 = 1;
    112                         nlua_pushunsigned( L, nv::random::get().urange( 1, static_cast<nv::uint32>( arg1 ) ) );
     114                        nlua_pushunsigned( L, lua_rng.urange( 1, static_cast<nv::uint32>( arg1 ) ) );
    113115                }
    114116                else
     
    116118                        int arg1 = static_cast< int >( luaL_checkinteger( L, 1 ) );
    117119                        int arg2 = static_cast< int >( luaL_checkinteger( L, 2 ) );
    118                         int result = ( arg2 >= arg1 ? nv::random::get().srange( arg1, arg2 ) : nv::random::get().srange( arg2, arg1 ) );
     120                        int result = ( arg2 >= arg1 ? lua_rng.srange( arg1, arg2 ) : lua_rng.srange( arg2, arg1 ) );
    119121                        lua_pushinteger( L, result );
    120122                }
     
    125127static int nluaaux_math_randomseed( lua_State* L )
    126128{
    127         nv::random::get().set_seed( nlua_tounsigned( L, 1 ) );
     129        lua_rng.set_seed( nlua_tounsigned( L, 1 ) );
    128130        return 0;
    129131}
     
    137139};
    138140
     141nv::random & nv::lua::rng()
     142{
     143        return lua_rng;
     144}
     145
    139146void nv::lua::register_aux( lua::state* state )
    140147{
Note: See TracChangeset for help on using the changeset viewer.