- Timestamp:
- 10/14/16 18:17:17 (9 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/engine/particle_engine.hh
r520 r522 13 13 #include <nv/stl/unordered_map.hh> 14 14 #include <nv/stl/handle.hh> 15 #include <nv/stl/functional/function.hh> 15 16 #include <nv/lua/lua_state.hh> 16 17 #include <nv/gfx/texture_atlas.hh> … … 19 20 #include <nv/interface/scene_node.hh> 20 21 #include <nv/interface/context.hh> 22 #include <nv/interface/physics_world.hh> 21 23 #include <nv/engine/particle_group.hh> 22 24 … … 84 86 struct particle_system_data : particle_group_settings 85 87 { 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]; 91 93 }; 92 94 93 95 struct particle_system_tag {}; 94 96 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& )>; 95 99 96 100 struct particle_system_info 97 101 { 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; 100 105 101 106 uint32 count; 102 107 vec2 texcoords[2]; 103 108 particle_group group; 109 104 110 105 111 const particle_system_data* data; … … 124 130 void release( particle_group group ); 125 131 void release( particle_system system ); 132 bool is_finished( particle_system system ); 126 133 void update( particle_system system, transform model, float dtime ); 127 134 void render( particle_system system, const scene_state& s ); 135 void set_on_collide( particle_system system, const particle_on_collide_func& f ); 128 136 void set_texcoords( particle_system system, vec2 a, vec2 b ); 129 137 static void register_emitter_type( const string_view& name, particle_emitter_func func ); -
trunk/nv/engine/renderer.hh
r508 r522 46 46 transform model; 47 47 flags< 32 > flags; 48 blending blending; 48 49 }; 49 50 -
trunk/nv/interface/render_state.hh
r503 r522 101 101 color( vec4() ) {} 102 102 }; 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 } 103 120 104 121 struct stencil_test_face -
trunk/src/engine/mesh_manager.cc
r509 r522 85 85 86 86 NV_LOG_ERROR( "Resource path fail! - ", path ); 87 NV_ASSERT( false, "Resource path fail!" );87 //NV_ASSERT( false, "Resource path fail!" ); 88 88 } 89 89 else 90 90 { 91 91 NV_LOG_ERROR( "Resource lock fail! - ", path ); 92 NV_ASSERT( false, "Resource lock fail!" );92 //NV_ASSERT( false, "Resource lock fail!" ); 93 93 } 94 94 return nv::resource< nv::data_channel_set >(); -
trunk/src/engine/particle_engine.cc
r520 r522 306 306 else 307 307 info->emitters[i].pause = m_rng->frange( data->emitters[i].duration_min, data->emitters[i].duration_max ); 308 309 308 } 310 309 … … 313 312 314 313 return result; 314 } 315 316 void 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; 315 321 } 316 322 … … 364 370 m_systems.destroy( system ); 365 371 } 372 } 373 374 bool 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; 366 390 } 367 391 … … 403 427 void nv::particle_engine::set_texcoords( particle_system system, vec2 a, vec2 b ) 404 428 { 405 406 429 particle_system_info* info = m_systems.get( system ); 407 430 if ( info ) … … 513 536 pdata.position += pdata.velocity * factor; 514 537 } 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 515 552 } 516 553 -
trunk/src/engine/renderer.cc
r518 r522 117 117 118 118 scene_state ss( s ); 119 render_state rs( pass.rstate ); 119 120 m_context->bind( pass.fbuffer, FRAMEBUFFER ); 120 121 m_context->set_draw_buffers( pass.output_count, pass.output ); … … 157 158 m_context->get_device()->set_opt_uniform( *program, "nv_index", unsigned( index ) ); 158 159 m_context->apply_engine_uniforms( *program, ss ); 160 if ( rs.blending != element.blending ) 161 rs.blending = element.blending; 159 162 160 163 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 ); 162 165 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 ); 164 167 165 168 m_statistics[TRIANGLE_COUNT] += ( element.count / 3 ) * max< uint32 >( element.instances, 1 );
Note: See TracChangeset
for help on using the changeset viewer.