Index: src/cube.h ================================================================== --- src/cube.h +++ src/cube.h @@ -286,17 +286,12 @@ #define PI (3.1415927f) #define PI2 (2 * PI) // simplistic vector ops #define dotprod(u, v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z) -#define vmul(u, f) u = OFMultiplyVector3D(u, f) -#define vdiv(u, f) u = OFMultiplyVector3D(u, (f) / 1.0f) -#define vadd(u, v) u = OFAddVectors3D(u, v) -#define vsub(u, v) u = OFSubtractVectors3D(u, v) -#define vdist(d, v, e, s) \ - OFVector3D v = s; \ - vsub(v, e); \ +#define vdist(d, v, e, s) \ + OFVector3D v = OFSubtractVectors3D(s, e); \ float d = (float)sqrt(dotprod(v, v)); #define vreject(v, u, max) \ ((v).x > (u).x + (max) || (v).x < (u).x - (max) || \ (v).y > (u).y + (max) || (v).y < (u).y - (max)) #define vlinterp(v, f, u, g) \ Index: src/entities.m ================================================================== --- src/entities.m +++ src/entities.m @@ -292,13 +292,13 @@ if (lastmillis - lastjumppad < 300) break; lastjumppad = lastmillis; OFVector3D v = OFMakeVector3D((int)(char)ents[n].attr3 / 10.0f, (int)(char)ents[n].attr2 / 10.0f, ents[n].attr1 / 10.0f); - player1.velocity = - OFMakeVector3D(player1.velocity.x, player1.velocity.y, 0); - vadd(player1.velocity, v); + player1.velocity = OFAddVectors3D( + OFMakeVector3D(player1.velocity.x, player1.velocity.y, 0), + v); playsoundc(S_JUMPPAD); break; } } } Index: src/physics.m ================================================================== --- src/physics.m +++ src/physics.m @@ -290,22 +290,23 @@ const float fpsfric = friction / curtime * 20.0f; // slowly apply friction and direction to // velocity, gives a smooth movement - vmul(pl.velocity, fpsfric - 1); - vadd(pl.velocity, d); - vdiv(pl.velocity, fpsfric); - d = pl.velocity; - vmul(d, speed); // d is now frametime based velocity vector + OFVector3D velocity = OFMultiplyVector3D(pl.velocity, fpsfric - 1); + velocity = OFAddVectors3D(velocity, d); + velocity = OFMultiplyVector3D(velocity, 1.0f / fpsfric); + pl.velocity = velocity; + // d is now frametime based velocity vector + d = OFMultiplyVector3D(velocity, speed); pl.blocked = false; pl.moving = true; if (floating) { // just apply velocity - vadd(pl.origin, d); + pl.origin = OFAddVectors3D(pl.origin, d); if (pl.jumpNext) { pl.jumpNext = false; pl.velocity = OFMakeVector3D(pl.velocity.x, pl.velocity.y, 2); } Index: src/renderparticles.m ================================================================== --- src/renderparticles.m +++ src/renderparticles.m @@ -119,14 +119,13 @@ parempty = p; } else { if (pt->gr) p->o.z -= ((lastmillis - p->millis) / 3.0f) * curtime / (pt->gr * 10000); - OFVector3D a = p->d; - vmul(a, time); - vdiv(a, 20000.0f); - vadd(p->o, a); + OFVector3D a = OFMultiplyVector3D(p->d, time); + a = OFMultiplyVector3D(a, 1.0f / 20000.0f); + p->o = OFAddVectors3D(p->o, a); pp = &p->next; } } glEnable(GL_FOG); @@ -152,14 +151,14 @@ void particle_trail(int type, int fade, const OFVector3D *s, const OFVector3D *e) { vdist(d, v, *s, *e); - vdiv(v, d * 2 + 0.1f); + v = OFMultiplyVector3D(v, 1.0f / (d * 2 + 0.1f)); OFVector3D p = *s; for (int i = 0; i < ((int)d * 2); i++) { - vadd(p, v); + p = OFAddVectors3D(p, v); OFVector3D d = OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5); newparticle(&p, &d, rnd(fade) + fade, type); } } Index: src/savegamedemo.m ================================================================== --- src/savegamedemo.m +++ src/savegamedemo.m @@ -386,32 +386,28 @@ } VAR(demodelaymsec, 0, 120, 500); // spline interpolation -#define catmulrom(z, a, b, c, s, dest) \ - { \ - OFVector3D t1 = b, t2 = c; \ - \ - vsub(t1, z); \ - vmul(t1, 0.5f); \ - vsub(t2, a); \ - vmul(t2, 0.5f); \ - \ - float s2 = s * s; \ - float s3 = s * s2; \ - \ - dest = a; \ - OFVector3D t = b; \ - \ - vmul(dest, 2 * s3 - 3 * s2 + 1); \ - vmul(t, -2 * s3 + 3 * s2); \ - vadd(dest, t); \ - vmul(t1, s3 - 2 * s2 + s); \ - vadd(dest, t1); \ - vmul(t2, s3 - s2); \ - vadd(dest, t2); \ +#define catmulrom(z, a, b, c, s, dest) \ + { \ + OFVector3D t1 = OFSubtractVectors3D(b, z); \ + t1 = OFMultiplyVector3D(t1, 0.5f); \ + \ + OFVector3D t2 = OFSubtractVectors3D(c, a); \ + t2 = OFMultiplyVector3D(t2, 0.5f); \ + \ + float s2 = s * s; \ + float s3 = s * s2; \ + \ + dest = OFMultiplyVector3D(a, 2 * s3 - 3 * s2 + 1); \ + OFVector3D t = OFMultiplyVector3D(b, -2 * s3 + 3 * s2); \ + dest = OFAddVectors3D(dest, t); \ + t1 = OFMultiplyVector3D(t1, s3 - 2 * s2 + s); \ + dest = OFAddVectors3D(dest, t1); \ + t2 = OFMultiplyVector3D(t2, s3 - s2); \ + dest = OFAddVectors3D(dest, t2); \ } void fixwrap(DynamicEntity *a, DynamicEntity *b) { Index: src/weapon.m ================================================================== --- src/weapon.m +++ src/weapon.m @@ -75,38 +75,34 @@ void createrays(const OFVector3D *from, const OFVector3D *to) { vdist(dist, dvec, *from, *to); float f = dist * SGSPREAD / 1000; - for (int i = 0; i < SGRAYS; i++) { + for (int i = 0; i < SGRAYS; i++) #define RNDD (rnd(101) - 50) * f - OFVector3D r = OFMakeVector3D(RNDD, RNDD, RNDD); - sg[i] = *to; - vadd(sg[i], r); - } + sg[i] = OFAddVectors3D(*to, OFMakeVector3D(RNDD, RNDD, RNDD)); } // if lineseg hits entity bounding box static bool intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to) { OFVector3D v = *to, w = d.origin; const OFVector3D *p; - vsub(v, *from); - vsub(w, *from); + v = OFSubtractVectors3D(v, *from); + w = OFSubtractVectors3D(w, *from); float c1 = dotprod(w, v); if (c1 <= 0) p = from; else { float c2 = dotprod(v, v); if (c2 <= c1) p = to; else { - float f = c1 / c2; - vmul(v, f); - vadd(v, *from); + v = OFMultiplyVector3D(v, c1 / c2); + v = OFAddVectors3D(v, *from); p = &v; } } return (p->x <= d.origin.x + d.radius && @@ -197,12 +193,13 @@ if (dist < RL_DAMRAD) { if (dist < 0) dist = 0; int damage = (int)(qdam * (1 - (dist / RL_DAMRAD))); hit(cn, damage, o, at); - vmul(temp, (RL_DAMRAD - dist) * damage / 800); - vadd(o.velocity, temp); + temp = + OFMultiplyVector3D(temp, (RL_DAMRAD - dist) * damage / 800); + o.velocity = OFAddVectors3D(o.velocity, temp); } } static void splash(Projectile *p, const OFVector3D *v, const OFVector3D *vold, @@ -271,12 +268,12 @@ qdam /= MONSTERDAMAGEFACTOR; vdist(dist, v, p.o, p.to); float dtime = dist * 1000 / p.speed; if (time > dtime) dtime = time; - vmul(v, time / dtime); - vadd(v, p.o); + v = OFMultiplyVector3D(v, time / dtime); + v = OFAddVectors3D(v, p.o); if (p.local) { for (id player in players) if (player != [OFNull null]) projdamage(player, p, &v, i, -1, qdam); @@ -352,12 +349,12 @@ hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at, const OFVector3D *from, const OFVector3D *to) { hit(target, damage, d, at); vdist(dist, v, *from, *to); - vmul(v, damage / dist / 50); - vadd(d.velocity, v); + v = OFMultiplyVector3D(v, damage / dist / 50); + d.velocity = OFAddVectors3D(d.velocity, v); } void raydamage(DynamicEntity *o, const OFVector3D *from, const OFVector3D *to, DynamicEntity *d, int i) @@ -402,21 +399,20 @@ OFVector3D from = d.origin; OFVector3D to = *targ; from.z -= 0.2f; // below eye vdist(dist, unitv, from, to); - vdiv(unitv, dist); - OFVector3D kickback = unitv; - vmul(kickback, guns[d.gunSelect].kickamount * -0.01f); - vadd(d.velocity, kickback); + unitv = OFMultiplyVector3D(unitv, 1.0f / dist); + OFVector3D kickback = + OFMultiplyVector3D(unitv, guns[d.gunSelect].kickamount * -0.01f); + d.velocity = OFAddVectors3D(d.velocity, kickback); if (d.pitch < 80.0f) d.pitch += guns[d.gunSelect].kickamount * 0.05f; if (d.gunSelect == GUN_FIST || d.gunSelect == GUN_BITE) { - vmul(unitv, 3); // punch range - to = from; - vadd(to, unitv); + unitv = OFMultiplyVector3D(unitv, 3); // punch range + to = OFAddVectors3D(from, unitv); } if (d.gunSelect == GUN_SG) createrays(&from, &to); if (d.quadMillis && attacktime > 200)