Changeset 522 for trunk


Ignore:
Timestamp:
10/14/16 18:17:17 (9 years ago)
Author:
epyon
Message:
  • updates lol
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/engine/particle_engine.hh

    r520 r522  
    1313#include <nv/stl/unordered_map.hh>
    1414#include <nv/stl/handle.hh>
     15#include <nv/stl/functional/function.hh>
    1516#include <nv/lua/lua_state.hh>
    1617#include <nv/gfx/texture_atlas.hh>
     
    1920#include <nv/interface/scene_node.hh>
    2021#include <nv/interface/context.hh>
     22#include <nv/interface/physics_world.hh>
    2123#include <nv/engine/particle_group.hh>
    2224
     
    8486        struct particle_system_data : particle_group_settings
    8587        {
    86                 uint32 quota;
    87                 uint32                 emitter_count;
    88                 particle_emitter_data  emitters[MAX_PARTICLE_EMITTERS];
    89                 uint32                 affector_count;
    90                 particle_affector_data affectors[MAX_PARTICLE_AFFECTORS];
     88                uint32                       quota;
     89                uint32                       emitter_count;
     90                particle_emitter_data        emitters[MAX_PARTICLE_EMITTERS];
     91                uint32                       affector_count;
     92                particle_affector_data       affectors[MAX_PARTICLE_AFFECTORS];
    9193        };
    9294
    9395        struct particle_system_tag {};
    9496        typedef handle< uint32, 16, 16, particle_system_tag > particle_system;
     97//      using particle_on_collide_func = function<bool( vec3, vec3 )>;
     98        using particle_on_collide_func = function<void( const vec3&, const vec3& )>;
    9599
    96100        struct particle_system_info
    97101        {
    98                 particle*             particles;
    99                 particle_emitter_info emitters[MAX_PARTICLE_EMITTERS];
     102                particle*                particles;
     103                particle_emitter_info    emitters[MAX_PARTICLE_EMITTERS];
     104                particle_on_collide_func on_collide;
    100105
    101106                uint32         count;
    102107                vec2           texcoords[2];
    103108                particle_group group;
     109
    104110
    105111                const particle_system_data*    data;
     
    124130                void release( particle_group group );
    125131                void release( particle_system system );
     132                bool is_finished( particle_system system );
    126133                void update( particle_system system, transform model, float dtime );
    127134                void render( particle_system system, const scene_state& s );
     135                void set_on_collide( particle_system system, const particle_on_collide_func& f );
    128136                void set_texcoords( particle_system system, vec2 a, vec2 b );
    129137                static void register_emitter_type( const string_view& name, particle_emitter_func func );
  • trunk/nv/engine/renderer.hh

    r508 r522  
    4646                transform                model;
    4747                flags< 32 >              flags;
     48                blending                 blending;
    4849        };
    4950
  • trunk/nv/interface/render_state.hh

    r503 r522  
    101101                        color( vec4() ) {}
    102102        };
     103
     104        constexpr bool operator==( const blending& rhs, const blending& lhs )
     105        {
     106                return
     107                        rhs.enabled          == lhs.enabled &&
     108                        rhs.src_rgb_factor   == lhs.src_rgb_factor &&
     109                        rhs.src_alpha_factor == lhs.src_alpha_factor &&
     110                        rhs.dst_rgb_factor   == lhs.dst_rgb_factor &&
     111                        rhs.dst_alpha_factor == lhs.dst_alpha_factor &&
     112                        rhs.rgb_equation     == lhs.rgb_equation &&
     113                        rhs.alpha_equation   == lhs.alpha_equation &&
     114                        rhs.color            == lhs.color;
     115        }
     116        constexpr bool operator!=( const blending& rhs, const blending& lhs )
     117        {
     118                return !( rhs == lhs );
     119        }
    103120
    104121        struct stencil_test_face
  • trunk/src/engine/mesh_manager.cc

    r509 r522  
    8585
    8686                NV_LOG_ERROR( "Resource path fail! - ", path );
    87                 NV_ASSERT( false, "Resource path fail!" );
     87                //NV_ASSERT( false, "Resource path fail!" );
    8888        }
    8989        else
    9090        {
    9191                NV_LOG_ERROR( "Resource lock fail! - ", path );
    92                 NV_ASSERT( false, "Resource lock fail!" );
     92                //NV_ASSERT( false, "Resource lock fail!" );
    9393        }
    9494        return nv::resource< nv::data_channel_set >();
  • trunk/src/engine/particle_engine.cc

    r520 r522  
    306306                else
    307307                        info->emitters[i].pause = m_rng->frange( data->emitters[i].duration_min, data->emitters[i].duration_max );
    308 
    309308        }
    310309
     
    313312
    314313        return result;
     314}
     315
     316void nv::particle_engine::set_on_collide( particle_system system, const particle_on_collide_func& f )
     317{
     318        particle_system_info* info = m_systems.get( system );
     319        if ( info )
     320                info->on_collide = f;
    315321}
    316322
     
    364370                m_systems.destroy( system );
    365371        }
     372}
     373
     374bool nv::particle_engine::is_finished( particle_system system )
     375{
     376        particle_system_info* info = m_systems.get( system );
     377        if ( info )
     378        {
     379                if ( info->count > 0 ) return false;
     380                for ( uint32 i = 0; i < info->data->emitter_count; ++i )
     381                {
     382                        const auto& edata = info->emitters[i];
     383                        if ( edata.active || edata.pause > 0.0f )
     384                        {
     385                                return false;
     386                        }
     387                }
     388        }
     389        return true;
    366390}
    367391
     
    403427void nv::particle_engine::set_texcoords( particle_system system, vec2 a, vec2 b )
    404428{
    405 
    406429        particle_system_info* info = m_systems.get( system );
    407430        if ( info )
     
    513536                pdata.position += pdata.velocity * factor;
    514537        }
     538
     539        if ( info->on_collide )
     540        {
     541                for ( uint32 i = 0; i < info->count; ++i )
     542                {
     543                        particle& pdata = info->particles[i];
     544                        if ( pdata.position.y <= 0.0f )
     545                        {
     546                                info->on_collide( pdata.position, pdata.velocity );
     547                                pdata.death = pdata.lifetime;
     548                        }
     549                }
     550        }
     551
    515552}
    516553
  • trunk/src/engine/renderer.cc

    r518 r522  
    117117
    118118        scene_state ss( s );
     119        render_state rs( pass.rstate );
    119120        m_context->bind( pass.fbuffer, FRAMEBUFFER );
    120121        m_context->set_draw_buffers( pass.output_count, pass.output );
     
    157158                                        m_context->get_device()->set_opt_uniform( *program, "nv_index", unsigned( index ) );
    158159                                        m_context->apply_engine_uniforms( *program, ss );
     160                                        if ( rs.blending != element.blending )
     161                                                rs.blending = element.blending;
    159162
    160163                                        if ( element.instances > 0 )
    161                                                 m_context->draw_instanced( TRIANGLES, pass.rstate, *program, element.instances, element.va, element.count, element.first );
     164                                                m_context->draw_instanced( TRIANGLES, rs, *program, element.instances, element.va, element.count, element.first );
    162165                                        else
    163                                                 m_context->draw( TRIANGLES, pass.rstate, *program, element.va, element.count, element.first );
     166                                                m_context->draw( TRIANGLES, rs, *program, element.va, element.count, element.first );
    164167
    165168                                        m_statistics[TRIANGLE_COUNT] += ( element.count / 3 ) * max< uint32 >( element.instances, 1 );
Note: See TracChangeset for help on using the changeset viewer.