X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fhairball.c;h=89c45c348b50f8baec77718316f97aec748f74b8;hp=49b5f783a28ac315f6c9a7cb6251b2e424f45dd9;hb=3398fc6c4188104048f99b650a6cb90beda9b6ed;hpb=9ecf7c26db456b3cef34a7d6d79ffb164cad17c5 diff --git a/src/hairball.c b/src/hairball.c index 49b5f78..89c45c3 100644 --- a/src/hairball.c +++ b/src/hairball.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "demo.h" #include "3dgfx.h" #include "vmath.h" @@ -74,7 +75,7 @@ struct screen *hairball_screen(void) static int init(void) { - int i; + int i, j, numpt = 0; gen_sphere_mesh(&sphmesh, 1.0f, 12, 6); @@ -87,8 +88,30 @@ static int init(void) return -1; } - for(i=0; i best_dist) { + spawnpos[numpt] = pos; + best_dist = mindist; + } + } + + spawndir[numpt] = spawnpos[numpt]; + ++numpt; } return 0; @@ -124,6 +147,10 @@ static void update(void) if(opt.sball) { memcpy(hball.xform, sball_matrix, 16 * sizeof(float)); + + hball.pos.x = hball.xform[12]; + hball.pos.y = hball.xform[13]; + hball.pos.z = hball.xform[14]; } else { if(mouse_bmask & MOUSE_BN_MIDDLE) { hball.pos.x += mouse_dx * 0.05; @@ -208,12 +235,15 @@ static void update_hairball(struct hairball *hb, float dt) struct particle *p = palloc(); float *mat = hb->xform; vec3_t pos = spawnpos[i]; + vec3_t dir = spawndir[i]; p->pos.x = mat[0] * pos.x + mat[4] * pos.y + mat[8] * pos.z + mat[12]; p->pos.y = mat[1] * pos.x + mat[5] * pos.y + mat[9] * pos.z + mat[13]; p->pos.z = mat[2] * pos.x + mat[6] * pos.y + mat[10] * pos.z + mat[14]; - p->vel = spawndir[i]; + p->vel.x = mat[0] * dir.x + mat[4] * dir.y + mat[8] * dir.z; + p->vel.y = mat[1] * dir.x + mat[5] * dir.y + mat[9] * dir.z; + p->vel.z = mat[2] * dir.x + mat[6] * dir.y + mat[10] * dir.z; p->life = HAIR_LENGTH; p->next = hb->plist[i];