*Massive cleanup redux.

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-17 16:20:24 -07:00
parent e585187b24
commit 3f338cc1c3
862 changed files with 2736 additions and 4797 deletions
-2
View File
@@ -65,7 +65,6 @@ public:
hi = high;
}
inline const Vector3& low() const {
return lo;
}
@@ -251,6 +250,5 @@ inline unsigned int hashCode(const G3D::AABox& b) {
return b.hashCode();
}
#endif
-16
View File
@@ -33,7 +33,6 @@
# pragma warning( disable : 4786)
#endif
namespace G3D {
/**
@@ -60,7 +59,6 @@ const int SORT_DECREASING = -1;
If SSE is defined Arrays allocate the first element aligned to
16 bytes.
Array is highly optimized compared to std::vector.
Array operations are less expensive than on std::vector and for large
amounts of data, Array consumes only 1.5x the total size of the
@@ -120,13 +118,11 @@ private:
return (address >= data) && (address < data + num);
}
/** Only compiled if you use the sort procedure. */
static bool __cdecl compareGT(const T& a, const T& b) {
return a > b;
}
/**
Allocates a new array of size numAllocated (not a parameter to the method)
and then copies at most oldNum elements from the old array to it. Destructors are
@@ -163,7 +159,6 @@ private:
ptr->~T();
}}
System::alignedFree(oldData);
}
@@ -255,7 +250,6 @@ public:
numAllocated = 0;
}
/**
Removes all elements. Use resize(0, false) or fastClear if you want to
remove all elements without deallocating the underlying array
@@ -329,7 +323,6 @@ public:
resize(n, false);
}
/**
Inserts at the specified index and shifts all other elements up by one.
*/
@@ -444,7 +437,6 @@ public:
}
}
inline void append(const T& v1, const T& v2) {
if (inArray(&v1) || inArray(&v2)) {
T t1 = v1;
@@ -463,7 +455,6 @@ public:
}
}
inline void append(const T& v1, const T& v2, const T& v3) {
if (inArray(&v1) || inArray(&v2) || inArray(&v3)) {
T t1 = v1;
@@ -485,7 +476,6 @@ public:
}
}
inline void append(const T& v1, const T& v2, const T& v3, const T& v4) {
if (inArray(&v1) || inArray(&v2) || inArray(&v3) || inArray(&v4)) {
T t1 = v1;
@@ -614,7 +604,6 @@ public:
resize(num - 1, shrinkUnderlyingArrayIfNecessary);
}
/**
"The member function swaps the controlled sequences between *this and str."
Note that this is slower than the optimal std implementation.
@@ -627,7 +616,6 @@ public:
*this = temp;
}
/**
Performs bounds checks in debug mode
*/
@@ -832,7 +820,6 @@ public:
std::sort(data, data + num, lessThan);
}
/**
Sorts the array in increasing order using the > or < operator. To
invoke this method on Array<T>, T must override those operator.
@@ -1118,7 +1105,6 @@ public:
medianPartition(ltMedian, eqMedian, gtMedian, temp, DefaultComparator());
}
/** Redistributes the elements so that the new order is statistically independent
of the original order. O(n) time.*/
void randomize() {
@@ -1133,10 +1119,8 @@ public:
}
}
};
/** Array::contains for C-arrays */
template<class T> bool contains(const T* array, int len, const T& e) {
for (int i = len - 1; i >= 0; --i) {
-2
View File
@@ -28,7 +28,6 @@ class CoordinateFrame;
/**
An arbitrary 3D box, useful as a bounding box.
To construct a box from a coordinate frame, center and extent, use the idiom:
<CODE>Box box = cframe.toObjectSpace(Box(center - extent/2, center + extent/2));</CODE>
@@ -86,7 +85,6 @@ public:
Box(const class AABox& b);
/**
Returns the object to world transformation for
this box. localFrame().worldToObject(...) takes
@@ -1,7 +1,6 @@
/**
@file CollisionDetection.h
Moving collision detection for simple primitives.
@author Morgan McGuire, [email protected]
@@ -32,7 +31,6 @@
namespace G3D {
/**
Collision detection primitives and tools for building
higher order collision detection schemes.
@@ -108,7 +106,6 @@ private:
*/
static Array<Vector3> ignoreArray;
// Static class!
CollisionDetection() {}
virtual ~CollisionDetection() {}
@@ -183,7 +180,6 @@ public:
const double* ad,
const double* bd);
/**
Creates a set of standard information about two boxes in order to
solve for their collision. This information includes a vector to
-1
View File
@@ -3,7 +3,6 @@
@maintainer Morgan McGuire, [email protected]
@created 2006-03-29
@edited 2006-04-06
*/
-4
View File
@@ -81,7 +81,6 @@ public:
virtual ~GCamera();
CoordinateFrame getCoordinateFrame() const;
void getCoordinateFrame(CoordinateFrame& c) const;
void setCoordinateFrame(const CoordinateFrame& c);
@@ -152,14 +151,12 @@ public:
float getImagePlaneDepth(
const class Rect2D& viewport) const;
/**
Returns the world space ray passing through the center of pixel
(x, y) on the image plane. The pixel x and y axes are opposite
the 3D object space axes: (0,0) is the upper left corner of the screen.
They are in viewport coordinates, not screen coordinates.
Integer (x, y) values correspond to
the upper left corners of pixels. If you want to cast rays
through pixel centers, add 0.5 to x and y.
@@ -169,7 +166,6 @@ public:
float y,
const class Rect2D& viewport) const;
/**
Returns a negative z-value.
*/
-1
View File
@@ -81,6 +81,5 @@ public:
};// namespace
#endif
-4
View File
@@ -54,7 +54,6 @@ public:
@cite Implementation from Watt and Watt, pg 362*/
Matrix3(const class Quat& q);
/**
Sets all elements.
*/
@@ -126,7 +125,6 @@ public:
return kProd;
}
/**
* vector * matrix [1x3 * 3x3 = 1x3]
*/
@@ -288,7 +286,6 @@ protected:
};
//----------------------------------------------------------------------------
/** <code>v * M == M.transpose() * v</code> */
inline Vector3 operator* (const Vector3& rkPoint, const Matrix3& rkMatrix) {
@@ -304,7 +301,6 @@ inline Vector3 operator* (const Vector3& rkPoint, const Matrix3& rkMatrix) {
return kProd;
}
} // namespace
#endif
-6
View File
@@ -209,13 +209,11 @@ public:
return (*this) * other.inverse();
}
/** Is the magnitude nearly 1.0? */
inline bool isUnit(float tolerance = 1e-5) const {
return abs(dot(*this) - 1.0f) < tolerance;
}
inline float magnitude() const {
return sqrtf(dot(*this));
}
@@ -268,7 +266,6 @@ public:
return Quat(sinf(A) * v, cosf(A));
}
/**
Raise this quaternion to a power. For a rotation, this is
the effect of rotating x times as much as the original
@@ -281,7 +278,6 @@ public:
return (log() * x).exp();
}
/**
@deprecated
Use toUnit()
@@ -695,8 +691,6 @@ inline G3D::Quat pow(const G3D::Quat& q, double x) {
return q.pow((float)x);
}
#include "Quat.inl"
#endif
+4 -6
View File
@@ -1,11 +1,11 @@
/**
Quat.inl
@cite Quaternion implementation based on Watt & Watt page 363.
@cite Quaternion implementation based on Watt & Watt page 363.
Thanks to Max McGuire for slerp optimizations.
@maintainer Morgan McGuire, [email protected]
@created 2002-01-23
@edited 2004-03-04
*/
@@ -24,8 +24,6 @@ inline const float& Quat::operator[] (int i) const {
return ((float*)this)[i];
}
inline Quat Quat::operator-(const Quat& other) const {
return Quat(x - other.x, y - other.y, z - other.z, w - other.w);
}
-5
View File
@@ -121,7 +121,6 @@ public:
const Vector3& edge01,
const Vector3& edge02) const;
inline float intersectionTime(
const Vector3& vert0,
const Vector3& vert1,
@@ -130,7 +129,6 @@ public:
return intersectionTime(vert0, vert1, vert2, vert1 - vert0, vert2 - vert0);
}
inline float intersectionTime(
const Vector3& vert0,
const Vector3& vert1,
@@ -177,7 +175,6 @@ public:
const Vector3& normal) const;
};
#define EPSILON 0.000001
#define CROSS(dest,v1,v2) \
dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \
@@ -236,7 +233,6 @@ inline float Ray::intersectionTime(
return (float)inf();
}
// Case where we don't need correct (u, v):
const float t = DOT(edge2, qvec);
@@ -249,7 +245,6 @@ inline float Ray::intersectionTime(
}
}
inline float Ray::intersectionTime(
const Vector3& vert0,
const Vector3& vert1,
-2
View File
@@ -22,7 +22,6 @@
# include <CoreServices/CoreServices.h>
#endif
namespace G3D {
typedef double RealTime;
@@ -116,7 +115,6 @@ public:
};
} // namespace
#endif
-11
View File
@@ -28,7 +28,6 @@
# pragma warning (disable : 4786)
#endif
template<typename Key>
struct GHashCode{};
@@ -76,7 +75,6 @@ struct GHashCode<std::string>
namespace G3D {
/**
An unordered data structure mapping keys to values.
@@ -103,7 +101,6 @@ namespace G3D {
And rely on the default enum operator==.
Periodically check that debugGetLoad() is low (> 0.1). When it gets near
1.0 your hash function is badly designed and maps too many inputs to
the same output.
@@ -131,7 +128,6 @@ private:
Entry entry;
Node* next;
/** Provide pooled allocation for speed. */
inline void* operator new (size_t size) {
return System::malloc(size);
@@ -141,7 +137,6 @@ private:
System::free(p);
}
Node(Key key, Value value, size_t hashCode, Node* next) {
this->entry.key = key;
this->entry.value = value;
@@ -419,7 +414,6 @@ public:
}
};
/**
C++ STL style iterator method. Returns the first Entry, which
contains a key and value. Use preincrement (++entry) to get to
@@ -448,7 +442,6 @@ public:
System::memset(bucket, 0, sizeof(Node*) * numBuckets);
}
/**
Returns the number of keys.
*/
@@ -456,7 +449,6 @@ public:
return _size;
}
/**
If you insert a pointer into the key or value of a table, you are
responsible for deallocating the object eventually. Inserting
@@ -546,7 +538,6 @@ public:
n = n->next;
} while (n != NULL);
alwaysAssertM(false, "Tried to remove a key that was not in the table.");
}
@@ -616,7 +607,6 @@ public:
return false;
}
/**
Short syntax for get.
*/
@@ -624,7 +614,6 @@ public:
return get(key);
}
/**
Returns an array of all of the keys in the table.
You can iterate over the keys to get the values.
-55
View File
@@ -144,8 +144,6 @@ public:
/** Largest representable vector */
static const Vector2& maxFinite();
// Deprecated. See Matrix3::identity() for details.
/** @deprecated Use Vector2::zero() */
static const Vector2 ZERO;
@@ -207,53 +205,42 @@ inline Vector2 operator*(int s, const Vector2& v) {
return v * (float)s;
}
inline unsigned int hashCode(const G3D::Vector2& v) {
return v.hashCode();
}
inline Vector2::Vector2 () : x(0.0f), y(0.0f) {
}
inline Vector2::Vector2(float _x, float _y) : x(_x), y(_y) {
}
inline Vector2::Vector2 (float afCoordinate[2]) {
x = afCoordinate[0];
y = afCoordinate[1];
}
inline Vector2::Vector2 (double afCoordinate[2]) {
x = (float)afCoordinate[0];
y = (float)afCoordinate[1];
}
inline Vector2::Vector2 (const Vector2& rkVector) {
x = rkVector.x;
y = rkVector.y;
}
inline Vector2::Vector2 (const Vector2int16& v) : x(v.x), y(v.y) {
}
inline float& Vector2::operator[] (int i) {
return ((float*)this)[i];
}
inline const float& Vector2::operator[] (int i) const {
return ((float*)this)[i];
}
inline Vector2::operator float* () {
return (float*)this;
}
@@ -262,62 +249,48 @@ inline Vector2::operator const float* () const {
return (float*)this;
}
inline Vector2& Vector2::operator= (const Vector2& rkVector) {
x = rkVector.x;
y = rkVector.y;
return *this;
}
inline bool Vector2::operator== (const Vector2& rkVector) const {
return ( x == rkVector.x && y == rkVector.y);
}
inline bool Vector2::operator!= (const Vector2& rkVector) const {
return ( x != rkVector.x || y != rkVector.y);
}
inline Vector2 Vector2::operator+ (const Vector2& rkVector) const {
return Vector2(x + rkVector.x, y + rkVector.y);
}
inline Vector2 Vector2::operator- (const Vector2& rkVector) const {
return Vector2(x - rkVector.x, y - rkVector.y);
}
inline Vector2 Vector2::operator* (float fScalar) const {
return Vector2(fScalar*x, fScalar*y);
}
inline Vector2 Vector2::operator- () const {
return Vector2( -x, -y);
}
inline Vector2& Vector2::operator+= (const Vector2& rkVector) {
x += rkVector.x;
y += rkVector.y;
return *this;
}
inline Vector2& Vector2::operator-= (const Vector2& rkVector) {
x -= rkVector.x;
y -= rkVector.y;
return *this;
}
inline Vector2& Vector2::operator*= (float fScalar) {
x *= fScalar;
y *= fScalar;
@@ -325,44 +298,34 @@ inline Vector2& Vector2::operator*= (float fScalar) {
}
inline Vector2& Vector2::operator*= (const Vector2& rkVector) {
x *= rkVector.x;
y *= rkVector.y;
return *this;
}
inline Vector2& Vector2::operator/= (const Vector2& rkVector) {
x /= rkVector.x;
y /= rkVector.y;
return *this;
}
inline Vector2 Vector2::operator* (const Vector2& rkVector) const {
return Vector2(x * rkVector.x, y * rkVector.y);
}
inline Vector2 Vector2::operator/ (const Vector2& rkVector) const {
return Vector2(x / rkVector.x, y / rkVector.y);
}
inline float Vector2::squaredLength () const {
return x*x + y*y;
}
inline float Vector2::length () const {
return sqrtf(x*x + y*y);
}
inline Vector2 Vector2::direction () const {
float lenSquared = x * x + y * y;
@@ -373,50 +336,34 @@ inline Vector2 Vector2::direction () const {
}
}
inline float Vector2::dot (const Vector2& rkVector) const {
return x*rkVector.x + y*rkVector.y;
}
inline Vector2 Vector2::min(const Vector2 &v) const {
return Vector2(G3D::min(v.x, x), G3D::min(v.y, y));
}
inline Vector2 Vector2::max(const Vector2 &v) const {
return Vector2(G3D::max(v.x, x), G3D::max(v.y, y));
}
inline bool Vector2::fuzzyEq(const Vector2& other) const {
return G3D::fuzzyEq((*this - other).squaredLength(), 0);
}
inline bool Vector2::fuzzyNe(const Vector2& other) const {
return G3D::fuzzyNe((*this - other).squaredLength(), 0);
}
inline bool Vector2::isFinite() const {
return G3D::isFinite(x) && G3D::isFinite(y);
}
inline bool Vector2::isZero() const {
return (x == 0.0f) && (y == 0.0f);
}
inline bool Vector2::isUnit() const {
return squaredLength() == 1.0f;
}
@@ -431,9 +378,7 @@ inline G3D::Vector2 operator*(int s, const G3D::Vector2& v) {
return v * (float)s;
}
inline unsigned int hashCode(const G3D::Vector2& v);
#endif
+3 -5
View File
@@ -1,13 +1,12 @@
/**
@file Vector2.inl
@maintainer Morgan McGuire, [email protected]
@cite Portions by Laura Wollstadt, graphics3d.com
@cite Portions based on Dave Eberly'x Magic Software Library
at http://www.magic-software.com
@created 2001-06-02
@edited 2006-01-14
@@ -15,6 +14,5 @@
All rights reserved.
*/
}
-1
View File
@@ -52,7 +52,6 @@ public:
return ((G3D::int16*)this)[i];
}
inline bool operator== (const Vector2int16& rkVector) const {
return ((int32*)this)[0] == ((int32*)&rkVector)[0];
}
-4
View File
@@ -41,7 +41,6 @@ b = v.xz();
j = b.xx();
</PRE>
<B>Warning</B>
Do not subclass-- this implementation makes assumptions about the
@@ -160,7 +159,6 @@ public:
*/
Vector3 fastDirection() const;
/**
See also G3D::Ray::reflect.
The length is 1.
@@ -174,7 +172,6 @@ public:
*/
Vector3 reflectionDirection(const Vector3& normal) const;
/**
Returns Vector3::zero() if the length is nearly zero, otherwise
returns a unit vector.
@@ -302,7 +299,6 @@ public:
*/
static Vector3 cosRandom(const Vector3& normal);
/**
Random vector distributed over the hemisphere about normal.
*/
+1 -2
View File
@@ -1,4 +1,4 @@
/**
/**
@file Vector3.inl
@maintainer Morgan McGuire, [email protected]
@@ -66,7 +66,6 @@ inline float& Vector3::operator[] (int i) {
return ((float*)this)[i];
}
//----------------------------------------------------------------------------
inline Vector3& Vector3::operator= (const Vector3& rkVector) {
x = rkVector.x;
+2 -4
View File
@@ -1,4 +1,4 @@
/**
/**
@file Vector4.inl
@maintainer Morgan McGuire, [email protected]
@@ -131,10 +131,9 @@ inline Vector4& Vector4::operator-= (const Vector4& rkVector) {
//----------------------------------------------------------------------------
inline Vector4 Vector4::lerp(const Vector4& v, float alpha) const {
return (*this) + (v - *this) * alpha;
return (*this) + (v - *this) * alpha;
}
//----------------------------------------------------------------------------
inline Vector4& Vector4::operator*= (float fScalar) {
x *= fScalar;
@@ -144,7 +143,6 @@ inline Vector4& Vector4::operator*= (float fScalar) {
return *this;
}
//----------------------------------------------------------------------------
inline float Vector4::dot(const Vector4& rkVector) const {
return x*rkVector.x + y*rkVector.y + z*rkVector.z + w*rkVector.w;
-1
View File
@@ -51,7 +51,6 @@ std::string vformat(
const char* fmt,
va_list argPtr) G3D_CHECK_VPRINTF_ARGS;
}; // namespace
#endif
-6
View File
@@ -100,12 +100,10 @@ __inline long int lrintf(float flt) {
return (long int)floorf(flt+0.5f);
}
#endif
#endif
const double fuzzyEpsilon = 0.00001;
/** Returns a reference to a static double.
@@ -225,7 +223,6 @@ inline int iSign(float f) {
return iSign((double)f);
}
/**
Fast round to integer using the lrint routine.
Typically 6x faster than casting to integer.
@@ -459,7 +456,6 @@ inline float dot(float a, float b) {
return a * b;
}
/**
a * b (for DirectX/Cg support)
*/
@@ -478,7 +474,6 @@ inline double rsqrt(double x) {
return 1.0 / sqrt(x);
}
/**
sin(x)/x
*/
@@ -512,7 +507,6 @@ inline double wrap(double t, double hi) {
return wrap(t, 0, hi);
}
} // namespace
#ifdef _MSC_VER
+2 -3
View File
@@ -1,8 +1,8 @@
/**
@file g3dmath.inl
@maintainer Morgan McGuire, [email protected]
@created 2001-06-02
@edited 2006-01-14
*/
@@ -159,7 +159,6 @@ inline float uniformRandom(float low, float hi) {
return (hi - low) * float(::rand()) / float(RAND_MAX) + low;
}
//----------------------------------------------------------------------------
inline double G3D_DEPRECATED symmetricRandom () {
return 2.0 * double(::rand()) / double(RAND_MAX) - 1.0;
-5
View File
@@ -49,7 +49,6 @@
#error Unknown platform
#endif
// Default to compiling with SSE, but if you want to compile
// without installing SP5.0 and the Processor Pack on Windows, compile with NO_SSE
// defined (can be passed to the compiler command line with /D "NO_SSE")
@@ -73,7 +72,6 @@
# endif
#endif
// Verify that the supported compilers are being used and that this is a known
// processor.
@@ -102,7 +100,6 @@
# define G3D_CHECK_VPRINTF_ARGS __attribute__((__format__(__printf__, 1, 0)))
#endif
#ifdef G3D_OSX
#ifndef __GNUC__
#error G3D only supports the gcc compiler on OS X.
@@ -132,7 +129,6 @@
# define G3D_CHECK_VPRINTF_ARGS __attribute__((__format__(__printf__, 1, 0)))
#endif
#ifdef G3D_WIN32
// Microsoft Visual C++ 7.1 _MSC_VER = 1310
// Microsoft Visual C++ 7.0 _MSC_VER = 1300
@@ -234,7 +230,6 @@
# define WIN32_LEAN_AND_MEAN 1
# endif
# define NOMINMAX 1
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN