// I want to draw a quad...
// from and to are MIDPOINTS.
- vector axis, thickdir, A, B, C, D;
- float length_tex;
+ float len = vlen(to - from);
+ if (!len)
+ return;
- axis = normalize(to - from);
- length_tex = aspect * vlen(to - from) / thickness;
+ float length_tex = aspect * len / thickness;
+ vector axis = (to - from) / len; // same as axis = normalize(to - from) but cheaper
// direction is perpendicular to the view normal, and perpendicular to the axis
- thickdir = normalize(cross(axis, vieworg - from));
+ vector thickdir = normalize(cross(axis, vieworg - from));
- A = from - thickdir * (thickness / 2);
- B = from + thickdir * (thickness / 2);
- C = to + thickdir * (thickness / 2);
- D = to - thickdir * (thickness / 2);
+ vector ofs = thickdir * (thickness / 2);
R_BeginPolygon(texture, drawflag, false);
- R_PolygonVertex(A, '0 0 0' + shift * '1 0 0', rgb, theAlpha);
- R_PolygonVertex(B, '0 1 0' + shift * '1 0 0', rgb, theAlpha);
- R_PolygonVertex(C, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha);
- R_PolygonVertex(D, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha);
+ R_PolygonVertex(from - ofs, '0 0 0' + shift * '1 0 0', rgb, theAlpha);
+ R_PolygonVertex(from + ofs, '0 1 0' + shift * '1 0 0', rgb, theAlpha);
+ R_PolygonVertex(to + ofs, '0 1 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha);
+ R_PolygonVertex(to - ofs, '0 0 0' + (shift + length_tex) * '1 0 0', rgb, theAlpha);
R_EndPolygon();
}