X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=blobdiff_plain;f=misc%2Fbuilddeps%2Fwin64%2Fdx%2Finclude%2Fd3dvec.inl;fp=misc%2Fbuilddeps%2Fwin64%2Fdx%2Finclude%2Fd3dvec.inl;h=9418dd22f57a202d25d2fd215dca9884f6a5bbbe;hp=0000000000000000000000000000000000000000;hb=85864bd56ab6212ceba8b493afe8a54b14a9abb2;hpb=493accd7676823aa175639b70ad31242e6abdbd8 diff --git a/misc/builddeps/win64/dx/include/d3dvec.inl b/misc/builddeps/win64/dx/include/d3dvec.inl new file mode 100644 index 00000000..9418dd22 --- /dev/null +++ b/misc/builddeps/win64/dx/include/d3dvec.inl @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2000 Ove Kaaven + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_D3DVEC_INL +#define __WINE_D3DVEC_INL + +/*** constructors ***/ + +inline _D3DVECTOR::_D3DVECTOR(D3DVALUE f) +{ + x = y = z = f; +} + +inline _D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z) +{ + x = _x; y = _y; z = _z; +} + +/*** assignment operators ***/ + +inline _D3DVECTOR& _D3DVECTOR::operator += (const _D3DVECTOR& v) +{ + x += v.x; y += v.y; z += v.z; + return *this; +} + +inline _D3DVECTOR& _D3DVECTOR::operator -= (const _D3DVECTOR& v) +{ + x -= v.x; y -= v.y; z -= v.z; + return *this; +} + +inline _D3DVECTOR& _D3DVECTOR::operator *= (const _D3DVECTOR& v) +{ + x *= v.x; y *= v.y; z *= v.z; + return *this; +} + +inline _D3DVECTOR& _D3DVECTOR::operator /= (const _D3DVECTOR& v) +{ + x /= v.x; y /= v.y; z /= v.z; + return *this; +} + +inline _D3DVECTOR& _D3DVECTOR::operator *= (D3DVALUE s) +{ + x *= s; y *= s; z *= s; + return *this; +} + +inline _D3DVECTOR& _D3DVECTOR::operator /= (D3DVALUE s) +{ + x /= s; y /= s; z /= s; + return *this; +} + +/*** unary operators ***/ + +inline _D3DVECTOR operator + (const _D3DVECTOR& v) +{ + return v; +} + +inline _D3DVECTOR operator - (const _D3DVECTOR& v) +{ + return _D3DVECTOR(-v.x, -v.y, -v.z); +} + +/*** binary operators ***/ + +inline _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z); +} + +inline _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z); +} + +inline _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s) +{ + return _D3DVECTOR(v.x*s, v.y*s, v.z*s); +} + +inline _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v) +{ + return _D3DVECTOR(v.x*s, v.y*s, v.z*s); +} + +inline _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s) +{ + return _D3DVECTOR(v.x/s, v.y/s, v.z/s); +} + +inline D3DVALUE SquareMagnitude(const _D3DVECTOR& v) +{ + return v.x*v.x + v.y*v.y + v.z*v.z; /* DotProduct(v, v) */ +} + +inline D3DVALUE Magnitude(const _D3DVECTOR& v) +{ + return sqrt(SquareMagnitude(v)); +} + +inline _D3DVECTOR Normalize(const _D3DVECTOR& v) +{ + return v / Magnitude(v); +} + +inline D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; +} + +inline _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2) +{ + _D3DVECTOR res; + /* this is a left-handed cross product, right? */ + res.x = v1.y * v2.z - v1.z * v2.y; + res.y = v1.z * v2.x - v1.x * v2.z; + res.z = v1.x * v2.y - v1.y * v2.x; + return res; +} + +#endif