Quake BSP renderer for PS1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

27 lines
926 B

#ifndef __QMATH_H__
#define __QMATH_H__
MATRIX *RotMatrixQ(SVECTOR *r, MATRIX *m);
INLINE short m_dot12s(const SVECTOR a, const SVECTOR b)
{
return (short)(((int)a.vx * b.vx) >> 12) + (((int)a.vy * b.vy) >> 12) + (((int)a.vz * b.vz) >> 12);
}
// TODO: worth a benchmark: is it faster to copy these vectors and use them from the stack, or to do six pointer dereferences?
INLINE short m_pointPlaneDist2(const VECTOR point2, const SVECTOR normal12, int dist2)
{
int x = ((int)point2.vx * normal12.vx) >> 12;
int y = ((int)point2.vy * normal12.vy) >> 12;
int z = ((int)point2.vz * normal12.vz) >> 12;
return (short)(x + y + z - dist2);
}
INLINE void m_lightColor(const CVECTOR *color, short light, CVECTOR *outColor)
{
outColor->r = (uint8_t)((light * color->r) >> 8);
outColor->g = (uint8_t)((light * color->g) >> 8);
outColor->b = (uint8_t)((light * color->b) >> 8);
}
#endif // __QMATH_H__