Enlightenment CVS committal Author : ningerso Project : e17 Module : proto
Dir : e17/proto/e_phys/src/lib Modified Files: E_Phys.h Makefile.am e_phys_world.c Added Files: e_phys_map.c Log Message: Use the actual elapsed time for animating rather than requested timer time. Add the ability to map out the relative particle positioning. =================================================================== RCS file: /cvs/e/e17/proto/e_phys/src/lib/E_Phys.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- E_Phys.h 18 Sep 2006 05:47:02 -0000 1.3 +++ E_Phys.h 21 Sep 2006 05:24:58 -0000 1.4 @@ -79,6 +79,16 @@ #define E_PHYS_CONSTRAINT(x) ((E_Phys_Constraint *)x) #define E_PHYS_FORCE(x) ((E_Phys_Force *)x) +enum _E_Phys_Particle_Direction { + E_PHYS_PARTICLE_DIRECTION_LEFT, + E_PHYS_PARTICLE_DIRECTION_RIGHT, + E_PHYS_PARTICLE_DIRECTION_ABOVE, + E_PHYS_PARTICLE_DIRECTION_BELOW, + E_PHYS_PARTICLE_DIRECTION_MAX +}; + +typedef enum _E_Phys_Particle_Direction E_Phys_Particle_Direction; + struct _E_Phys_Particle { E_Phys_World *world; float m; @@ -86,6 +96,8 @@ E_Phys_Point cur; E_Phys_Point prev; E_Phys_Vector force; + unsigned int steps; + E_Phys_Particle *neighbor[E_PHYS_PARTICLE_DIRECTION_MAX]; }; struct _E_Phys_Constraint { @@ -158,6 +170,7 @@ float time; float dt; + float elapsed; int constraint_iter; float friction; =================================================================== RCS file: /cvs/e/e17/proto/e_phys/src/lib/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- Makefile.am 17 Sep 2006 22:59:16 -0000 1.4 +++ Makefile.am 21 Sep 2006 05:24:58 -0000 1.5 @@ -10,6 +10,7 @@ e_phys_constraint.c \ e_phys_force.c \ e_phys_particle.c \ - e_phys_world.c + e_phys_world.c \ + e_phys_map.c libephys_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@ -lm =================================================================== RCS file: /cvs/e/e17/proto/e_phys/src/lib/e_phys_world.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_phys_world.c 17 Sep 2006 22:59:16 -0000 1.2 +++ e_phys_world.c 21 Sep 2006 05:24:58 -0000 1.3 @@ -45,6 +45,7 @@ e_phys_world_timer(void *data) { E_Phys_World *world; + float now; int i; // XXX right now, each timeslice is world->dt apart. it would probably @@ -52,7 +53,9 @@ // actually elapsed between slices. (then if a slice takes longer than dt to // calc, the frame rate will drop, the physical motion will remain 'at speed' world = data; - world->time += world->dt; + now = ecore_time_get(); + world->elapsed = now - world->time; + world->time = now; e_phys_world_accumulate_forces(world); e_phys_world_verlet_integrate(world); for (i = 0; i < world->constraint_iter; i++) @@ -65,6 +68,7 @@ void e_phys_world_go(E_Phys_World *world) { + world->time = ecore_time_get(); world->timer = ecore_timer_add(world->dt, e_phys_world_timer, world); } @@ -155,8 +159,8 @@ tmp.y = p->cur.y; //printf("force: (%0.2f, %0.2f)\n", p->force.x, p->force.y); - p->cur.x = (2 - world->friction) * p->cur.x - (1 - world->friction) * p->prev.x + p->force.x * world->dt * world->dt / p->m; - p->cur.y = (2 - world->friction) * p->cur.y - (1 - world->friction) *p->prev.y + p->force.y * world->dt * world->dt / p->m; + p->cur.x = (2 - world->friction) * p->cur.x - (1 - world->friction) * p->prev.x + p->force.x * world->elapsed * world->elapsed / p->m; + p->cur.y = (2 - world->friction) * p->cur.y - (1 - world->friction) *p->prev.y + p->force.y * world->elapsed * world->elapsed / p->m; p->prev.x = tmp.x; p->prev.y = tmp.y; ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs