#define VectorScale(in, scale, out) ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale),(out)[2] = (in)[2] * (scale))
#define VectorCompare(a,b) (((a)[0]==(b)[0])&&((a)[1]==(b)[1])&&((a)[2]==(b)[2]))
#define VectorMA(a, scale, b, c) ((c)[0] = (a)[0] + (scale) * (b)[0],(c)[1] = (a)[1] + (scale) * (b)[1],(c)[2] = (a)[2] + (scale) * (b)[2])
-#define VectorNormalizeFast(_v)\
-{\
- float _y, _number;\
- _number = DotProduct(_v, _v);\
- if (_number != 0.0)\
- {\
- *((long *)&_y) = 0x5f3759df - ((* (long *) &_number) >> 1);\
- _y = _y * (1.5f - (_number * 0.5f * _y * _y));\
- VectorScale(_v, _y, _v);\
- }\
-}
#define VectorRandom(v) {do{(v)[0] = CGVM_RandomRange(-1, 1);(v)[1] = CGVM_RandomRange(-1, 1);(v)[2] = CGVM_RandomRange(-1, 1);}while(DotProduct(v, v) > 1);}
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
#define NUMVERTEXNORMALS 162
siextern float r_avertexnormals[NUMVERTEXNORMALS][3];
#define m_bytenormals r_avertexnormals
-#define VectorNormalizeFast VectorNormalize
#define CL_PointQ1Contents(v) (Mod_PointInLeaf(v,cl.worldmodel)->contents)
typedef unsigned char qbyte;
#define cl_stainmaps.integer 0
vec3_t right1, right2, diff, normal;
VectorSubtract (org2, org1, normal);
- VectorNormalizeFast (normal);
+ VectorNormalize (normal);
// calculate 'right' vector for start
VectorSubtract (r_vieworigin, org1, diff);
- VectorNormalizeFast (diff);
+ VectorNormalize (diff);
CrossProduct (normal, diff, right1);
// calculate 'right' vector for end
VectorSubtract (r_vieworigin, org2, diff);
- VectorNormalizeFast (diff);
+ VectorNormalize (diff);
CrossProduct (normal, diff, right2);
vert[ 0] = org1[0] + width * right1[0];
right[0] -= d * forward[0];
right[1] -= d * forward[1];
right[2] -= d * forward[2];
- VectorNormalizeFast(right);
+ VectorNormalize(right);
CrossProduct(right, forward, up);
}
#if QW
o[1] = lhrandom(mins[1], maxs[1]);
o[2] = lhrandom(mins[2], maxs[2]);
VectorSubtract(o, center, v);
- VectorNormalizeFast(v);
+ VectorNormalize(v);
VectorScale(v, 100, v);
v[2] += sv_gravity.value * 0.15f;
particle(particletype + pt_static, 0x903010, 0xFFD030, tex_particle, 1.5, lhrandom(64, 128) / cl_particles_quality.value, 128 / cl_particles_quality.value, 1, 0, o[0], o[1], o[2], v[0], v[1], v[2], 0.2);
{
R_CalcBeam_Vertex3f(particle_vertex3f, p->org, p->vel, size);
VectorSubtract(p->vel, p->org, up);
- VectorNormalizeFast(up);
+ VectorNormalize(up);
v[0] = DotProduct(p->org, up) * (1.0f / 64.0f);
v[1] = DotProduct(p->vel, up) * (1.0f / 64.0f);
particle_texcoord2f[0] = 1;particle_texcoord2f[1] = v[0];
VectorClear(n); // FIXME: complain?
}
-float Q_RSqrt(float number)
-{
- float y;
-
- if (number == 0.0f)
- return 0.0f;
-
- *((int *)&y) = 0x5f3759df - ((* (int *) &number) >> 1);
- return y * (1.5f - (number * 0.5f * y * y));
-}
-
// assumes "src" is normalized
void PerpendicularVector( vec3_t dst, const vec3_t src )
{
d = DotProduct(forward, right);
VectorMA(right, -d, forward, right);
- VectorNormalizeFast(right);
+ VectorNormalize(right);
CrossProduct(right, forward, up);
}
#define VectorMAM(scale1, b1, scale2, b2, c) ((c)[0] = (scale1) * (b1)[0] + (scale2) * (b2)[0],(c)[1] = (scale1) * (b1)[1] + (scale2) * (b2)[1],(c)[2] = (scale1) * (b1)[2] + (scale2) * (b2)[2])
#define VectorMAMAM(scale1, b1, scale2, b2, scale3, b3, c) ((c)[0] = (scale1) * (b1)[0] + (scale2) * (b2)[0] + (scale3) * (b3)[0],(c)[1] = (scale1) * (b1)[1] + (scale2) * (b2)[1] + (scale3) * (b3)[1],(c)[2] = (scale1) * (b1)[2] + (scale2) * (b2)[2] + (scale3) * (b3)[2])
#define VectorMAMAMAM(scale1, b1, scale2, b2, scale3, b3, scale4, b4, c) ((c)[0] = (scale1) * (b1)[0] + (scale2) * (b2)[0] + (scale3) * (b3)[0] + (scale4) * (b4)[0],(c)[1] = (scale1) * (b1)[1] + (scale2) * (b2)[1] + (scale3) * (b3)[1] + (scale4) * (b4)[1],(c)[2] = (scale1) * (b1)[2] + (scale2) * (b2)[2] + (scale3) * (b3)[2] + (scale4) * (b4)[2])
-#define VectorNormalizeFast(_v)\
-{\
- float _y, _number;\
- _number = DotProduct(_v, _v);\
- if (_number != 0.0)\
- {\
- *((long *)&_y) = 0x5f3759df - ((* (long *) &_number) >> 1);\
- _y = _y * (1.5f - (_number * 0.5f * _y * _y));\
- VectorScale(_v, _y, _v);\
- }\
-}
#define VectorRandom(v) do{(v)[0] = lhrandom(-1, 1);(v)[1] = lhrandom(-1, 1);(v)[2] = lhrandom(-1, 1);}while(DotProduct(v, v) > 1)
#define VectorLerp(v1,lerp,v2,c) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]), (c)[2] = (v1)[2] + (lerp) * ((v2)[2] - (v1)[2]))
#define VectorReflect(a,r,b,c) do{double d;d = DotProduct((a), (b)) * -(1.0 + (r));VectorMA((a), (d), (b), (c));}while(0)
static int portal_markid = 0;
static float boxpoints[4*3];
-int Portal_PortalThroughPortalPlanes(tinyplane_t *clipplanes, int clipnumplanes, float *targpoints, int targnumpoints, float *out, int maxpoints)
+static int Portal_PortalThroughPortalPlanes(tinyplane_t *clipplanes, int clipnumplanes, float *targpoints, int targnumpoints, float *out, int maxpoints)
{
int numpoints, i;
if (targnumpoints < 3)
return numpoints;
}
-int Portal_RecursiveFlowSearch (mleaf_t *leaf, vec3_t eye, int firstclipplane, int numclipplanes)
+static int Portal_RecursiveFlowSearch (mleaf_t *leaf, vec3_t eye, int firstclipplane, int numclipplanes)
{
mportal_t *p;
int newpoints, i, prev;
VectorSubtract(eye, portaltemppoints2[i], v1);
VectorSubtract(portaltemppoints2[prev], portaltemppoints2[i], v2);
CrossProduct(v1, v2, newplanes[i].normal);
- VectorNormalizeFast(newplanes[i].normal);
+ VectorNormalize(newplanes[i].normal);
newplanes[i].dist = DotProduct(eye, newplanes[i].normal);
if (DotProduct(newplanes[i].normal, center) <= newplanes[i].dist)
{
return false;
}
-void Portal_PolygonRecursiveMarkLeafs(mnode_t *node, float *polypoints, int numpoints)
+static void Portal_PolygonRecursiveMarkLeafs(mnode_t *node, float *polypoints, int numpoints)
{
int i, front;
float *p;
VectorSubtract(eye, (&polypoints[i * 3]), v1);
VectorSubtract((&polypoints[prev * 3]), (&polypoints[i * 3]), v2);
CrossProduct(v1, v2, portalplanes[i].normal);
- VectorNormalizeFast(portalplanes[i].normal);
+ VectorNormalize(portalplanes[i].normal);
portalplanes[i].dist = DotProduct(eye, portalplanes[i].normal);
if (DotProduct(portalplanes[i].normal, center) <= portalplanes[i].dist)
{
return false;
}
-vec3_t trianglepoints[3];
-
typedef struct portalrecursioninfo_s
{
int exact;
}
portalrecursioninfo_t;
-void Portal_RecursiveFlow (portalrecursioninfo_t *info, mleaf_t *leaf, int firstclipplane, int numclipplanes)
+static void Portal_RecursiveFlow (portalrecursioninfo_t *info, mleaf_t *leaf, int firstclipplane, int numclipplanes)
{
mportal_t *p;
int newpoints, i, prev;
VectorAdd(center, portaltemppoints2[i], center);
// ixtable is a 1.0f / N table
VectorScale(center, ixtable[newpoints], center);
- // calculate the planes, and make sure the polygon can see it's own center
+ // calculate the planes, and make sure the polygon can see its own center
newplanes = &portalplanes[firstclipplane + numclipplanes];
for (prev = newpoints - 1, i = 0;i < newpoints;prev = i, i++)
{
- VectorSubtract(portaltemppoints2[prev], portaltemppoints2[i], v1);
- VectorSubtract(info->eye, portaltemppoints2[i], v2);
- CrossProduct(v1, v2, newplanes[i].normal);
- VectorNormalizeFast(newplanes[i].normal);
+ TriangleNormal(portaltemppoints2[prev], portaltemppoints2[i], info->eye, newplanes[i].normal);
+ VectorNormalize(newplanes[i].normal);
newplanes[i].dist = DotProduct(info->eye, newplanes[i].normal);
if (DotProduct(newplanes[i].normal, center) <= newplanes[i].dist)
{
- // polygon can't see it's own center, discard and use parent portal
+ // polygon can't see its own center, discard and use parent portal
break;
}
}
}
}
-void Portal_RecursiveFindLeafForFlow(portalrecursioninfo_t *info, mnode_t *node)
+static void Portal_RecursiveFindLeafForFlow(portalrecursioninfo_t *info, mnode_t *node)
{
if (node->plane)
{
for (i = 0;i < numverts;i++, vertex3f += 3, svector3f += 3, tvector3f += 3, normal3f += 3, out3f += 3)
{
VectorSubtract(vertex3f, relativelightorigin, lightdir);
- VectorNormalizeFast(lightdir);
+ VectorNormalize(lightdir);
VectorSubtract(vertex3f, relativeeyeorigin, eyedir);
- VectorNormalizeFast(eyedir);
+ VectorNormalize(eyedir);
VectorAdd(lightdir, eyedir, halfdir);
// the cubemap normalizes this for us
out3f[0] = DotProduct(svector3f, halfdir);