Changeset 520 for trunk/src/engine
- Timestamp:
- 10/03/16 17:45:46 (9 years ago)
- Location:
- trunk/src/engine
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/engine/default_resource_manager.cc
r519 r520 11 11 default_resource_manager::default_resource_manager( context* context, bool clear_material_paths ) 12 12 { 13 m_images 14 m_meshes 15 m_binds 16 m_animators 17 m_materials 18 m_programs 19 m_gpu_meshes 20 m_mesh_datas 13 m_images = register_resource_handler< image_data >( new image_manager ); 14 m_meshes = register_resource_handler< data_channel_set >( new mesh_manager ); 15 m_binds = register_resource_handler< animator_bind_data >( new animator_bind_manager ); 16 m_animators = register_resource_handler< animator_data >( new animator_manager ); 17 m_materials = register_resource_handler< material >( new material_manager( clear_material_paths ) ); 18 m_programs = register_resource_handler< program >( new program_manager( context ) ); 19 m_gpu_meshes = register_resource_handler< gpu_mesh >( new gpu_mesh_manager( context, m_meshes ) ); 20 m_mesh_datas = register_resource_handler< mesh_data >( new mesh_data_manager( m_meshes ) ); 21 21 m_gpu_materials = register_resource_handler< gpu_material >( new gpu_material_manager( context, m_materials, m_images ) ); 22 m_models = register_resource_handler< model >( new model_manager( this, m_binds, m_mesh_datas ) ); 23 m_particles = register_resource_handler< particle_system_data >( new particle_manager ); 22 m_models = register_resource_handler< model >( new model_manager( this, m_binds, m_mesh_datas ) ); 23 m_particles = register_resource_handler< particle_system_data >( new particle_manager ); 24 m_ragdolls = register_resource_handler< ragdoll_data >( new ragdoll_manager( m_models ) ); 24 25 } 25 26 26 void default_resource_manager::initialize( lua::state* lua )27 void default_resource_manager::initialize( lua::state* lua, physics_world* world ) 27 28 { 28 29 m_lua = lua; … … 72 73 m_models->initialize( lua ); 73 74 m_particles->initialize( lua ); 75 m_ragdolls->initialize( lua ); 76 m_ragdolls->initialize( world ); 74 77 } 75 78 -
trunk/src/engine/particle_engine.cc
r519 r520 1 // Copyright (C) 2014-201 5ChaosForge Ltd1 // Copyright (C) 2014-2016 ChaosForge Ltd 2 2 // http://chaosforge.org/ 3 3 // … … 26 26 using namespace nv; 27 27 28 static void nv_particle_emitter_point( const particle_emitter_data*, particle* p, uint32 count )28 static void nv_particle_emitter_point( random_base*, const particle_emitter_data*, particle* p, uint32 count ) 29 29 { 30 30 for ( uint32 i = 0; i < count; ++i ) … … 34 34 } 35 35 36 static void nv_particle_emitter_box( const particle_emitter_data* pe, particle* p, uint32 count ) 37 { 38 random& r = random::get(); 39 for ( uint32 i = 0; i < count; ++i ) 40 { 41 p[i].position = 42 r.frange( -pe->hextents[0], pe->hextents[0] ) * pe->cdir + 43 r.frange( 0.0f, pe->extents[1] ) * pe->dir + 44 r.frange( -pe->hextents[2], pe->hextents[2] ) * pe->odir; 45 } 46 } 47 48 static void nv_particle_emitter_cylinder( const particle_emitter_data* pe, particle* p, uint32 count ) 49 { 50 random& r = random::get(); 51 for ( uint32 i = 0; i < count; ++i ) 52 { 53 vec2 rellipse( r.disk_point( pe->precise ) * pe->extents[0] ); 36 static void nv_particle_emitter_box( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 37 { 38 for ( uint32 i = 0; i < count; ++i ) 39 { 40 p[i].position = 41 r->frange( -pe->hextents[0], pe->hextents[0] ) * pe->cdir + 42 r->frange( 0.0f, pe->extents[1] ) * pe->dir + 43 r->frange( -pe->hextents[2], pe->hextents[2] ) * pe->odir; 44 } 45 } 46 47 static void nv_particle_emitter_cylinder( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 48 { 49 for ( uint32 i = 0; i < count; ++i ) 50 { 51 vec2 rellipse( r->disk_point( pe->precise ) * pe->extents[0] ); 54 52 p[i].position = 55 53 rellipse.x * pe->cdir + 56 r .frange( 0.0f, pe->extents[1] ) * pe->dir +54 r->frange( 0.0f, pe->extents[1] ) * pe->dir + 57 55 rellipse.y * pe->odir; 58 56 } 59 57 } 60 58 61 static void nv_particle_emitter_sphere( const particle_emitter_data* pe, particle* p, uint32 count ) 62 { 63 random& r = random::get(); 64 for ( uint32 i = 0; i < count; ++i ) 65 { 66 vec3 rsphere = r.sphere_point( pe->precise ) * pe->extents[0]; 59 static void nv_particle_emitter_sphere( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 60 { 61 for ( uint32 i = 0; i < count; ++i ) 62 { 63 vec3 rsphere = r->sphere_point( pe->precise ) * pe->extents[0]; 67 64 p[i].position = 68 65 rsphere.x * pe->cdir + … … 72 69 } 73 70 74 static void nv_particle_emitter_cylindroid( const particle_emitter_data* pe, particle* p, uint32 count ) 75 { 76 random& r = random::get(); 77 for ( uint32 i = 0; i < count; ++i ) 78 { 79 vec2 rellipse = r.ellipse_point( vec2( pe->hextents[0], pe->hextents[2] ), pe->precise ); 71 static void nv_particle_emitter_cylindroid( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 72 { 73 for ( uint32 i = 0; i < count; ++i ) 74 { 75 vec2 rellipse = r->ellipse_point( vec2( pe->hextents[0], pe->hextents[2] ), pe->precise ); 80 76 p[i].position = 81 77 rellipse.x * pe->cdir + 82 r .frange( 0.0f, pe->extents[1] ) * pe->dir +78 r->frange( 0.0f, pe->extents[1] ) * pe->dir + 83 79 rellipse.y * pe->odir; 84 80 } 85 81 } 86 82 87 static void nv_particle_emitter_ellipsoid( const particle_emitter_data* pe, particle* p, uint32 count ) 88 { 89 random& r = random::get(); 90 for ( uint32 i = 0; i < count; ++i ) 91 { 92 vec3 rsphere = r.ellipsoid_point( pe->hextents, pe->precise ); 83 static void nv_particle_emitter_ellipsoid( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 84 { 85 for ( uint32 i = 0; i < count; ++i ) 86 { 87 vec3 rsphere = r->ellipsoid_point( pe->hextents, pe->precise ); 93 88 p[i].position = 94 89 rsphere.x * pe->cdir + … … 98 93 } 99 94 100 static void nv_particle_emitter_hollow_cylinder( const particle_emitter_data* pe, particle* p, uint32 count ) 101 { 102 random& r = random::get(); 103 for ( uint32 i = 0; i < count; ++i ) 104 { 105 vec2 rellipse = r.hollow_disk_point( 95 static void nv_particle_emitter_hollow_cylinder( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 96 { 97 for ( uint32 i = 0; i < count; ++i ) 98 { 99 vec2 rellipse = r->hollow_disk_point( 106 100 pe->ihextents[0], 107 101 pe->hextents[0], … … 109 103 p[i].position = 110 104 rellipse.x * pe->cdir + 111 r .frange( 0.0f, pe->extents[1] ) * pe->dir +105 r->frange( 0.0f, pe->extents[1] ) * pe->dir + 112 106 rellipse.y * pe->odir; 113 107 } 114 108 } 115 109 116 static void nv_particle_emitter_hollow_sphere( const particle_emitter_data* pe, particle* p, uint32 count ) 117 { 118 random& r = random::get(); 119 for ( uint32 i = 0; i < count; ++i ) 120 { 121 vec3 rellipse = r.hollow_sphere_point( pe->ihextents[0], pe->hextents[0], pe->precise ); 110 static void nv_particle_emitter_hollow_sphere( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 111 { 112 for ( uint32 i = 0; i < count; ++i ) 113 { 114 vec3 rellipse = r->hollow_sphere_point( pe->ihextents[0], pe->hextents[0], pe->precise ); 122 115 p[i].position = 123 116 rellipse.x * pe->cdir + … … 127 120 } 128 121 129 static void nv_particle_emitter_hollow_cylindroid( const particle_emitter_data* pe, particle* p, uint32 count ) 130 { 131 random& r = random::get(); 132 for ( uint32 i = 0; i < count; ++i ) 133 { 134 vec2 rellipse = r.hollow_ellipse_point( 122 static void nv_particle_emitter_hollow_cylindroid( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 123 { 124 for ( uint32 i = 0; i < count; ++i ) 125 { 126 vec2 rellipse = r->hollow_ellipse_point( 135 127 vec2( pe->ihextents[0], pe->ihextents[2] ), 136 128 vec2( pe->hextents[0], pe->hextents[2] ), … … 138 130 p[i].position = 139 131 rellipse.x * pe->cdir + 140 r .frange( 0.0f, pe->extents[1] ) * pe->dir +132 r->frange( 0.0f, pe->extents[1] ) * pe->dir + 141 133 rellipse.y * pe->odir; 142 134 } 143 135 } 144 136 145 static void nv_particle_emitter_hollow_ellipsoid( const particle_emitter_data* pe, particle* p, uint32 count ) 146 { 147 random& r = random::get(); 148 for ( uint32 i = 0; i < count; ++i ) 149 { 150 vec3 rellipse = r.hollow_ellipsoid_point( pe->ihextents, pe->hextents, pe->precise ); 137 static void nv_particle_emitter_hollow_ellipsoid( random_base* r, const particle_emitter_data* pe, particle* p, uint32 count ) 138 { 139 for ( uint32 i = 0; i < count; ++i ) 140 { 141 vec3 rellipse = r->hollow_ellipsoid_point( pe->ihextents, pe->hextents, pe->precise ); 151 142 p[i].position = 152 143 rellipse.x * pe->cdir + … … 278 269 } 279 270 280 nv::particle_engine::particle_engine( context* a_context, bool debug_data ) 281 { 282 m_context = a_context; 271 nv::particle_engine::particle_engine( context* a_context, random_base* rng, particle_group_manager* groups, bool debug_data ) 272 { 273 m_context = a_context; 274 m_pgm = groups; 275 m_rng = rng; 276 if ( m_rng == nullptr ) 277 m_rng = &random::get(); 278 283 279 if ( debug_data ) 284 280 { 285 281 m_debug_emitter_names = new nv::hash_map< nv::particle_emitter_func, nv::const_string >; 286 282 m_debug_affector_names = new nv::hash_map< nv::particle_affector_func, nv::const_string >; 287 m_debug_affector_types = new nv::hash_map< nv::particle_affector_func, nv::type_entry* >;288 283 m_debug_emitter_list = new nv::vector< nv::particle_emitter_func >; 289 284 m_debug_affector_list = new nv::vector< nv::particle_affector_func >; … … 294 289 } 295 290 296 nv::particle_system nv::particle_engine::create_system( const particle_system_data* data, particle_ system_group group )297 { 298 particle_system_group_info* ginfo = m_groups.get( group );299 if ( !ginfo )return nv::particle_system();300 291 nv::particle_system nv::particle_engine::create_system( const particle_system_data* data, particle_group group ) 292 { 293 if ( !m_pgm->ref( group ) ) 294 return nv::particle_system(); 295 301 296 particle_system result = m_systems.create(); 302 297 particle_system_info* info = m_systems.get( result ); … … 310 305 info->emitters[i].pause = 0; 311 306 else 312 info->emitters[i].pause = random::get().frange( data->emitters[i].duration_min, data->emitters[i].duration_max );307 info->emitters[i].pause = m_rng->frange( data->emitters[i].duration_min, data->emitters[i].duration_max ); 313 308 314 309 } … … 316 311 info->count = 0; 317 312 info->particles = new particle[data->quota]; 318 ginfo->ref_counter++;319 313 320 314 return result; 321 315 } 322 316 323 nv::particle_system nv::particle_engine::create_system( resource< nv::particle_system_data > rdata, particle_ system_group group )317 nv::particle_system nv::particle_engine::create_system( resource< nv::particle_system_data > rdata, particle_group group ) 324 318 { 325 319 if ( auto data = rdata.lock() ) … … 328 322 } 329 323 330 void nv::particle_engine::prepare( particle_system_group group ) 331 { 332 particle_system_group_info* info = m_groups.get( group ); 333 if ( info ) 334 { 335 info->count = 0; 336 } 337 } 338 339 nv::particle_system_group nv::particle_engine::create_group( uint32 max_particles ) 340 { 341 particle_system_group result = m_groups.create(); 342 particle_system_group_info* info = m_groups.get( result ); 343 info->local = false; 344 info->count = 0; 345 info->quota = max_particles; 346 info->vtx_buffer = m_context->create_buffer( VERTEX_BUFFER, STREAM_DRAW, info->quota * sizeof( particle_quad )/*, info->quads_[0].data*/ ); 347 vertex_array_desc desc; 348 desc.add_vertex_buffers< particle_vtx >( info->vtx_buffer, true ); 349 info->vtx_array = m_context->create_vertex_array( desc ); 350 info->quads = new particle_quad[info->quota]; 351 info->ref_counter = 0; 352 return result; 324 void nv::particle_engine::prepare( particle_group group ) 325 { 326 m_pgm->prepare( group ); 327 } 328 329 nv::particle_group nv::particle_engine::create_group( uint32 max_particles ) 330 { 331 return m_pgm->create_group( max_particles ); 353 332 } 354 333 … … 369 348 while ( m_systems.size() > 0 ) 370 349 release( m_systems.get_handle( 0 ) ); 371 while ( m_groups.size() > 0)372 release( m_groups.get_handle( 0 ));350 if ( m_pgm ) 351 m_pgm->reset(); 373 352 m_emitters.clear(); 374 353 m_affectors.clear(); … … 381 360 if ( info ) 382 361 { 383 particle_system_group_info* ginfo = m_groups.get( info->group ); 384 if ( ginfo ) ginfo->ref_counter--; 385 delete[] info->particles; 362 m_pgm->unref( info->group ); 363 delete[] info->particles; 386 364 m_systems.destroy( system ); 387 365 } 388 366 } 389 367 390 void nv::particle_engine::release( particle_system_group group ) 391 { 392 particle_system_group_info* info = m_groups.get( group ); 393 if ( info ) 394 { 395 delete[] info->quads; 396 m_context->release( info->vtx_array ); 397 m_groups.destroy( group ); 398 } 368 void nv::particle_engine::release( particle_group group ) 369 { 370 m_pgm->release( group ); 399 371 } 400 372 … … 403 375 particle_system_info* info = m_systems.get( system ); 404 376 if ( info ) 405 { 406 generate_data( info, s ); 407 } 377 m_pgm->generate_data( array_view< particle >( info->particles, info->count ), info->data, info->group, s ); 408 378 } 409 379 … … 440 410 info->texcoords[1] = b; 441 411 } 442 }443 444 void nv::particle_engine::generate_data( particle_system_info* info, const scene_state& s )445 {446 // void* rawptr = m_context->map_buffer( info->vtx_buffer, nv::WRITE_UNSYNCHRONIZED, offset, info->count*sizeof( particle_quad ) );447 // particle_quad* quads = reinterpret_cast<particle_quad*>( rawptr );448 449 particle_system_group_info* group = m_groups.get( info->group );450 if ( !info )451 {452 return;453 }454 455 vec2 lb = vec2( -0.5f, -0.5f );456 vec2 rt = vec2( 0.5f, 0.5f );457 458 switch ( info->data->origin )459 {460 case particle_origin::CENTER : break;461 case particle_origin::TOP_LEFT : lb = vec2(0.f,-1.f); rt = vec2(1.f,0.f); break;462 case particle_origin::TOP_CENTER : lb.y = -1.f; rt.y = 0.f; break;463 case particle_origin::TOP_RIGHT : lb = vec2(-1.f,-1.f); rt = vec2(); break;464 case particle_origin::CENTER_LEFT : lb.x = 0.f; rt.x = 1.f; break;465 case particle_origin::CENTER_RIGHT : lb.x = -1.f; rt.x = 0.f; break;466 case particle_origin::BOTTOM_LEFT : lb = vec2(); rt = vec2(1.f,1.f); break;467 case particle_origin::BOTTOM_CENTER : lb.y = 0.f; rt.y = 1.f; break;468 case particle_origin::BOTTOM_RIGHT : lb = vec2(-1.f,0.f); rt = vec2(.0f,1.f); break;469 }470 471 const vec3 sm[4] =472 {473 vec3( lb.x, lb.y, 0.0f ),474 vec3( rt.x, lb.y, 0.0f ),475 vec3( lb.x, rt.y, 0.0f ),476 vec3( rt.x, rt.y, 0.0f ),477 };478 vec3 z( 0.0f, 0.0f ,1.0f );479 480 particle_orientation orientation = info->data->orientation;481 vec3 common_up ( info->data->common_up );482 vec3 common_dir( info->data->common_dir );483 bool accurate_facing = info->data->accurate_facing;484 mat3 rot_mat;485 vec3 right;486 vec3 pdir( 0.0f, 1.0f, 0.0f );487 488 vec3 camera_pos = s.get_camera().get_position();489 vec3 inv_view_dir = math::normalize( -s.get_camera().get_direction() );490 491 for ( uint32 i = 0; i < info->count; ++i )492 {493 const particle& pdata = info->particles[i];494 // particle_quad& rdata = quads[i];495 particle_quad& rdata = group->quads[i + group->count];496 497 vec3 view_dir( inv_view_dir );498 if ( accurate_facing ) view_dir = math::normalize( camera_pos - pdata.position );499 500 switch ( orientation )501 {502 case particle_orientation::POINT :503 right = math::normalize( math::cross( view_dir, vec3( 0, 1, 0 ) ) );504 right = math::rotate( right, pdata.rotation, view_dir );505 rot_mat = mat3( right, math::cross( right, -view_dir ), -view_dir );506 break;507 case particle_orientation::ORIENTED :508 pdir = normalize_safe( pdata.velocity, pdir );509 right = math::normalize( math::cross( pdir, view_dir ) );510 rot_mat = mat3( right, pdir, math::cross( pdir, right ) );511 break;512 case particle_orientation::ORIENTED_COMMON :513 right = math::normalize( math::cross( common_dir, view_dir ) );514 rot_mat = mat3( right, common_dir, math::cross( common_dir, right ) );515 break;516 case particle_orientation::PERPENDICULAR :517 pdir = normalize_safe( pdata.velocity, pdir );518 right = math::normalize( math::cross( common_up, pdir ) );519 rot_mat = mat3( right, common_up, math::cross( common_up, right ) );520 break;521 case particle_orientation::PERPENDICULAR_COMMON :522 right = math::normalize( math::cross( common_up, common_dir ) );523 rot_mat = mat3( right, common_up, math::cross( common_up, right ) );524 break;525 }526 527 vec2 texcoords[4] =528 {529 pdata.tcoord_a,530 vec2( pdata.tcoord_b.x, pdata.tcoord_a.y ),531 vec2( pdata.tcoord_a.x, pdata.tcoord_b.y ),532 pdata.tcoord_b533 };534 535 vec3 size( pdata.size.x, pdata.size.y, 0.0f );536 vec3 s0 = rot_mat * ( ( size * sm[0] ) );537 vec3 s1 = rot_mat * ( ( size * sm[1] ) );538 vec3 s2 = rot_mat * ( ( size * sm[2] ) );539 vec3 s3 = rot_mat * ( ( size * sm[3] ) );540 541 rdata.data[0].position = pdata.position + s0;542 rdata.data[0].color = pdata.color;543 rdata.data[0].texcoord = texcoords[0];544 545 rdata.data[1].position = pdata.position + s1;546 rdata.data[1].color = pdata.color;547 rdata.data[1].texcoord = texcoords[1];548 549 rdata.data[2].position = pdata.position + s2;550 rdata.data[2].color = pdata.color;551 rdata.data[2].texcoord = texcoords[2];552 553 rdata.data[3].position = pdata.position + s3;554 rdata.data[3].color = pdata.color;555 rdata.data[3].texcoord = texcoords[3];556 557 rdata.data[4] = rdata.data[2];558 rdata.data[5] = rdata.data[1];559 }560 // m_context->unmap_buffer( info->vtx_buffer );561 562 m_context->update( group->vtx_buffer, group->quads, group->count*sizeof(particle_quad), info->count*sizeof( particle_quad ) );563 group->count += info->count;564 412 } 565 413 … … 584 432 if ( ecount == 0 ) return; 585 433 586 random& r = random::get();587 434 bool local = model.is_identity(); 588 435 // if ( !local ) … … 605 452 { 606 453 particle& pinfo = info->particles[info->count]; 607 edata.emitter_func( &(info->data->emitters[i]), &pinfo, 1 );454 edata.emitter_func( m_rng, &(info->data->emitters[i]), &pinfo, 1 ); 608 455 pinfo.position = vec3(); 609 456 pinfo.position+= edata.position; … … 611 458 pinfo.position = pinfo.position * model; 612 459 pinfo.color = edata.color_min == edata.color_max ? 613 edata.color_min : r.range( edata.color_min, edata.color_max );460 edata.color_min : m_rng->range( edata.color_min, edata.color_max ); 614 461 pinfo.size = edata.size_min == edata.size_max ? 615 edata.size_min : r.range( edata.size_min, edata.size_max );462 edata.size_min : m_rng->range( edata.size_min, edata.size_max ); 616 463 if ( edata.square ) pinfo.size.y = pinfo.size.x; 617 464 float velocity = edata.velocity_min == edata.velocity_max ? 618 edata.velocity_min : r.frange( edata.velocity_min, edata.velocity_max );465 edata.velocity_min : m_rng->frange( edata.velocity_min, edata.velocity_max ); 619 466 pinfo.lifetime = dtime + einfo.next; 620 467 pinfo.death = ( edata.lifetime_min == edata.lifetime_max ? 621 edata.lifetime_min : r.frange( edata.lifetime_min, edata.lifetime_max ) );622 pinfo.rotation = r.frand( 2* math::pi<float>() );468 edata.lifetime_min : m_rng->frange( edata.lifetime_min, edata.lifetime_max ) ); 469 pinfo.rotation = m_rng->frand( 2* math::pi<float>() ); 623 470 pinfo.tcoord_a = info->texcoords[0]; 624 471 pinfo.tcoord_b = info->texcoords[1]; … … 628 475 { 629 476 float emission_angle = math::radians( edata.angle ); 630 float cos_theta = r.frange( cos( emission_angle ), 1.0f );477 float cos_theta = m_rng->frange( cos( emission_angle ), 1.0f ); 631 478 float sin_theta = sqrt(1.0f - cos_theta * cos_theta ); 632 float phi = r.frange( 0.0f, 2* math::pi<float>() );479 float phi = m_rng->frange( 0.0f, 2* math::pi<float>() ); 633 480 pinfo.velocity = model.get_orientation() * 634 481 ( edata.odir * ( cos(phi) * sin_theta ) + … … 672 519 uint32 ecount = info->data->emitter_count; 673 520 if ( ecount == 0 ) return; 674 random& r = random::get();675 521 676 522 for ( uint32 i = 0; i < ecount; ++i ) … … 691 537 einfo.active = false; 692 538 if ( edata.repeat_min > 0.0f ) 693 einfo.pause += r.frange( edata.repeat_min, edata.repeat_max );539 einfo.pause += m_rng->frange( edata.repeat_min, edata.repeat_max ); 694 540 else 695 541 einfo.pause = 0.0f; … … 698 544 { 699 545 einfo.active = true; 700 einfo.pause += r.frange( edata.duration_min, edata.duration_max );546 einfo.pause += m_rng->frange( edata.duration_min, edata.duration_max ); 701 547 } 702 548 } … … 776 622 } 777 623 778 nv::particle_render_data nv::particle_engine::get_render_data( particle_system_group group ) 779 { 780 const particle_system_group_info* info = m_groups.get( group ); 781 if ( info ) 782 { 783 return{ info->count, info->vtx_array }; 784 } 785 return { 0, nv::vertex_array() }; 624 nv::particle_render_data nv::particle_engine::get_render_data( particle_group group ) 625 { 626 return m_pgm->get_render_data( group ); 786 627 } 787 628 … … 794 635 } 795 636 796 void nv::particle_engine::register_types( type_database* db ) 637 const nv::type_entry* nv::particle_engine::get_debug_type( particle_affector_func f ) 638 { 639 if ( m_debug_affector_types ) 640 { 641 auto it = m_debug_affector_types->find( f ); 642 if ( it != m_debug_affector_types->end() ) 643 return it->second; 644 } 645 return nullptr; 646 } 647 648 void nv::particle_engine::register_types( type_database* db, bool debug_data ) 797 649 { 798 650 db->create_type<particle_orientation>() … … 816 668 ; 817 669 818 if ( m_debug_affector_types ) 819 { 670 if ( debug_data ) 671 { 672 if ( !m_debug_affector_types ) 673 m_debug_affector_types = new nv::hash_map< nv::particle_affector_func, nv::type_entry* >; 674 820 675 int you_could_get_rid_of_the_init_function_using_these; int error; 821 676 int universal_vm_based_affector; … … 849 704 } 850 705 } 706 -
trunk/src/engine/particle_manager.cc
r518 r520 61 61 data->emitter_count = 0; 62 62 data->affector_count = 0; 63 64 const_string orientation = table.get_string( "orientation", "point" ); 65 if ( orientation == "point" ) { data->orientation = particle_orientation::POINT; } 66 else if ( orientation == "oriented" ) { data->orientation = particle_orientation::ORIENTED; } 67 else if ( orientation == "oriented_common" ) { data->orientation = particle_orientation::ORIENTED_COMMON; } 68 else if ( orientation == "perpendicular" ) { data->orientation = particle_orientation::PERPENDICULAR; } 69 else if ( orientation == "perpendicular_common" ) { data->orientation = particle_orientation::PERPENDICULAR_COMMON; } 70 else 71 { 72 NV_LOG_ERROR( "Unknown orientation type! (", orientation, ")!" ); 73 data->orientation = particle_orientation::POINT; 74 } 75 76 const_string origin = table.get_string( "origin", "center" ); 77 if ( origin == "center" ) { data->origin = particle_origin::CENTER; } 78 else if ( origin == "top_left" ) { data->origin = particle_origin::TOP_LEFT; } 79 else if ( origin == "top_center" ) { data->origin = particle_origin::TOP_CENTER; } 80 else if ( origin == "top_right" ) { data->origin = particle_origin::TOP_RIGHT; } 81 else if ( origin == "center_left" ) { data->origin = particle_origin::CENTER_LEFT; } 82 else if ( origin == "center_right" ) { data->origin = particle_origin::CENTER_RIGHT; } 83 else if ( origin == "bottom_left" ) { data->origin = particle_origin::BOTTOM_LEFT; } 84 else if ( origin == "bottom_center" ) { data->origin = particle_origin::BOTTOM_CENTER; } 85 else if ( origin == "bottom_right" ) { data->origin = particle_origin::BOTTOM_RIGHT; } 86 else 87 { 88 NV_LOG_ERROR( "Unknown particle origin! (", origin, ")!" ); 89 data->origin = particle_origin::CENTER; 90 } 63 data->orientation = particle_orientation( table.get_unsigned("orientation", 0) ); 64 data->origin = particle_origin( table.get_unsigned( "origin",0 ) ); 91 65 92 66 data->common_up = math::normalize( table.get<vec3>("common_up", vec3(1,0,0) ) );
Note: See TracChangeset
for help on using the changeset viewer.