X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=particle.c;h=2e05a1923dc05a5d94560731832d94704a339b1f;hb=304647a7672165dd35ffe54884ed9aedcc9bf363;hp=e1f6ac85b0f31270b75c0fafb91160aa0c767233;hpb=b6c1b99a420927d4f4b7a52865e908712ae55484;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/particle.c b/particle.c index e1f6ac8..2e05a19 100644 --- a/particle.c +++ b/particle.c @@ -1,8 +1,22 @@ +#include "vg/vg_lines.h" +#include "vg/vg_async.h" #include "particle.h" -#include "shaders/trail.h" +#include "shaders/particle.h" + +struct particle_system particles_grind = { + .scale = 0.02f, + .velocity_scale = 0.001f, + .width = 0.0125f +}, +particles_env = { + .scale = 0.04f, + .velocity_scale = 0.001f, + .width = 0.25f +}; -static void particle_spawn( particle_system *sys, - v3f co, v3f v, f32 lifetime, u32 colour ){ +void particle_spawn( particle_system *sys, v3f co, v3f v, + f32 lifetime, u32 colour ) +{ if( sys->alive == sys->max ) return; particle *p = &sys->array[ sys->alive ++ ]; @@ -12,9 +26,10 @@ static void particle_spawn( particle_system *sys, p->colour = colour; } -static void particle_spawn_cone( particle_system *sys, - v3f co, v3f dir, f32 angle, f32 speed, - f32 lifetime, u32 colour ){ +void particle_spawn_cone( particle_system *sys, + v3f co, v3f dir, f32 angle, f32 speed, + f32 lifetime, u32 colour ) +{ if( sys->alive == sys->max ) return; particle *p = &sys->array[ sys->alive ++ ]; @@ -33,7 +48,8 @@ static void particle_spawn_cone( particle_system *sys, v3_copy( co, p->co ); } -static void particle_system_update( particle_system *sys, f32 dt ){ +void particle_system_update( particle_system *sys, f32 dt ) +{ u32 i = 0; iter: if( i == sys->alive ) return; @@ -52,7 +68,8 @@ iter: if( i == sys->alive ) return; goto iter; } -static void particle_system_debug( particle_system *sys ){ +void particle_system_debug( particle_system *sys ) +{ for( u32 i=0; ialive; i ++ ){ particle *p = &sys->array[i]; v3f p1; @@ -95,14 +112,8 @@ static void async_particle_init( void *payload, u32 size ){ VG_CHECK_GL_ERR(); } -static void particle_alloc( particle_system *sys, u32 max ){ - static int reg = 1; - if( reg ){ - shader_particle_register(); - shader_trail_register(); - reg = 0; - } - +void particle_alloc( particle_system *sys, u32 max ) +{ size_t stride = sizeof(particle_vert); sys->max = max; @@ -126,7 +137,8 @@ static void particle_alloc( particle_system *sys, u32 max ){ vg_async_dispatch( call, async_particle_init ); } -static void particle_system_prerender( particle_system *sys ){ +void particle_system_prerender( particle_system *sys ) +{ for( u32 i=0; ialive; i ++ ){ particle *p = &sys->array[i]; particle_vert *vs = &sys->vertices[i*4]; @@ -163,7 +175,8 @@ static void particle_system_prerender( particle_system *sys ){ glBufferSubData( GL_ARRAY_BUFFER, 0, sys->alive*stride*4, sys->vertices ); } -static void particle_system_render( particle_system *sys, camera *cam ){ +void particle_system_render( particle_system *sys, vg_camera *cam ) +{ glDisable( GL_CULL_FACE ); glEnable( GL_DEPTH_TEST );