libpsys

diff src/psys.h @ 5:613d2bf3ea1f

almost finished with the reorg
author John Tsiombikas <nuclear@mutantstargoat.com>
date Tue, 27 Sep 2011 07:42:32 +0300
parents 133094e2f5a5
children 3c0a306c5f01
line diff
     1.1 --- a/src/psys.h	Mon Sep 26 18:25:18 2011 +0300
     1.2 +++ b/src/psys.h	Tue Sep 27 07:42:32 2011 +0300
     1.3 @@ -4,10 +4,18 @@
     1.4  #include <vmath.h>
     1.5  #include <anim/anim.h>
     1.6  #include "rndval.h"
     1.7 +#include "pattr.h"
     1.8  
     1.9 -struct anm_track_vec3 {
    1.10 -	struct anm_track x, y, z;
    1.11 -};
    1.12 +struct psys_particle;
    1.13 +struct psys_emitter;
    1.14 +
    1.15 +typedef int (*psys_spawn_func_t)(struct psys_emitter*, struct psys_particle*, void*);
    1.16 +typedef void (*psys_update_func_t)(struct psys_emitter*, struct psys_particle*, float, float, void*);
    1.17 +
    1.18 +typedef void (*psys_draw_func_t)(struct psys_emitter*, struct psys_particle*, void*);
    1.19 +typedef void (*psys_draw_start_func_t)(struct psys_emitter*, void*);
    1.20 +typedef void (*psys_draw_end_func_t)(struct psys_emitter*, void*);
    1.21 +
    1.22  
    1.23  struct psys_plane {
    1.24  	plane_t p;
    1.25 @@ -15,29 +23,19 @@
    1.26  	struct psys_plane *next;
    1.27  };
    1.28  
    1.29 -struct psys_particle;
    1.30  
    1.31  struct psys_emitter {
    1.32 -	float last_update;
    1.33 +	struct anm_node prs;
    1.34 +	vec3_t cur_pos;
    1.35  
    1.36 -	unsigned int tex;
    1.37 -
    1.38 -	struct anm_node prs;
    1.39 -	struct anm_track_vec3 pos_range;
    1.40 -
    1.41 -	struct anm_track rate;
    1.42 -	struct anm_track life, life_range;
    1.43 -	struct anm_track size, size_range;
    1.44 -	struct anm_track_vec3 dir, dir_range;
    1.45 -	struct anm_track_vec3 grav;
    1.46 -
    1.47 -	float drag;	/* I don't think this needs to animate */
    1.48 +	struct psys_attributes attr;
    1.49  
    1.50  	/* list of active particles */
    1.51  	struct psys_particle *plist;
    1.52 +	int pcount;	/* number of active particles */
    1.53  
    1.54  	/* list of collision planes */
    1.55 -	struct col_plane *planes;
    1.56 +	struct psys_plane *planes;
    1.57  
    1.58  	/* custom spawn closure */
    1.59  	void *spawn_cls;
    1.60 @@ -53,16 +51,8 @@
    1.61  	psys_draw_start_func_t draw_start;
    1.62  	psys_draw_end_func_t draw_end;
    1.63  
    1.64 -	/* calculated on update */
    1.65 -	vec3_t cur_pos, cur_pos_range;
    1.66 -	quat_t cur_rot;
    1.67 -	float cur_rate, cur_life;
    1.68 -	float cur_size, cur_size_range;
    1.69 -	vec3_t cur_dir;
    1.70 -	vec3_t cur_grav;
    1.71 -
    1.72 -	/* partial spawn accumulator */
    1.73 -	float spawn_acc;
    1.74 +	float spawn_acc;	/* partial spawn accumulator */
    1.75 +	float last_update;	/* last update time (to calc dt) */
    1.76  };
    1.77  
    1.78  
    1.79 @@ -74,13 +64,6 @@
    1.80  };
    1.81  
    1.82  
    1.83 -typedef int (*psys_spawn_func_t)(struct psys_emitter*, struct psys_particle*, void*);
    1.84 -typedef void (*psys_update_func_t)(struct psys_emitter*, struct psys_particle*, float, float, void*);
    1.85 -
    1.86 -typedef void (*psys_draw_func_t)(struct psys_emitter*, struct psys_particle*, void*);
    1.87 -typedef void (*psys_draw_start_func_t)(struct psys_emitter*, void*);
    1.88 -typedef void (*psys_draw_end_func_t)(struct psys_emitter*, void*);
    1.89 -
    1.90  
    1.91  struct psys_emitter *psys_create(void);
    1.92  void psys_free(struct psys_emitter *em);
    1.93 @@ -89,18 +72,10 @@
    1.94  void psys_destroy(struct psys_emitter *em);
    1.95  
    1.96  /* set properties */
    1.97 -void psys_set_texture(struct psys_emitter *em, unsigned int tex);
    1.98 -
    1.99 -void psys_set_pos(struct psys_emitter *em, vec3_t pos, vec3_t range, float tm);
   1.100 +void psys_set_pos(struct psys_emitter *em, vec3_t pos, float tm);
   1.101  void psys_set_rot(struct psys_emitter *em, quat_t rot, float tm);
   1.102  void psys_set_pivot(struct psys_emitter *em, vec3_t pivot);
   1.103  
   1.104 -void psys_set_rate(struct psys_emitter *em, float rate, float tm);
   1.105 -void psys_set_life(struct psys_emitter *em, float life, float range, float tm);
   1.106 -void psys_set_size(struct psys_emitter *em, float size, float range, float tm);
   1.107 -void psys_set_dir(struct psys_emitter *em, vec3_t dir, vec3_t range, float tm);
   1.108 -void psys_set_grav(struct psys_emitter *em, vec3_t grav, float tm);
   1.109 -
   1.110  void psys_clear_collision_planes(struct psys_emitter *em);
   1.111  int psys_add_collision_plane(struct psys_emitter *em, plane_t plane, float elast);
   1.112