aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/Kernel
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2014-05-23 01:49:32 -0700
committerBrad Davis <[email protected]>2014-05-23 01:49:32 -0700
commit46acc0e194ff3c1f120199eeca8324b4502118e9 (patch)
treeb1030198d3ee4698445d1fc5161cebe4158e45d1 /LibOVR/Src/Kernel
parent07d0f4d0bbf3477ac6a9584f726e8ec6ab285707 (diff)
Updating to 0.3.2 (windows version)
Diffstat (limited to 'LibOVR/Src/Kernel')
-rw-r--r--LibOVR/Src/Kernel/OVR_Alg.h18
-rw-r--r--LibOVR/Src/Kernel/OVR_Deque.h30
-rw-r--r--LibOVR/Src/Kernel/OVR_FileFILE.cpp2
-rw-r--r--LibOVR/Src/Kernel/OVR_Math.h107
-rw-r--r--LibOVR/Src/Kernel/OVR_String.cpp11
-rw-r--r--LibOVR/Src/Kernel/OVR_String.h1
-rw-r--r--LibOVR/Src/Kernel/OVR_SysFile.cpp2
-rw-r--r--LibOVR/Src/Kernel/OVR_SysFile.h2
-rw-r--r--LibOVR/Src/Kernel/OVR_Threads.h2
-rw-r--r--LibOVR/Src/Kernel/OVR_Types.h2
10 files changed, 104 insertions, 73 deletions
diff --git a/LibOVR/Src/Kernel/OVR_Alg.h b/LibOVR/Src/Kernel/OVR_Alg.h
index 783af21..e03cea0 100644
--- a/LibOVR/Src/Kernel/OVR_Alg.h
+++ b/LibOVR/Src/Kernel/OVR_Alg.h
@@ -446,10 +446,10 @@ typename Array::ValueType& Median(Array& arr)
UPInt mid = (count - 1) / 2;
OVR_ASSERT(count > 0);
- for (int j = 0; j <= mid; j++)
+ for (UPInt j = 0; j <= mid; j++)
{
- int min = j;
- for (int k = j + 1; k < count; k++)
+ UPInt min = j;
+ for (UPInt k = j + 1; k < count; k++)
if (arr[k] < arr[min])
min = k;
Swap(arr[j], arr[min]);
@@ -842,12 +842,12 @@ namespace ByteUtil {
inline UInt64 SwapOrder(UInt64 v)
{
return (v>>56) |
- ((v&UInt64(0x00FF000000000000))>>40) |
- ((v&UInt64(0x0000FF0000000000))>>24) |
- ((v&UInt64(0x000000FF00000000))>>8) |
- ((v&UInt64(0x00000000FF000000))<<8) |
- ((v&UInt64(0x0000000000FF0000))<<24) |
- ((v&UInt64(0x000000000000FF00))<<40) |
+ ((v&UInt64(0x00FF000000000000ULL))>>40) |
+ ((v&UInt64(0x0000FF0000000000ULL))>>24) |
+ ((v&UInt64(0x000000FF00000000ULL))>>8) |
+ ((v&UInt64(0x00000000FF000000ULL))<<8) |
+ ((v&UInt64(0x0000000000FF0000ULL))<<24) |
+ ((v&UInt64(0x000000000000FF00ULL))<<40) |
(v<<56);
}
inline SInt64 SwapOrder(SInt64 v) { return (SInt64)SwapOrder(UInt64(v)); }
diff --git a/LibOVR/Src/Kernel/OVR_Deque.h b/LibOVR/Src/Kernel/OVR_Deque.h
index 747810e..ca242ad 100644
--- a/LibOVR/Src/Kernel/OVR_Deque.h
+++ b/LibOVR/Src/Kernel/OVR_Deque.h
@@ -39,7 +39,6 @@ public:
};
Deque(int capacity = DefaultCapacity);
- Deque(const Deque<Elem> &OtherDeque);
virtual ~Deque(void);
virtual void PushBack (const Elem &Item); // Adds Item to the end
@@ -67,6 +66,7 @@ protected:
private:
Deque& operator= (const Deque& q) { }; // forbidden
+ Deque(const Deque<Elem> &OtherDeque) { };
};
template <class Elem>
@@ -76,19 +76,19 @@ public:
InPlaceMutableDeque( int capacity = Deque<Elem>::DefaultCapacity ) : Deque<Elem>( capacity ) {}
virtual ~InPlaceMutableDeque() {};
+ using Deque<Elem>::PeekBack;
+ using Deque<Elem>::PeekFront;
virtual Elem& PeekBack (int count = 0); // Returns count-th Item from the end
virtual Elem& PeekFront (int count = 0); // Returns count-th Item from the beginning
-private:
- InPlaceMutableDeque& operator=(const InPlaceMutableDeque& q) {};
};
// Same as Deque, but allows to write more elements than maximum capacity
// Old elements are lost as they are overwritten with the new ones
template <class Elem>
-class CircularBuffer : public Deque<Elem>
+class CircularBuffer : public InPlaceMutableDeque<Elem>
{
public:
- CircularBuffer(int MaxSize = Deque<Elem>::DefaultCapacity) : Deque<Elem>(MaxSize) { };
+ CircularBuffer(int MaxSize = Deque<Elem>::DefaultCapacity) : InPlaceMutableDeque<Elem>(MaxSize) { };
// The following methods are inline as a workaround for a VS bug causing erroneous C4505 warnings
// See: http://stackoverflow.com/questions/3051992/compiler-warning-at-c-template-base-class
@@ -107,20 +107,6 @@ Capacity( capacity ), Beginning(0), End(0), ElemCount(0)
ConstructArray<Elem>(Data, Capacity);
}
-// Deque Copy Constructor function
-template <class Elem>
-Deque<Elem>::Deque(const Deque &OtherDeque) :
-Capacity( OtherDeque.Capacity ) // Initialize the constant
-{
- Beginning = OtherDeque.Beginning;
- End = OtherDeque.End;
- ElemCount = OtherDeque.ElemCount;
-
- Data = (Elem*) OVR_ALLOC(Capacity * sizeof(Elem));
- for (int i = 0; i < Capacity; i++)
- Data[i] = OtherDeque.Data[i];
-}
-
// Deque Destructor function
template <class Elem>
Deque<Elem>::~Deque(void)
@@ -242,7 +228,7 @@ const Elem& Deque<Elem>::PeekBack(int count) const
template <class Elem>
Elem& InPlaceMutableDeque<Elem>::PeekFront(int count)
{
- // Error Check: Make sure we aren't reading from an empty Deque
+ // Error Check: Make sure we aren't reading from an empty Deque
OVR_ASSERT( Deque<Elem>::ElemCount > count );
int idx = Deque<Elem>::Beginning + count;
@@ -254,11 +240,11 @@ Elem& InPlaceMutableDeque<Elem>::PeekFront(int count)
template <class Elem>
Elem& InPlaceMutableDeque<Elem>::PeekBack(int count)
{
- // Error Check: Make sure we aren't reading from an empty Deque
+ // Error Check: Make sure we aren't reading from an empty Deque
OVR_ASSERT( Deque<Elem>::ElemCount > count );
int idx = Deque<Elem>::End - count - 1;
- if (idx < 0)
+ if (idx < 0)
idx += Deque<Elem>::Capacity;
return Deque<Elem>::Data[ idx ];
}
diff --git a/LibOVR/Src/Kernel/OVR_FileFILE.cpp b/LibOVR/Src/Kernel/OVR_FileFILE.cpp
index 4fe4cbe..8478086 100644
--- a/LibOVR/Src/Kernel/OVR_FileFILE.cpp
+++ b/LibOVR/Src/Kernel/OVR_FileFILE.cpp
@@ -89,7 +89,7 @@ public:
class SysErrorModeDisabler
{
public:
- SysErrorModeDisabler(const char* pfileName) { }
+ SysErrorModeDisabler(const char* pfileName) { OVR_UNUSED(pfileName); }
};
#endif // OVR_OS_WIN32
diff --git a/LibOVR/Src/Kernel/OVR_Math.h b/LibOVR/Src/Kernel/OVR_Math.h
index 9bd5bad..4aa42b0 100644
--- a/LibOVR/Src/Kernel/OVR_Math.h
+++ b/LibOVR/Src/Kernel/OVR_Math.h
@@ -125,7 +125,7 @@ template<class T> class Vector2;
template<class T> class Vector3;
template<class T> class Matrix3;
template<class T> class Matrix4;
-template<class T> class Pose;
+template<class T> class Transform;
template<class T> class PoseState;
// CompatibleTypes::Type is used to lookup a compatible C-version of a C++ class.
@@ -140,7 +140,7 @@ struct CompatibleTypes
// Specializations providing CompatibleTypes::Type value.
template<> struct CompatibleTypes<Quat<float> > { typedef ovrQuatf Type; };
template<> struct CompatibleTypes<Quat<double> > { typedef ovrQuatd Type; };
-template<> struct CompatibleTypes<Matrix3<double> > { typedef ovrMatrix3d Type; };
+template<> struct CompatibleTypes<Matrix3<double> > { typedef ovrMatrix3d Type; };
template<> struct CompatibleTypes<Matrix4<float> > { typedef ovrMatrix4f Type; };
template<> struct CompatibleTypes<Size<int> > { typedef ovrSizei Type; };
template<> struct CompatibleTypes<Size<float> > { typedef ovrSizef Type; };
@@ -150,11 +150,11 @@ template<> struct CompatibleTypes<Vector2<float> > { typedef ovrVector2f Type;
template<> struct CompatibleTypes<Vector3<float> > { typedef ovrVector3f Type; };
template<> struct CompatibleTypes<Vector3<double> > { typedef ovrVector3d Type; };
-template<> struct CompatibleTypes<Pose<float> > { typedef ovrPosef Type; };
-template<> struct CompatibleTypes<PoseState<float> >{ typedef ovrPoseStatef Type; };
+template<> struct CompatibleTypes<Transform<float> > { typedef ovrPosef Type; };
+template<> struct CompatibleTypes<PoseState<float> > { typedef ovrPoseStatef Type; };
-template<> struct CompatibleTypes<Pose<double> > { typedef ovrPosed Type; };
-template<> struct CompatibleTypes<PoseState<double> >{ typedef ovrPoseStated Type; };
+template<> struct CompatibleTypes<Transform<double> > { typedef ovrPosed Type; };
+template<> struct CompatibleTypes<PoseState<double> > { typedef ovrPoseStated Type; };
//------------------------------------------------------------------------------------//
// ***** Math
@@ -509,7 +509,7 @@ public:
T Length() const { return sqrt(LengthSq()); }
// Returns squared distance between two points represented by vectors.
- T DistanceSq(Vector3& b) const { return (*this - b).LengthSq(); }
+ T DistanceSq(Vector3 const& b) const { return (*this - b).LengthSq(); }
// Returns distance between two points represented by vectors.
T Distance(Vector3 const& b) const { return (*this - b).Length(); }
@@ -705,7 +705,7 @@ public:
// C-interop support.
Quat(const typename CompatibleTypes<Quat<T> >::Type& s) : x(s.x), y(s.y), z(s.z), w(s.w) { }
- operator const typename CompatibleTypes<Quat<T> >::Type () const
+ operator typename CompatibleTypes<Quat<T> >::Type () const
{
typename CompatibleTypes<Quat<T> >::Type result;
result.x = x;
@@ -1091,36 +1091,73 @@ typedef Quat<double> Quatd;
// Position and orientation combined.
template<class T>
-class Pose
+class Transform
{
public:
- typedef typename CompatibleTypes<Pose<T> >::Type CompatibleType;
+ typedef typename CompatibleTypes<Transform<T> >::Type CompatibleType;
- Pose() { }
- Pose(const Quat<T>& orientation, const Vector3<T>& pos)
- : Orientation(orientation), Position(pos) { }
- Pose(const Pose& s)
- : Orientation(s.Orientation), Position(s.Position) { }
- Pose(const CompatibleType& s)
- : Orientation(s.Orientation), Position(s.Position) { }
- explicit Pose(const Pose<typename Math<T>::OtherFloatType> &s)
- : Orientation(s.Orientation), Position(s.Position) { }
+ Transform() { }
+ Transform(const Quat<T>& orientation, const Vector3<T>& pos)
+ : Rotation(orientation), Translation(pos) { }
+ Transform(const Transform& s)
+ : Rotation(s.Rotation), Translation(s.Translation) { }
+ Transform(const CompatibleType& s)
+ : Rotation(s.Orientation), Translation(s.Position) { }
+ explicit Transform(const Transform<typename Math<T>::OtherFloatType> &s)
+ : Rotation(s.Rotation), Translation(s.Translation) { }
- operator const typename CompatibleTypes<Pose<T> >::Type () const
+ operator typename CompatibleTypes<Transform<T> >::Type () const
{
- typename CompatibleTypes<Pose<T> >::Type result;
- result.Orientation = Orientation;
- result.Position = Position;
+ typename CompatibleTypes<Transform<T> >::Type result;
+ result.Orientation = Rotation;
+ result.Position = Translation;
return result;
}
- Quat<T> Orientation;
- Vector3<T> Position;
+ Quat<T> Rotation;
+ Vector3<T> Translation;
+
+ Vector3<T> Rotate(const Vector3<T>& v) const
+ {
+ return Rotation.Rotate(v);
+ }
+
+ Vector3<T> Translate(const Vector3<T>& v) const
+ {
+ return v + Translation;
+ }
+
+ Vector3<T> Apply(const Vector3<T>& v) const
+ {
+ return Translate(Rotate(v));
+ }
+
+ Transform operator*(const Transform& other) const
+ {
+ return Transform(Rotation * other.Rotation, Apply(other.Translation));
+ }
+
+ PoseState<T> operator*(const PoseState<T>& poseState) const
+ {
+ PoseState<T> result;
+ result.Pose = (*this) * poseState.Pose;
+ result.LinearVelocity = this->Rotate(poseState.LinearVelocity);
+ result.LinearAcceleration = this->Rotate(poseState.LinearAcceleration);
+ result.AngularVelocity = this->Rotate(poseState.AngularVelocity);
+ result.AngularAcceleration = this->Rotate(poseState.AngularAcceleration);
+ return result;
+ }
+
+ Transform Inverted() const
+ {
+ Quat<T> inv = Rotation.Inverted();
+ return Transform(inv, inv.Rotate(-Translation));
+ }
};
-typedef Pose<float> Posef;
-typedef Pose<double> Posed;
+typedef Transform<float> Transformf;
+typedef Transform<double> Transformd;
//-------------------------------------------------------------------------------------
@@ -1204,10 +1241,10 @@ public:
M[3][0] = 0; M[3][1] = 0; M[3][2] = 0; M[3][3] = 1;
}
- explicit Matrix4(const Pose<T>& p)
+ explicit Matrix4(const Transform<T>& p)
{
- Matrix4 result(p.Orientation);
- result.SetTranslation(p.Position);
+ Matrix4 result(p.Rotation);
+ result.SetTranslation(p.Translation);
*this = result;
}
@@ -1226,7 +1263,7 @@ public:
memcpy(M, s.M, sizeof(M));
}
- operator const typename CompatibleTypes<Matrix4<T> >::Type () const
+ operator typename CompatibleTypes<Matrix4<T> >::Type () const
{
typename CompatibleTypes<Matrix4<T> >::Type result;
OVR_COMPILER_ASSERT(sizeof(result) == sizeof(Matrix4));
@@ -1879,10 +1916,10 @@ public:
M[0][1] = M[0][2] = M[1][0] = M[1][2] = M[2][0] = M[2][1] = 0;
}
- explicit Matrix3(const Pose<T>& p)
+ explicit Matrix3(const Transform<T>& p)
{
- Matrix3 result(p.Orientation);
- result.SetTranslation(p.Position);
+ Matrix3 result(p.Rotation);
+ result.SetTranslation(p.Translation);
*this = result;
}
@@ -1901,7 +1938,7 @@ public:
memcpy(M, s.M, sizeof(M));
}
- operator const typename CompatibleTypes<Matrix3<T> >::Type () const
+ operator typename CompatibleTypes<Matrix3<T> >::Type () const
{
typename CompatibleTypes<Matrix3<T> >::Type result;
OVR_COMPILER_ASSERT(sizeof(result) == sizeof(Matrix3));
diff --git a/LibOVR/Src/Kernel/OVR_String.cpp b/LibOVR/Src/Kernel/OVR_String.cpp
index 86aa126..75b7c0e 100644
--- a/LibOVR/Src/Kernel/OVR_String.cpp
+++ b/LibOVR/Src/Kernel/OVR_String.cpp
@@ -569,7 +569,7 @@ StringBuffer::StringBuffer(UPInt growSize)
StringBuffer::StringBuffer(const char* data)
: pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
{
- *this = data;
+ AppendString(data);
}
StringBuffer::StringBuffer(const char* data, UPInt dataSize)
@@ -585,10 +585,9 @@ StringBuffer::StringBuffer(const String& src)
}
StringBuffer::StringBuffer(const StringBuffer& src)
- : pData(NULL), Size(0), BufferSize(src.GetGrowSize()), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
+ : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
{
AppendString(src.ToCStr(), src.GetSize());
- LengthIsSize = src.LengthIsSize;
}
StringBuffer::StringBuffer(const wchar_t* data)
@@ -728,6 +727,12 @@ void StringBuffer::operator = (const String& src)
memcpy(pData, src.ToCStr(), src.GetSize());
}
+void StringBuffer::operator = (const StringBuffer& src)
+{
+ Clear();
+ AppendString(src.ToCStr(), src.GetSize());
+}
+
// Inserts substr at posAt
void StringBuffer::Insert(const char* substr, UPInt posAt, SPInt len)
diff --git a/LibOVR/Src/Kernel/OVR_String.h b/LibOVR/Src/Kernel/OVR_String.h
index f7151c7..0866968 100644
--- a/LibOVR/Src/Kernel/OVR_String.h
+++ b/LibOVR/Src/Kernel/OVR_String.h
@@ -474,6 +474,7 @@ public:
void operator = (const char* str);
void operator = (const wchar_t* str);
void operator = (const String& src);
+ void operator = (const StringBuffer& src);
// Addition
void operator += (const String& src) { AppendString(src.ToCStr(),src.GetSize()); }
diff --git a/LibOVR/Src/Kernel/OVR_SysFile.cpp b/LibOVR/Src/Kernel/OVR_SysFile.cpp
index f487492..604527a 100644
--- a/LibOVR/Src/Kernel/OVR_SysFile.cpp
+++ b/LibOVR/Src/Kernel/OVR_SysFile.cpp
@@ -31,6 +31,7 @@ limitations under the License.
#include <stdio.h>
#include "OVR_SysFile.h"
+#include "OVR_Log.h"
namespace OVR {
@@ -100,6 +101,7 @@ bool SysFile::Open(const String& path, int flags, int mode)
if ((!pFile) || (!pFile->IsValid()))
{
pFile = *new UnopenedFile;
+ OVR_DEBUG_LOG(("Failed to open file: %s", path.ToCStr()));
return 0;
}
//pFile = *OVR_NEW DelegatedFile(pFile); // MA Testing
diff --git a/LibOVR/Src/Kernel/OVR_SysFile.h b/LibOVR/Src/Kernel/OVR_SysFile.h
index d492377..61ad6e8 100644
--- a/LibOVR/Src/Kernel/OVR_SysFile.h
+++ b/LibOVR/Src/Kernel/OVR_SysFile.h
@@ -86,7 +86,7 @@ public:
OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite)
{ return Open(path, Open_ReadWrite|Open_Create, mode); }
- // Helper function: obtain file statistics information. In GFx, this is used to detect file changes.
+ // Helper function: obtain file statistics information. In OVR, this is used to detect file changes.
// Return 0 if function failed, most likely because the file doesn't exist.
static bool OVR_CDECL GetFileStat(FileStat* pfileStats, const String& path);
diff --git a/LibOVR/Src/Kernel/OVR_Threads.h b/LibOVR/Src/Kernel/OVR_Threads.h
index e1f5abe..307f107 100644
--- a/LibOVR/Src/Kernel/OVR_Threads.h
+++ b/LibOVR/Src/Kernel/OVR_Threads.h
@@ -392,7 +392,7 @@ protected:
void Init(const CreateParams& params);
// Protected copy constructor
- Thread(const Thread &source) { OVR_UNUSED(source); }
+ Thread(const Thread &source) : RefCountBase<Thread>() { OVR_UNUSED(source); }
};
diff --git a/LibOVR/Src/Kernel/OVR_Types.h b/LibOVR/Src/Kernel/OVR_Types.h
index f45df59..8f2b3f3 100644
--- a/LibOVR/Src/Kernel/OVR_Types.h
+++ b/LibOVR/Src/Kernel/OVR_Types.h
@@ -262,7 +262,7 @@ typedef uint64_t UInt64;
// BaseTypes namespace is explicitly declared to allow base types to be used
// by customers directly without other contents of OVR namespace.
//
-// Its is expected that GFx samples will declare 'using namespace OVR::BaseTypes'
+// Its is expected that OVR samples will declare 'using namespace OVR::BaseTypes'
// to allow using these directly without polluting the target scope with other
// OVR declarations, such as Ptr<>, String or Mutex.
namespace BaseTypes