From 8a66d4966a5e156d254d2c960b4a546ca5d68943 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 11 Dec 2015 01:34:22 +0100 Subject: Moto: remove some unused code. --- intern/moto/CMakeLists.txt | 6 -- intern/moto/include/GEN_List.h | 87 ------------------ intern/moto/include/GEN_Map.h | 181 -------------------------------------- intern/moto/include/MT_Plane3.h | 137 ----------------------------- intern/moto/include/MT_Plane3.inl | 128 --------------------------- intern/moto/include/MT_Scalar.h | 1 - intern/moto/include/NM_Scalar.h | 159 --------------------------------- intern/moto/intern/MT_Plane3.cpp | 37 -------- 8 files changed, 736 deletions(-) delete mode 100644 intern/moto/include/GEN_List.h delete mode 100644 intern/moto/include/GEN_Map.h delete mode 100644 intern/moto/include/MT_Plane3.h delete mode 100644 intern/moto/include/MT_Plane3.inl delete mode 100644 intern/moto/include/NM_Scalar.h delete mode 100644 intern/moto/intern/MT_Plane3.cpp (limited to 'intern/moto') diff --git a/intern/moto/CMakeLists.txt b/intern/moto/CMakeLists.txt index 8075c66b847..d17181c6809 100644 --- a/intern/moto/CMakeLists.txt +++ b/intern/moto/CMakeLists.txt @@ -36,7 +36,6 @@ set(SRC intern/MT_CmMatrix4x4.cpp intern/MT_Matrix3x3.cpp intern/MT_Matrix4x4.cpp - intern/MT_Plane3.cpp intern/MT_Point3.cpp intern/MT_Quaternion.cpp intern/MT_Transform.cpp @@ -45,14 +44,11 @@ set(SRC intern/MT_Vector4.cpp intern/MT_random.cpp - include/GEN_List.h - include/GEN_Map.h include/MT_CmMatrix4x4.h include/MT_Matrix3x3.h include/MT_Matrix4x4.h include/MT_MinMax.h include/MT_Optimize.h - include/MT_Plane3.h include/MT_Point2.h include/MT_Point3.h include/MT_Quaternion.h @@ -67,11 +63,9 @@ set(SRC include/MT_Vector4.h include/MT_assert.h include/MT_random.h - include/NM_Scalar.h include/MT_Matrix3x3.inl include/MT_Matrix4x4.inl - include/MT_Plane3.inl include/MT_Point2.inl include/MT_Point3.inl include/MT_Quaternion.inl diff --git a/intern/moto/include/GEN_List.h b/intern/moto/include/GEN_List.h deleted file mode 100644 index 3aefe5e060c..00000000000 --- a/intern/moto/include/GEN_List.h +++ /dev/null @@ -1,87 +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/GEN_List.h - * \ingroup moto - */ - - -#ifndef GEN_LIST_H -#define GEN_LIST_H - -class GEN_Link { -public: - GEN_Link() : m_next(0), m_prev(0) {} - GEN_Link(GEN_Link *next, GEN_Link *prev) : m_next(next), m_prev(prev) {} - - GEN_Link *getNext() const { return m_next; } - GEN_Link *getPrev() const { return m_prev; } - - bool isHead() const { return m_prev == 0; } - bool isTail() const { return m_next == 0; } - - void insertBefore(GEN_Link *link) { - m_next = link; - m_prev = link->m_prev; - m_next->m_prev = this; - m_prev->m_next = this; - } - - void insertAfter(GEN_Link *link) { - m_next = link->m_next; - m_prev = link; - m_next->m_prev = this; - m_prev->m_next = this; - } - - void remove() { - m_next->m_prev = m_prev; - m_prev->m_next = m_next; - } - -private: - GEN_Link *m_next; - GEN_Link *m_prev; -}; - -class GEN_List { -public: - GEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {} - - GEN_Link *getHead() const { return m_head.getNext(); } - GEN_Link *getTail() const { return m_tail.getPrev(); } - - void addHead(GEN_Link *link) { link->insertAfter(&m_head); } - void addTail(GEN_Link *link) { link->insertBefore(&m_tail); } - -private: - GEN_Link m_head; - GEN_Link m_tail; -}; - -#endif - diff --git a/intern/moto/include/GEN_Map.h b/intern/moto/include/GEN_Map.h deleted file mode 100644 index 526bfdc8caf..00000000000 --- a/intern/moto/include/GEN_Map.h +++ /dev/null @@ -1,181 +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/GEN_Map.h - * \ingroup moto - */ - - -#ifndef GEN_MAP_H -#define GEN_MAP_H - -template -class GEN_Map { -private: - struct Entry { - Entry (Entry *next, Key key, Value value) : - m_next(next), - m_key(key), - m_value(value) {} - - Entry *m_next; - Key m_key; - Value m_value; - }; - -public: - GEN_Map(int num_buckets = 100) : m_num_buckets(num_buckets) { - m_buckets = new Entry *[num_buckets]; - for (int i = 0; i < num_buckets; ++i) { - m_buckets[i] = 0; - } - } - - GEN_Map(const GEN_Map& map) - { - m_num_buckets = map.m_num_buckets; - m_buckets = new Entry *[m_num_buckets]; - - for (int i = 0; i < m_num_buckets; ++i) { - m_buckets[i] = 0; - - for(Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next) - insert(entry->m_key, entry->m_value); - } - } - - int size() { - int count=0; - for (int i=0;im_next; - count++; - } - } - return count; - } - - Value* at(int index) { - int count=0; - for (int i=0;im_value; - } - bucket = bucket->m_next; - count++; - } - } - return 0; - } - - Key* getKey(int index) { - int count=0; - for (int i=0;im_key; - } - bucket = bucket->m_next; - count++; - } - } - return 0; - } - - void clear() { - for (int i = 0; i < m_num_buckets; ++i) { - Entry *entry_ptr = m_buckets[i]; - - while (entry_ptr != 0) { - Entry *tmp_ptr = entry_ptr->m_next; - delete entry_ptr; - entry_ptr = tmp_ptr; - } - m_buckets[i] = 0; - } - } - - ~GEN_Map() { - clear(); - delete [] m_buckets; - } - - void insert(const Key& key, const Value& value) { - Entry *entry_ptr = m_buckets[key.hash() % m_num_buckets]; - while ((entry_ptr != 0) && !(key == entry_ptr->m_key)) { - entry_ptr = entry_ptr->m_next; - } - - if (entry_ptr != 0) { - entry_ptr->m_value = value; - } - else { - Entry **bucket = &m_buckets[key.hash() % m_num_buckets]; - *bucket = new Entry(*bucket, key, value); - } - } - - void remove(const Key& key) { - Entry **entry_ptr = &m_buckets[key.hash() % m_num_buckets]; - while ((*entry_ptr != 0) && !(key == (*entry_ptr)->m_key)) { - entry_ptr = &(*entry_ptr)->m_next; - } - - if (*entry_ptr != 0) { - Entry *tmp_ptr = (*entry_ptr)->m_next; - delete *entry_ptr; - *entry_ptr = tmp_ptr; - } - } - - Value *operator[](Key key) { - Entry *bucket = m_buckets[key.hash() % m_num_buckets]; - while ((bucket != 0) && !(key == bucket->m_key)) { - bucket = bucket->m_next; - } - return bucket != 0 ? &bucket->m_value : 0; - } - -private: - int m_num_buckets; - Entry **m_buckets; -}; - -#endif - diff --git a/intern/moto/include/MT_Plane3.h b/intern/moto/include/MT_Plane3.h deleted file mode 100644 index f208b377a81..00000000000 --- a/intern/moto/include/MT_Plane3.h +++ /dev/null @@ -1,137 +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_Plane3.h - * \ingroup moto - */ - - -#ifndef MT_PLANE3 -#define MT_PLANE3 - -#include "MT_Tuple4.h" -#include "MT_Point3.h" - -/** - * A simple 3d plane class. - * - * This class represents a plane in 3d. The internal parameterization used - * is n.x + d =0 where n is a unit vector and d is a scalar. - * - * It inherits data from MT_Tuple4 please see this class for low level - * access to the internal representation. - * - */ - -class MT_Plane3 : public MT_Tuple4 -{ -public : - /** - * Constructor from 3 points - */ - - MT_Plane3( - const MT_Vector3 &a, - const MT_Vector3 &b, - const MT_Vector3 &c - ); - /** - * Construction from vector and a point. - */ - - MT_Plane3( - const MT_Vector3 &n, - const MT_Vector3 &p - ); - - /** - * Default constructor - */ - MT_Plane3( - ); - - /** - * Default constructor - */ - - MT_Plane3( - const MT_Plane3 & p - ): - MT_Tuple4(p) - { - } - - /** - * Return plane normal - */ - - MT_Vector3 - Normal( - ) const; - - /** - * Return plane scalar i.e the d from n.x + d = 0 - */ - - MT_Scalar - Scalar( - ) const ; - - /** - * Invert the plane - just swaps direction of normal. - */ - void - Invert( - ); - - /** - * Assignment operator - */ - - MT_Plane3 & - operator = ( - const MT_Plane3 & rhs - ); - - /** - * Return the signed perpendicular distance from a point to the plane - */ - - MT_Scalar - signedDistance( - const MT_Vector3 & - ) const; - - -}; - -#ifdef GEN_INLINED -#include "MT_Plane3.inl" -#endif - -#endif - diff --git a/intern/moto/include/MT_Plane3.inl b/intern/moto/include/MT_Plane3.inl deleted file mode 100644 index 77db9b35e1d..00000000000 --- a/intern/moto/include/MT_Plane3.inl +++ /dev/null @@ -1,128 +0,0 @@ -#include "MT_Optimize.h" - - -GEN_INLINE -MT_Plane3:: -MT_Plane3( - const MT_Vector3 &a, - const MT_Vector3 &b, - const MT_Vector3 &c -){ - MT_Vector3 l1 = b-a; - MT_Vector3 l2 = c-b; - - MT_Vector3 n = l1.cross(l2); - n = n.safe_normalized(); - MT_Scalar d = n.dot(a); - - m_co[0] = n.x(); - m_co[1] = n.y(); - m_co[2] = n.z(); - m_co[3] = -d; -} - -/** - * Construction from vector and a point. - */ -GEN_INLINE -MT_Plane3:: -MT_Plane3( - const MT_Vector3 &n, - const MT_Vector3 &p -){ - - MT_Vector3 mn = n.safe_normalized(); - MT_Scalar md = mn.dot(p); - - m_co[0] = mn.x(); - m_co[1] = mn.y(); - m_co[2] = mn.z(); - m_co[3] = -md; -} - - -/** - * Default constructor - */ -GEN_INLINE -MT_Plane3:: -MT_Plane3( -): - MT_Tuple4() -{ - m_co[0] = MT_Scalar(1); - m_co[1] = MT_Scalar(0); - m_co[2] = MT_Scalar(0); - m_co[3] = MT_Scalar(0); -} - -/** - * Return plane normal - */ - -GEN_INLINE - MT_Vector3 -MT_Plane3:: -Normal( -) const { - return MT_Vector3(m_co[0],m_co[1],m_co[2]); -} - -/** - * Return plane scalar i.e the d from n.x + d = 0 - */ - -GEN_INLINE - MT_Scalar -MT_Plane3:: -Scalar( -) const { - return m_co[3]; -} - -GEN_INLINE - void -MT_Plane3:: -Invert( -) { - m_co[0] = -m_co[0]; - m_co[1] = -m_co[1]; - m_co[2] = -m_co[2]; - m_co[3] = -m_co[3]; -} - - -/** - * Assignment operator - */ - -GEN_INLINE - MT_Plane3 & -MT_Plane3:: -operator = ( - const MT_Plane3 & rhs -) { - m_co[0] = rhs.m_co[0]; - m_co[1] = rhs.m_co[1]; - m_co[2] = rhs.m_co[2]; - m_co[3] = rhs.m_co[3]; - return *this; -} - -/** - * Return the distance from a point to the plane - */ - -GEN_INLINE - MT_Scalar -MT_Plane3:: -signedDistance( - const MT_Vector3 &v -) const { - return Normal().dot(v) + m_co[3]; -} - - - - - diff --git a/intern/moto/include/MT_Scalar.h b/intern/moto/include/MT_Scalar.h index 5c4a5c2a44a..5e516292d77 100644 --- a/intern/moto/include/MT_Scalar.h +++ b/intern/moto/include/MT_Scalar.h @@ -51,7 +51,6 @@ #include #include "MT_random.h" -#include "NM_Scalar.h" typedef double MT_Scalar; //this should be float ! diff --git a/intern/moto/include/NM_Scalar.h b/intern/moto/include/NM_Scalar.h deleted file mode 100644 index 0e33979c521..00000000000 --- a/intern/moto/include/NM_Scalar.h +++ /dev/null @@ -1,159 +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/NM_Scalar.h - * \ingroup moto - */ - - -#include -#include - -template -class NM_Scalar { -public: - NM_Scalar() {} - explicit NM_Scalar(T value, T error = 0.0) : - m_value(value), m_error(error) {} - - T getValue() const { return m_value; } - T getError() const { return m_error; } - - operator T() const { return m_value; } - - NM_Scalar operator-() const { - return NM_Scalar(-m_value, m_error); - } - - NM_Scalar& operator=(T value) { - m_value = value; - m_error = 0.0; - return *this; - } - - NM_Scalar& operator+=(const NM_Scalar& x) { - m_value += x.m_value; - m_error = (fabs(m_value) * (m_error + 1.0) + - fabs(x.m_value) * (x.m_error + 1.0)) / - fabs(m_value + x.m_value); - return *this; - } - - NM_Scalar& operator-=(const NM_Scalar& x) { - m_value -= x.m_value; - m_error = (fabs(m_value) * (m_error + 1.0) + - fabs(x.m_value) * (x.m_error + 1.0)) / - fabs(m_value - x.m_value); - return *this; - } - - NM_Scalar& operator*=(const NM_Scalar& x) { - m_value *= x.m_value; - m_error += x.m_error + 1.0; - return *this; - } - - NM_Scalar& operator/=(const NM_Scalar& x) { - m_value /= x.m_value; - m_error += x.m_error + 1.0; - return *this; - } - -private: - T m_value; - T m_error; -}; - -template -inline NM_Scalar operator+(const NM_Scalar& x, const NM_Scalar& y) { - return x.getValue() == 0.0 && y.getValue() == 0.0 ? - NM_Scalar(0.0, 0.0) : - NM_Scalar(x.getValue() + y.getValue(), - (fabs(x.getValue()) * (x.getError() + 1.0) + - fabs(y.getValue()) * (y.getError() + 1.0)) / - fabs(x.getValue() + y.getValue())); -} - -template -inline NM_Scalar operator-(const NM_Scalar& x, const NM_Scalar& y) { - return x.getValue() == 0.0 && y.getValue() == 0.0 ? - NM_Scalar(0.0, 0.0) : - NM_Scalar(x.getValue() - y.getValue(), - (fabs(x.getValue()) * (x.getError() + 1.0) + - fabs(y.getValue()) * (y.getError() + 1.0)) / - fabs(x.getValue() - y.getValue())); -} - -template -inline NM_Scalar operator*(const NM_Scalar& x, const NM_Scalar& y) { - return NM_Scalar(x.getValue() * y.getValue(), - x.getError() + y.getError() + 1.0); -} - -template -inline NM_Scalar operator/(const NM_Scalar& x, const NM_Scalar& y) { - return NM_Scalar(x.getValue() / y.getValue(), - x.getError() + y.getError() + 1.0); -} - -template -inline std::ostream& operator<<(std::ostream& os, const NM_Scalar& x) { - return os << x.getValue() << '[' << x.getError() << ']'; -} - -template -inline NM_Scalar sqrt(const NM_Scalar& x) { - return NM_Scalar(sqrt(x.getValue()), - 0.5 * x.getError() + 1.0); -} - -template -inline NM_Scalar acos(const NM_Scalar& x) { - return NM_Scalar(acos(x.getValue()), x.getError() + 1.0); -} - -template -inline NM_Scalar cos(const NM_Scalar& x) { - return NM_Scalar(cos(x.getValue()), x.getError() + 1.0); -} - -template -inline NM_Scalar sin(const NM_Scalar& x) { - return NM_Scalar(sin(x.getValue()), x.getError() + 1.0); -} - -template -inline NM_Scalar fabs(const NM_Scalar& x) { - return NM_Scalar(fabs(x.getValue()), x.getError()); -} - -template -inline NM_Scalar pow(const NM_Scalar& x, const NM_Scalar& y) { - return NM_Scalar(pow(x.getValue(), y.getValue()), - fabs(y.getValue()) * x.getError() + 1.0); -} - diff --git a/intern/moto/intern/MT_Plane3.cpp b/intern/moto/intern/MT_Plane3.cpp deleted file mode 100644 index 22f7cfdbded..00000000000 --- a/intern/moto/intern/MT_Plane3.cpp +++ /dev/null @@ -1,37 +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/intern/MT_Plane3.cpp - * \ingroup moto - */ - - -#ifndef GEN_INLINED -#include "MT_Plane3.h" -#include "MT_Plane3.inl" -#endif - -- cgit v1.2.3