Replace tabs with spaces in more files.

--HG--
branch : trunk
This commit is contained in:
Paradox
2009-02-09 08:16:34 -05:00
parent b0694d7e5e
commit d230302b16
602 changed files with 41367 additions and 41366 deletions
+33 -33
View File
@@ -1,10 +1,10 @@
/**
@file AABox.h
Axis-aligned box class
@maintainer Morgan McGuire, [email protected]
@created 2004-01-10
@edited 2006-02-10
@@ -112,23 +112,23 @@ public:
}
/**
@deprecated Use culledBy(Array<Plane>&)
@deprecated Use culledBy(Array<Plane>&)
*/
bool culledBy(
const class Plane* plane,
int numPlanes,
int32& cullingPlaneIndex,
const uint32 testMask,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
/**
@deprecated Use culledBy(Array<Plane>&)
@deprecated Use culledBy(Array<Plane>&)
*/
bool culledBy(
const class Plane* plane,
int numPlanes,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = 0xFFFFFF) const;
int32& cullingPlaneIndex = dummy,
const uint32 testMask = 0xFFFFFF) const;
/**
Splits the box into two AABoxes along the specified axis. low contains
@@ -137,46 +137,46 @@ public:
*/
void split(const Vector3::Axis& axis, float location, AABox& low, AABox& high) const;
/**
Conservative culling test for up to 32 planes.
Returns true if there exists a <CODE>plane[p]</CODE> for
/**
Conservative culling test for up to 32 planes.
Returns true if there exists a <CODE>plane[p]</CODE> for
which the entire object is in the negative half space
(opposite the plane normal).
<CODE>testMask</CODE> and <CODE>childMask</CODE>
are used for optimizing bounding volume hierarchies.
<CODE>testMask</CODE> and <CODE>childMask</CODE>
are used for optimizing bounding volume hierarchies.
The version of this method that produces childMask
is slower than the version without; it should only
be used for parent nodes.
@param cullingPlaneIndex The index of the first plane for which
the entire object is in the negative half-space. The function
exits early when one plane is found. -1 when the function
returns false (i.e. when no plane culls the whole object).
@param cullingPlaneIndex The index of the first plane for which
the entire object is in the negative half-space. The function
exits early when one plane is found. -1 when the function
returns false (i.e. when no plane culls the whole object).
@param testMask If bit <I>p</I> is 0, the
bounding volume automatically passes the culling test for
<CODE>plane[p]</CODE> (i.e. it is known that the volume
is entirely within the positive half space). The function
@param testMask If bit <I>p</I> is 0, the
bounding volume automatically passes the culling test for
<CODE>plane[p]</CODE> (i.e. it is known that the volume
is entirely within the positive half space). The function
must return false if testMask is 0 and test all planes
when testMask is -1 (0xFFFFFFFF).
@param childMask Test mask for the children of this volume.
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
/**
Conservative culling test that does not produce a mask for children.
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
inline bool contains(
const Vector3& point) const {
@@ -248,7 +248,7 @@ public:
Hashing function for use with Table.
*/
inline unsigned int hashCode(const G3D::AABox& b) {
return b.hashCode();
return b.hashCode();
}
+58 -58
View File
@@ -1,9 +1,9 @@
/**
/**
@file Array.h
@maintainer Morgan McGuire, graphics3d.com
@cite Portions written by Aaron Orenstein, [email protected]
@created 2001-03-11
@edited 2007-05-12
@@ -26,7 +26,7 @@
#ifdef G3D_WIN32
# include <new>
# pragma warning (push)
// debug information too long
# pragma warning( disable : 4312)
@@ -47,7 +47,7 @@ const int SORT_INCREASING = 1;
const int SORT_DECREASING = -1;
/**
Dynamic 1D array.
Dynamic 1D array.
Objects must have a default constructor (constructor that
takes no arguments) in order to be used with this template.
@@ -61,9 +61,9 @@ const int SORT_DECREASING = -1;
16 bytes.
Array is highly optimized compared to std::vector.
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
amounts of data, Array consumes only 1.5x the total size of the
data, while std::vector consumes 2.0x. The default
array takes up zero heap space. The first resize (or append)
operation grows it to a reasonable internal size so it is efficient
@@ -128,16 +128,16 @@ private:
/**
Allocates a new array of size numAllocated (not a parameter to the method)
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
called for oldNum elements of the old array.
*/
void realloc(int oldNum) {
T* oldData = data;
// The allocation is separate from the constructor invocation because we don't want
// The allocation is separate from the constructor invocation because we don't want
// to pay for the cost of constructors until the newly allocated
// elements are actually revealed to the application. They
// elements are actually revealed to the application. They
// will be constructed in the resize() method.
data = (T*)System::alignedMalloc(sizeof(T) * numAllocated, 16);
@@ -153,7 +153,7 @@ private:
const T* constructed = new (ptr) T(*oldPtr);
(void)constructed;
debugAssertM(constructed == ptr,
debugAssertM(constructed == ptr,
"new returned a different address than the one provided by Array.");
}}
@@ -170,7 +170,7 @@ private:
public:
/**
C++ STL style iterator variable. Call begin() to get
C++ STL style iterator variable. Call begin() to get
the first iterator, pre-increment (++i) the iterator to get to
the next value. Use dereference (*i) to access the element.
*/
@@ -201,16 +201,16 @@ public:
}
/**
The array returned is only valid until the next append() or resize call, or
the Array is deallocated.
The array returned is only valid until the next append() or resize call, or
the Array is deallocated.
*/
T* getCArray() {
return data;
}
/**
The array returned is only valid until the next append() or resize call, or
the Array is deallocated.
The array returned is only valid until the next append() or resize call, or
the Array is deallocated.
*/
const T* getCArray() const {
return data;
@@ -237,7 +237,7 @@ public:
/**
Destructor does not delete() the objects if T is a pointer type
(e.g. T = int*) instead, it deletes the <B>pointers themselves</B> and
(e.g. T = int*) instead, it deletes the <B>pointers themselves</B> and
leaves the objects. Call deleteAll if you want to dealocate
the objects referenced. Do not call deleteAll if <CODE>T</CODE> is not a pointer
type (e.g. do call Array<Foo*>::deleteAll, do <B>not</B> call Array<Foo>::deleteAll).
@@ -247,17 +247,17 @@ public:
for (int i = 0; i < num; i++) {
(data + i)->~T();
}
System::alignedFree(data);
// Set to 0 in case this Array is global and gets referenced during app exit
data = NULL;
num = 0;
num = 0;
numAllocated = 0;
}
/**
Removes all elements. Use resize(0, false) or fastClear if you want to
Removes all elements. Use resize(0, false) or fastClear if you want to
remove all elements without deallocating the underlying array
so that future append() calls will be faster.
*/
@@ -316,7 +316,7 @@ public:
}
/**
Resizes, calling the default constructor for
Resizes, calling the default constructor for
newly created objects and shrinking the underlying
array as needed (and calling destructors as needed).
*/
@@ -367,7 +367,7 @@ public:
debugAssert(oldNum == 0);
realloc(oldNum);
} else {
if (num < minSize) {
// Grow to at least the minimum size
numAllocated = minSize;
@@ -424,7 +424,7 @@ public:
in the array.
*/
inline void append(const T& value) {
if (num < numAllocated) {
// This is a simple situation; just stick it in the next free slot using
// the copy constructor.
@@ -570,27 +570,27 @@ public:
pop();
}
/**
/**
"The member function returns the storage currently allocated to hold the controlled
sequence, a value at least as large as size()"
sequence, a value at least as large as size()"
For compatibility with std::vector.
*/
int capacity() const {
return numAllocated;
}
/**
"The member function returns a reference to the first element of the controlled sequence,
which must be non-empty."
/**
"The member function returns a reference to the first element of the controlled sequence,
which must be non-empty."
For compatibility with std::vector.
*/
T& front() {
return (*this)[0];
}
/**
"The member function returns a reference to the first element of the controlled sequence,
which must be non-empty."
/**
"The member function returns a reference to the first element of the controlled sequence,
which must be non-empty."
For compatibility with std::vector.
*/
const T& front() const {
@@ -717,13 +717,13 @@ public:
/** Returns element middleIndex() */
inline const T& middle() const {
debugAssertM(num > 0, "Array is empty");
return data[num >> 1];
return data[num >> 1];
}
/** Returns element middleIndex() */
inline T& middle() {
debugAssertM(num > 0, "Array is empty");
return data[num >> 1];
return data[num >> 1];
}
/**
@@ -785,14 +785,14 @@ public:
element[0] = element[count];
++element;
}
resize(num - count);
}
void remove(int index, int count = 1) {
debugAssert((index >= 0) && (index < num));
debugAssert((count > 0) && (index + count <= num));
remove(begin() + index, count);
}
@@ -801,7 +801,7 @@ public:
*/
void reverse() {
T temp;
int n2 = num / 2;
for (int i = 0; i < n2; ++i) {
temp = data[num - 1 - i];
@@ -819,7 +819,7 @@ public:
}
</PRE>
Note that for pointer arrays, the <CODE>const</CODE> must come
Note that for pointer arrays, the <CODE>const</CODE> must come
<I>after</I> the class name, e.g., <CODE>Array<MyClass*></CODE> uses:
<PRE>
@@ -834,7 +834,7 @@ public:
/**
Sorts the array in increasing order using the > or < operator. To
Sorts the array in increasing order using the > or < operator. To
invoke this method on Array<T>, T must override those operator.
You can overide these operators as follows:
<code>
@@ -893,8 +893,8 @@ public:
};
/** The output arrays are resized with fastClear() so that if they are already of the same size
as this array no memory is allocated during partitioning.
as this array no memory is allocated during partitioning.
@param comparator A function, or class instance with an overloaded operator() that compares
two elements of type <code>T</code> and returns 0 if they are equal, -1 if the second is smaller,
and 1 if the first is smaller (i.e., following the conventions of std::string::compare). For example:
@@ -913,7 +913,7 @@ public:
*/
template<typename Comparator>
void partition(
const T& partitionElement,
const T& partitionElement,
Array<T>& ltArray,
Array<T>& eqArray,
Array<T>& gtArray,
@@ -948,7 +948,7 @@ public:
Uses < and == on elements to perform a partition. See partition().
*/
void partition(
const T& partitionElement,
const T& partitionElement,
Array<T>& ltArray,
Array<T>& eqArray,
Array<T>& gtArray) const {
@@ -956,7 +956,7 @@ public:
partition(partitionElement, ltArray, eqArray, gtArray, typename Array<T>::DefaultComparator());
}
/**
/**
Paritions the array into those below the median, those above the median, and those elements
equal to the median in expected O(n) time using quickselect. If the array has an even
number of different elements, the median for partition purposes is the largest value
@@ -966,8 +966,8 @@ public:
@param comparator see parition() for a discussion.*/
template<typename Comparator>
void medianPartition(
Array<T>& ltMedian,
Array<T>& eqMedian,
Array<T>& ltMedian,
Array<T>& eqMedian,
Array<T>& gtMedian,
Array<T>& tempArray,
const Comparator& comparator) const {
@@ -991,7 +991,7 @@ public:
{
// Two element array; median is the smaller
int c = comparator(first(), last());
switch (c) {
case -1:
// first was bigger
@@ -1016,14 +1016,14 @@ public:
// All other cases use a recursive randomized median
// Number of values less than all in the current arrays
// Number of values less than all in the current arrays
int ltBoost = 0;
// Number of values greater than all in the current arrays
// Number of values greater than all in the current arrays
int gtBoost = 0;
// For even length arrays, force the gt array to be one larger than the
// lt array:
// lt array:
// [1 2 3] size = 3, choose half = (s + 1) /2
//
int lowerHalfSize, upperHalfSize;
@@ -1062,7 +1062,7 @@ public:
if ((L >= lowerHalfSize) &&
(U >= upperHalfSize)) {
// x must be the partition median
// x must be the partition median
break;
} else if (L < lowerHalfSize) {
@@ -1071,10 +1071,10 @@ public:
ltBoost += lt->size() + eq->size();
// The new gt array will be the old source array, unless
// that was the this pointer (i.e., unless we are on the
// that was the this pointer (i.e., unless we are on the
// first iteration)
Array<T>* newGt = (source == this) ? extra : const_cast<Array<T>*>(source);
// Now set up the gt array as the new source
source = gt;
gt = newGt;
@@ -1085,10 +1085,10 @@ public:
gtBoost += gt->size() + eq->size();
// The new lt array will be the old source array, unless
// that was the this pointer (i.e., unless we are on the
// that was the this pointer (i.e., unless we are on the
// first iteration)
Array<T>* newLt = (source == this) ? extra : const_cast<Array<T>*>(source);
// Now set up the lt array as the new source
source = lt;
lt = newLt;
@@ -1105,13 +1105,13 @@ public:
}
/**
Computes a median partition using the default comparator and a dynamically allocated temporary
Computes a median partition using the default comparator and a dynamically allocated temporary
working array. If the median is not in the array, it is chosen to be the largest value smaller
than the true median.
*/
void medianPartition(
Array<T>& ltMedian,
Array<T>& eqMedian,
Array<T>& ltMedian,
Array<T>& eqMedian,
Array<T>& gtMedian) const {
Array<T> temp;
+23 -23
View File
@@ -1,10 +1,10 @@
/**
@file Box.h
Box class
@maintainer Morgan McGuire, [email protected]
@cite Portions based on Dave Eberly's Magic Software Library at <A HREF="http://www.magic-software.com">http://www.magic-software.com</A>
@created 2001-06-02
@edited 2006-01-05
@@ -26,7 +26,7 @@ namespace G3D {
class CoordinateFrame;
/**
An arbitrary 3D box, useful as a bounding box.
An arbitrary 3D box, useful as a bounding box.
To construct a box from a coordinate frame, center and extent, use the idiom:
@@ -43,7 +43,7 @@ private:
/**
<PRE>
3 2 7 6
0 1 4 5
front back (seen through front)
@@ -55,7 +55,7 @@ private:
Unit axes.
*/
Vector3 _axis[3];
Vector3 _center;
/**
@@ -88,7 +88,7 @@ public:
/**
Returns the object to world transformation for
Returns the object to world transformation for
this box. localFrame().worldToObject(...) takes
objects into the space where the box axes are
(1,0,0), (0,1,0), (0,0,1). Note that there
@@ -156,40 +156,40 @@ public:
Vector3& v3) const;
/**
@deprecated Use culledBy(Array<Plane>&)
@deprecated Use culledBy(Array<Plane>&)
*/
bool culledBy(
const class Plane* plane,
int numPlanes,
int32& cullingPlaneIndex,
const uint32 testMask,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
/**
@deprecated Use culledBy(Array<Plane>&)
@deprecated Use culledBy(Array<Plane>&)
*/
bool culledBy(
const class Plane* plane,
int numPlanes,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
/**
/**
See AABox::culledBy
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
/**
Conservative culling test that does not produce a mask for children.
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
bool contains(
const Vector3& point) const;
File diff suppressed because it is too large Load Diff
+39 -39
View File
@@ -2,7 +2,7 @@
@file CoordinateFrame.h
@maintainer Morgan McGuire, [email protected]
@created 2001-03-04
@edited 2006-04-07
@@ -28,21 +28,21 @@ namespace G3D {
/**
A rigid body RT (rotation-translation) transformation.
CoordinateFrame abstracts a 4x4 matrix that maps object space to world space:
v_world = C * v_object
CoordinateFrame::rotation is the upper 3x3 submatrix, CoordinateFrame::translation
is the right 3x1 column. The 4th row is always [0 0 0 1], so it isn't stored.
is the right 3x1 column. The 4th row is always [0 0 0 1], so it isn't stored.
So you don't have to remember which way the multiplication and transformation work,
it provides explicit toWorldSpace and toObjectSpace methods. Also, points, vectors
it provides explicit toWorldSpace and toObjectSpace methods. Also, points, vectors
(directions), and surface normals transform differently, so they have separate methods.
Some helper functions transform whole primitives like boxes in and out of object space.
Convert to Matrix4 using CoordinateFrame::toMatrix4. You <I>can</I> construct a CoordinateFrame
from a Matrix4 using Matrix4::approxCoordinateFrame, however, because a Matrix4 is more
from a Matrix4 using Matrix4::approxCoordinateFrame, however, because a Matrix4 is more
general than a CoordinateFrame, some information may be lost.
See also: G3D::Matrix4, G3D::Quat
@@ -53,18 +53,18 @@ public:
/**
Takes object space points to world space.
*/
Matrix3 rotation;
Matrix3 rotation;
/**
Takes object space points to world space.
*/
Vector3 translation;
Vector3 translation;
/**
The direction an object "looks" relative to its own axes.
@deprecated This is always -1 and will be fixed at that value in future releases.
*/
static const float zLookDirection;
static const float zLookDirection;
inline bool operator==(const CoordinateFrame& other) const {
return (translation == other.translation) && (rotation == other.rotation);
@@ -83,13 +83,13 @@ public:
/**
Initializes to the identity coordinate frame.
*/
inline CoordinateFrame() :
inline CoordinateFrame() :
rotation(Matrix3::identity()), translation(Vector3::zero()) {
}
CoordinateFrame(const Vector3& _translation) :
CoordinateFrame(const Vector3& _translation) :
rotation(Matrix3::identity()), translation(_translation) {
}
}
CoordinateFrame(const Matrix3 &rotation, const Vector3 &translation) :
rotation(rotation), translation(translation) {
@@ -124,7 +124,7 @@ public:
/**
Returns the heading of the lookVector as an angle in radians relative to
the world -z axis. That is, a counter-clockwise heading where north (-z)
the world -z axis. That is, a counter-clockwise heading where north (-z)
is 0 and west (-x) is PI/2.
Note that the heading ignores the Y axis, so an inverted
@@ -157,23 +157,23 @@ public:
*/
inline Vector3 pointToWorldSpace(const Vector3& v) const {
return Vector3(
rotation[0][0] * v[0] + rotation[0][1] * v[1] + rotation[0][2] * v[2] + translation[0],
rotation[1][0] * v[0] + rotation[1][1] * v[1] + rotation[1][2] * v[2] + translation[1],
rotation[2][0] * v[0] + rotation[2][1] * v[1] + rotation[2][2] * v[2] + translation[2]);
rotation[0][0] * v[0] + rotation[0][1] * v[1] + rotation[0][2] * v[2] + translation[0],
rotation[1][0] * v[0] + rotation[1][1] * v[1] + rotation[1][2] * v[2] + translation[1],
rotation[2][0] * v[0] + rotation[2][1] * v[1] + rotation[2][2] * v[2] + translation[2]);
}
/**
Transforms the point into object space.
*/
inline Vector3 pointToObjectSpace(const Vector3& v) const {
float p[3];
p[0] = v[0] - translation[0];
p[1] = v[1] - translation[1];
p[2] = v[2] - translation[2];
return Vector3(
rotation[0][0] * p[0] + rotation[1][0] * p[1] + rotation[2][0] * p[2],
rotation[0][1] * p[0] + rotation[1][1] * p[1] + rotation[2][1] * p[2],
rotation[0][2] * p[0] + rotation[1][2] * p[1] + rotation[2][2] * p[2]);
inline Vector3 pointToObjectSpace(const Vector3& v) const {
float p[3];
p[0] = v[0] - translation[0];
p[1] = v[1] - translation[1];
p[2] = v[2] - translation[2];
return Vector3(
rotation[0][0] * p[0] + rotation[1][0] * p[1] + rotation[2][0] * p[2],
rotation[0][1] * p[0] + rotation[1][1] * p[1] + rotation[2][1] * p[2],
rotation[0][2] * p[0] + rotation[1][2] * p[1] + rotation[2][2] * p[2]);
}
/**
@@ -235,7 +235,7 @@ public:
class Box toObjectSpace(const Box& b) const;
class Plane toObjectSpace(const Plane& p) const;
class Sphere toObjectSpace(const Sphere& b) const;
Triangle toObjectSpace(const Triangle& t) const;
@@ -261,14 +261,14 @@ public:
Vector3 up);
/** @deprecated See lookVector */
inline Vector3 getLookVector() const {
return rotation.getColumn(2) * zLookDirection;
}
inline Vector3 getLookVector() const {
return rotation.getColumn(2) * zLookDirection;
}
/** The direction this camera is looking (its negative z axis)*/
inline Vector3 lookVector() const {
return rotation.getColumn(2) * zLookDirection;
}
inline Vector3 lookVector() const {
return rotation.getColumn(2) * zLookDirection;
}
/** Returns the ray starting at the camera origin travelling in direction CoordinateFrame::lookVector. */
class Ray lookRay() const;
@@ -283,24 +283,24 @@ public:
@deprecated leftVector
*/
inline Vector3 getLeftVector() const {
return -rotation.getColumn(0);
}
return -rotation.getColumn(0);
}
/** @deprecated See rightVector */
inline Vector3 getRightVector() const {
return rotation.getColumn(0);
}
return rotation.getColumn(0);
}
/**
If a viewer looks along the look vector, this is the viewer's "left".
Useful for strafing motions and building alternative coordinate frames.
*/
inline Vector3 leftVector() const {
return -rotation.getColumn(0);
return -rotation.getColumn(0);
}
inline Vector3 rightVector() const {
return rotation.getColumn(0);
return rotation.getColumn(0);
}
/**
+3 -3
View File
@@ -1,8 +1,8 @@
/**
/**
@file Crypto.h
@maintainer Morgan McGuire, [email protected]
@created 2006-03-29
@edited 2006-04-06
+53 -53
View File
@@ -32,23 +32,23 @@ private:
/**
Vertical field of view (in radians)
*/
float fieldOfView;
float fieldOfView;
/**
The image plane depth corresponding to a vertical field of
view, where the film size is 1x1.
/**
The image plane depth corresponding to a vertical field of
view, where the film size is 1x1.
*/
float imagePlaneDepth;
float imagePlaneDepth;
/**
Clipping plane, *not* imaging plane. Positive numbers.
*/
float nearPlane;
float nearPlane;
/**
Positive
Positive
*/
float farPlane;
float farPlane;
CoordinateFrame cframe;
@@ -64,7 +64,7 @@ public:
/** The plane containing the face. */
Plane plane;
};
/** The vertices, in homogeneous space. If w == 0,
a vertex is at infinity. */
Array<Vector4> vertexPos;
@@ -77,42 +77,42 @@ public:
Array<Face> faceArray;
};
GCamera();
GCamera();
virtual ~GCamera();
CoordinateFrame getCoordinateFrame() const;
void getCoordinateFrame(CoordinateFrame& c) const;
void setCoordinateFrame(const CoordinateFrame& c);
/**
Sets the horizontal field of view, in radians. The
initial angle is toRadians(55).
<UL>
<LI> toRadians(50) - Telephoto
<LI> toRadians(110) - Normal
<LI> toRadians(140) - Wide angle
</UL>
*/
void setFieldOfView(float angle);
CoordinateFrame getCoordinateFrame() const;
void getCoordinateFrame(CoordinateFrame& c) const;
void setCoordinateFrame(const CoordinateFrame& c);
/**
Sets the field of view based on a desired image plane depth
(<I>s'</I>) and film dimensions in world space. Depth must be positive. Width,
depth, and height are measured in the same units (meters are
recommended). The field of view will span the diagonal to the
image.<P> <I>Note</I>: to simulate a 35mm GCamera, set width =
0.36 mm and height = 0.24 mm. The width and height used are
generally not the pixel dimensions of the image.
*/
void setImagePlaneDepth(
/**
Sets the horizontal field of view, in radians. The
initial angle is toRadians(55).
<UL>
<LI> toRadians(50) - Telephoto
<LI> toRadians(110) - Normal
<LI> toRadians(140) - Wide angle
</UL>
*/
void setFieldOfView(float angle);
/**
Sets the field of view based on a desired image plane depth
(<I>s'</I>) and film dimensions in world space. Depth must be positive. Width,
depth, and height are measured in the same units (meters are
recommended). The field of view will span the diagonal to the
image.<P> <I>Note</I>: to simulate a 35mm GCamera, set width =
0.36 mm and height = 0.24 mm. The width and height used are
generally not the pixel dimensions of the image.
*/
void setImagePlaneDepth(
float depth,
const class Rect2D& viewport);
inline double getFieldOfView() const {
return fieldOfView;
}
inline double getFieldOfView() const {
return fieldOfView;
}
/**
Projects a world space point onto a width x height screen. The
@@ -147,7 +147,7 @@ public:
/**
Returns the image plane depth, <I>s'</I>, given the current field
of view for film of dimensions width x height. See
setImagePlaneDepth for a discussion of worldspace values width and height.
setImagePlaneDepth for a discussion of worldspace values width and height.
*/
float getImagePlaneDepth(
const class Rect2D& viewport) const;
@@ -162,7 +162,7 @@ public:
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.
through pixel centers, add 0.5 to x and y.
*/
Ray worldRay(
float x,
@@ -184,15 +184,15 @@ public:
return -farPlane;
}
inline void setFarPlaneZ(float z) {
debugAssert(z < 0);
farPlane = -z;
}
inline void setFarPlaneZ(float z) {
debugAssert(z < 0);
farPlane = -z;
}
inline void setNearPlaneZ(float z) {
debugAssert(z < 0);
nearPlane = -z;
}
inline void setNearPlaneZ(float z) {
debugAssert(z < 0);
nearPlane = -z;
}
/**
Returns the GCamera space width of the viewport.
@@ -203,16 +203,16 @@ public:
/**
Returns the GCamera space height of the viewport.
*/
float getViewportHeight(
float getViewportHeight(
const class Rect2D& viewport) const;
/**
Read back a GCamera space z-value at pixel (x, y) from the depth buffer.
double getZValue(
double x,
double y,
double x,
double y,
const class Rect2D& viewport,
double polygonOffset = 0) const;
double polygonOffset = 0) const;
*/
void setPosition(const Vector3& t);
@@ -220,13 +220,13 @@ public:
void lookAt(const Vector3& position, const Vector3& up = Vector3::unitY());
/**
Returns the clipping planes of the frustum, in world space.
Returns the clipping planes of the frustum, in world space.
The planes have normals facing <B>into</B> the view frustum.
The plane order is guaranteed to be:
Near, Right, Left, Top, Bottom, [Far]
If the far plane is at infinity, the resulting array will have
If the far plane is at infinity, the resulting array will have
5 planes, otherwise there will be 6.
The viewport is used only to determine the aspect ratio of the screen; the
+3 -3
View File
@@ -1,10 +1,10 @@
/**
@file Line.h
Line class
@maintainer Morgan McGuire, [email protected]
@created 2001-06-02
@edited 2006-02-28
*/
+27 -27
View File
@@ -1,12 +1,12 @@
/**
@file Matrix3.h
3x3 matrix class
@maintainer Morgan McGuire, [email protected]
@cite Portions based on Dave Eberly's Magic Software Library at <A HREF="http://www.magic-software.com">http://www.magic-software.com</A>
@created 2001-06-02
@edited 2006-04-05
*/
@@ -37,7 +37,7 @@ private:
public:
/** Initial values are undefined for performance. See also
/** Initial values are undefined for performance. See also
Matrix3::zero(), Matrix3::identity(), Matrix3::fromAxisAngle, etc.*/
inline Matrix3() {}
@@ -51,7 +51,7 @@ public:
/** Constructs a matrix from a quaternion.
@cite Graphics Gems II, p. 351--354
@cite Implementation from Watt and Watt, pg 362*/
@cite Implementation from Watt and Watt, pg 362*/
Matrix3(const class Quat& q);
@@ -148,7 +148,7 @@ private:
static void _mul(const Matrix3& A, const Matrix3& B, Matrix3& out);
public:
/** Optimized implementation of out = A * B. It is safe (but slow) to call
/** Optimized implementation of out = A * B. It is safe (but slow) to call
with A, B, and out possibly pointer equal to one another.*/
// This is a static method so that it is not ambiguous whether "this"
// is an input or output argument.
@@ -166,10 +166,10 @@ private:
static void _transpose(const Matrix3& A, Matrix3& out);
public:
/** Optimized implementation of out = A.transpose(). It is safe (but slow) to call
/** Optimized implementation of out = A.transpose(). It is safe (but slow) to call
with A and out possibly pointer equal to one another.
Note that <CODE>A.transpose() * v</CODE> can be computed
Note that <CODE>A.transpose() * v</CODE> can be computed
more efficiently as <CODE>v * A</CODE>.
*/
inline static void transpose(const Matrix3& A, Matrix3& out) {
@@ -239,32 +239,32 @@ public:
static void tensorProduct (const Vector3& rkU, const Vector3& rkV,
Matrix3& rkProduct);
std::string toString() const;
std::string toString() const;
static const float EPSILON;
static const float EPSILON;
// Special values.
// The unguaranteed order of initialization of static variables across
// The unguaranteed order of initialization of static variables across
// translation units can be a source of annoying bugs, so now the static
// special values (like Vector3::ZERO, Color3::WHITE, ...) are wrapped
// inside static functions that return references to them.
// These functions are intentionally not inlined, because:
// "You might be tempted to write [...] them as inline functions
// inside their respective header files, but this is something you
// must definitely not do. An inline function can be duplicated
// in every file in which it appears – and this duplication
// includes the static object definition. Because inline functions
// automatically default to internal linkage, this would result in
// having multiple static objects across the various translation
// units, which would certainly cause problems. So you must
// ensure that there is only one definition of each wrapping
// inside static functions that return references to them.
// These functions are intentionally not inlined, because:
// "You might be tempted to write [...] them as inline functions
// inside their respective header files, but this is something you
// must definitely not do. An inline function can be duplicated
// in every file in which it appears – and this duplication
// includes the static object definition. Because inline functions
// automatically default to internal linkage, this would result in
// having multiple static objects across the various translation
// units, which would certainly cause problems. So you must
// ensure that there is only one definition of each wrapping
// function, and this means not making the wrapping functions inline",
// according to Chapter 10 of "Thinking in C++, 2nd ed. Volume 1" by Bruce Eckel,
// according to Chapter 10 of "Thinking in C++, 2nd ed. Volume 1" by Bruce Eckel,
// http://www.mindview.net/
static const Matrix3& zero();
static const Matrix3& identity();
static const Matrix3& identity();
// Deprecated.
// Deprecated.
/** @deprecated Use Matrix3::zero() */
static const Matrix3 ZERO;
/** @deprecated Use Matrix3::identity() */
+8 -8
View File
@@ -25,8 +25,8 @@ class Plane {
private:
/** normal.Dot(x,y,z) = distance */
Vector3 _normal;
float _distance;
Vector3 _normal;
float _distance;
/**
Assumes the normal has unit length.
@@ -68,7 +68,7 @@ public:
virtual ~Plane() {}
/**
Returns true if point is on the side the normal points to or
Returns true if point is on the side the normal points to or
is in the plane.
*/
inline bool halfSpaceContains(Vector3 point) const {
@@ -81,7 +81,7 @@ public:
}
/**
Returns true if point is on the side the normal points to or
Returns true if point is on the side the normal points to or
is in the plane.
*/
inline bool halfSpaceContains(const Vector4& point) const {
@@ -93,7 +93,7 @@ public:
}
/**
Returns true if point is on the side the normal points to or
Returns true if point is on the side the normal points to or
is in the plane. Only call on finite points. Faster than halfSpaceContains.
*/
inline bool halfSpaceContainsFinite(const Vector3& point) const {
@@ -108,9 +108,9 @@ public:
return fuzzyEq(point.dot(_normal), _distance);
}
inline const Vector3& normal() const {
return _normal;
}
inline const Vector3& normal() const {
return _normal;
}
/**
Returns distance from point to plane. Distance is negative if point is behind (not in plane in direction opposite normal) the plane.
+33 -33
View File
@@ -1,10 +1,10 @@
/**
@file Quat.h
Quaternion
@maintainer Morgan McGuire, [email protected]
@created 2002-01-23
@edited 2006-05-10
*/
@@ -27,11 +27,11 @@ namespace G3D {
A quaternion represents the sum of a real scalar and
an imaginary vector: ix + jy + kz + w. A unit quaternion
representing a rotation by A about axis v has the form
representing a rotation by A about axis v has the form
[sin(A/2)*v, cos(A/2)]. For a unit quaternion, q.conj() == q.inverse()
is a rotation by -A about v. -q is the same rotation as q
(negate both the axis and angle).
(negate both the axis and angle).
A non-unit quaterion q represents the same rotation as
q.unitize() (Dam98 pg 28).
@@ -56,9 +56,9 @@ public:
/**
q = [sin(angle / 2) * axis, cos(angle / 2)]
In Watt & Watt's notation, s = w, v = (x, y, z)
In the Real-Time Rendering notation, u = (x, y, z), w = w
In the Real-Time Rendering notation, u = (x, y, z), w = w
*/
float x, y, z, w;
@@ -89,20 +89,20 @@ public:
}
/** Note: two quats can represent the Quat::sameRotation and not be equal. */
bool fuzzyEq(const Quat& q) {
return G3D::fuzzyEq(x, q.x) && G3D::fuzzyEq(y, q.y) && G3D::fuzzyEq(z, q.z) && G3D::fuzzyEq(w, q.w);
}
bool fuzzyEq(const Quat& q) {
return G3D::fuzzyEq(x, q.x) && G3D::fuzzyEq(y, q.y) && G3D::fuzzyEq(z, q.z) && G3D::fuzzyEq(w, q.w);
}
/** True if these quaternions represent the same rotation (note that every rotation is
/** True if these quaternions represent the same rotation (note that every rotation is
represented by two values; q and -q).
*/
bool sameRotation(const Quat& q) {
return fuzzyEq(q) || fuzzyEq(-q);
}
inline Quat operator-() const {
return Quat(-x, -y, -z, -w);
}
inline Quat operator-() const {
return Quat(-x, -y, -z, -w);
}
/**
Returns the imaginary part (x, y, z)
@@ -129,34 +129,34 @@ public:
void toAxisAngleRotation(
Vector3& axis,
float& angle) const {
double d;
toAxisAngleRotation(axis, d);
angle = (float)d;
}
double d;
toAxisAngleRotation(axis, d);
angle = (float)d;
}
Matrix3 toRotationMatrix() const;
void toRotationMatrix(
Matrix3& rot) const;
/**
Spherical linear interpolation: linear interpolation along the
Spherical linear interpolation: linear interpolation along the
shortest (3D) great-circle route between two quaternions.
Note: Correct rotations are expected between 0 and PI in the right order.
@cite Based on Game Physics -- David Eberly pg 538-540
@param threshold Critical angle between between rotations at which
the algorithm switches to normalized lerp, which is more
numerically stable in those situations. 0.0 will always slerp.
the algorithm switches to normalized lerp, which is more
numerically stable in those situations. 0.0 will always slerp.
*/
Quat slerp(
const Quat& other,
float alpha,
float threshold = 0.05f) const;
/** Normalized linear interpolation of quaternion components. */
Quat nlerp(const Quat& other, float alpha) const;
/** Normalized linear interpolation of quaternion components. */
Quat nlerp(const Quat& other, float alpha) const;
/**
Negates the imaginary part.
@@ -177,7 +177,7 @@ public:
return Quat(x * s, y * s, z * s, w * s);
}
/** @cite Based on Watt & Watt, page 360 */
/** @cite Based on Watt & Watt, page 360 */
friend Quat operator* (float s, const Quat& q);
inline Quat operator/(float s) const {
@@ -188,7 +188,7 @@ public:
return (x * other.x) + (y * other.y) + (z * other.z) + (w * other.w);
}
/** Note that q<SUP>-1</SUP> = q.conj() for a unit quaternion.
/** Note that q<SUP>-1</SUP> = q.conj() for a unit quaternion.
@cite Dam99 page 13 */
inline Quat inverse() const {
return conj() / dot(*this);
@@ -214,7 +214,7 @@ public:
inline bool isUnit(float tolerance = 1e-5) const {
return abs(dot(*this) - 1.0f) < tolerance;
}
inline float magnitude() const {
return sqrtf(dot(*this));
@@ -242,18 +242,18 @@ public:
}
}
/** log q = [Av, 0] where q = [sin(A) * v, cos(A)].
Only for unit quaternions
Only for unit quaternions
debugAssertM(isUnit(), "Log only defined for unit quaternions");
// Solve for A in q = [sin(A)*v, cos(A)]
Vector3 u(x, y, z);
double len = u.magnitude();
if (len == 0.0) {
return
return
}
double A = atan2((double)w, len);
Vector3 v = u / len;
return Quat(v * A, 0);
}
*/
@@ -321,8 +321,8 @@ public:
const float& operator[] (int i) const;
float& operator[] (int i);
/** Generate uniform random unit quaternion (i.e. random "direction")
@cite From "Uniform Random Rotations", Ken Shoemake, Graphics Gems III.
/** Generate uniform random unit quaternion (i.e. random "direction")
@cite From "Uniform Random Rotations", Ken Shoemake, Graphics Gems III.
*/
static Quat unitRandom();
+22 -22
View File
@@ -1,10 +1,10 @@
/**
@file Ray.h
Ray class
@maintainer Morgan McGuire, [email protected]
@created 2002-07-12
@edited 2006-02-21
*/
@@ -142,7 +142,7 @@ public:
return intersectionTime(vert0, vert1, vert2, vert1 - vert0, vert2 - vert0, w0, w1, w2);
}
/* One-sided triangle
/* One-sided triangle
*/
inline float intersectionTime(const Triangle& triangle) const {
return intersectionTime(
@@ -189,7 +189,7 @@ public:
#define SUB(dest,v1,v2) \
dest[0]=v1[0]-v2[0]; \
dest[1]=v1[1]-v2[1]; \
dest[2]=v1[2]-v2[2];
dest[2]=v1[2]-v2[2];
inline float Ray::intersectionTime(
const Vector3& vert0,
@@ -205,41 +205,41 @@ inline float Ray::intersectionTime(
float u, v;
float tvec[3], pvec[3], qvec[3];
// begin calculating determinant - also used to calculate U parameter
CROSS(pvec, direction, edge2);
// if determinant is near zero, ray lies in plane of triangle
const float det = DOT(edge1, pvec);
if (det < EPSILON) {
return (float)inf();
}
// calculate distance from vert0 to ray origin
SUB(tvec, origin, vert0);
// calculate U parameter and test bounds
u = DOT(tvec, pvec);
if ((u < 0.0f) || (u > det)) {
// Hit the plane outside the triangle
return (float)inf();
}
// prepare to test V parameter
CROSS(qvec, tvec, edge1);
// calculate V parameter and test bounds
v = DOT(direction, qvec);
if ((v < 0.0f) || (u + v > det)) {
// Hit the plane outside the triangle
return (float)inf();
}
// Case where we don't need correct (u, v):
const float t = DOT(edge2, qvec);
if (t >= 0.0f) {
// Note that det must be positive
return t / det;
@@ -270,36 +270,36 @@ inline float Ray::intersectionTime(
// begin calculating determinant - also used to calculate U parameter
CROSS(pvec, direction, edge2);
// if determinant is near zero, ray lies in plane of triangle
const float det = DOT(edge1, pvec);
if (det < EPSILON) {
return (float)inf();
}
// calculate distance from vert0 to ray origin
SUB(tvec, origin, vert0);
// calculate U parameter and test bounds
u = DOT(tvec, pvec);
if ((u < 0.0f) || (u > det)) {
// Hit the plane outside the triangle
return (float)inf();
}
// prepare to test V parameter
CROSS(qvec, tvec, edge1);
// calculate V parameter and test bounds
v = DOT(direction, qvec);
if ((v < 0.0f) || (u + v > det)) {
// Hit the plane outside the triangle
return (float)inf();
}
float t = DOT(edge2, qvec);
if (t >= 0) {
const float inv_det = 1.0f / det;
t *= inv_det;
+5 -5
View File
@@ -21,7 +21,7 @@
namespace G3D {
/**
/**
Provides generalized Windows registry querying.
All key names are one string in the format:
@@ -49,10 +49,10 @@ public:
/** returns false if the key could not be read for any reason. */
static bool readInt32(const std::string& key, int32& valueData);
/**
/**
Reads an arbitrary amount of data from a binary registry key.
returns false if the key could not be read for any reason.
@beta
@param valueData pointer to the output buffer of sufficient size. Pass NULL as valueData in order to have available data size returned in dataSize.
@param dataSize size of the output buffer. When NULL is passed for valueData, contains the size of available data on successful return.
@@ -65,10 +65,10 @@ public:
/** returns false if the key could not be written for any reason. */
static bool writeInt32(const std::string& key, int32 valueData);
/**
/**
Writes an arbitrary amount of data to a binary registry key.
returns false if the key could not be written for any reason.
@param valueData pointer to the input buffer
@param dataSize size of the input buffer that should be written
*/
+19 -19
View File
@@ -1,10 +1,10 @@
/**
@file Sphere.h
Sphere class
@maintainer Morgan McGuire, matrix@graphics3d.com
@created 2001-06-02
@edited 2004-07-05
*/
@@ -61,40 +61,40 @@ public:
bool contains(const Vector3& point) const;
/**
@deprecated Use culledBy(Array<Plane>&)
@deprecated Use culledBy(Array<Plane>&)
*/
bool culledBy(
const class Plane* plane,
int numPlanes,
int32& cullingPlaneIndex,
const uint32 testMask,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
/**
@deprecated Use culledBy(Array<Plane>&)
@deprecated Use culledBy(Array<Plane>&)
*/
bool culledBy(
const class Plane* plane,
int numPlanes,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
/**
/**
See AABox::culledBy
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
/**
Conservative culling test that does not produce a mask for children.
*/
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
bool culledBy(
const Array<Plane>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = -1) const;
virtual std::string toString() const;
float volume() const;
+13 -13
View File
@@ -1,8 +1,8 @@
/**
/**
@file System.h
@maintainer Morgan McGuire, matrix@graphics3d.com
@cite Rob Wyatt http://www.gamasutra.com/features/wyatts_world/19990709/processor_detection_01.htm
@cite Benjamin Jurke http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-ProcessorDetectionClass&forum=cotd&id=-1
@cite Michael Herf http://www.stereopsis.com/memcpy.html
@@ -19,7 +19,7 @@
#include <string>
#ifdef G3D_OSX
# include <CoreServices/CoreServices.h>
# include <CoreServices/CoreServices.h>
#endif
@@ -34,13 +34,13 @@ public:
static void init();
/**
Guarantees that the start of the array is aligned to the
Guarantees that the start of the array is aligned to the
specified number of bytes.
*/
static void* alignedMalloc(size_t bytes, size_t alignment);
/**
Uses pooled storage to optimize small allocations (1 byte to 5 kilobytes).
Uses pooled storage to optimize small allocations (1 byte to 5 kilobytes).
Can be 10x to 100x faster than calling ::malloc or new.
The result must be freed with free.
@@ -56,7 +56,7 @@ public:
/**
@param size Size of memory that the system was trying to allocate
@param recoverable If true, the system will attempt to allocate again
if the callback returns true. If false, malloc is going to return
if the callback returns true. If false, malloc is going to return
NULL and this invocation is just to notify the application.
@return Return true to force malloc to attempt allocation again if the
error was recoverable.
@@ -71,7 +71,7 @@ public:
true, System::malloc will attempt to allocate the memory again.
If the callback returns false, then System::malloc will return NULL.
You can use outOfMemoryCallback to free data structures or to
You can use outOfMemoryCallback to free data structures or to
register the failure.
*/
static OutOfMemoryCallback outOfMemoryCallback;
@@ -86,7 +86,7 @@ public:
static std::string mallocPerformance();
static void resetMallocPerformanceCounters();
/**
/**
Returns a string describing the current usage of the buffer pools used for
optimizing System::malloc.
*/
@@ -105,13 +105,13 @@ public:
static void alignedFree(void* ptr);
/** An implementation of memcpy that may be up to 2x as fast as the C library
one on some processors. Guaranteed to have the same behavior as memcpy
in all cases. */
one on some processors. Guaranteed to have the same behavior as memcpy
in all cases. */
static void memcpy(void* dst, const void* src, size_t numBytes);
/** An implementation of memset that may be up to 2x as fast as the C library
one on some processors. Guaranteed to have the same behavior as memset
in all cases. */
one on some processors. Guaranteed to have the same behavior as memset
in all cases. */
static void memset(void* dst, uint8 value, size_t numBytes);
};
+20 -20
View File
@@ -81,7 +81,7 @@ namespace G3D {
An unordered data structure mapping keys to values.
Key must be a pointer, an int, a std::string, a class with a hashCode() method,
or provide overloads for:
or provide overloads for:
<PRE>
template<> struct GHashCode<class Key> {
@@ -108,7 +108,7 @@ namespace G3D {
1.0 your hash function is badly designed and maps too many inputs to
the same output.
*/
template<class Key, class Value, class HashFunc = GHashCode<Key> >
template<class Key, class Value, class HashFunc = GHashCode<Key> >
class Table {
public:
@@ -131,12 +131,12 @@ private:
Entry entry;
Node* next;
/** Provide pooled allocation for speed. */
inline void* operator new (size_t size) {
return System::malloc(size);
}
inline void operator delete (void* p) {
System::free(p);
}
@@ -165,12 +165,12 @@ private:
size_t _size;
/**
Array of Node*.
Array of Node*.
We don't use Array<Node*> because Table is lower level.
Some elements may be NULL.
*/
Node** bucket;
/**
Length of the bucket array.
*/
@@ -187,15 +187,15 @@ private:
for (size_t b = 0; b < this->numBuckets; b++) {
Node* node = oldBucket[b];
while (node != NULL) {
Node* nextNode = node->next;
// insert at the head of the list for bucket[i]
size_t i = node->hashCode % numBuckets;
node->next = bucket[i];
bucket[i] = node;
node = nextNode;
}
}
@@ -294,7 +294,7 @@ public:
/**
A small load (close to zero) means the hash table is acting very
efficiently most of the time. A large load (close to 1) means
efficiently most of the time. A large load (close to 1) means
the hash table is acting poorly-- all operations will be very slow.
A large load will result from a bad hash function that maps too
many keys to the same code.
@@ -342,7 +342,7 @@ public:
table(const_cast<Table<Key, Value>*>(table)),
numBuckets(numBuckets),
bucket(bucket) {
if (numBuckets == 0) {
// Empty table
isDone = true;
@@ -383,7 +383,7 @@ public:
} else {
return
(table == other.table) &&
(node == other.node) &&
(node == other.node) &&
(index == other.index);
}
}
@@ -421,7 +421,7 @@ public:
/**
C++ STL style iterator method. Returns the first Entry, which
C++ STL style iterator method. Returns the first Entry, which
contains a key and value. Use preincrement (++entry) to get to
the next element. Do not modify the table while iterating.
*/
@@ -448,7 +448,7 @@ public:
System::memset(bucket, 0, sizeof(Node*) * numBuckets);
}
/**
Returns the number of keys.
*/
@@ -459,13 +459,13 @@ public:
/**
If you insert a pointer into the key or value of a table, you are
responsible for deallocating the object eventually. Inserting
responsible for deallocating the object eventually. Inserting
key into a table is O(1), but may cause a potentially slow rehashing.
*/
void set(const Key& key, const Value& value) {
size_t code = m_HashFunc(key);
size_t b = code % numBuckets;
// Go to the bucket
Node* n = bucket[b];
@@ -479,7 +479,7 @@ public:
size_t bucketLength = 1;
// Sometimes a bad hash code will cause all elements
// to collide. Detect this case and don't rehash when
// to collide. Detect this case and don't rehash when
// it occurs; nothing good will come from the rehashing.
bool allSameCode = true;
@@ -515,7 +515,7 @@ public:
to remove an element that isn't present.
*/
void remove(const Key& key) {
size_t code = m_HashFunc(key);
size_t b = code % numBuckets;
@@ -552,7 +552,7 @@ public:
/**
Returns the value associated with key.
@deprecated Use get(key, val) or
@deprecated Use get(key, val) or
*/
Value& get(const Key& key) const {
@@ -647,7 +647,7 @@ public:
}
/**
Calls delete on all of the keys. Does not clear the table,
Calls delete on all of the keys. Does not clear the table,
however, so you are left with a table of dangling pointers.
Same as <CODE>getKeys().deleteAll();</CODE>
+6 -6
View File
@@ -1,8 +1,8 @@
/**
@file Triangle.h
@maintainer Morgan McGuire, matrix@graphics3d.com
@created 2003-04-05
@edited 2004-03-14
@@ -52,11 +52,11 @@ private:
void init(const Vector3& v0, const Vector3& v1, const Vector3& v2);
public:
Triangle();
Triangle(const Vector3& v0, const Vector3& v1, const Vector3& v2);
~Triangle();
/** 0, 1, or 2 */
@@ -110,7 +110,7 @@ public:
} // namespace
inline unsigned int hashCode(const G3D::Triangle& t) {
return t.hashCode();
return t.hashCode();
}
#endif
+8 -8
View File
@@ -1,10 +1,10 @@
/**
@file Vector2.h
2D vector class
@maintainer Morgan McGuire, matrix@graphics3d.com
@created 2001-06-02
@edited 2006-01-14
Copyright 2000-2006, Morgan McGuire.
@@ -21,7 +21,7 @@
namespace G3D {
class Vector2;
class Vector2;
class Vector3;
class Vector4;
@@ -47,7 +47,7 @@ public:
Vector2(float coordinate[2]);
Vector2(double coordinate[2]);
Vector2(const Vector2& rkVector);
Vector2(const class Vector2int16& v);
Vector2(const class Vector2int16& v);
float& operator[] (int i);
const float& operator[] (int i) const;
@@ -87,7 +87,7 @@ public:
Linear interpolation
*/
inline Vector2 lerp(const Vector2& v, float alpha) const {
return (*this) + (v - *this) * alpha;
return (*this) + (v - *this) * alpha;
}
inline Vector2 clamp(const Vector2& low, const Vector2& high) const {
@@ -137,10 +137,10 @@ public:
inline static const Vector2& one() { static const Vector2 v(1, 1); return v; }
static const Vector2& unitX();
static const Vector2& unitY();
static const Vector2& inf();
static const Vector2& inf();
static const Vector2& nan();
/** smallest (most negative) representable vector */
static const Vector2& minFinite();
static const Vector2& minFinite();
/** Largest representable vector */
static const Vector2& maxFinite();
+1 -1
View File
@@ -1,6 +1,6 @@
/**
@file Vector2int16.h
@maintainer Morgan McGuire, matrix@brown.edu
@created 2003-08-09
+17 -17
View File
@@ -1,8 +1,8 @@
/**
@file Vector3.h
3D vector class
@maintainer Morgan McGuire, matrix@graphics3d.com
@created 2001-06-02
@@ -22,14 +22,14 @@
namespace G3D {
class Vector2;
class Vector2;
class Vector3;
class Vector4;
/**
<B>Swizzles</B>
Vector classes have swizzle operators, e.g. <CODE>v.xy()</CODE>, that
allow selection of arbitrary sub-fields. These cannot be used as write
allow selection of arbitrary sub-fields. These cannot be used as write
masks. Examples
<PRE>
@@ -57,7 +57,7 @@ private:
<PRE>
V' N V
r ^ -,
\ | /
\|/
@@ -126,7 +126,7 @@ public:
/** Returns true if this vector has length ~= 1 */
bool isUnit() const;
// arithmetic operations
Vector3 operator+ (const Vector3& v) const;
Vector3 operator- (const Vector3& v) const;
@@ -145,10 +145,10 @@ public:
Vector3& operator/= (const Vector3& v);
/** @deprecated Use magnitude */
float G3D_DEPRECATED length() const;
float G3D_DEPRECATED length() const;
float magnitude() const;
/**
The result is a nan vector if the length is almost zero.
*/
@@ -163,17 +163,17 @@ public:
/**
See also G3D::Ray::reflect.
The length is 1.
The length is 1.
<PRE>
V' N V
r ^ /
\ | /
\|'-
</PRE>
*/
Vector3 reflectionDirection(const Vector3& normal) const;
/**
Returns Vector3::zero() if the length is nearly zero, otherwise
@@ -195,7 +195,7 @@ public:
where iExit is the index of refraction for the
previous material and iEnter is the index of refraction
for the new material. Like Vector3::reflectionDirection,
the result has length 1 and is
the result has length 1 and is
pointed <I>away</I> from the intersection.
Returns Vector3::zero() in the case of total internal refraction.
@@ -209,7 +209,7 @@ public:
See also G3D::Ray::refract.
<PRE>
N V
^ /
| /
|'-
@@ -236,14 +236,14 @@ public:
float G3D_DEPRECATED squaredLength() const;
float squaredMagnitude () const;
/** @deprecated Use squaredMagnitude */
inline float G3D_DEPRECATED norm() const {
return squaredMagnitude();
}
float dot(const Vector3& rkVector) const;
float G3D_DEPRECATED unitize(float fTolerance = 1e-06);
/** Cross product. Note that two cross products in a row
@@ -285,7 +285,7 @@ public:
Linear interpolation
*/
inline Vector3 lerp(const Vector3& v, float alpha) const {
return (*this) + (v - *this) * alpha;
return (*this) + (v - *this) * alpha;
}
/** Gram-Schmidt orthonormalization. */
@@ -295,7 +295,7 @@ public:
static Vector3 random();
/** Random unit vector, distributed
so that the probability of V is proportional
so that the probability of V is proportional
to max(V dot Normal, 0).
@cite Henrik Wann Jensen, Realistic Image Synthesis using Photon Mapping eqn 2.24
+1 -1
View File
@@ -1,6 +1,6 @@
/**
@file Vector3int16.h
@maintainer Morgan McGuire, matrix@brown.edu
@created 2003-04-07
+5 -5
View File
@@ -1,10 +1,10 @@
/**
@file Vector4.h
Homogeneous vector class.
@maintainer Morgan McGuire, matrix@graphics3d.com
@created 2002-07-09
@edited 2005-03-28
@@ -23,7 +23,7 @@
namespace G3D {
class Vector2;
class Vector2;
class Vector3;
class Vector4;
@@ -116,7 +116,7 @@ public:
// arithmetic operations
Vector4 operator+ (const Vector4& rkVector) const;
Vector4 operator- (const Vector4& rkVector) const;
inline Vector4 operator*(const Vector4& rkVector) const {
return Vector4(x * rkVector.x, y * rkVector.y, z * rkVector.z, w * rkVector.w);
}
+2 -2
View File
@@ -1,8 +1,8 @@
/**
@file format.h
@maintainer Morgan McGuire, matrix@graphics3d.com
@author 2000-09-09
@edited 2005-11-03
+31 -31
View File
@@ -1,11 +1,11 @@
/**
@file g3dmath.h
Math util class.
@maintainer Morgan McGuire, matrix@graphics3d.com
@cite highestBit by Jukka Liimatta
@created 2001-06-02
@edited 2006-01-16
@@ -32,7 +32,7 @@
/*These defines enable functionality introduced with the 1999 ISO C
**standard. They must be defined before the inclusion of math.h to
**engage them. If optimisation is enabled, these functions will be
**engage them. If optimisation is enabled, these functions will be
**inlined. With optimisation switched off, you have to link in the
**maths library using -lm.
*/
@@ -52,19 +52,19 @@
namespace G3D {
#if defined(_MSC_VER)
#if !defined(_WIN64)
/**
Win32 implementation of the C99 fast rounding routines.
@cite routines are
Copyright (C) 2001 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
Permission to use, copy, modify, distribute, and sell this file for any
purpose is hereby granted without fee, provided that the above copyright
Permission to use, copy, modify, distribute, and sell this file for any
purpose is hereby granted without fee, provided that the above copyright
and this permission notice appear in all copies. No representations are
made about the suitability of this software for any purpose. It is
made about the suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
*/
@@ -115,13 +115,13 @@ inline const double& inf() {
// We already have <limits> included but
// not using it in older gcc for safe compilations
#if (__GNUC__ == 2)
#if (__GNUC__ == 2)
static const double i = 1.0/sin(0.0);
#else
// double is a standard type and should have infinity
static const double i = std::numeric_limits<double>::infinity();
#endif
return i;
return i;
}
/** Returns a reference to a static double.
@@ -137,7 +137,7 @@ inline const double& nan() {
// double is a standard type and should have quiet NaN
static const double n = std::numeric_limits<double>::quiet_NaN();
#endif
return n;
return n;
}
/** Returns a reference to a static double. Use instead of G3D_PI. */
@@ -168,24 +168,24 @@ inline const double& twoPi() {
@deprecated Use G3D::twoPi() instead. */
#define G3D_TWO_PI (6.283185)
typedef signed char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
typedef signed char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
#ifdef _MSC_EXTENSIONS
typedef __int64 int64;
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
typedef long long int64;
typedef long long int64;
typedef unsigned long long uint64;
#endif
typedef unsigned int uint;
typedef float float32;
typedef double float64;
typedef float float32;
typedef double float64;
int iAbs(int iValue);
int iCeil(double fValue);
@@ -226,7 +226,7 @@ inline int iSign(float f) {
}
/**
/**
Fast round to integer using the lrint routine.
Typically 6x faster than casting to integer.
*/
@@ -234,7 +234,7 @@ inline int iRound(double fValue) {
return lrint(fValue);
}
/**
/**
Fast round to integer using the lrint routine.
Typically 6x faster than casting to integer.
*/
@@ -273,7 +273,7 @@ bool isNaN(double x);
*/
int iMod3(int x);
/**
/**
[0, 1]
@deprecated use uniformRandom()
*/
@@ -297,7 +297,7 @@ double symmetricRandom ();
float uniformRandom(float low = 0.0f, float hi = 1.0f);
/**
Normally distributed random number.
Normally distributed random number.
*/
float gaussRandom(float mean = 0.0f, float stdev = 1.0f);
@@ -360,7 +360,7 @@ double distance(double x, double y, double z);
the left. -1 means the number was 0.
@cite Based on code by jukka@liimatta.org
*/
*/
int highestBit(uint32 x);
/**
@@ -370,8 +370,8 @@ int highestBit(uint32 x);
*/
bool fuzzyEq(double a, double b);
/** True if a is definitely not equal to b.
Guaranteed false if a == b.
/** True if a is definitely not equal to b.
Guaranteed false if a == b.
Possibly false when a != b.*/
bool fuzzyNe(double a, double b);
@@ -415,7 +415,7 @@ inline float SSErsq(float x) {
/**
Return the next power of 2 higher than the input
If the input is already a power of 2, the output will be the same
If the input is already a power of 2, the output will be the same
as the input.
*/
int ceilPow2(unsigned int in);
+32 -32
View File
@@ -13,7 +13,7 @@
#define G3D_PLATFORM_H
/**
The version number of G3D in the form: MmmBB ->
The version number of G3D in the form: MmmBB ->
version M.mm [beta BB]
*/
#define G3D_VER 61000
@@ -30,11 +30,11 @@
# define G3D_DEBUG
#endif
#ifdef _MSC_VER
#ifdef _MSC_VER
#define G3D_WIN32
#elif defined(__MINGW32__)
#define G3D_WIN32
#define G3D_MINGW32
#define G3D_WIN32
#define G3D_MINGW32
#elif defined(__linux__)
#define G3D_LINUX
#elif defined(__OpenBSD__)
@@ -46,11 +46,11 @@
#elif defined(__APPLE__)
#define G3D_OSX
#else
#error Unknown platform
#error Unknown platform
#endif
// Default to compiling with SSE, but if you want to compile
// 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")
#if !defined(NO_SSE)
@@ -59,7 +59,7 @@
#ifdef G3D_WIN32
// Turn off warnings about deprecated C routines (TODO: revisit)
# pragma warning (disable : 4996)
# pragma warning (disable : 4996)
#endif
// On g++, recognize cases where the -msse2 flag was not specified
@@ -107,14 +107,14 @@
#ifndef __GNUC__
#error G3D only supports the gcc compiler on OS X.
#endif
#if defined(__i386__)
#define G3D_OSX_INTEL
#elif defined(__PPC__)
#define G3D_OSX_PPC
#else
#define G3D_OSX_UNKNOWN
#endif
#if defined(__i386__)
#define G3D_OSX_INTEL
#elif defined(__PPC__)
#define G3D_OSX_PPC
#else
#define G3D_OSX_UNKNOWN
#endif
# ifndef __cdecl
# define __cdecl __attribute__((cdecl))
@@ -134,10 +134,10 @@
#ifdef G3D_WIN32
// Microsoft Visual C++ 7.1 _MSC_VER = 1310
// Microsoft Visual C++ 7.0 _MSC_VER = 1300
// Microsoft Visual C++ 6.0 _MSC_VER = 1200
// Microsoft Visual C++ 5.0 _MSC_VER = 1100
// Microsoft Visual C++ 7.1 _MSC_VER = 1310
// Microsoft Visual C++ 7.0 _MSC_VER = 1300
// Microsoft Visual C++ 6.0 _MSC_VER = 1200
// Microsoft Visual C++ 5.0 _MSC_VER = 1100
// Old versions of MSVC (6.0 and previous) don't
// support C99 for loop scoping rules. This fixes them.
@@ -165,10 +165,10 @@
// TODO: remove
# pragma warning (disable : 4244)
# if defined(_MSC_VER) && (_MSC_VER <= 1200)
// VC6 std:: has signed problems in it
# pragma warning (disable : 4018)
# endif
# if defined(_MSC_VER) && (_MSC_VER <= 1200)
// VC6 std:: has signed problems in it
# pragma warning (disable : 4018)
# endif
# define ZLIB_WINAPI
@@ -177,15 +177,15 @@
# define restrict
# endif
# define G3D_CHECK_PRINTF_ARGS
# define G3D_CHECK_PRINTF_ARGS
# define G3D_CHECK_VPRINTF_ARGS
# define G3D_CHECK_PRINTF_METHOD_ARGS
# define G3D_CHECK_PRINTF_METHOD_ARGS
# define G3D_CHECK_VPRINTF_METHOD_ARGS
// On MSVC, we need to link against the multithreaded DLL version of
// the C++ runtime because that is what SDL and ZLIB are compiled
// against. This is not the default for MSVC, so we set the following
// defines to force correct linking.
// defines to force correct linking.
//
// For documentation on compiler options, see:
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_.2f.md.2c_2f.ml.2c_2f.mt.2c_2f.ld.asp
@@ -195,16 +195,16 @@
#if 0 //ignore that for Trinity
// DLL runtime
#ifndef _DLL
#define _DLL
#define _DLL
#endif
// Multithreaded runtime
#ifndef _MT
#define _MT 1
#define _MT 1
#endif
// Ensure that we aren't forced into the static lib
#ifdef _STATIC_CPPLIB
#undef _STATIC_CPPLIB
#undef _STATIC_CPPLIB
#endif
#endif
@@ -228,7 +228,7 @@
// zlib and SDL were linked against the release MSVCRT; force
// the debug version.
#pragma comment(linker, "/NODEFAULTLIB:MSVCRT.LIB")
# endif
# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
@@ -252,11 +252,11 @@
# pragma warning (disable : 4018)
# endif
/**
/**
@def STR(expression)
Creates a string from the expression. Frequently used with G3D::Shader
to express shading programs inline.
to express shading programs inline.
<CODE>STR(this becomes a string)<PRE> evaluates the same as <CODE>"this becomes a string"</CODE>
*/
+2 -2
View File
@@ -1,8 +1,8 @@
/**
@file stringutils.h
@maintainer Morgan McGuire, matrix@graphics3d.com
@author 2000-09-09
@edited 2002-11-30
*/