浏览代码

Removed use of STL from the Math library, except for AreaAllocator.

Lasse Öörni 14 年之前
父节点
当前提交
7aecd79aab

+ 2 - 0
Engine/Math/AreaAllocator.h

@@ -25,6 +25,8 @@
 
 
 #include "Rect.h"
 #include "Rect.h"
 
 
+#include <vector>
+
 /// Rectangle allocator, used for font glyph packing
 /// Rectangle allocator, used for font glyph packing
 class AreaAllocator
 class AreaAllocator
 {
 {

+ 3 - 16
Engine/Math/BoundingBox.cpp

@@ -24,13 +24,6 @@
 #include "Precompiled.h"
 #include "Precompiled.h"
 #include "Frustum.h"
 #include "Frustum.h"
 
 
-void BoundingBox::Define(const std::vector<Vector3>& vertices)
-{
-    defined_ = false;
-    for (std::vector<Vector3>::const_iterator i = vertices.begin(); i != vertices.end(); ++i)
-        Merge(*i);
-}
-
 void BoundingBox::Define(const Vector3* vertices, unsigned count)
 void BoundingBox::Define(const Vector3* vertices, unsigned count)
 {
 {
     if (!count)
     if (!count)
@@ -55,12 +48,6 @@ void BoundingBox::Define(const Sphere& sphere)
     defined_ = true;
     defined_ = true;
 }
 }
 
 
-void BoundingBox::Merge(const std::vector<Vector3>& vertices)
-{
-    for (std::vector<Vector3>::const_iterator i = vertices.begin(); i != vertices.end(); ++i)
-        Merge(*i);
-}
-
 void BoundingBox::Merge(const Vector3* vertices, unsigned count)
 void BoundingBox::Merge(const Vector3* vertices, unsigned count)
 {
 {
     while (count--)
     while (count--)
@@ -100,11 +87,11 @@ void BoundingBox::Intersect(const BoundingBox& box)
         max_.z_ = box.max_.z_;
         max_.z_ = box.max_.z_;
     
     
     if (min_.x_ > max_.x_)
     if (min_.x_ > max_.x_)
-        std::swap(min_.x_, max_.x_);
+        Swap(min_.x_, max_.x_);
     if (min_.y_ > max_.y_)
     if (min_.y_ > max_.y_)
-        std::swap(min_.y_, max_.y_);
+        Swap(min_.y_, max_.y_);
     if (min_.z_ > max_.z_)
     if (min_.z_ > max_.z_)
-        std::swap(min_.z_, max_.z_);
+        Swap(min_.z_, max_.z_);
 }
 }
 
 
 void BoundingBox::Transform(const Matrix3& transform)
 void BoundingBox::Transform(const Matrix3& transform)

+ 0 - 6
Engine/Math/BoundingBox.h

@@ -26,8 +26,6 @@
 #include "Rect.h"
 #include "Rect.h"
 #include "Vector3.h"
 #include "Vector3.h"
 
 
-#include <vector>
-
 class Frustum;
 class Frustum;
 class Matrix3;
 class Matrix3;
 class Matrix4;
 class Matrix4;
@@ -171,16 +169,12 @@ public:
         if (box.max_.z_ > max_.z_) max_.z_ = box.max_.z_;
         if (box.max_.z_ > max_.z_) max_.z_ = box.max_.z_;
     }
     }
     
     
-    /// Define from a vector of vertices
-    void Define(const std::vector<Vector3>& vertices);
     /// Define from an array of vertices
     /// Define from an array of vertices
     void Define(const Vector3* vertices, unsigned count);
     void Define(const Vector3* vertices, unsigned count);
     /// Define from a frustum
     /// Define from a frustum
     void Define(const Frustum& frustum);
     void Define(const Frustum& frustum);
     /// Define from a sphere
     /// Define from a sphere
     void Define(const Sphere& sphere);
     void Define(const Sphere& sphere);
-    /// Merge a vector of vertices
-    void Merge(const std::vector<Vector3>& vertices);
     /// Merge an array of vertices
     /// Merge an array of vertices
     void Merge(const Vector3* vertices, unsigned count);
     void Merge(const Vector3* vertices, unsigned count);
     /// Merge a frustum
     /// Merge a frustum

+ 8 - 0
Engine/Math/MathDefs.h

@@ -125,6 +125,14 @@ inline int Clamp(int value, int min, int max)
     return value;
     return value;
 }
 }
 
 
+/// Swap two values
+template<class T> inline void Swap(T& first, T& second)
+{
+    T temp = first;
+    first = second;
+    second = temp;
+}
+
 /// Check whether an unsigned integer is a power of two
 /// Check whether an unsigned integer is a power of two
 inline bool IsPowerOfTwo(unsigned value)
 inline bool IsPowerOfTwo(unsigned value)
 {
 {

+ 0 - 2
Engine/Math/Precompiled.h

@@ -22,5 +22,3 @@
 //
 //
 
 
 #pragma once
 #pragma once
-
-#include <vector>

+ 0 - 13
Engine/Math/Sphere.cpp

@@ -24,13 +24,6 @@
 #include "Precompiled.h"
 #include "Precompiled.h"
 #include "Frustum.h"
 #include "Frustum.h"
 
 
-void Sphere::Define(const std::vector<Vector3>& vertices)
-{
-    defined_ = false;
-    for (std::vector<Vector3>::const_iterator i = vertices.begin(); i != vertices.end(); ++i)
-        Merge(*i);
-}
-
 void Sphere::Define(const Vector3* vertices, unsigned count)
 void Sphere::Define(const Vector3* vertices, unsigned count)
 {
 {
     if (!count)
     if (!count)
@@ -61,12 +54,6 @@ void Sphere::Define(const Frustum& frustum)
     Define(frustum.GetVertices(), NUM_FRUSTUM_VERTICES);
     Define(frustum.GetVertices(), NUM_FRUSTUM_VERTICES);
 }
 }
 
 
-void Sphere::Merge(const std::vector<Vector3>& vertices)
-{
-    for (std::vector<Vector3>::const_iterator i = vertices.begin(); i != vertices.end(); ++i)
-        Merge(*i);
-}
-
 void Sphere::Merge(const Vector3* vertices, unsigned count)
 void Sphere::Merge(const Vector3* vertices, unsigned count)
 {
 {
     while (count--)
     while (count--)

+ 0 - 4
Engine/Math/Sphere.h

@@ -79,8 +79,6 @@ public:
         defined_ = true;
         defined_ = true;
     }
     }
     
     
-    /// Define from a vector of vertices
-    void Define(const std::vector<Vector3>& vertices);
     /// Define from an array of vertices
     /// Define from an array of vertices
     void Define(const Vector3* vertices, unsigned count);
     void Define(const Vector3* vertices, unsigned count);
     /// Define from a boundingBox
     /// Define from a boundingBox
@@ -109,8 +107,6 @@ public:
         }
         }
     }
     }
     
     
-    /// Merge a vector of vertices
-    void Merge(const std::vector<Vector3>& vertices);
     /// Merge an array of vertices
     /// Merge an array of vertices
     void Merge(const Vector3* vertices, unsigned count);
     void Merge(const Vector3* vertices, unsigned count);
     /// Merge a bounding box
     /// Merge a bounding box