]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/vector.qh
Merge branch 'terencehill/eraseable_functions'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / vector.qh
index 5d2b795f4515f6915141cc7ff0c5758ebda26dd9..746a43d089015eec6eed881b76ea86df8eb10d87 100644 (file)
@@ -100,6 +100,10 @@ float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { ret
        up = v_up; \
 } MACRO_END
 
+//pseudo prototypes:
+// vector vec2(vector v); // returns a vector with just the x and y components of the given vector
+// vector vec2(float x, float y); // returns a vector with the given x and y components
+
 noref vector _vec2;
 #define vec2(...) EVAL(OVERLOAD(vec2, __VA_ARGS__))
 #define vec2_1(v) (_vec2 = (v), _vec2.z = 0, _vec2)
@@ -112,10 +116,7 @@ noref vector _vec3;
 vector Rotate(vector v, float a)
 {
        float a_sin = sin(a), a_cos = cos(a);
-       vector r = '0 0 0';
-       r.x =      v.x * a_cos + v.y * a_sin;
-       r.y = -1 * v.x * a_sin + v.y * a_cos;
-       return r;
+       return vec2(v.x * a_cos + v.y * a_sin, -v.x * a_sin + v.y * a_cos);
 }
 
 noref vector _yinvert;
@@ -177,10 +178,10 @@ vector vec_epsilon(vector this, float eps)
                vector m1 = box.mins + box.origin;
                vector m2 = box.maxs + box.origin;
 
-               vector ret;
-               ret.x = bound(m1.x, org.x, m2.x);
-               ret.y = bound(m1.y, org.y, m2.y);
-               ret.z = bound(m1.z, org.z, m2.z);
-               return ret;
+               return vec3(
+                       bound(m1.x, org.x, m2.x),
+                       bound(m1.y, org.y, m2.y),
+                       bound(m1.z, org.z, m2.z)
+               );
        }
 #endif