Moto: remove some unused code.

This commit is contained in:
Brecht Van Lommel
2015-12-11 01:34:22 +01:00
parent becc85c5d4
commit 8a66d4966a
8 changed files with 0 additions and 736 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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 Key, class Value>
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;i<m_num_buckets;i++)
{
Entry* bucket = m_buckets[i];
while(bucket)
{
bucket = bucket->m_next;
count++;
}
}
return count;
}
Value* at(int index) {
int count=0;
for (int i=0;i<m_num_buckets;i++)
{
Entry* bucket = m_buckets[i];
while(bucket)
{
if (count==index)
{
return &bucket->m_value;
}
bucket = bucket->m_next;
count++;
}
}
return 0;
}
Key* getKey(int index) {
int count=0;
for (int i=0;i<m_num_buckets;i++)
{
Entry* bucket = m_buckets[i];
while(bucket)
{
if (count==index)
{
return &bucket->m_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

View File

@@ -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

View File

@@ -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];
}

View File

@@ -51,7 +51,6 @@
#include <float.h>
#include "MT_random.h"
#include "NM_Scalar.h"
typedef double MT_Scalar; //this should be float !

View File

@@ -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 <math.h>
#include <iostream>
template <class T>
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<T>(-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 <class T>
inline NM_Scalar<T> operator+(const NM_Scalar<T>& x, const NM_Scalar<T>& y) {
return x.getValue() == 0.0 && y.getValue() == 0.0 ?
NM_Scalar<T>(0.0, 0.0) :
NM_Scalar<T>(x.getValue() + y.getValue(),
(fabs(x.getValue()) * (x.getError() + 1.0) +
fabs(y.getValue()) * (y.getError() + 1.0)) /
fabs(x.getValue() + y.getValue()));
}
template <class T>
inline NM_Scalar<T> operator-(const NM_Scalar<T>& x, const NM_Scalar<T>& y) {
return x.getValue() == 0.0 && y.getValue() == 0.0 ?
NM_Scalar<T>(0.0, 0.0) :
NM_Scalar<T>(x.getValue() - y.getValue(),
(fabs(x.getValue()) * (x.getError() + 1.0) +
fabs(y.getValue()) * (y.getError() + 1.0)) /
fabs(x.getValue() - y.getValue()));
}
template <class T>
inline NM_Scalar<T> operator*(const NM_Scalar<T>& x, const NM_Scalar<T>& y) {
return NM_Scalar<T>(x.getValue() * y.getValue(),
x.getError() + y.getError() + 1.0);
}
template <class T>
inline NM_Scalar<T> operator/(const NM_Scalar<T>& x, const NM_Scalar<T>& y) {
return NM_Scalar<T>(x.getValue() / y.getValue(),
x.getError() + y.getError() + 1.0);
}
template <class T>
inline std::ostream& operator<<(std::ostream& os, const NM_Scalar<T>& x) {
return os << x.getValue() << '[' << x.getError() << ']';
}
template <class T>
inline NM_Scalar<T> sqrt(const NM_Scalar<T>& x) {
return NM_Scalar<T>(sqrt(x.getValue()),
0.5 * x.getError() + 1.0);
}
template <class T>
inline NM_Scalar<T> acos(const NM_Scalar<T>& x) {
return NM_Scalar<T>(acos(x.getValue()), x.getError() + 1.0);
}
template <class T>
inline NM_Scalar<T> cos(const NM_Scalar<T>& x) {
return NM_Scalar<T>(cos(x.getValue()), x.getError() + 1.0);
}
template <class T>
inline NM_Scalar<T> sin(const NM_Scalar<T>& x) {
return NM_Scalar<T>(sin(x.getValue()), x.getError() + 1.0);
}
template <class T>
inline NM_Scalar<T> fabs(const NM_Scalar<T>& x) {
return NM_Scalar<T>(fabs(x.getValue()), x.getError());
}
template <class T>
inline NM_Scalar<T> pow(const NM_Scalar<T>& x, const NM_Scalar<T>& y) {
return NM_Scalar<T>(pow(x.getValue(), y.getValue()),
fabs(y.getValue()) * x.getError() + 1.0);
}

View File

@@ -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