Panagiotis Christopoulos Charitos преди 14 години
родител
ревизия
a9fc2371e0
променени са 2 файла, в които са добавени 14 реда и са изтрити 6 реда
  1. 11 5
      anki/collision/Frustum.cpp
  2. 3 1
      anki/collision/Frustum.h

+ 11 - 5
anki/collision/Frustum.cpp

@@ -9,7 +9,13 @@ namespace anki {
 //==============================================================================
 Frustum& Frustum::operator=(const Frustum& b)
 {
-	memcpy(this, &b, sizeof(Frustum));
+	type = b.type;
+	planes = b.planes;
+
+	eye = b.eye;
+	dirs = b.dirs;
+
+	obb = b.obb;
 	return *this;
 }
 
@@ -25,9 +31,9 @@ float Frustum::testPlane(const Plane& p) const
 	{
 		float o = 0.0;
 
-		for(uint i = 0; i < dirs.size(); i++)
+		BOOST_FOREACH(const Vec3& dir, dirs)
 		{
-			LineSegment ls(eye, dirs[i]);
+			LineSegment ls(eye, dir);
 			float t = ls.testPlane(p);
 
 			if(t == 0)
@@ -97,9 +103,9 @@ void Frustum::setPerspective(float fovX, float fovY,
 	dirs[3] = Vec3(x, -y, z - zNear); // bottom right
 
 	eye.transform(trf);
-	for(uint i = 0; i < 4; i++)
+	BOOST_FOREACH(Vec3& dir, dirs)
 	{
-		dirs[i] = trf.getRotation() * dirs[i];
+		dir = trf.getRotation() * dir;
 	}
 }
 

+ 3 - 1
anki/collision/Frustum.h

@@ -110,17 +110,19 @@ public:
 private:
 	FrustumType type;
 
-	boost::array<Plane, 6> planes;
+	boost::array<Plane, FP_COUNT> planes;
 
 	/// @name Including shape for perspective cameras
 	/// @{
 	Vec3 eye; ///< The eye point
 	boost::array<Vec3, 4> dirs; ///< Directions
+	float fovX, fovY, zNear, zFar;
 	/// @}
 
 	/// @name Including shape for orthographic cameras
 	/// @{
 	Obb obb;
+	float left, right, near, far, top, bottom;
 	/// @}
 };
 /// @}