diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-04-16 15:07:42 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-04-17 18:51:28 +0300 |
commit | 159806140fd33e6ddab951c0f6f180cfbf927d38 (patch) | |
tree | da076be3baa4d987fb5935e220a3d901c926e0e7 /intern/moto/include | |
parent | 28b996a9d2090efdd74115a653629ef9d7d871f7 (diff) |
Removing Blender Game Engine from Blender 2.8
Folders removed entirely:
* //extern/recastnavigation
* //intern/decklink
* //intern/moto
* //source/blender/editors/space_logic
* //source/blenderplayer
* //source/gameengine
This includes DNA data and any reference to the BGE code in Blender itself.
We are bumping the subversion.
Pending tasks:
* Tile/clamp code in image editor draw code.
* Viewport drawing code (so much of this will go away because of BI removal
that we can wait until then to remove this.
Diffstat (limited to 'intern/moto/include')
27 files changed, 0 insertions, 3022 deletions
diff --git a/intern/moto/include/MT_CmMatrix4x4.h b/intern/moto/include/MT_CmMatrix4x4.h deleted file mode 100644 index 53fdd41fb28..00000000000 --- a/intern/moto/include/MT_CmMatrix4x4.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_CmMatrix4x4.h - * \ingroup moto - */ - - -#ifndef INCLUDED_MT_CmMatrix4x4 -#define INCLUDED_MT_CmMatrix4x4 - -/** - * A 4x4 matrix. This is an OpenGl style matrix (column major) meaning - * that the vector {m[0][0],m[0][1],m[0][2],m[0][3]} is the first column of - * the matrix , the same as what you get if you transform {1,0,0,0}. - * This makes it easy to transform stuff to OpenGl. Please note that the - * the other MoTo matrices are row major. - * - * This class should be deprecated in favour of the more consistent - * MT_Matrix4x4. Please do not start using this class. - */ - -#include "MT_Scalar.h" - -class MT_Point3; -class MT_Vector3; - -class MT_CmMatrix4x4 -{ - -public : - - MT_CmMatrix4x4( - const MT_Scalar value[4][4] - ); - - MT_CmMatrix4x4( - ); - - - MT_CmMatrix4x4( - const MT_Scalar value[16] - ); - - MT_CmMatrix4x4( - const MT_CmMatrix4x4 & other - ); - - MT_CmMatrix4x4( - const MT_Point3& orig, - const MT_Vector3& dir, - const MT_Vector3 up - ); - - void - Identity( - ); - - void - SetMatrix( - const MT_CmMatrix4x4 & other - ); - - MT_Scalar* - getPointer( - ); - - const - MT_Scalar* - getPointer( - ) const; - - void - setElem( - int pos, - MT_Scalar newvalue - ); - - MT_Vector3 - GetRight( - ) const; - - MT_Vector3 - GetUp( - ) const; - - MT_Vector3 - GetDir( - ) const; - - MT_Point3 - GetPos( - ) const; - - void - SetPos( - const MT_Vector3 & v - ); - - MT_Scalar& - operator ( - ) (int row,int col) { return m_V[col][row]; } - - static - MT_CmMatrix4x4 - Perspective( - MT_Scalar inLeft, - MT_Scalar inRight, - MT_Scalar inBottom, - MT_Scalar inTop, - MT_Scalar inNear, - MT_Scalar inFar - ); - -protected: - union - { - MT_Scalar m_V[4][4]; - MT_Scalar m_Vflat[16]; - }; -}; - -#endif //MT_CmMatrix4x4 - diff --git a/intern/moto/include/MT_Matrix3x3.h b/intern/moto/include/MT_Matrix3x3.h deleted file mode 100644 index 6f965f59069..00000000000 --- a/intern/moto/include/MT_Matrix3x3.h +++ /dev/null @@ -1,276 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Matrix3x3.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_MATRIX3X3_H -#define MT_MATRIX3X3_H - -#include <MT_assert.h> - -#include "MT_Vector3.h" -#include "MT_Quaternion.h" - -class MT_Matrix3x3 { -public: - MT_Matrix3x3() {} - MT_Matrix3x3(const float *m) { setValue(m); } - MT_Matrix3x3(const double *m) { setValue(m); } - MT_Matrix3x3(const MT_Quaternion& q) { setRotation(q); } - - MT_Matrix3x3(const MT_Quaternion& q, const MT_Vector3& s) { - setRotation(q); - scale(s[0], s[1], s[2]); - } - - MT_Matrix3x3(const MT_Vector3& euler) { setEuler(euler); } - MT_Matrix3x3(const MT_Vector3& euler, const MT_Vector3& s) { - setEuler(euler); - scale(s[0], s[1], s[2]); - } - - MT_Matrix3x3(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz, - MT_Scalar yx, MT_Scalar yy, MT_Scalar yz, - MT_Scalar zx, MT_Scalar zy, MT_Scalar zz) { - setValue(xx, xy, xz, - yx, yy, yz, - zx, zy, zz); - } - - MT_Vector3& operator[](int i) { return m_el[i]; } - const MT_Vector3& operator[](int i) const { return m_el[i]; } - - MT_Vector3 getColumn(int i) const { - return MT_Vector3(m_el[0][i], m_el[1][i], m_el[2][i]); - } - - void setColumn(int i, const MT_Vector3& v) { - m_el[0][i] = v[0]; - m_el[1][i] = v[1]; - m_el[2][i] = v[2]; - } - - void setRow(int i, const MT_Vector3& v) { - m_el[i][0] = v[0]; - m_el[i][1] = v[1]; - m_el[i][2] = v[2]; - } - - void setValue(const float *m) { - m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m++; - m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m++; - m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m; - } - - void setValue(const double *m) { - m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m++; - m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m++; - m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m; - } - - void setValue3x3(const float *m) { - m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; - m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; - m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m; - } - - void setValue3x3(const double *m) { - m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; - m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; - m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m; - } - - void setValue(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz, - MT_Scalar yx, MT_Scalar yy, MT_Scalar yz, - MT_Scalar zx, MT_Scalar zy, MT_Scalar zz) { - m_el[0][0] = xx; m_el[0][1] = xy; m_el[0][2] = xz; - m_el[1][0] = yx; m_el[1][1] = yy; m_el[1][2] = yz; - m_el[2][0] = zx; m_el[2][1] = zy; m_el[2][2] = zz; - } - - void setRotation(const MT_Quaternion& q) { - MT_Scalar d = q.length2(); - MT_assert(!MT_fuzzyZero2(d)); - MT_Scalar s = MT_Scalar(2.0f) / d; - MT_Scalar xs = q[0] * s, ys = q[1] * s, zs = q[2] * s; - MT_Scalar wx = q[3] * xs, wy = q[3] * ys, wz = q[3] * zs; - MT_Scalar xx = q[0] * xs, xy = q[0] * ys, xz = q[0] * zs; - MT_Scalar yy = q[1] * ys, yz = q[1] * zs, zz = q[2] * zs; - setValue(MT_Scalar(1.0f) - (yy + zz), xy - wz , xz + wy, - xy + wz , MT_Scalar(1.0f) - (xx + zz), yz - wx, - xz - wy , yz + wx, MT_Scalar(1.0f) - (xx + yy)); - } - - /** - * setEuler - * @param euler a const reference to a MT_Vector3 of euler angles - * These angles are used to produce a rotation matrix. The euler - * angles are applied in ZYX order. I.e a vector is first rotated - * about X then Y and then Z - **/ - - void setEuler(const MT_Vector3& euler) { - MT_Scalar ci = cosf(euler[0]); - MT_Scalar cj = cosf(euler[1]); - MT_Scalar ch = cosf(euler[2]); - MT_Scalar si = sinf(euler[0]); - MT_Scalar sj = sinf(euler[1]); - MT_Scalar sh = sinf(euler[2]); - MT_Scalar cc = ci * ch; - MT_Scalar cs = ci * sh; - MT_Scalar sc = si * ch; - MT_Scalar ss = si * sh; - - setValue(cj * ch, sj * sc - cs, sj * cc + ss, - cj * sh, sj * ss + cc, sj * cs - sc, - -sj, cj * si, cj * ci); - } - - void getEuler(MT_Scalar& yaw, MT_Scalar& pitch, MT_Scalar& roll) const - { - if (m_el[2][0] != -1.0f && m_el[2][0] != 1.0f) { - pitch = MT_Scalar(-asinf(m_el[2][0])); - yaw = MT_Scalar(atan2f(m_el[2][1] / cosf(pitch), m_el[2][2] / cosf(pitch))); - roll = MT_Scalar(atan2f(m_el[1][0] / cosf(pitch), m_el[0][0] / cosf(pitch))); - } - else { - roll = MT_Scalar(0); - if (m_el[2][0] == -1.0f) { - pitch = (float)MT_PI / 2.0f; - yaw = MT_Scalar(atan2f(m_el[0][1], m_el[0][2])); - } - else { - pitch = (float)-MT_PI / 2.0f; - yaw = MT_Scalar(atan2f(m_el[0][1], m_el[0][2])); - } - } - } - - void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z) { - m_el[0][0] *= x; m_el[0][1] *= y; m_el[0][2] *= z; - m_el[1][0] *= x; m_el[1][1] *= y; m_el[1][2] *= z; - m_el[2][0] *= x; m_el[2][1] *= y; m_el[2][2] *= z; - } - - MT_Matrix3x3 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z) const { - return MT_Matrix3x3(m_el[0][0] * x, m_el[0][1] * y, m_el[0][2] * z, - m_el[1][0] * x, m_el[1][1] * y, m_el[1][2] * z, - m_el[2][0] * x, m_el[2][1] * y, m_el[2][2] * z); - } - - void setIdentity() { - setValue(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), - MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f), - MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f)); - } - - void getValue(float *m) const { - *m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; *m++ = (float) 0.0f; - *m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; *m++ = (float) 0.0f; - *m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; *m = (float) 0.0f; - } - - void getValue(double *m) const { - *m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0]; *m++ = 0.0; - *m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1]; *m++ = 0.0; - *m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2]; *m = 0.0; - } - - void getValue3x3(float *m) const { - *m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; - *m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; - *m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; - } - - void getValue3x3(double *m) const { - *m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0]; - *m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1]; - *m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2]; - } - - MT_Quaternion getRotation() const; - - MT_Matrix3x3& operator*=(const MT_Matrix3x3& m); - - MT_Scalar tdot(int c, const MT_Vector3& v) const { - return m_el[0][c] * v[0] + m_el[1][c] * v[1] + m_el[2][c] * v[2]; - } - - MT_Scalar cofac(int r1, int c1, int r2, int c2) const { - return m_el[r1][c1] * m_el[r2][c2] - m_el[r1][c2] * m_el[r2][c1]; - } - - MT_Scalar determinant() const; - MT_Matrix3x3 adjoint() const; - - MT_Matrix3x3 absolute() const; - - MT_Matrix3x3 transposed() const; - void transpose(); - - MT_Matrix3x3 inverse() const; - void invert(); - -protected: - - MT_Vector3 m_el[3]; -}; - -MT_Vector3 operator*(const MT_Matrix3x3& m, const MT_Vector3& v); -MT_Vector3 operator*(const MT_Vector3& v, const MT_Matrix3x3& m); -MT_Matrix3x3 operator*(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2); - -MT_Matrix3x3 MT_multTransposeLeft(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2); -MT_Matrix3x3 MT_multTransposeRight(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2); - -inline MT_OStream& operator<<(MT_OStream& os, const MT_Matrix3x3& m) { - return os << m[0] << GEN_endl << m[1] << GEN_endl << m[2] << GEN_endl; -} - -#ifdef GEN_INLINED -#include "MT_Matrix3x3.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Matrix3x3.inl b/intern/moto/include/MT_Matrix3x3.inl deleted file mode 100644 index 614e4f93a81..00000000000 --- a/intern/moto/include/MT_Matrix3x3.inl +++ /dev/null @@ -1,128 +0,0 @@ -#include "MT_Optimize.h" - -GEN_INLINE MT_Quaternion MT_Matrix3x3::getRotation() const { - static int next[3] = { 1, 2, 0 }; - - MT_Quaternion result; - - MT_Scalar trace = m_el[0][0] + m_el[1][1] + m_el[2][2]; - - if (trace > 0.0f) - { - MT_Scalar s = sqrtf(trace + MT_Scalar(1.0f)); - result[3] = s * MT_Scalar(0.5f); - s = MT_Scalar(0.5f) / s; - - result[0] = (m_el[2][1] - m_el[1][2]) * s; - result[1] = (m_el[0][2] - m_el[2][0]) * s; - result[2] = (m_el[1][0] - m_el[0][1]) * s; - } - else - { - int i = 0; - if (m_el[1][1] > m_el[0][0]) - i = 1; - if (m_el[2][2] > m_el[i][i]) - i = 2; - - int j = next[i]; - int k = next[j]; - - MT_Scalar s = sqrtf(m_el[i][i] - m_el[j][j] - m_el[k][k] + MT_Scalar(1.0f)); - - result[i] = s * MT_Scalar(0.5f); - - s = MT_Scalar(0.5f) / s; - - result[3] = (m_el[k][j] - m_el[j][k]) * s; - result[j] = (m_el[j][i] + m_el[i][j]) * s; - result[k] = (m_el[k][i] + m_el[i][k]) * s; - } - return result; -} - -GEN_INLINE MT_Matrix3x3& MT_Matrix3x3::operator*=(const MT_Matrix3x3& m) { - setValue(m.tdot(0, m_el[0]), m.tdot(1, m_el[0]), m.tdot(2, m_el[0]), - m.tdot(0, m_el[1]), m.tdot(1, m_el[1]), m.tdot(2, m_el[1]), - m.tdot(0, m_el[2]), m.tdot(1, m_el[2]), m.tdot(2, m_el[2])); - return *this; -} - -GEN_INLINE MT_Scalar MT_Matrix3x3::determinant() const { - return MT_triple((*this)[0], (*this)[1], (*this)[2]); -} - -GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::absolute() const { - return - MT_Matrix3x3(MT_abs(m_el[0][0]), MT_abs(m_el[0][1]), MT_abs(m_el[0][2]), - MT_abs(m_el[1][0]), MT_abs(m_el[1][1]), MT_abs(m_el[1][2]), - MT_abs(m_el[2][0]), MT_abs(m_el[2][1]), MT_abs(m_el[2][2])); -} - -GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::transposed() const { - return MT_Matrix3x3(m_el[0][0], m_el[1][0], m_el[2][0], - m_el[0][1], m_el[1][1], m_el[2][1], - m_el[0][2], m_el[1][2], m_el[2][2]); -} - -GEN_INLINE void MT_Matrix3x3::transpose() { - *this = transposed(); -} - -GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::adjoint() const { - return - MT_Matrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2), - cofac(1, 2, 2, 0), cofac(0, 0, 2, 2), cofac(0, 2, 1, 0), - cofac(1, 0, 2, 1), cofac(0, 1, 2, 0), cofac(0, 0, 1, 1)); -} - -GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::inverse() const { - MT_Vector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)); - MT_Scalar det = MT_dot((*this)[0], co); - MT_assert(!MT_fuzzyZero2(det)); - MT_Scalar s = MT_Scalar(1.0f) / det; - return - MT_Matrix3x3(co[0] * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s, - co[1] * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s, - co[2] * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s); -} - -GEN_INLINE void MT_Matrix3x3::invert() { - *this = inverse(); -} - -GEN_INLINE MT_Vector3 operator*(const MT_Matrix3x3& m, const MT_Vector3& v) { - return MT_Vector3(MT_dot(m[0], v), MT_dot(m[1], v), MT_dot(m[2], v)); -} - -GEN_INLINE MT_Vector3 operator*(const MT_Vector3& v, const MT_Matrix3x3& m) { - return MT_Vector3(m.tdot(0, v), m.tdot(1, v), m.tdot(2, v)); -} - -GEN_INLINE MT_Matrix3x3 operator*(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2) { - return - MT_Matrix3x3(m2.tdot(0, m1[0]), m2.tdot(1, m1[0]), m2.tdot(2, m1[0]), - m2.tdot(0, m1[1]), m2.tdot(1, m1[1]), m2.tdot(2, m1[1]), - m2.tdot(0, m1[2]), m2.tdot(1, m1[2]), m2.tdot(2, m1[2])); -} - -GEN_INLINE MT_Matrix3x3 MT_multTransposeLeft(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2) { - return MT_Matrix3x3( - m1[0][0] * m2[0][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0], - m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1], - m1[0][0] * m2[0][2] + m1[1][0] * m2[1][2] + m1[2][0] * m2[2][2], - m1[0][1] * m2[0][0] + m1[1][1] * m2[1][0] + m1[2][1] * m2[2][0], - m1[0][1] * m2[0][1] + m1[1][1] * m2[1][1] + m1[2][1] * m2[2][1], - m1[0][1] * m2[0][2] + m1[1][1] * m2[1][2] + m1[2][1] * m2[2][2], - m1[0][2] * m2[0][0] + m1[1][2] * m2[1][0] + m1[2][2] * m2[2][0], - m1[0][2] * m2[0][1] + m1[1][2] * m2[1][1] + m1[2][2] * m2[2][1], - m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]); -} - -GEN_INLINE MT_Matrix3x3 MT_multTransposeRight(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2) { - return - MT_Matrix3x3(m1[0].dot(m2[0]), m1[0].dot(m2[1]), m1[0].dot(m2[2]), - m1[1].dot(m2[0]), m1[1].dot(m2[1]), m1[1].dot(m2[2]), - m1[2].dot(m2[0]), m1[2].dot(m2[1]), m1[2].dot(m2[2])); - -} diff --git a/intern/moto/include/MT_Matrix4x4.h b/intern/moto/include/MT_Matrix4x4.h deleted file mode 100644 index 2ecac81ea6f..00000000000 --- a/intern/moto/include/MT_Matrix4x4.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Matrix4x4.h - * \ingroup moto - */ - - -/** - - * Copyright (C) 2001 NaN Technologies B.V. - * A 4x4 matrix compatible with other stuff. - */ - -#ifndef MT_MATRIX4X4_H -#define MT_MATRIX4X4_H - -#include <MT_assert.h> - -#include "MT_Vector4.h" -#include "MT_Transform.h" - -// Row-major 4x4 matrix - -class MT_Matrix4x4 { -public: - /** - * Empty contructor. - */ - MT_Matrix4x4() {} - /** - * Initialize all fields with the values pointed at by m. A - * contigous block of 16 values is read. */ - MT_Matrix4x4(const float *m) { setValue(m); } - /** - * Initialize all fields with the values pointed at by m. A - * contigous block of 16 values is read. */ - MT_Matrix4x4(const double *m) { setValue(m); } - - /** - * Initialise with these 16 explicit values. - */ - MT_Matrix4x4(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz, MT_Scalar xw, - MT_Scalar yx, MT_Scalar yy, MT_Scalar yz, MT_Scalar yw, - MT_Scalar zx, MT_Scalar zy, MT_Scalar zz, MT_Scalar zw, - MT_Scalar wx, MT_Scalar wy, MT_Scalar wz, MT_Scalar ww) { - setValue(xx, xy, xz, xw, - yx, yy, yz, yw, - zx, zy, zz, zw, - wx, wy, wz, ww); - } - - /** - * Initialize from an MT_Transform. - */ - MT_Matrix4x4(const MT_Transform &t) { - - const MT_Matrix3x3 &basis = t.getBasis(); - const MT_Vector3 &origin = t.getOrigin(); - - setValue( - basis[0][0],basis[0][1],basis[0][2],origin[0], - basis[1][0],basis[1][1],basis[1][2],origin[1], - basis[2][0],basis[2][1],basis[2][2],origin[2], - MT_Scalar(0.0f),MT_Scalar(0.0f),MT_Scalar(0.0f),MT_Scalar(1.0f) - ); - } - - /** - * Get the i-th row. - */ - MT_Vector4& operator[](int i) { return m_el[i]; } - /** - * Get the i-th row. - */ - const MT_Vector4& operator[](int i) const { return m_el[i]; } - - /** - * Set the matrix to the values pointer at by m. A contiguous - * block of 16 values is copied. */ - void setValue(const float *m) { - m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m_el[3][0] = *m++; - m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m_el[3][1] = *m++; - m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m++; m_el[3][2] = *m++; - m_el[0][3] = *m++; m_el[1][3] = *m++; m_el[2][3] = *m++; m_el[3][3] = *m; - } - - /** - * Set the matrix to the values pointer at by m. A contiguous - * block of 16 values is copied. - */ - void setValue(const double *m) { - m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m_el[3][0] = *m++; - m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m_el[3][1] = *m++; - m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m++; m_el[3][2] = *m++; - m_el[0][3] = *m++; m_el[1][3] = *m++; m_el[2][3] = *m++; m_el[3][3] = *m; - } - - /** - * Set the matrix to these 16 explicit values. - */ - void setValue(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz, MT_Scalar xw, - MT_Scalar yx, MT_Scalar yy, MT_Scalar yz, MT_Scalar yw, - MT_Scalar zx, MT_Scalar zy, MT_Scalar zz, MT_Scalar zw, - MT_Scalar wx, MT_Scalar wy, MT_Scalar wz, MT_Scalar ww) { - m_el[0][0] = xx; m_el[0][1] = xy; m_el[0][2] = xz; m_el[0][3] = xw; - m_el[1][0] = yx; m_el[1][1] = yy; m_el[1][2] = yz; m_el[1][3] = yw; - m_el[2][0] = zx; m_el[2][1] = zy; m_el[2][2] = zz; m_el[2][3] = zw; - m_el[3][0] = wx; m_el[3][1] = wy; m_el[3][2] = wz; m_el[3][3] = ww; - } - - /** - * Scale the columns of this matrix with x, y, z, w respectively. - */ - void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) { - m_el[0][0] *= x; m_el[0][1] *= y; m_el[0][2] *= z; m_el[0][3] *= w; - m_el[1][0] *= x; m_el[1][1] *= y; m_el[1][2] *= z; m_el[1][3] *= w; - m_el[2][0] *= x; m_el[2][1] *= y; m_el[2][2] *= z; m_el[2][3] *= w; - m_el[3][0] *= x; m_el[3][1] *= y; m_el[3][2] *= z; m_el[3][3] *= w; - } - - /** - * Scale the rows of this matrix with x, y, z, w respectively. - */ - void tscale(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) { - m_el[0][0] *= x; m_el[1][0] *= y; m_el[2][0] *= z; m_el[3][0] *= w; - m_el[0][1] *= x; m_el[1][1] *= y; m_el[2][1] *= z; m_el[3][1] *= w; - m_el[0][2] *= x; m_el[1][2] *= y; m_el[2][2] *= z; m_el[3][2] *= w; - m_el[0][3] *= x; m_el[1][3] *= y; m_el[2][3] *= z; m_el[3][3] *= w; - } - - /** - * Return a column-scaled version of this matrix. - */ - MT_Matrix4x4 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) const { - return MT_Matrix4x4(m_el[0][0] * x, m_el[0][1] * y, m_el[0][2] * z, m_el[0][3] * w, - m_el[1][0] * x, m_el[1][1] * y, m_el[1][2] * z, m_el[1][3] * w, - m_el[2][0] * x, m_el[2][1] * y, m_el[2][2] * z, m_el[2][3] * w, - m_el[3][0] * x, m_el[3][1] * y, m_el[3][2] * z, m_el[3][3] * w); - } - - /** - * Set this matrix to I. - */ - void setIdentity() { - setValue(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), - MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), - MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f), - MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f)); - } - - /** - * Read the element from row i, column j. - */ - float getElement(int i, int j) { - return (float) m_el[i][j]; - } - - /** - * Copy the contents to a contiguous block of 16 floats. - */ - void getValue(float *m) const { - *m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; *m++ = (float) m_el[3][0]; - *m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; *m++ = (float) m_el[3][1]; - *m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; *m++ = (float) m_el[3][2]; - *m++ = (float) m_el[0][3]; *m++ = (float) m_el[1][3]; *m++ = (float) m_el[2][3]; *m = (float) m_el[3][3]; - } - - /** - * Copy the contents to a contiguous block of 16 doubles. - */ - void getValue(double *m) const { - *m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0]; *m++ = m_el[3][0]; - *m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1]; *m++ = m_el[3][1]; - *m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2]; *m++ = m_el[3][2]; - *m++ = m_el[0][3]; *m++ = m_el[1][3]; *m++ = m_el[2][3]; *m = m_el[3][3]; - } - - /** - * Left-multiply this matrix with the argument. - */ - MT_Matrix4x4& operator*=(const MT_Matrix4x4& m); - - /** - * Left-multiply column c with row vector c. - */ - MT_Scalar tdot(int c, const MT_Vector4& v) const { - return m_el[0][c] * v[0] - + m_el[1][c] * v[1] - + m_el[2][c] * v[2] - + m_el[3][c] * v[3]; - } - - /* I'll postpone this for now... - nzc*/ -/* MT_Scalar determinant() const; */ -/* MT_Matrix4x4 adjoint() const; */ -/* MT_Matrix4x4 inverse() const; */ - - MT_Matrix4x4 absolute() const; - - MT_Matrix4x4 transposed() const; - void transpose(); - - MT_Matrix4x4 inverse() const; - void invert(); - -protected: - /** - * Access with [row index][column index] - */ - MT_Vector4 m_el[4]; -}; - -/* These multiplicators do exactly what you ask from them: they - * multiply in the indicated order. */ -MT_Vector4 operator*(const MT_Matrix4x4& m, const MT_Vector4& v); -MT_Vector4 operator*(const MT_Vector4& v, const MT_Matrix4x4& m); -MT_Matrix4x4 operator*(const MT_Matrix4x4& m1, const MT_Matrix4x4& m2); - -/* MT_Matrix4x4 MT_multTransposeLeft(const MT_Matrix4x4& m1, const MT_Matrix4x4& m2); */ -/* MT_Matrix4x4 MT_multTransposeRight(const MT_Matrix4x4& m1, const MT_Matrix4x4& m2); */ - -inline MT_OStream& operator<<(MT_OStream& os, const MT_Matrix4x4& m) { - return os << m[0] << GEN_endl - << m[1] << GEN_endl - << m[2] << GEN_endl - << m[3] << GEN_endl; - - - -} - -#ifdef GEN_INLINED -#include "MT_Matrix4x4.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Matrix4x4.inl b/intern/moto/include/MT_Matrix4x4.inl deleted file mode 100644 index fb72af1f9bf..00000000000 --- a/intern/moto/include/MT_Matrix4x4.inl +++ /dev/null @@ -1,108 +0,0 @@ -#include "MT_Optimize.h" - -/* - * This is a supposedly faster inverter than the cofactor - * computation. It uses an LU decomposition sort of thing. */ -GEN_INLINE void MT_Matrix4x4::invert() { - /* normalize row 0 */ - - int i,j,k; - - for (i=1; i < 4; i++) m_el[0][i] /= m_el[0][0]; - for (i=1; i < 4; i++) { - for (j=i; j < 4; j++) { // do a column of L - MT_Scalar sum = 0.0f; - for (k = 0; k < i; k++) - sum += m_el[j][k] * m_el[k][i]; - m_el[j][i] -= sum; - } - if (i == 3) continue; - for (j=i+1; j < 4; j++) { // do a row of U - MT_Scalar sum = 0.0f; - for (k = 0; k < i; k++) - sum += m_el[i][k]*m_el[k][j]; - m_el[i][j] = - (m_el[i][j]-sum) / m_el[i][i]; - } - } - for (i = 0; i < 4; i++ ) // invert L - for (j = i; j < 4; j++ ) { - MT_Scalar x = 1.0f; - if ( i != j ) { - x = 0.0f; - for (k = i; k < j; k++ ) - x -= m_el[j][k]*m_el[k][i]; - } - m_el[j][i] = x / m_el[j][j]; - } - for (i = 0; i < 4; i++ ) // invert U - for (j = i; j < 4; j++ ) { - if ( i == j ) continue; - MT_Scalar sum = 0.0f; - for (k = i; k < j; k++ ) - sum += m_el[k][j]*( (i==k) ? 1.0f : m_el[i][k] ); - m_el[i][j] = -sum; - } - for (i = 0; i < 4; i++ ) // final inversion - for (j = 0; j < 4; j++ ) { - MT_Scalar sum = 0.0f; - for (k = ((i>j)?i:j); k < 4; k++ ) - sum += ((j==k)?1.0f:m_el[j][k])*m_el[k][i]; - m_el[j][i] = sum; - } -} - -GEN_INLINE MT_Matrix4x4 MT_Matrix4x4::inverse() const -{ - MT_Matrix4x4 invmat = *this; - - invmat.invert(); - - return invmat; -} - -GEN_INLINE MT_Matrix4x4& MT_Matrix4x4::operator*=(const MT_Matrix4x4& m) -{ - setValue(m.tdot(0, m_el[0]), m.tdot(1, m_el[0]), m.tdot(2, m_el[0]), m.tdot(3, m_el[0]), - m.tdot(0, m_el[1]), m.tdot(1, m_el[1]), m.tdot(2, m_el[1]), m.tdot(3, m_el[1]), - m.tdot(0, m_el[2]), m.tdot(1, m_el[2]), m.tdot(2, m_el[2]), m.tdot(3, m_el[2]), - m.tdot(0, m_el[3]), m.tdot(1, m_el[3]), m.tdot(2, m_el[3]), m.tdot(3, m_el[3])); - return *this; - -} - -GEN_INLINE MT_Vector4 operator*(const MT_Matrix4x4& m, const MT_Vector4& v) { - return MT_Vector4(MT_dot(m[0], v), MT_dot(m[1], v), MT_dot(m[2], v), MT_dot(m[3], v)); -} - -GEN_INLINE MT_Vector4 operator*(const MT_Vector4& v, const MT_Matrix4x4& m) { - return MT_Vector4(m.tdot(0, v), m.tdot(1, v), m.tdot(2, v), m.tdot(3, v)); -} - -GEN_INLINE MT_Matrix4x4 operator*(const MT_Matrix4x4& m1, const MT_Matrix4x4& m2) { - return - MT_Matrix4x4(m2.tdot(0, m1[0]), m2.tdot(1, m1[0]), m2.tdot(2, m1[0]), m2.tdot(3, m1[0]), - m2.tdot(0, m1[1]), m2.tdot(1, m1[1]), m2.tdot(2, m1[1]), m2.tdot(3, m1[1]), - m2.tdot(0, m1[2]), m2.tdot(1, m1[2]), m2.tdot(2, m1[2]), m2.tdot(3, m1[2]), - m2.tdot(0, m1[3]), m2.tdot(1, m1[3]), m2.tdot(2, m1[3]), m2.tdot(3, m1[3])); -} - - -GEN_INLINE MT_Matrix4x4 MT_Matrix4x4::transposed() const { - return MT_Matrix4x4(m_el[0][0], m_el[1][0], m_el[2][0], m_el[3][0], - m_el[0][1], m_el[1][1], m_el[2][1], m_el[3][1], - m_el[0][2], m_el[1][2], m_el[2][2], m_el[3][2], - m_el[0][3], m_el[1][3], m_el[2][3], m_el[3][3]); -} - -GEN_INLINE void MT_Matrix4x4::transpose() { - *this = transposed(); -} - -GEN_INLINE MT_Matrix4x4 MT_Matrix4x4::absolute() const { - return - MT_Matrix4x4(MT_abs(m_el[0][0]), MT_abs(m_el[0][1]), MT_abs(m_el[0][2]), MT_abs(m_el[0][3]), - MT_abs(m_el[1][0]), MT_abs(m_el[1][1]), MT_abs(m_el[1][2]), MT_abs(m_el[1][3]), - MT_abs(m_el[2][0]), MT_abs(m_el[2][1]), MT_abs(m_el[2][2]), MT_abs(m_el[2][3]), - MT_abs(m_el[3][0]), MT_abs(m_el[3][1]), MT_abs(m_el[3][2]), MT_abs(m_el[3][3])); -} diff --git a/intern/moto/include/MT_MinMax.h b/intern/moto/include/MT_MinMax.h deleted file mode 100644 index 42e689f45a4..00000000000 --- a/intern/moto/include/MT_MinMax.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_MinMax.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_MINMAX_H -#define MT_MINMAX_H - -template <class T> -inline const T& MT_min(const T& a, const T& b) { - return b < a ? b : a; -} - -template <class T> -inline const T& MT_max(const T& a, const T& b) { - return a < b ? b : a; -} - -template <class T> -inline void MT_set_min(T& a, const T& b) { - if (a > b) a = b; -} - -template <class T> -inline void MT_set_max(T& a, const T& b) { - if (a < b) a = b; -} - -#endif - diff --git a/intern/moto/include/MT_Optimize.h b/intern/moto/include/MT_Optimize.h deleted file mode 100644 index e16bab1ecf9..00000000000 --- a/intern/moto/include/MT_Optimize.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Optimize.h - * \ingroup moto - */ - - -#ifndef GEN_OPTIMIZE_H -#define GEN_OPTIMIZE_H - -#ifdef GEN_INLINED -#define GEN_INLINE inline -#else -#define GEN_INLINE -#endif - -#endif - diff --git a/intern/moto/include/MT_Point2.h b/intern/moto/include/MT_Point2.h deleted file mode 100644 index 587379b21f4..00000000000 --- a/intern/moto/include/MT_Point2.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Point2.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_POINT2_H -#define MT_POINT2_H - -#include "MT_Vector2.h" - -class MT_Point2 : public MT_Vector2 { -public: - MT_Point2() {} - MT_Point2(const float *v2) : MT_Vector2(v2) {} - MT_Point2(const double *v2) : MT_Vector2(v2) {} - MT_Point2(MT_Scalar x2, MT_Scalar y2) : MT_Vector2(x2, y2) {} - - MT_Point2& operator+=(const MT_Vector2& v); - MT_Point2& operator-=(const MT_Vector2& v); - MT_Point2& operator=(const MT_Vector2& v); - - MT_Scalar distance(const MT_Point2& p) const; - MT_Scalar distance2(const MT_Point2& p) const; - - MT_Point2 lerp(const MT_Point2& p, MT_Scalar t) const; -}; - -MT_Point2 operator+(const MT_Point2& p, const MT_Vector2& v); -MT_Point2 operator-(const MT_Point2& p, const MT_Vector2& v); -MT_Vector2 operator-(const MT_Point2& p1, const MT_Point2& p2); - -MT_Scalar MT_distance(const MT_Point2& p1, const MT_Point2& p2); -MT_Scalar MT_distance2(const MT_Point2& p1, const MT_Point2& p2); - -MT_Point2 MT_lerp(const MT_Point2& p1, const MT_Point2& p2, MT_Scalar t); - -#ifdef GEN_INLINED -#include "MT_Point2.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Point2.inl b/intern/moto/include/MT_Point2.inl deleted file mode 100644 index ec09a3260e2..00000000000 --- a/intern/moto/include/MT_Point2.inl +++ /dev/null @@ -1,54 +0,0 @@ -#include "MT_Optimize.h" - -GEN_INLINE MT_Point2& MT_Point2::operator+=(const MT_Vector2& v) { - m_co[0] += v[0]; m_co[1] += v[1]; - return *this; -} - -GEN_INLINE MT_Point2& MT_Point2::operator-=(const MT_Vector2& v) { - m_co[0] -= v[0]; m_co[1] -= v[1]; - return *this; -} - -GEN_INLINE MT_Point2& MT_Point2::operator=(const MT_Vector2& v) { - m_co[0] = v[0]; m_co[1] = v[1]; - return *this; -} - -GEN_INLINE MT_Scalar MT_Point2::distance(const MT_Point2& p) const { - return (p - *this).length(); -} - -GEN_INLINE MT_Scalar MT_Point2::distance2(const MT_Point2& p) const { - return (p - *this).length2(); -} - -GEN_INLINE MT_Point2 MT_Point2::lerp(const MT_Point2& p, MT_Scalar t) const { - return MT_Point2(m_co[0] + (p[0] - m_co[0]) * t, - m_co[1] + (p[1] - m_co[1]) * t); -} - -GEN_INLINE MT_Point2 operator+(const MT_Point2& p, const MT_Vector2& v) { - return MT_Point2(p[0] + v[0], p[1] + v[1]); -} - -GEN_INLINE MT_Point2 operator-(const MT_Point2& p, const MT_Vector2& v) { - return MT_Point2(p[0] - v[0], p[1] - v[1]); -} - -GEN_INLINE MT_Vector2 operator-(const MT_Point2& p1, const MT_Point2& p2) { - return MT_Vector2(p1[0] - p2[0], p1[1] - p2[1]); -} - -GEN_INLINE MT_Scalar MT_distance(const MT_Point2& p1, const MT_Point2& p2) { - return p1.distance(p2); -} - -GEN_INLINE MT_Scalar MT_distance2(const MT_Point2& p1, const MT_Point2& p2) { - return p1.distance2(p2); -} - -GEN_INLINE MT_Point2 MT_lerp(const MT_Point2& p1, const MT_Point2& p2, MT_Scalar t) { - return p1.lerp(p2, t); -} - diff --git a/intern/moto/include/MT_Point3.h b/intern/moto/include/MT_Point3.h deleted file mode 100644 index f19b2e2f324..00000000000 --- a/intern/moto/include/MT_Point3.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Point3.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_POINT_H -#define MT_POINT_H - -#include "MT_Vector3.h" - -class MT_Point3 : public MT_Vector3 { -public: - MT_Point3() {} - MT_Point3(const float *v) : MT_Vector3(v) {} - MT_Point3(const double *v) : MT_Vector3(v) {} - MT_Point3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) : MT_Vector3(xx, yy, zz) {} - - MT_Point3& operator+=(const MT_Vector3& v); - MT_Point3& operator-=(const MT_Vector3& v); - MT_Point3& operator=(const MT_Vector3& v); - MT_Point3& operator=(const MT_Point3& v); - - MT_Scalar distance(const MT_Point3& p) const; - MT_Scalar distance2(const MT_Point3& p) const; - - MT_Point3 lerp(const MT_Point3& p, MT_Scalar t) const; -}; - -MT_Point3 operator+(const MT_Point3& p, const MT_Vector3& v); -MT_Point3 operator-(const MT_Point3& p, const MT_Vector3& v); -MT_Vector3 operator-(const MT_Point3& p1, const MT_Point3& p2); - -MT_Scalar MT_distance(const MT_Point3& p1, const MT_Point3& p2); -MT_Scalar MT_distance2(const MT_Point3& p1, const MT_Point3& p2); - -MT_Point3 MT_lerp(const MT_Point3& p1, const MT_Point3& p2, MT_Scalar t); - -#ifdef GEN_INLINED -#include "MT_Point3.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Point3.inl b/intern/moto/include/MT_Point3.inl deleted file mode 100644 index 081a8195694..00000000000 --- a/intern/moto/include/MT_Point3.inl +++ /dev/null @@ -1,59 +0,0 @@ -#include "MT_Optimize.h" - -GEN_INLINE MT_Point3& MT_Point3::operator+=(const MT_Vector3& v) { - m_co[0] += v[0]; m_co[1] += v[1]; m_co[2] += v[2]; - return *this; -} - -GEN_INLINE MT_Point3& MT_Point3::operator-=(const MT_Vector3& v) { - m_co[0] -= v[0]; m_co[1] -= v[1]; m_co[2] -= v[2]; - return *this; -} - -GEN_INLINE MT_Point3& MT_Point3::operator=(const MT_Vector3& v) { - m_co[0] = v[0]; m_co[1] = v[1]; m_co[2] = v[2]; - return *this; -} - -GEN_INLINE MT_Point3& MT_Point3::operator=(const MT_Point3& v) { - m_co[0] = v[0]; m_co[1] = v[1]; m_co[2] = v[2]; - return *this; -} - -GEN_INLINE MT_Scalar MT_Point3::distance(const MT_Point3& p) const { - return (p - *this).length(); -} - -GEN_INLINE MT_Scalar MT_Point3::distance2(const MT_Point3& p) const { - return (p - *this).length2(); -} - -GEN_INLINE MT_Point3 MT_Point3::lerp(const MT_Point3& p, MT_Scalar t) const { - return MT_Point3(m_co[0] + (p[0] - m_co[0]) * t, - m_co[1] + (p[1] - m_co[1]) * t, - m_co[2] + (p[2] - m_co[2]) * t); -} - -GEN_INLINE MT_Point3 operator+(const MT_Point3& p, const MT_Vector3& v) { - return MT_Point3(p[0] + v[0], p[1] + v[1], p[2] + v[2]); -} - -GEN_INLINE MT_Point3 operator-(const MT_Point3& p, const MT_Vector3& v) { - return MT_Point3(p[0] - v[0], p[1] - v[1], p[2] - v[2]); -} - -GEN_INLINE MT_Vector3 operator-(const MT_Point3& p1, const MT_Point3& p2) { - return MT_Vector3(p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]); -} - -GEN_INLINE MT_Scalar MT_distance(const MT_Point3& p1, const MT_Point3& p2) { - return p1.distance(p2); -} - -GEN_INLINE MT_Scalar MT_distance2(const MT_Point3& p1, const MT_Point3& p2) { - return p1.distance2(p2); -} - -GEN_INLINE MT_Point3 MT_lerp(const MT_Point3& p1, const MT_Point3& p2, MT_Scalar t) { - return p1.lerp(p2, t); -} diff --git a/intern/moto/include/MT_Quaternion.h b/intern/moto/include/MT_Quaternion.h deleted file mode 100644 index 6aabb1f2ed4..00000000000 --- a/intern/moto/include/MT_Quaternion.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Quaternion.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_QUATERNION_H -#define MT_QUATERNION_H - -#include <MT_assert.h> - -#include "MT_Vector3.h" -#include "MT_Vector4.h" - -class MT_Quaternion : public MT_Vector4 { -public: - MT_Quaternion() {} - MT_Quaternion(const MT_Vector4& v) : MT_Vector4(v) {} - MT_Quaternion(const float v[4]) : MT_Vector4(v) {} - MT_Quaternion(const double v[4]) : MT_Vector4(v) {} - MT_Quaternion(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) : - MT_Vector4(xx, yy, zz, ww) {} - MT_Quaternion(const MT_Vector3& axis, MT_Scalar mt_angle) { - setRotation(axis, mt_angle); - } - MT_Quaternion(MT_Scalar yaw, MT_Scalar pitch, MT_Scalar roll) { - setEuler(yaw, pitch, roll); - } - - void setRotation(const MT_Vector3& axis, MT_Scalar mt_angle) { - MT_Scalar d = axis.length(); - MT_assert(!MT_fuzzyZero(d)); - MT_Scalar s = sinf(mt_angle * MT_Scalar(0.5f)) / d; - setValue(axis[0] * s, axis[1] * s, axis[2] * s, - cosf(mt_angle * MT_Scalar(0.5f))); - } - - void setEuler(MT_Scalar yaw, MT_Scalar pitch, MT_Scalar roll) { - MT_Scalar cosYaw = cosf(yaw * MT_Scalar(0.5f)); - MT_Scalar sinYaw = sinf(yaw * MT_Scalar(0.5f)); - MT_Scalar cosPitch = cosf(pitch * MT_Scalar(0.5f)); - MT_Scalar sinPitch = sinf(pitch * MT_Scalar(0.5f)); - MT_Scalar cosRoll = cosf(roll * MT_Scalar(0.5f)); - MT_Scalar sinRoll = sinf(roll * MT_Scalar(0.5f)); - setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw, - cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw, - sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw, - cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw); - } - - MT_Quaternion& operator*=(const MT_Quaternion& q); - - void conjugate(); - MT_Quaternion conjugate() const; - - void invert(); - MT_Quaternion inverse() const; - - MT_Scalar angle(const MT_Quaternion& q) const; - MT_Quaternion slerp(const MT_Quaternion& q, const MT_Scalar& t) const; - - static MT_Quaternion random(); -}; - -MT_Quaternion operator*(const MT_Quaternion& q1, const MT_Quaternion& q2); -MT_Quaternion operator*(const MT_Quaternion& q, const MT_Vector3& w); -MT_Quaternion operator*(const MT_Vector3& w, const MT_Quaternion& q); - -#ifdef GEN_INLINED -#include "MT_Quaternion.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Quaternion.inl b/intern/moto/include/MT_Quaternion.inl deleted file mode 100644 index 8fe71b7b214..00000000000 --- a/intern/moto/include/MT_Quaternion.inl +++ /dev/null @@ -1,100 +0,0 @@ -#include "MT_Optimize.h" - -GEN_INLINE MT_Quaternion& MT_Quaternion::operator*=(const MT_Quaternion& q) { - setValue(m_co[3] * q[0] + m_co[0] * q[3] + m_co[1] * q[2] - m_co[2] * q[1], - m_co[3] * q[1] + m_co[1] * q[3] + m_co[2] * q[0] - m_co[0] * q[2], - m_co[3] * q[2] + m_co[2] * q[3] + m_co[0] * q[1] - m_co[1] * q[0], - m_co[3] * q[3] - m_co[0] * q[0] - m_co[1] * q[1] - m_co[2] * q[2]); - return *this; -} - -GEN_INLINE void MT_Quaternion::conjugate() { - m_co[0] = -m_co[0]; m_co[1] = -m_co[1]; m_co[2] = -m_co[2]; -} - -GEN_INLINE MT_Quaternion MT_Quaternion::conjugate() const { - return MT_Quaternion(-m_co[0], -m_co[1], -m_co[2], m_co[3]); -} - -GEN_INLINE void MT_Quaternion::invert() { - conjugate(); - *this /= length2(); -} - -GEN_INLINE MT_Quaternion MT_Quaternion::inverse() const { - return conjugate() / length2(); -} - -// From: "Uniform Random Rotations", Ken Shoemake, Graphics Gems III, -// pg. 124-132 -GEN_INLINE MT_Quaternion MT_Quaternion::random() { - MT_Scalar x0 = MT_random(); - MT_Scalar r1 = sqrtf(MT_Scalar(1.0f) - x0), r2 = sqrtf(x0); - MT_Scalar t1 = (float)MT_2_PI * MT_random(), t2 = (float)MT_2_PI * MT_random(); - MT_Scalar c1 = cosf(t1), s1 = sinf(t1); - MT_Scalar c2 = cosf(t2), s2 = sinf(t2); - return MT_Quaternion(s1 * r1, c1 * r1, s2 * r2, c2 * r2); -} - -GEN_INLINE MT_Quaternion operator*(const MT_Quaternion& q1, - const MT_Quaternion& q2) { - return MT_Quaternion(q1[3] * q2[0] + q1[0] * q2[3] + q1[1] * q2[2] - q1[2] * q2[1], - q1[3] * q2[1] + q1[1] * q2[3] + q1[2] * q2[0] - q1[0] * q2[2], - q1[3] * q2[2] + q1[2] * q2[3] + q1[0] * q2[1] - q1[1] * q2[0], - q1[3] * q2[3] - q1[0] * q2[0] - q1[1] * q2[1] - q1[2] * q2[2]); -} - -GEN_INLINE MT_Quaternion operator*(const MT_Quaternion& q, const MT_Vector3& w) -{ - return MT_Quaternion( q[3] * w[0] + q[1] * w[2] - q[2] * w[1], - q[3] * w[1] + q[2] * w[0] - q[0] * w[2], - q[3] * w[2] + q[0] * w[1] - q[1] * w[0], - -q[0] * w[0] - q[1] * w[1] - q[2] * w[2]); -} - -GEN_INLINE MT_Quaternion operator*(const MT_Vector3& w, const MT_Quaternion& q) -{ - return MT_Quaternion( w[0] * q[3] + w[1] * q[2] - w[2] * q[1], - w[1] * q[3] + w[2] * q[0] - w[0] * q[2], - w[2] * q[3] + w[0] * q[1] - w[1] * q[0], - -w[0] * q[0] - w[1] * q[1] - w[2] * q[2]); -} - -GEN_INLINE MT_Scalar MT_Quaternion::angle(const MT_Quaternion& q) const -{ - MT_Scalar s = sqrtf(length2() * q.length2()); - assert(s != MT_Scalar(0.0f)); - - s = dot(q) / s; - - s = MT_clamp(s, -1.0f, 1.0f); - - return acosf(s); -} - -GEN_INLINE MT_Quaternion MT_Quaternion::slerp(const MT_Quaternion& q, const MT_Scalar& t) const -{ - MT_Scalar d, s0, s1; - MT_Scalar s = dot(q); - bool neg = (s < 0.0f); - - if (neg) - s = -s; - if ((1.0f - s) > 0.0001f) - { - MT_Scalar theta = acosf(s); - d = MT_Scalar(1.0f) / sinf(theta); - s0 = sinf((MT_Scalar(1.0f) - t) * theta); - s1 = sinf(t * theta); - } - else - { - d = MT_Scalar(1.0f); - s0 = MT_Scalar(1.0f) - t; - s1 = t; - } - if (neg) - s1 = -s1; - return d*(*this * s0 + q * s1); -} - diff --git a/intern/moto/include/MT_Scalar.h b/intern/moto/include/MT_Scalar.h deleted file mode 100644 index 94723f4d7ec..00000000000 --- a/intern/moto/include/MT_Scalar.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Scalar.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_SCALAR_H -#define MT_SCALAR_H - -#include <math.h> -#include <float.h> - -#include "MT_random.h" - -typedef float MT_Scalar; - - -const MT_Scalar MT_DEGS_PER_RAD(57.29577951308232286465); -const MT_Scalar MT_RADS_PER_DEG(0.01745329251994329547); -const MT_Scalar MT_PI(3.14159265358979323846); -const MT_Scalar MT_2_PI(6.28318530717958623200); -const MT_Scalar MT_EPSILON(1.0e-10); -const MT_Scalar MT_EPSILON2(1.0e-20); -const MT_Scalar MT_INFINITY(1.0e38); - -inline int MT_sign(MT_Scalar x) { - return x < 0.0f ? -1 : x > 0.0f ? 1 : 0; -} - -inline MT_Scalar MT_abs(MT_Scalar x) { return fabs(x); } - -inline bool MT_fuzzyZero(MT_Scalar x) { return MT_abs(x) < (float)MT_EPSILON; } -inline bool MT_fuzzyZero2(MT_Scalar x) { return MT_abs(x) < (float)MT_EPSILON2; } - -inline MT_Scalar MT_radians(MT_Scalar x) { - return x * (float)MT_RADS_PER_DEG; -} - -inline MT_Scalar MT_degrees(MT_Scalar x) { - return x * (float)MT_DEGS_PER_RAD; -} - -inline MT_Scalar MT_random() { - return MT_Scalar(MT_rand()) / MT_Scalar(MT_RAND_MAX); -} - -inline MT_Scalar MT_clamp(const MT_Scalar x, const MT_Scalar min, const MT_Scalar max) -{ - if (x < min) - return min; - else if (x > max) - return max; - return x; -} -#endif - diff --git a/intern/moto/include/MT_Stream.h b/intern/moto/include/MT_Stream.h deleted file mode 100644 index 42861e6c099..00000000000 --- a/intern/moto/include/MT_Stream.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Stream.h - * \ingroup moto - */ - - -#ifndef GEN_STREAM_H -#define GEN_STREAM_H - -#ifdef __CUSTOM_STREAM - -class MT_OStream -{ -public: - inline MT_OStream& operator<<(double); - inline MT_OStream& operator<<(int); - inline MT_OStream& operator<<(char*); -}; - -const char GEN_endl = '\n'; - -#else - -#include <iostream> - -typedef std::ostream MT_OStream; - -inline MT_OStream& GEN_endl(MT_OStream& os) { return std::endl(os); } - -#endif - -#endif - diff --git a/intern/moto/include/MT_Transform.h b/intern/moto/include/MT_Transform.h deleted file mode 100644 index 9c23482925c..00000000000 --- a/intern/moto/include/MT_Transform.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Transform.h - * \ingroup moto - */ - - -/* - - MoTo - 3D Motion Toolkit - Copyright (C) 2000 Gino van den Bergen <gino@acm.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef MT_TRANSFORM_H -#define MT_TRANSFORM_H - -#include "MT_Point3.h" -#include "MT_Matrix3x3.h" - -class MT_Transform { -public: - MT_Transform() {} - MT_Transform(const float *m) { setValue(m); } - MT_Transform(const double *m) { setValue(m); } - MT_Transform(const MT_Point3& p, const MT_Quaternion& q) - : m_type(IDENTITY) - { - setOrigin(p); - setRotation(q); - } - - MT_Transform(const MT_Point3& p, const MT_Matrix3x3& m) - : m_type(IDENTITY) - { - setOrigin(p); - setBasis(m); - } - - static MT_Transform Identity() - { - MT_Transform t; - t.setIdentity(); - return t; - } - - - MT_Point3 operator()(const MT_Point3& p) const { - return MT_Point3(MT_dot(m_basis[0], p) + m_origin[0], - MT_dot(m_basis[1], p) + m_origin[1], - MT_dot(m_basis[2], p) + m_origin[2]); - } - - MT_Vector3 operator()(const MT_Vector3& p) const { - return MT_Vector3(MT_dot(m_basis[0], p) + m_origin[0], - MT_dot(m_basis[1], p) + m_origin[1], - MT_dot(m_basis[2], p) + m_origin[2]); - } - - MT_Point3 operator*(const MT_Point3& p) const { - return (*this)(p); - } - - MT_Vector3 operator*(const MT_Vector3& p) const { - return (*this)(p); - } - - - MT_Matrix3x3& getBasis() { return m_basis; } - const MT_Matrix3x3& getBasis() const { return m_basis; } - MT_Point3& getOrigin() { return m_origin; } - const MT_Point3& getOrigin() const { return m_origin; } - MT_Quaternion getRotation() const { return m_basis.getRotation(); } - - void setValue(const float *m); - void setValue(const double *m); - - void setOrigin(const MT_Point3& origin) { - m_origin = origin; - m_type |= TRANSLATION; - } - - void setBasis(const MT_Matrix3x3& basis) { - m_basis = basis; - m_type |= LINEAR; - } - - void setRotation(const MT_Quaternion& q) { - m_basis.setRotation(q); - m_type &= ~SCALING; - m_type |= ROTATION; - } - - void getValue(float *m) const; - void getValue(double *m) const; - - void setIdentity(); - - MT_Transform& operator*=(const MT_Transform& t); - - /** - * Translate the origin of the transform according to the vector. - * @param v The vector to translate over. The vector is specified - * in the coordinate system of the transform itself. - */ - void translate(const MT_Vector3& v); - void rotate(const MT_Quaternion& q); - void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z); - - void invert(const MT_Transform& t); - void mult(const MT_Transform& t1, const MT_Transform& t2); - void multInverseLeft(const MT_Transform& t1, const MT_Transform& t2); - -private: - enum { - IDENTITY = 0x00, - TRANSLATION = 0x01, - ROTATION = 0x02, - RIGID = TRANSLATION | ROTATION, - SCALING = 0x04, - LINEAR = ROTATION | SCALING, - AFFINE = TRANSLATION | LINEAR - }; - - MT_Transform(const MT_Matrix3x3& basis, const MT_Point3& origin, - unsigned int type) { - setValue(basis, origin, type); - } - - void setValue(const MT_Matrix3x3& basis, const MT_Point3& origin, - unsigned int type) { - m_basis = basis; - m_origin = origin; - m_type = type; - } - - friend MT_Transform operator*(const MT_Transform& t1, const MT_Transform& t2); - - MT_Matrix3x3 m_basis; - MT_Point3 m_origin; - unsigned int m_type; -}; - -inline MT_Transform operator*(const MT_Transform& t1, const MT_Transform& t2) { - return MT_Transform(t1.m_basis * t2.m_basis, - t1(t2.m_origin), - t1.m_type | t2.m_type); -} - -#endif - diff --git a/intern/moto/include/MT_Tuple2.h b/intern/moto/include/MT_Tuple2.h deleted file mode 100644 index 465b31a6781..00000000000 --- a/intern/moto/include/MT_Tuple2.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Tuple2.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_Tuple2_H -#define MT_Tuple2_H - -#include "MT_Stream.h" -#include "MT_Scalar.h" - -class MT_Tuple2 { -public: - MT_Tuple2() {} - MT_Tuple2(const float *vv) { setValue(vv); } - MT_Tuple2(const double *vv) { setValue(vv); } - MT_Tuple2(MT_Scalar xx, MT_Scalar yy) { setValue(xx, yy); } - - MT_Scalar& operator[](int i) { return m_co[i]; } - const MT_Scalar& operator[](int i) const { return m_co[i]; } - - MT_Scalar& x() { return m_co[0]; } - const MT_Scalar& x() const { return m_co[0]; } - - MT_Scalar& y() { return m_co[1]; } - const MT_Scalar& y() const { return m_co[1]; } - - MT_Scalar& u() { return m_co[0]; } - const MT_Scalar& u() const { return m_co[0]; } - - MT_Scalar& v() { return m_co[1]; } - const MT_Scalar& v() const { return m_co[1]; } - - MT_Scalar *getValue() { return m_co; } - const MT_Scalar *getValue() const { return m_co; } - - void getValue(float *vv) const { - vv[0] = (float) m_co[0]; vv[1] = (float) m_co[1]; - } - - void getValue(double *vv) const { - vv[0] = m_co[0]; vv[1] = m_co[1]; - } - - void setValue(const float *vv) { - m_co[0] = vv[0]; m_co[1] = vv[1]; - } - - void setValue(const double *vv) { - m_co[0] = vv[0]; m_co[1] = vv[1]; - } - - void setValue(MT_Scalar xx, MT_Scalar yy) { - m_co[0] = xx; m_co[1] = yy; - } - -protected: - MT_Scalar m_co[2]; -}; - -inline bool operator==(const MT_Tuple2& t1, const MT_Tuple2& t2) { - return t1[0] == t2[0] && t1[1] == t2[1]; -} - -inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple2& t) { - return os << t[0] << ' ' << t[1]; -} - -#endif - diff --git a/intern/moto/include/MT_Tuple3.h b/intern/moto/include/MT_Tuple3.h deleted file mode 100644 index ddd8ed724ca..00000000000 --- a/intern/moto/include/MT_Tuple3.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Tuple3.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_TUPLE3_H -#define MT_TUPLE3_H - -#include "MT_Stream.h" -#include "MT_Scalar.h" - -class MT_Tuple3 { -public: - MT_Tuple3() {} - MT_Tuple3(const float *v) { setValue(v); } - MT_Tuple3(const double *v) { setValue(v); } - MT_Tuple3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) { setValue(xx, yy, zz); } - - MT_Scalar& operator[](int i) { return m_co[i]; } - const MT_Scalar& operator[](int i) const { return m_co[i]; } - - MT_Scalar& x() { return m_co[0]; } - const MT_Scalar& x() const { return m_co[0]; } - - MT_Scalar& y() { return m_co[1]; } - const MT_Scalar& y() const { return m_co[1]; } - - MT_Scalar& z() { return m_co[2]; } - const MT_Scalar& z() const { return m_co[2]; } - - MT_Scalar *getValue() { return m_co; } - const MT_Scalar *getValue() const { return m_co; } - - void getValue(float *v) const { - v[0] = float(m_co[0]); - v[1] = float(m_co[1]); - v[2] = float(m_co[2]); - } - - void getValue(double *v) const { - v[0] = double(m_co[0]); - v[1] = double(m_co[1]); - v[2] = double(m_co[2]); - } - - void setValue(const float *v) { - m_co[0] = MT_Scalar(v[0]); - m_co[1] = MT_Scalar(v[1]); - m_co[2] = MT_Scalar(v[2]); - } - - void setValue(const double *v) { - m_co[0] = MT_Scalar(v[0]); - m_co[1] = MT_Scalar(v[1]); - m_co[2] = MT_Scalar(v[2]); - } - - void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) { - m_co[0] = xx; m_co[1] = yy; m_co[2] = zz; - } - -protected: - MT_Scalar m_co[3]; -}; - -inline bool operator==(const MT_Tuple3& t1, const MT_Tuple3& t2) { - return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2]; -} - -inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple3& t) { - return os << t[0] << ' ' << t[1] << ' ' << t[2]; -} - -#endif - diff --git a/intern/moto/include/MT_Tuple4.h b/intern/moto/include/MT_Tuple4.h deleted file mode 100644 index aa3b60f1c9b..00000000000 --- a/intern/moto/include/MT_Tuple4.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Tuple4.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_TUPLE4_H -#define MT_TUPLE4_H - -#include "MT_Stream.h" -#include "MT_Scalar.h" - -class MT_Tuple4 { -public: - MT_Tuple4() {} - MT_Tuple4(const float *v) { setValue(v); } - MT_Tuple4(const double *v) { setValue(v); } - MT_Tuple4(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) { - setValue(xx, yy, zz, ww); - } - - MT_Scalar& operator[](int i) { return m_co[i]; } - const MT_Scalar& operator[](int i) const { return m_co[i]; } - - MT_Scalar& x() { return m_co[0]; } - const MT_Scalar& x() const { return m_co[0]; } - - MT_Scalar& y() { return m_co[1]; } - const MT_Scalar& y() const { return m_co[1]; } - - MT_Scalar& z() { return m_co[2]; } - const MT_Scalar& z() const { return m_co[2]; } - - MT_Scalar& w() { return m_co[3]; } - const MT_Scalar& w() const { return m_co[3]; } - - MT_Scalar *getValue() { return m_co; } - const MT_Scalar *getValue() const { return m_co; } - - - void getValue(float *v) const { - v[0] = float(m_co[0]); - v[1] = float(m_co[1]); - v[2] = float(m_co[2]); - v[3] = float(m_co[3]); - } - - void getValue(double *v) const { - v[0] = double(m_co[0]); - v[1] = double(m_co[1]); - v[2] = double(m_co[2]); - v[3] = double(m_co[3]); - } - - void setValue(const float *v) { - m_co[0] = MT_Scalar(v[0]); - m_co[1] = MT_Scalar(v[1]); - m_co[2] = MT_Scalar(v[2]); - m_co[3] = MT_Scalar(v[3]); - } - - void setValue(const double *v) { - m_co[0] = MT_Scalar(v[0]); - m_co[1] = MT_Scalar(v[1]); - m_co[2] = MT_Scalar(v[2]); - m_co[3] = MT_Scalar(v[3]); - } - - void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) { - m_co[0] = xx; m_co[1] = yy; m_co[2] = zz; m_co[3] = ww; - } - -protected: - MT_Scalar m_co[4]; -}; - -inline bool operator==(const MT_Tuple4& t1, const MT_Tuple4& t2) { - return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2] && t1[3] == t2[3]; -} - -inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple4& t) { - return os << t[0] << ' ' << t[1] << ' ' << t[2] << ' ' << t[3]; -} - -#endif - diff --git a/intern/moto/include/MT_Vector2.h b/intern/moto/include/MT_Vector2.h deleted file mode 100644 index 8b8f2478ce3..00000000000 --- a/intern/moto/include/MT_Vector2.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Vector2.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_VECTOR2_H -#define MT_VECTOR2_H - -#include <MT_assert.h> -#include "MT_Tuple2.h" - -class MT_Vector2 : public MT_Tuple2 { -public: - MT_Vector2() {} - MT_Vector2(const float *v2) : MT_Tuple2(v2) {} - MT_Vector2(const double *v2) : MT_Tuple2(v2) {} - MT_Vector2(MT_Scalar xx, MT_Scalar yy) : MT_Tuple2(xx, yy) {} - - MT_Vector2& operator+=(const MT_Vector2& v); - MT_Vector2& operator-=(const MT_Vector2& v); - MT_Vector2& operator*=(MT_Scalar s); - MT_Vector2& operator/=(MT_Scalar s); - - MT_Scalar dot(const MT_Vector2& v) const; - - MT_Scalar length2() const; - MT_Scalar length() const; - - MT_Vector2 absolute() const; - - void normalize(); - MT_Vector2 normalized() const; - - void scale(MT_Scalar x, MT_Scalar y); - MT_Vector2 scaled(MT_Scalar x, MT_Scalar y) const; - - bool fuzzyZero() const; - - MT_Scalar angle(const MT_Vector2& v) const; - MT_Vector2 cross(const MT_Vector2& v) const; - MT_Scalar triple(const MT_Vector2& v1, const MT_Vector2& v2) const; - - int closestAxis() const; - - static MT_Vector2 random(); -}; - -MT_Vector2 operator+(const MT_Vector2& v1, const MT_Vector2& v2); -MT_Vector2 operator-(const MT_Vector2& v1, const MT_Vector2& v2); -MT_Vector2 operator-(const MT_Vector2& v); -MT_Vector2 operator*(const MT_Vector2& v, MT_Scalar s); -MT_Vector2 operator*(MT_Scalar s, const MT_Vector2& v); -MT_Vector2 operator/(const MT_Vector2& v, MT_Scalar s); - -MT_Scalar MT_dot(const MT_Vector2& v1, const MT_Vector2& v2); - -MT_Scalar MT_length2(const MT_Vector2& v); -MT_Scalar MT_length(const MT_Vector2& v); - -bool MT_fuzzyZero(const MT_Vector2& v); -bool MT_fuzzyEqual(const MT_Vector2& v1, const MT_Vector2& v2); - -MT_Scalar MT_angle(const MT_Vector2& v1, const MT_Vector2& v2); -MT_Vector2 MT_cross(const MT_Vector2& v1, const MT_Vector2& v2); -MT_Scalar MT_triple(const MT_Vector2& v1, const MT_Vector2& v2, - const MT_Vector2& v3); - -#ifdef GEN_INLINED -#include "MT_Vector2.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Vector2.inl b/intern/moto/include/MT_Vector2.inl deleted file mode 100644 index ed16025e733..00000000000 --- a/intern/moto/include/MT_Vector2.inl +++ /dev/null @@ -1,89 +0,0 @@ -#include "MT_Optimize.h" - -GEN_INLINE MT_Vector2& MT_Vector2::operator+=(const MT_Vector2& vv) { - m_co[0] += vv[0]; m_co[1] += vv[1]; - return *this; -} - -GEN_INLINE MT_Vector2& MT_Vector2::operator-=(const MT_Vector2& vv) { - m_co[0] -= vv[0]; m_co[1] -= vv[1]; - return *this; -} - -GEN_INLINE MT_Vector2& MT_Vector2::operator*=(MT_Scalar s) { - m_co[0] *= s; m_co[1] *= s; - return *this; -} - -GEN_INLINE MT_Vector2& MT_Vector2::operator/=(MT_Scalar s) { - MT_assert(!MT_fuzzyZero(s)); - return *this *= 1.0f / s; -} - -GEN_INLINE MT_Vector2 operator+(const MT_Vector2& v1, const MT_Vector2& v2) { - return MT_Vector2(v1[0] + v2[0], v1[1] + v2[1]); -} - -GEN_INLINE MT_Vector2 operator-(const MT_Vector2& v1, const MT_Vector2& v2) { - return MT_Vector2(v1[0] - v2[0], v1[1] - v2[1]); -} - -GEN_INLINE MT_Vector2 operator-(const MT_Vector2& v) { - return MT_Vector2(-v[0], -v[1]); -} - -GEN_INLINE MT_Vector2 operator*(const MT_Vector2& v, MT_Scalar s) { - return MT_Vector2(v[0] * s, v[1] * s); -} - -GEN_INLINE MT_Vector2 operator*(MT_Scalar s, const MT_Vector2& v) { return v * s; } - -GEN_INLINE MT_Vector2 operator/(const MT_Vector2& v, MT_Scalar s) { - MT_assert(!MT_fuzzyZero(s)); - return v * (1.0f / s); -} - -GEN_INLINE MT_Scalar MT_Vector2::dot(const MT_Vector2& vv) const { - return m_co[0] * vv[0] + m_co[1] * vv[1]; -} - -GEN_INLINE MT_Scalar MT_Vector2::length2() const { return dot(*this); } -GEN_INLINE MT_Scalar MT_Vector2::length() const { return sqrtf(length2()); } - -GEN_INLINE MT_Vector2 MT_Vector2::absolute() const { - return MT_Vector2(MT_abs(m_co[0]), MT_abs(m_co[1])); -} - -GEN_INLINE bool MT_Vector2::fuzzyZero() const { return MT_fuzzyZero2(length2()); } - -GEN_INLINE void MT_Vector2::normalize() { *this /= length(); } -GEN_INLINE MT_Vector2 MT_Vector2::normalized() const { return *this / length(); } - -GEN_INLINE void MT_Vector2::scale(MT_Scalar xx, MT_Scalar yy) { - m_co[0] *= xx; m_co[1] *= yy; -} - -GEN_INLINE MT_Vector2 MT_Vector2::scaled(MT_Scalar xx, MT_Scalar yy) const { - return MT_Vector2(m_co[0] * xx, m_co[1] * yy); -} - -GEN_INLINE MT_Scalar MT_Vector2::angle(const MT_Vector2& vv) const { - MT_Scalar s = sqrtf(length2() * vv.length2()); - MT_assert(!MT_fuzzyZero(s)); - return acosf(dot(vv) / s); -} - - -GEN_INLINE MT_Scalar MT_dot(const MT_Vector2& v1, const MT_Vector2& v2) { - return v1.dot(v2); -} - -GEN_INLINE MT_Scalar MT_length2(const MT_Vector2& v) { return v.length2(); } -GEN_INLINE MT_Scalar MT_length(const MT_Vector2& v) { return v.length(); } - -GEN_INLINE bool MT_fuzzyZero(const MT_Vector2& v) { return v.fuzzyZero(); } -GEN_INLINE bool MT_fuzzyEqual(const MT_Vector2& v1, const MT_Vector2& v2) { - return MT_fuzzyZero(v1 - v2); -} - -GEN_INLINE MT_Scalar MT_angle(const MT_Vector2& v1, const MT_Vector2& v2) { return v1.angle(v2); } diff --git a/intern/moto/include/MT_Vector3.h b/intern/moto/include/MT_Vector3.h deleted file mode 100644 index 545ca1fad0b..00000000000 --- a/intern/moto/include/MT_Vector3.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Vector3.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_VECTOR3_H -#define MT_VECTOR3_H - -#include <MT_assert.h> -#include "MT_Tuple3.h" - -class MT_Vector3 : public MT_Tuple3 { -public: - MT_Vector3() {} - MT_Vector3(const float *v) : MT_Tuple3(v) {} - MT_Vector3(const double *v) : MT_Tuple3(v) {} - MT_Vector3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) : MT_Tuple3(xx, yy, zz) {} - - MT_Vector3& operator+=(const MT_Vector3& v); - MT_Vector3& operator-=(const MT_Vector3& v); - MT_Vector3& operator*=(MT_Scalar s); - MT_Vector3& operator/=(MT_Scalar s); - - MT_Scalar dot(const MT_Vector3& v) const; - - MT_Scalar length2() const; - MT_Scalar length() const; - - MT_Vector3 absolute() const; - - void noiseGate(MT_Scalar threshold); - - void normalize(); - MT_Vector3 normalized() const; - MT_Vector3 safe_normalized() const; - MT_Vector3 safe_normalized_vec(MT_Vector3 vecnormalized) const; - - void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z); - MT_Vector3 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z) const; - - bool fuzzyZero() const; - - MT_Scalar angle(const MT_Vector3& v) const; - MT_Vector3 cross(const MT_Vector3& v) const; - MT_Scalar triple(const MT_Vector3& v1, const MT_Vector3& v2) const; - - int closestAxis() const; - - static MT_Vector3 random(); -}; - -MT_Vector3 operator+(const MT_Vector3& v1, const MT_Vector3& v2); -MT_Vector3 operator-(const MT_Vector3& v1, const MT_Vector3& v2); -MT_Vector3 operator-(const MT_Vector3& v); -MT_Vector3 operator*(const MT_Vector3& v, MT_Scalar s); -MT_Vector3 operator*(MT_Scalar s, const MT_Vector3& v); -MT_Vector3 operator/(const MT_Vector3& v, MT_Scalar s); - -MT_Vector3 operator*(const MT_Vector3& v1, const MT_Vector3& v2); - -MT_Scalar MT_dot(const MT_Vector3& v1, const MT_Vector3& v2); - -MT_Scalar MT_length2(const MT_Vector3& v); -MT_Scalar MT_length(const MT_Vector3& v); - -bool MT_fuzzyZero(const MT_Vector3& v); -bool MT_fuzzyEqual(const MT_Vector3& v1, const MT_Vector3& v2); - -MT_Scalar MT_angle(const MT_Vector3& v1, const MT_Vector3& v2); -MT_Vector3 MT_cross(const MT_Vector3& v1, const MT_Vector3& v2); -MT_Scalar MT_triple(const MT_Vector3& v1, const MT_Vector3& v2, - const MT_Vector3& v3); - -#ifdef GEN_INLINED -#include "MT_Vector3.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Vector3.inl b/intern/moto/include/MT_Vector3.inl deleted file mode 100644 index 7994bf7c55c..00000000000 --- a/intern/moto/include/MT_Vector3.inl +++ /dev/null @@ -1,141 +0,0 @@ -#include "MT_Optimize.h" - -GEN_INLINE MT_Vector3& MT_Vector3::operator+=(const MT_Vector3& v) { - m_co[0] += v[0]; m_co[1] += v[1]; m_co[2] += v[2]; - return *this; -} - -GEN_INLINE MT_Vector3& MT_Vector3::operator-=(const MT_Vector3& v) { - m_co[0] -= v[0]; m_co[1] -= v[1]; m_co[2] -= v[2]; - return *this; -} - -GEN_INLINE MT_Vector3& MT_Vector3::operator*=(MT_Scalar s) { - m_co[0] *= s; m_co[1] *= s; m_co[2] *= s; - return *this; -} - -GEN_INLINE MT_Vector3& MT_Vector3::operator/=(MT_Scalar s) { - MT_assert(!MT_fuzzyZero(s)); - return *this *= MT_Scalar(1.0f) / s; -} - -GEN_INLINE MT_Vector3 operator+(const MT_Vector3& v1, const MT_Vector3& v2) { - return MT_Vector3(v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]); -} - -GEN_INLINE MT_Vector3 operator-(const MT_Vector3& v1, const MT_Vector3& v2) { - return MT_Vector3(v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]); -} - -GEN_INLINE MT_Vector3 operator-(const MT_Vector3& v) { - return MT_Vector3(-v[0], -v[1], -v[2]); -} - -GEN_INLINE MT_Vector3 operator*(const MT_Vector3& v, MT_Scalar s) { - return MT_Vector3(v[0] * s, v[1] * s, v[2] * s); -} - -GEN_INLINE MT_Vector3 operator*(MT_Scalar s, const MT_Vector3& v) { return v * s; } - -GEN_INLINE MT_Vector3 operator/(const MT_Vector3& v, MT_Scalar s) { - MT_assert(!MT_fuzzyZero(s)); - return v * (MT_Scalar(1.0f) / s); -} - -GEN_INLINE MT_Vector3 operator*(const MT_Vector3& v1, const MT_Vector3& v2) { - return MT_Vector3(v1[0] * v2[0], v1[1] * v2[1], v1[2] * v2[2]); -} - -GEN_INLINE MT_Scalar MT_Vector3::dot(const MT_Vector3& v) const { - return m_co[0] * v[0] + m_co[1] * v[1] + m_co[2] * v[2]; -} - -GEN_INLINE MT_Scalar MT_Vector3::length2() const { return dot(*this); } -GEN_INLINE MT_Scalar MT_Vector3::length() const { return sqrtf(length2()); } - -GEN_INLINE MT_Vector3 MT_Vector3::absolute() const { - return MT_Vector3(MT_abs(m_co[0]), MT_abs(m_co[1]), MT_abs(m_co[2])); -} - -GEN_INLINE bool MT_Vector3::fuzzyZero() const { - return MT_fuzzyZero(length2()); -} - -GEN_INLINE void MT_Vector3::noiseGate(MT_Scalar threshold) { - if (length2() < threshold) { - setValue(MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f)); - } -} - -GEN_INLINE void MT_Vector3::normalize() { *this /= length(); } -GEN_INLINE MT_Vector3 MT_Vector3::normalized() const { return *this / length(); } -GEN_INLINE MT_Vector3 MT_Vector3::safe_normalized() const { - MT_Scalar len = length(); - return MT_fuzzyZero(len) ? - MT_Vector3(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f)) : - *this / len; -} - -GEN_INLINE MT_Vector3 MT_Vector3::safe_normalized_vec(MT_Vector3 vecnormalized) const { - MT_Scalar len = length(); - return MT_fuzzyZero(len) ? - vecnormalized : - *this / len; -} - -GEN_INLINE void MT_Vector3::scale(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) { - m_co[0] *= xx; m_co[1] *= yy; m_co[2] *= zz; -} - -GEN_INLINE MT_Vector3 MT_Vector3::scaled(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) const { - return MT_Vector3(m_co[0] * xx, m_co[1] * yy, m_co[2] * zz); -} - -GEN_INLINE MT_Scalar MT_Vector3::angle(const MT_Vector3& v) const { - MT_Scalar s = sqrtf(length2() * v.length2()); - MT_assert(!MT_fuzzyZero(s)); - return acosf(dot(v) / s); -} - -GEN_INLINE MT_Vector3 MT_Vector3::cross(const MT_Vector3& v) const { - return MT_Vector3(m_co[1] * v[2] - m_co[2] * v[1], - m_co[2] * v[0] - m_co[0] * v[2], - m_co[0] * v[1] - m_co[1] * v[0]); -} - -GEN_INLINE MT_Scalar MT_Vector3::triple(const MT_Vector3& v1, const MT_Vector3& v2) const { - return m_co[0] * (v1[1] * v2[2] - v1[2] * v2[1]) + - m_co[1] * (v1[2] * v2[0] - v1[0] * v2[2]) + - m_co[2] * (v1[0] * v2[1] - v1[1] * v2[0]); -} - -GEN_INLINE int MT_Vector3::closestAxis() const { - MT_Vector3 a = absolute(); - return a[0] < a[1] ? (a[1] < a[2] ? 2 : 1) : (a[0] < a[2] ? 2 : 0); -} - -GEN_INLINE MT_Vector3 MT_Vector3::random() { - MT_Scalar z = MT_Scalar(2.0f) * MT_random() - MT_Scalar(1.0f); - MT_Scalar r = sqrtf(MT_Scalar(1.0f) - z * z); - MT_Scalar t = (float)MT_2_PI * MT_random(); - return MT_Vector3(r * cosf(t), r * sinf(t), z); -} - -GEN_INLINE MT_Scalar MT_dot(const MT_Vector3& v1, const MT_Vector3& v2) { - return v1.dot(v2); -} - -GEN_INLINE MT_Scalar MT_length2(const MT_Vector3& v) { return v.length2(); } -GEN_INLINE MT_Scalar MT_length(const MT_Vector3& v) { return v.length(); } - -GEN_INLINE bool MT_fuzzyZero(const MT_Vector3& v) { return v.fuzzyZero(); } -GEN_INLINE bool MT_fuzzyEqual(const MT_Vector3& v1, const MT_Vector3& v2) { - return MT_fuzzyZero(v1 - v2); -} - -GEN_INLINE MT_Scalar MT_angle(const MT_Vector3& v1, const MT_Vector3& v2) { return v1.angle(v2); } -GEN_INLINE MT_Vector3 MT_cross(const MT_Vector3& v1, const MT_Vector3& v2) { return v1.cross(v2); } -GEN_INLINE MT_Scalar MT_triple(const MT_Vector3& v1, const MT_Vector3& v2, const MT_Vector3& v3) { - return v1.triple(v2, v3); -} diff --git a/intern/moto/include/MT_Vector4.h b/intern/moto/include/MT_Vector4.h deleted file mode 100644 index 440bf9b84f1..00000000000 --- a/intern/moto/include/MT_Vector4.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_Vector4.h - * \ingroup moto - */ - - -/* - - * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Gino van den Bergen makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef MT_VECTOR4_H -#define MT_VECTOR4_H - -#include <MT_assert.h> - -#include "MT_Tuple4.h" - -class MT_Vector4 : public MT_Tuple4 { -public: - MT_Vector4() {} - MT_Vector4(const float *v) : MT_Tuple4(v) {} - MT_Vector4(const double *v) : MT_Tuple4(v) {} - MT_Vector4(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) : - MT_Tuple4(xx, yy, zz, ww) {} - - MT_Vector4& operator+=(const MT_Vector4& v); - MT_Vector4& operator-=(const MT_Vector4& v); - MT_Vector4& operator*=(MT_Scalar s); - MT_Vector4& operator/=(MT_Scalar s); - - MT_Scalar dot(const MT_Vector4& v) const; - - MT_Scalar length2() const; - MT_Scalar length() const; - - MT_Vector4 absolute() const; - - void normalize(); - MT_Vector4 normalized() const; - - void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w); - MT_Vector4 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) const; - - bool fuzzyZero() const; -}; - -MT_Vector4 operator+(const MT_Vector4& v1, const MT_Vector4& v2); -MT_Vector4 operator-(const MT_Vector4& v1, const MT_Vector4& v2); -MT_Vector4 operator-(const MT_Vector4& v); -MT_Vector4 operator*(const MT_Vector4& v, MT_Scalar s); -MT_Vector4 operator*(MT_Scalar s, const MT_Vector4& v); -MT_Vector4 operator/(const MT_Vector4& v, MT_Scalar s); - -MT_Scalar MT_dot(const MT_Vector4& v1, const MT_Vector4& v2); - -MT_Scalar MT_length2(const MT_Vector4& v); -MT_Scalar MT_length(const MT_Vector4& v); - -bool MT_fuzzyZero(const MT_Vector4& v); -bool MT_fuzzyEqual(const MT_Vector4& v1, const MT_Vector4& v2); - -#ifdef GEN_INLINED -#include "MT_Vector4.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Vector4.inl b/intern/moto/include/MT_Vector4.inl deleted file mode 100644 index 5b6e6766416..00000000000 --- a/intern/moto/include/MT_Vector4.inl +++ /dev/null @@ -1,80 +0,0 @@ -#include "MT_Optimize.h" - -GEN_INLINE MT_Vector4& MT_Vector4::operator+=(const MT_Vector4& v) { - m_co[0] += v[0]; m_co[1] += v[1]; m_co[2] += v[2]; m_co[3] += v[3]; - return *this; -} - -GEN_INLINE MT_Vector4& MT_Vector4::operator-=(const MT_Vector4& v) { - m_co[0] -= v[0]; m_co[1] -= v[1]; m_co[2] -= v[2]; m_co[3] -= v[3]; - return *this; -} - -GEN_INLINE MT_Vector4& MT_Vector4::operator*=(MT_Scalar s) { - m_co[0] *= s; m_co[1] *= s; m_co[2] *= s; m_co[3] *= s; - return *this; -} - -GEN_INLINE MT_Vector4& MT_Vector4::operator/=(MT_Scalar s) { - MT_assert(!MT_fuzzyZero(s)); - return *this *= MT_Scalar(1.0f) / s; -} - -GEN_INLINE MT_Vector4 operator+(const MT_Vector4& v1, const MT_Vector4& v2) { - return MT_Vector4(v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2], v1[3] + v2[3]); -} - -GEN_INLINE MT_Vector4 operator-(const MT_Vector4& v1, const MT_Vector4& v2) { - return MT_Vector4(v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2], v1[3] - v2[3]); -} - -GEN_INLINE MT_Vector4 operator-(const MT_Vector4& v) { - return MT_Vector4(-v[0], -v[1], -v[2], -v[3]); -} - -GEN_INLINE MT_Vector4 operator*(const MT_Vector4& v, MT_Scalar s) { - return MT_Vector4(v[0] * s, v[1] * s, v[2] * s, v[3] * s); -} - -GEN_INLINE MT_Vector4 operator*(MT_Scalar s, const MT_Vector4& v) { return v * s; } - -GEN_INLINE MT_Vector4 operator/(const MT_Vector4& v, MT_Scalar s) { - MT_assert(!MT_fuzzyZero(s)); - return v * (MT_Scalar(1.0f) / s); -} - -GEN_INLINE MT_Scalar MT_Vector4::dot(const MT_Vector4& v) const { - return m_co[0] * v[0] + m_co[1] * v[1] + m_co[2] * v[2] + m_co[3] * v[3]; -} - -GEN_INLINE MT_Scalar MT_Vector4::length2() const { return MT_dot(*this, *this); } -GEN_INLINE MT_Scalar MT_Vector4::length() const { return sqrtf(length2()); } - -GEN_INLINE MT_Vector4 MT_Vector4::absolute() const { - return MT_Vector4(MT_abs(m_co[0]), MT_abs(m_co[1]), MT_abs(m_co[2]), MT_abs(m_co[3])); -} - -GEN_INLINE void MT_Vector4::scale(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) { - m_co[0] *= xx; m_co[1] *= yy; m_co[2] *= zz; m_co[3] *= ww; -} - -GEN_INLINE MT_Vector4 MT_Vector4::scaled(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) const { - return MT_Vector4(m_co[0] * xx, m_co[1] * yy, m_co[2] * zz, m_co[3] * ww); -} - -GEN_INLINE bool MT_Vector4::fuzzyZero() const { return MT_fuzzyZero2(length2()); } - -GEN_INLINE void MT_Vector4::normalize() { *this /= length(); } -GEN_INLINE MT_Vector4 MT_Vector4::normalized() const { return *this / length(); } - -GEN_INLINE MT_Scalar MT_dot(const MT_Vector4& v1, const MT_Vector4& v2) { - return v1.dot(v2); -} - -GEN_INLINE MT_Scalar MT_length2(const MT_Vector4& v) { return v.length2(); } -GEN_INLINE MT_Scalar MT_length(const MT_Vector4& v) { return v.length(); } - -GEN_INLINE bool MT_fuzzyZero(const MT_Vector4& v) { return v.fuzzyZero(); } -GEN_INLINE bool MT_fuzzyEqual(const MT_Vector4& v1, const MT_Vector4& v2) { - return MT_fuzzyZero(v1 - v2); -} diff --git a/intern/moto/include/MT_assert.h b/intern/moto/include/MT_assert.h deleted file mode 100644 index 256397036de..00000000000 --- a/intern/moto/include/MT_assert.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -* ***** BEGIN GPL LICENSE BLOCK ***** -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -* All rights reserved. -* -* The Original Code is: all of this file. -* -* Contributor(s): none yet. -* -* ***** END GPL LICENSE BLOCK ***** -*/ - -/** \file moto/include/MT_assert.h - * \ingroup moto - */ - - -#ifndef MT_ASSERT_H -#define MT_ASSERT_H - -#include <signal.h> -#include <stdlib.h> -#include <assert.h> - - -// So it can be used from C -#ifdef __cplusplus -#define MT_CDECL extern "C" -#else -#define MT_CDECL -#endif - -// Ask the user if they wish to abort/break, ignore, or ignore for good. -// file, line, predicate form the message to ask, *do_assert should be set -// to 0 to ignore. -// returns 1 to break, false to ignore -MT_CDECL int MT_QueryAssert(const char *file, int line, const char *predicate, int *do_assert); - - -#if !defined(DEBUG) -#define MT_assert(predicate) ((void)0) -#define BREAKPOINT() ((void)0) -#else - -// BREAKPOINT() will cause a break into the debugger -#if defined(__i386) && defined(__GNUC__) -// gcc on intel... -#define BREAKPOINT() \ -asm("int $3") -#elif defined(_MSC_VER) -// Visual C++ (on Intel) -#define BREAKPOINT() \ -{ _asm int 3 } -#elif defined(SIGTRAP) -// POSIX compatible... -#define BREAKPOINT() \ -raise(SIGTRAP); -#else -// FIXME: Don't know how to do a decent break! -// Add some code for your cpu type, or get a posix -// system. -// abort instead -#define BREAKPOINT() \ -abort(); -#endif /* breakpoint */ - - -#if defined(_WIN32) && !defined(__GNUC__) -#define MT_assert(predicate) assert(predicate) -#else - - - -// Abort the program if predicate is not true -#define MT_assert(predicate) \ -{ \ - static int do_assert = 1; \ - if (!(predicate) && MT_QueryAssert(__FILE__, __LINE__, #predicate, &do_assert)) \ - { \ - BREAKPOINT(); \ - } \ -} -#endif /* windows */ - -#endif /* !defined(DEBUG) */ - -#endif - diff --git a/intern/moto/include/MT_random.h b/intern/moto/include/MT_random.h deleted file mode 100644 index 735316278d6..00000000000 --- a/intern/moto/include/MT_random.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file moto/include/MT_random.h - * \ingroup moto - */ - - -#ifndef MT_RANDOM_H -#define MT_RANDOM_H - -#include <limits.h> - -#define MT_RAND_MAX UINT_MAX - -extern void MT_srand(unsigned int); -extern unsigned int MT_rand(); - -#endif - |