From: TimePath Date: Wed, 11 Nov 2015 11:22:22 +0000 (+1100) Subject: Vector: inline cross function X-Git-Tag: xonotic-v0.8.2~1678 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5c1cb16cc45f647b44c6a0bdd1e42e088f90b6a1;p=xonotic%2Fxonotic-data.pk3dir.git Vector: inline cross function --- diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 6cbaebdcd..0cda013c0 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -1,6 +1,17 @@ #ifndef VECTOR_H #define VECTOR_H +#define cross(a, b) ((a) >< (b)) +/* +vector cross(vector a, vector b) +{ + return + '1 0 0' * (a.y * b.z - a.z * b.y) + + '0 1 0' * (a.z * b.x - a.x * b.z) + + '0 0 1' * (a.x * b.y - a.y * b.x); +} +*/ + const vector eX = '1 0 0'; const vector eY = '0 1 0'; const vector eZ = '0 0 1'; diff --git a/qcsrc/lib/warpzone/mathlib.qc b/qcsrc/lib/warpzone/mathlib.qc index 92b7ee14d..ac3b65ff1 100644 --- a/qcsrc/lib/warpzone/mathlib.qc +++ b/qcsrc/lib/warpzone/mathlib.qc @@ -290,11 +290,3 @@ int isunordered(float x, float y) { return !(x < y || x == y || x > y); } - -vector cross(vector a, vector b) -{ - return - '1 0 0' * (a.y * b.z - a.z * b.y) - + '0 1 0' * (a.z * b.x - a.x * b.z) - + '0 0 1' * (a.x * b.y - a.y * b.x); -} diff --git a/qcsrc/lib/warpzone/mathlib.qh b/qcsrc/lib/warpzone/mathlib.qh index 9acece2ab..c3de3838d 100644 --- a/qcsrc/lib/warpzone/mathlib.qh +++ b/qcsrc/lib/warpzone/mathlib.qh @@ -115,7 +115,4 @@ const float M_2_SQRTPI = 1.12837916709551257390; /* 2/sqrt(pi) */ const float M_SQRT2 = 1.41421356237309504880; /* sqrt(2) */ const float M_SQRT1_2 = 0.70710678118654752440; /* 1/sqrt(2) */ -// Non- stuff follows here. -vector cross(vector a, vector b); - #endif diff --git a/qcsrc/menu/xonotic/crosshairpicker.qc b/qcsrc/menu/xonotic/crosshairpicker.qc index 0ac826a44..63da9cd92 100644 --- a/qcsrc/menu/xonotic/crosshairpicker.qc +++ b/qcsrc/menu/xonotic/crosshairpicker.qc @@ -60,18 +60,17 @@ bool XonoticCrosshairPicker_cellIsValid(entity me, vector cell) void XonoticCrosshairPicker_cellDraw(entity me, vector cell, vector cellPos) { - vector sz; - string cross = strcat("/gfx/crosshair", crosshairpicker_cellToCrosshair(me, cell)); - sz = draw_PictureSize(cross); + string s = strcat("/gfx/crosshair", crosshairpicker_cellToCrosshair(me, cell)); + vector sz = draw_PictureSize(s); sz = globalToBoxSize(sz, me.size); float ar = sz.x / sz.y; sz.x = me.realCellSize.x; sz.y = sz.x / ar; - sz = sz * 0.95; + sz *= 0.95; vector crosshairPos = cellPos + 0.5 * me.realCellSize; - draw_Picture(crosshairPos - 0.5 * sz, cross, sz, SKINCOLOR_CROSSHAIRPICKER_CROSSHAIR, SKINALPHA_CROSSHAIRPICKER_CROSSHAIR); + draw_Picture(crosshairPos - 0.5 * sz, s, sz, SKINCOLOR_CROSSHAIRPICKER_CROSSHAIR, SKINALPHA_CROSSHAIRPICKER_CROSSHAIR); if(cvar("crosshair_dot")) draw_Picture(crosshairPos - 0.5 * sz * cvar("crosshair_dot_size"), "/gfx/crosshairdot", sz * cvar("crosshair_dot_size"), SKINCOLOR_CROSSHAIRPICKER_CROSSHAIR, SKINALPHA_CROSSHAIRPICKER_CROSSHAIR);