Browse Source

Coding style changes

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
5afc523c2e

+ 73 - 77
anki/collision/Aabb.h

@@ -14,93 +14,89 @@ namespace anki {
 /// Axis align bounding box collision shape
 class Aabb: public CollisionShape
 {
-	public:
-		/// @name Constructors
-		/// @{
-		Aabb()
-		:	CollisionShape(CST_AABB)
-		{}
-
-		Aabb(const Vec3& min_, const Vec3& max_)
-		:	CollisionShape(CST_AABB),
-			min(min_),
-			max(max_)
-		{
-			ANKI_ASSERT(min < max);
-		}
+public:
+	/// @name Constructors
+	/// @{
+	Aabb()
+		: CollisionShape(CST_AABB)
+	{}
+
+	Aabb(const Vec3& min_, const Vec3& max_)
+		: CollisionShape(CST_AABB), min(min_), max(max_)
+	{
+		ANKI_ASSERT(min < max);
+	}
 
-		Aabb(const Aabb& b)
-		:	CollisionShape(CST_AABB),
-		 	min(b.min),
-		 	max(b.max)
-		{}
-		/// @}
+	Aabb(const Aabb& b)
+		: CollisionShape(CST_AABB), min(b.min), max(b.max)
+	{}
+	/// @}
 
-		/// @name Accessors
-		/// @{
-		const Vec3& getMin() const
-		{
-			return min;
-		}
-		Vec3& getMin()
-		{
-			return min;
-		}
-		void setMin(const Vec3& x)
-		{
-			min = x;
-		}
+	/// @name Accessors
+	/// @{
+	const Vec3& getMin() const
+	{
+		return min;
+	}
+	Vec3& getMin()
+	{
+		return min;
+	}
+	void setMin(const Vec3& x)
+	{
+		min = x;
+	}
 
-		const Vec3& getMax() const
-		{
-			return max;
-		}
-		Vec3& getMax()
-		{
-			return max;
-		}
-		void setMax(const Vec3& x)
-		{
-			max = x;
-		}
-		/// @}
+	const Vec3& getMax() const
+	{
+		return max;
+	}
+	Vec3& getMax()
+	{
+		return max;
+	}
+	void setMax(const Vec3& x)
+	{
+		max = x;
+	}
+	/// @}
 
-		/// Implements CollisionShape::accept
-		void accept(MutableVisitor& v)
-		{
-			v.visit(*this);
-		}
-		/// Implements CollisionShape::accept
-		void accept(ConstVisitor& v) const
-		{
-			v.visit(*this);
-		}
+	/// Implements CollisionShape::accept
+	void accept(MutableVisitor& v)
+	{
+		v.visit(*this);
+	}
+	/// Implements CollisionShape::accept
+	void accept(ConstVisitor& v) const
+	{
+		v.visit(*this);
+	}
 
-		/// Implements CollisionShape::testPlane
-		float testPlane(const Plane& p) const;
+	/// Implements CollisionShape::testPlane
+	float testPlane(const Plane& p) const;
 
-		/// Implements CollisionShape::transform
-		void transform(const Transform& trf)
-		{
-			*this = getTransformed(trf);
-		}
+	/// Implements CollisionShape::transform
+	void transform(const Transform& trf)
+	{
+		*this = getTransformed(trf);
+	}
 
-		Aabb getTransformed(const Transform& transform) const;
+	Aabb getTransformed(const Transform& transform) const;
 
-		/// Get a collision shape that includes this and the given. Its not
-		/// very accurate
-		Aabb getCompoundShape(const Aabb& b) const;
+	/// Get a collision shape that includes this and the given. Its not
+	/// very accurate
+	Aabb getCompoundShape(const Aabb& b) const;
 
-		/// Calculate from a set of points
-		template<typename Container>
-		void set(const Container& container);
+	/// Calculate from a set of points
+	template<typename Container>
+	void set(const Container& container);
 
-	private:
-		/// @name Data
-		/// @{
-		Vec3 min;
-		Vec3 max;
-		/// @}
+private:
+	/// @name Data
+	/// @{
+	Vec3 min;
+	Vec3 max;
+	/// @}
 };
 /// @}
 

+ 137 - 137
anki/collision/CollisionAlgorithmsMatrix.h

@@ -34,143 +34,143 @@ namespace anki {
 /// @endcode
 class CollisionAlgorithmsMatrix
 {
-	public:
-		typedef PerspectiveCameraShape Pcs;
-		typedef LineSegment Ls;
-
-		/// Generic collide function. It doesn't uses visitor pattern for
-		/// speed reasons
-		static bool collide(const CollisionShape& a, const CollisionShape& b);
-
-		// 1st line (LS)
-		static bool collide(const Ls& a, const Ls& b);
-		static bool collide(const Ls& a, const Obb& b);
-		static bool collide(const Ls& a, const Pcs& b);
-		static bool collide(const Ls& a, const Plane& b);
-		static bool collide(const Ls& a, const Ray& b);
-		static bool collide(const Ls& a, const Sphere& b);
-		static bool collide(const Ls& a, const Aabb& b);
-
-		// 2nd line (OBB)
-		static bool collide(const Obb& a, const Ls& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Obb& a, const Obb& b);
-		static bool collide(const Obb& a, const Pcs& b);
-		static bool collide(const Obb& a, const Plane& b);
-		static bool collide(const Obb& a, const Ray& b);
-		static bool collide(const Obb& a, const Sphere& b);
-		static bool collide(const Obb& a, const Aabb& b);
-
-		// 3rd line (PCS)
-		static bool collide(const Pcs& a, const Ls& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Pcs& a, const Obb& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Pcs& a, const Pcs& b);
-		static bool collide(const Pcs& a, const Plane& b);
-		static bool collide(const Pcs& a, const Ray& b);
-		static bool collide(const Pcs& a, const Sphere& b);
-		static bool collide(const Pcs& a, const Aabb& b);
-
-		// 4th line (P)
-		static bool collide(const Plane& a, const Ls& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Plane& a, const Obb& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Plane& a,const Pcs& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Plane& a, const Plane& b);
-		static bool collide(const Plane& a, const Ray& b);
-		static bool collide(const Plane& a, const Sphere& b);
-		static bool collide(const Plane& a, const Aabb& b);
-
-		// 5th line (R)
-		static bool collide(const Ray& a, const Ls& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Ray& a, const Obb& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Ray& a, const Pcs& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Ray& a, const Plane& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Ray& a, const Ray& b);
-		static bool collide(const Ray& a, const Sphere& b);
-		static bool collide(const Ray& a, const Aabb& b);
-
-		// 6th line (S)
-		static bool collide(const Sphere& a, const Ls& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Sphere& a, const Obb& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Sphere& a, const Pcs& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Sphere& a, const Plane& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Sphere& a, const Ray& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Sphere& a, const Sphere& b);
-		static bool collide(const Sphere& a, const Aabb& b);
-
-		// 7th line (AABB)
-		static bool collide(const Aabb& a, const Ls& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Aabb& a, const Obb& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Aabb& a, const Pcs& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Aabb& a, const Plane& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Aabb& a, const Ray& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Aabb& a, const Sphere& b)
-		{
-			return collide(b, a);
-		}
-		static bool collide(const Aabb& a, const Aabb& b);
-
-	private:
-		template<typename T>
-		static bool tcollide(const CollisionShape& a, const CollisionShape& b);
+public:
+	typedef PerspectiveCameraShape Pcs;
+	typedef LineSegment Ls;
+
+	/// Generic collide function. It doesn't uses visitor pattern for
+	/// speed reasons
+	static bool collide(const CollisionShape& a, const CollisionShape& b);
+
+	// 1st line (LS)
+	static bool collide(const Ls& a, const Ls& b);
+	static bool collide(const Ls& a, const Obb& b);
+	static bool collide(const Ls& a, const Pcs& b);
+	static bool collide(const Ls& a, const Plane& b);
+	static bool collide(const Ls& a, const Ray& b);
+	static bool collide(const Ls& a, const Sphere& b);
+	static bool collide(const Ls& a, const Aabb& b);
+
+	// 2nd line (OBB)
+	static bool collide(const Obb& a, const Ls& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Obb& a, const Obb& b);
+	static bool collide(const Obb& a, const Pcs& b);
+	static bool collide(const Obb& a, const Plane& b);
+	static bool collide(const Obb& a, const Ray& b);
+	static bool collide(const Obb& a, const Sphere& b);
+	static bool collide(const Obb& a, const Aabb& b);
+
+	// 3rd line (PCS)
+	static bool collide(const Pcs& a, const Ls& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Pcs& a, const Obb& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Pcs& a, const Pcs& b);
+	static bool collide(const Pcs& a, const Plane& b);
+	static bool collide(const Pcs& a, const Ray& b);
+	static bool collide(const Pcs& a, const Sphere& b);
+	static bool collide(const Pcs& a, const Aabb& b);
+
+	// 4th line (P)
+	static bool collide(const Plane& a, const Ls& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Plane& a, const Obb& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Plane& a,const Pcs& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Plane& a, const Plane& b);
+	static bool collide(const Plane& a, const Ray& b);
+	static bool collide(const Plane& a, const Sphere& b);
+	static bool collide(const Plane& a, const Aabb& b);
+
+	// 5th line (R)
+	static bool collide(const Ray& a, const Ls& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Ray& a, const Obb& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Ray& a, const Pcs& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Ray& a, const Plane& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Ray& a, const Ray& b);
+	static bool collide(const Ray& a, const Sphere& b);
+	static bool collide(const Ray& a, const Aabb& b);
+
+	// 6th line (S)
+	static bool collide(const Sphere& a, const Ls& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Sphere& a, const Obb& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Sphere& a, const Pcs& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Sphere& a, const Plane& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Sphere& a, const Ray& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Sphere& a, const Sphere& b);
+	static bool collide(const Sphere& a, const Aabb& b);
+
+	// 7th line (AABB)
+	static bool collide(const Aabb& a, const Ls& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Aabb& a, const Obb& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Aabb& a, const Pcs& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Aabb& a, const Plane& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Aabb& a, const Ray& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Aabb& a, const Sphere& b)
+	{
+		return collide(b, a);
+	}
+	static bool collide(const Aabb& a, const Aabb& b);
+
+private:
+	template<typename T>
+	static bool tcollide(const CollisionShape& a, const CollisionShape& b);
 };
 /// @}
 

+ 63 - 63
anki/collision/CollisionShape.h

@@ -14,70 +14,70 @@ namespace anki {
 /// Abstract class for collision shapes
 class CollisionShape
 {
+public:
+	/// Collision shape type
+	enum CollisionShapeType
+	{
+		CST_LINE_SEG,
+		CST_RAY,
+		CST_PLANE,
+		CST_SPHERE,
+		CST_AABB,
+		CST_OBB,
+		CST_PERSPECTIVE_CAMERA_FRUSTRUM
+	};
+
+	/// Generic mutable visitor
+	class MutableVisitor
+	{
 	public:
-		/// Collision shape type
-		enum CollisionShapeType
-		{
-			CST_LINE_SEG,
-			CST_RAY,
-			CST_PLANE,
-			CST_SPHERE,
-			CST_AABB,
-			CST_OBB,
-			CST_PERSPECTIVE_CAMERA_FRUSTRUM
-		};
-
-		/// Generic mutable visitor
-		class MutableVisitor
-		{
-			public:
-				virtual void visit(LineSegment&) = 0;
-				virtual void visit(Obb&) = 0;
-				virtual void visit(PerspectiveCameraShape&) = 0;
-				virtual void visit(Plane&) = 0;
-				virtual void visit(Ray&) = 0;
-				virtual void visit(Sphere&) = 0;
-				virtual void visit(Aabb&) = 0;
-		};
-
-		/// Generic const visitor
-		class ConstVisitor
-		{
-			public:
-				virtual void visit(const LineSegment&) = 0;
-				virtual void visit(const Obb&) = 0;
-				virtual void visit(const PerspectiveCameraShape&) = 0;
-				virtual void visit(const Plane&) = 0;
-				virtual void visit(const Ray&) = 0;
-				virtual void visit(const Sphere&) = 0;
-				virtual void visit(const Aabb&) = 0;
-		};
-
-		CollisionShape(CollisionShapeType cid_)
-		:	cid(cid_)
-		{}
-
-		CollisionShapeType getCollisionShapeType() const
-		{
-			return cid;
-		}
-
-		/// Visitor accept
-		virtual void accept(MutableVisitor& v) = 0;
-		/// Visitor accept
-		virtual void accept(ConstVisitor& v) const = 0;
-
-		/// If the collision shape intersects with the plane then the method
-		/// returns 0.0, else it returns the distance. If the distance is < 0.0
-		/// then the collision shape lies behind the plane and if > 0.0 then
-		/// in front of it
-		virtual float testPlane(const Plane& p) const = 0;
-
-		/// Transform
-		virtual void transform(const Transform& trf) = 0;
-
-	private:
-		CollisionShapeType cid;
+		virtual void visit(LineSegment&) = 0;
+		virtual void visit(Obb&) = 0;
+		virtual void visit(PerspectiveCameraShape&) = 0;
+		virtual void visit(Plane&) = 0;
+		virtual void visit(Ray&) = 0;
+		virtual void visit(Sphere&) = 0;
+		virtual void visit(Aabb&) = 0;
+	};
+
+	/// Generic const visitor
+	class ConstVisitor
+	{
+	public:
+		virtual void visit(const LineSegment&) = 0;
+		virtual void visit(const Obb&) = 0;
+		virtual void visit(const PerspectiveCameraShape&) = 0;
+		virtual void visit(const Plane&) = 0;
+		virtual void visit(const Ray&) = 0;
+		virtual void visit(const Sphere&) = 0;
+		virtual void visit(const Aabb&) = 0;
+	};
+
+	CollisionShape(CollisionShapeType cid_)
+		: cid(cid_)
+	{}
+
+	CollisionShapeType getCollisionShapeType() const
+	{
+		return cid;
+	}
+
+	/// Visitor accept
+	virtual void accept(MutableVisitor& v) = 0;
+	/// Visitor accept
+	virtual void accept(ConstVisitor& v) const = 0;
+
+	/// If the collision shape intersects with the plane then the method
+	/// returns 0.0, else it returns the distance. If the distance is < 0.0
+	/// then the collision shape lies behind the plane and if > 0.0 then
+	/// in front of it
+	virtual float testPlane(const Plane& p) const = 0;
+
+	/// Transform
+	virtual void transform(const Transform& trf) = 0;
+
+private:
+	CollisionShapeType cid;
 };
 /// @}
 

+ 73 - 77
anki/collision/LineSegment.h

@@ -15,83 +15,79 @@ namespace anki {
 /// P1 = direction + origin
 class LineSegment: public CollisionShape
 {
-	public:
-		/// @name Constructors
-		/// @{
-		LineSegment()
-		:	CollisionShape(CST_LINE_SEG)
-		{}
-
-		LineSegment(const Vec3& origin_, const Vec3& direction)
-		:	CollisionShape(CST_LINE_SEG),
-			origin(origin_),
-			dir(direction)
-		{}
-
-		LineSegment(const LineSegment& b)
-		:	CollisionShape(CST_LINE_SEG),
-			origin(b.origin),
-			dir(b.dir)
-		{}
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		const Vec3& getOrigin() const
-		{
-			return origin;
-		}
-		Vec3& getOrigin()
-		{
-			return origin;
-		}
-		void setOrigin(const Vec3& x)
-		{
-			origin = x;
-		}
-
-		const Vec3& getDirection() const
-		{
-			return dir;
-		}
-		Vec3& getDirection()
-		{
-			return dir;
-		}
-		void setDirection(const Vec3& x)
-		{
-			dir = x;
-		}
-		/// @}
-
-		/// Implements CollisionShape::accept
-		void accept(MutableVisitor& v)
-		{
-			v.visit(*this);
-		}
-		/// Implements CollisionShape::accept
-		void accept(ConstVisitor& v) const
-		{
-			v.visit(*this);
-		}
-
-		/// Implements CollisionShape::testPlane
-		float testPlane(const Plane& p) const;
-
-		/// Implements CollisionShape::transform
-		void transform(const Transform& trf)
-		{
-			*this = getTransformed(trf);
-		}
-
-		LineSegment getTransformed(const Transform& transform) const;
-
-	private:
-		/// @name Data
-		/// @{
-		Vec3 origin; ///< P0
-		Vec3 dir; ///< P1 = origin+dir so dir = P1-origin
-		/// @}
+public:
+	/// @name Constructors
+	/// @{
+	LineSegment()
+		: CollisionShape(CST_LINE_SEG)
+	{}
+
+	LineSegment(const Vec3& origin_, const Vec3& direction)
+		: CollisionShape(CST_LINE_SEG), origin(origin_), dir(direction)
+	{}
+
+	LineSegment(const LineSegment& b)
+		: CollisionShape(CST_LINE_SEG), origin(b.origin), dir(b.dir)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	const Vec3& getOrigin() const
+	{
+		return origin;
+	}
+	Vec3& getOrigin()
+	{
+		return origin;
+	}
+	void setOrigin(const Vec3& x)
+	{
+		origin = x;
+	}
+
+	const Vec3& getDirection() const
+	{
+		return dir;
+	}
+	Vec3& getDirection()
+	{
+		return dir;
+	}
+	void setDirection(const Vec3& x)
+	{
+		dir = x;
+	}
+	/// @}
+
+	/// Implements CollisionShape::accept
+	void accept(MutableVisitor& v)
+	{
+		v.visit(*this);
+	}
+	/// Implements CollisionShape::accept
+	void accept(ConstVisitor& v) const
+	{
+		v.visit(*this);
+	}
+
+	/// Implements CollisionShape::testPlane
+	float testPlane(const Plane& p) const;
+
+	/// Implements CollisionShape::transform
+	void transform(const Transform& trf)
+	{
+		*this = getTransformed(trf);
+	}
+
+	LineSegment getTransformed(const Transform& transform) const;
+
+private:
+	/// @name Data
+	/// @{
+	Vec3 origin; ///< P0
+	Vec3 dir; ///< P1 = origin+dir so dir = P1-origin
+	/// @}
 };
 /// @}
 

+ 3 - 2
anki/collision/Obb.cpp

@@ -122,9 +122,10 @@ void Obb::getExtremePoints(boost::array<Vec3, 8>& points) const
 	points[RTB] = 2.0 * points[LTF].dot(yAxis) * yAxis - points[LTF];
 	points[RBF] = 2.0 * points[LTF].dot(zAxis) * zAxis - points[LTF];
 
-	BOOST_FOREACH(Vec3& point, points)
+	boost::array<Vec3, 8>::iterator it = points.begin();
+	for(; it != points.end(); ++it)
 	{
-		point += center;
+		(*it) += center;
 	}
 }
 

+ 125 - 93
anki/collision/Obb.h

@@ -15,110 +15,142 @@ namespace anki {
 /// Object oriented bounding box
 class Obb: public CollisionShape
 {
-	public:
-		/// @name Constructors
-		/// @{
-		Obb()
-		:	CollisionShape(CST_OBB)
-		{}
-
-		Obb(const Obb& b);
-
-		Obb(const Vec3& center, const Mat3& rotation, const Vec3& extends);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		const Vec3& getCenter() const
-		{
-			return center;
-		}
-		Vec3& getCenter()
-		{
-			return center;
-		}
-		void setCenter(const Vec3& x)
-		{
-			center = x;
-		}
+public:
+	/// @name Constructors
+	/// @{
+	Obb()
+		: CollisionShape(CST_OBB)
+	{}
+
+	Obb(const Obb& b);
+
+	Obb(const Vec3& center, const Mat3& rotation, const Vec3& extends);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	const Vec3& getCenter() const
+	{
+		return center;
+	}
+	Vec3& getCenter()
+	{
+		return center;
+	}
+	void setCenter(const Vec3& x)
+	{
+		center = x;
+	}
+
+	const Mat3& getRotation() const
+	{
+		return rotation;
+	}
+	Mat3& getRotation()
+	{
+		return rotation;
+	}
+	void setRotation(const Mat3& x)
+	{
+		rotation = x;
+	}
+
+	const Vec3& getExtend() const
+	{
+		return extends;
+	}
+	Vec3& getExtend()
+	{
+		return extends;
+	}
+	void setExtend(const Vec3& x)
+	{
+		extends = x;
+	}
+	/// @}
+
+	/// Implements CollisionShape::accept
+	void accept(MutableVisitor& v)
+	{
+		v.visit(*this);
+	}
+	/// Implements CollisionShape::accept
+	void accept(ConstVisitor& v) const
+	{
+		v.visit(*this);
+	}
+
+	/// Implements CollisionShape::testPlane
+	float testPlane(const Plane& p) const;
+
+	/// Implements CollisionShape::transform
+	void transform(const Transform& trf)
+	{
+		*this = getTransformed(trf);
+	}
+
+	Obb getTransformed(const Transform& transform) const;
+
+	/// Get a collision shape that includes this and the given. Its not
+	/// very accurate
+	Obb getCompoundShape(const Obb& b) const;
+
+	/// Calculate from a set of points
+	template<typename Container>
+	void set(const Container& container);
+
+	/// Get extreme points in 3D space
+	void getExtremePoints(boost::array<Vec3, 8>& points) const;
+
+public:
+	/// @name Data
+	/// @{
+	Vec3 center;
+	Mat3 rotation;
+	/// With identity rotation this points to max (front, right, top in
+	/// our case)
+	Vec3 extends;
+	/// @}
+};
+/// @}
 
-		const Mat3& getRotation() const
-		{
-			return rotation;
-		}
-		Mat3& getRotation()
-		{
-			return rotation;
-		}
-		void setRotation(const Mat3& x)
-		{
-			rotation = x;
-		}
 
-		const Vec3& getExtend() const
-		{
-			return extends;
-		}
-		Vec3& getExtend()
-		{
-			return extends;
-		}
-		void setExtend(const Vec3& x)
-		{
-			extends = x;
-		}
-		/// @}
+//==============================================================================
+template<typename Container>
+void Obb::set(const Container& container)
+{
+	ANKI_ASSERT(container.size() >= 1);
 
-		/// Implements CollisionShape::accept
-		void accept(MutableVisitor& v)
-		{
-			v.visit(*this);
-		}
-		/// Implements CollisionShape::accept
-		void accept(ConstVisitor& v) const
-		{
-			v.visit(*this);
-		}
+	Vec3 min(container.front());
+	Vec3 max(container.front());
 
-		/// Implements CollisionShape::testPlane
-		float testPlane(const Plane& p) const;
+	// for all the Vec3s calc the max and min
+	typename Container::const_iterator it = container.begin() + 1;
+	for(; it != container.end(); ++it)
+	{
+		const Vec3& v = *it;
 
-		/// Implements CollisionShape::transform
-		void transform(const Transform& trf)
+		for(int j = 0; j < 3; j++)
 		{
-			*this = getTransformed(trf);
+			if(v[j] > max[j])
+			{
+				max[j] = v[j];
+			}
+			else if(v[j] < min[j])
+			{
+				min[j] = v[j];
+			}
 		}
+	}
 
-		Obb getTransformed(const Transform& transform) const;
-
-		/// Get a collision shape that includes this and the given. Its not
-		/// very accurate
-		Obb getCompoundShape(const Obb& b) const;
-
-		/// Calculate from a set of points
-		template<typename Container>
-		void set(const Container& container);
-
-		/// Get extreme points in 3D space
-		void getExtremePoints(boost::array<Vec3, 8>& points) const;
-
-	public:
-		/// @name Data
-		/// @{
-		Vec3 center;
-		Mat3 rotation;
-		/// With identity rotation this points to max (front, right, top in
-		/// our case)
-		Vec3 extends;
-		/// @}
-};
-/// @}
+	// set the locals
+	center = (max + min) / 2.0;
+	rotation = Mat3::getIdentity();
+	extends = max - center;
+}
 
 
 } // end namespace
 
 
-#include "anki/collision/Obb.inl.h"
-
-
 #endif

+ 0 - 41
anki/collision/Obb.inl.h

@@ -1,41 +0,0 @@
-#include <boost/foreach.hpp>
-#include <boost/range/iterator_range.hpp>
-
-
-namespace anki {
-
-
-//==============================================================================
-template<typename Container>
-void Obb::set(const Container& container)
-{
-	ANKI_ASSERT(container.size() >= 1);
-
-	Vec3 min(container.front());
-	Vec3 max(container.front());
-
-	// for all the Vec3s calc the max and min
-	BOOST_FOREACH(const Vec3& v,
-		boost::make_iterator_range(container.begin() + 1, container.end()))
-	{
-		for(int j = 0; j < 3; j++)
-		{
-			if(v[j] > max[j])
-			{
-				max[j] = v[j];
-			}
-			else if(v[j] < min[j])
-			{
-				min[j] = v[j];
-			}
-		}
-	}
-
-	// set the locals
-	center = (max + min) / 2.0;
-	rotation = Mat3::getIdentity();
-	extends = max - center;
-}
-
-
-} // end namespace

+ 55 - 55
anki/collision/PerspectiveCameraShape.h

@@ -14,61 +14,61 @@ namespace anki {
 /// Collision shape for the projection cameras
 class PerspectiveCameraShape: public CollisionShape
 {
-	public:
-		/// Default constructor
-		PerspectiveCameraShape()
-		:	CollisionShape(CST_PERSPECTIVE_CAMERA_FRUSTRUM)
-		{}
-
-		PerspectiveCameraShape(float fovX, float fovY, float zNear,
-			float zFar, const Transform& trf)
-		:	CollisionShape(CST_PERSPECTIVE_CAMERA_FRUSTRUM)
-		{
-			setAll(fovX, fovY, zNear, zFar, trf);
-		}
-
-		/// @name Accessors
-		/// @{
-		const Vec3& getEye() const
-		{
-			return eye;
-		}
-
-		const boost::array<Vec3, 4>& getDirections() const
-		{
-			return dirs;
-		}
-		/// @{
-
-		/// Implements CollisionShape::accept
-		void accept(MutableVisitor& v)
-		{
-			v.visit(*this);
-		}
-		/// Implements CollisionShape::accept
-		void accept(ConstVisitor& v) const
-		{
-			v.visit(*this);
-		}
-
-		/// Implements CollisionShape::testPlane
-		float testPlane(const Plane& p) const;
-
-		/// Implements CollisionShape::transform
-		void transform(const Transform& trf)
-		{
-			*this = getTransformed(trf);
-		}
-
-		PerspectiveCameraShape getTransformed(const Transform& trf) const;
-
-		/// Set all
-		void setAll(float fovX, float fovY, float zNear,
-			float zFar, const Transform& trf);
-
-	private:
-		Vec3 eye; ///< The eye point
-		boost::array<Vec3, 4> dirs; ///< Directions
+public:
+	/// Default constructor
+	PerspectiveCameraShape()
+		: CollisionShape(CST_PERSPECTIVE_CAMERA_FRUSTRUM)
+	{}
+
+	PerspectiveCameraShape(float fovX, float fovY, float zNear,
+		float zFar, const Transform& trf)
+		: CollisionShape(CST_PERSPECTIVE_CAMERA_FRUSTRUM)
+	{
+		setAll(fovX, fovY, zNear, zFar, trf);
+	}
+
+	/// @name Accessors
+	/// @{
+	const Vec3& getEye() const
+	{
+		return eye;
+	}
+
+	const boost::array<Vec3, 4>& getDirections() const
+	{
+		return dirs;
+	}
+	/// @{
+
+	/// Implements CollisionShape::accept
+	void accept(MutableVisitor& v)
+	{
+		v.visit(*this);
+	}
+	/// Implements CollisionShape::accept
+	void accept(ConstVisitor& v) const
+	{
+		v.visit(*this);
+	}
+
+	/// Implements CollisionShape::testPlane
+	float testPlane(const Plane& p) const;
+
+	/// Implements CollisionShape::transform
+	void transform(const Transform& trf)
+	{
+		*this = getTransformed(trf);
+	}
+
+	PerspectiveCameraShape getTransformed(const Transform& trf) const;
+
+	/// Set all
+	void setAll(float fovX, float fovY, float zNear,
+		float zFar, const Transform& trf);
+
+private:
+	Vec3 eye; ///< The eye point
+	boost::array<Vec3, 4> dirs; ///< Directions
 };
 ///@}
 

+ 122 - 122
anki/collision/Plane.h

@@ -14,128 +14,128 @@ namespace anki {
 /// Plane collision shape
 class Plane: public CollisionShape
 {
-	public:
-		/// @name Constructors
-		/// @{
-
-		/// Default constructor
-		Plane()
-		:	CollisionShape(CST_PLANE)
-		{}
-
-		/// Copy constructor
-		Plane(const Plane& b);
-
-		/// Constructor
-		Plane(const Vec3& normal_, float offset_);
-
-		/// @see setFrom3Points
-		Plane(const Vec3& p0, const Vec3& p1, const Vec3& p2)
-		:	CollisionShape(CST_PLANE)
-		{
-			setFrom3Points(p0, p1, p2);
-		}
-
-		/// @see setFromPlaneEquation
-		Plane(float a, float b, float c, float d)
-		:	CollisionShape(CST_PLANE)
-		{
-			setFromPlaneEquation(a, b, c, d);
-		}
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		const Vec3& getNormal() const
-		{
-			return normal;
-		}
-		Vec3& getNormal()
-		{
-			return normal;
-		}
-		void setNormal(const Vec3& x)
-		{
-			normal = x;
-		}
-
-		float getOffset() const
-		{
-			return offset;
-		}
-		float& getOffset()
-		{
-			return offset;
-		}
-		void setOffset(const float x)
-		{
-			offset = x;
-		}
-		/// @}
-
-		/// Implements CollisionShape::accept
-		void accept(MutableVisitor& v)
-		{
-			v.visit(*this);
-		}
-		/// Implements CollisionShape::accept
-		void accept(ConstVisitor& v) const
-		{
-			v.visit(*this);
-		}
-
-		/// Implements CollisionShape::testPlane
-		float testPlane(const Plane& p) const;
-
-		/// Implements CollisionShape::transform
-		void transform(const Transform& trf)
-		{
-			*this = getTransformed(trf);
-		}
-
-		/// Return the transformed
-		Plane getTransformed(const Transform& trf) const;
-
-		/// It gives the distance between a point and a plane. if returns >0
-		/// then the point lies in front of the plane, if <0 then it is behind
-		/// and if =0 then it is co-planar
-		float test(const Vec3& point) const
-		{
-			return normal.dot(point) - offset;
-		}
-
-		/// Get the distance from a point to this plane
-		float getDistance(const Vec3& point) const
-		{
-			return fabs(test(point));
-		}
-
-		/// Returns the perpedicular point of a given point in this plane.
-		/// Plane's normal and returned-point are perpedicular
-		Vec3 getClosestPoint(const Vec3& point) const
-		{
-			return point - normal * test(point);
-		}
-
-		/// Test a CollisionShape
-		template<typename T>
-		float testShape(const T& x) const
-		{
-			return x.testPlane(*this, x);
-		}
-
-	private:
-		/// @name Data
-		/// @{
-		Vec3 normal;
-		float offset;
-		/// @}
-
-		/// Set the plane from 3 points
-		void setFrom3Points(const Vec3& p0, const Vec3& p1, const Vec3& p2);
-
-		/// Set from plane equation is ax+by+cz+d
-		void setFromPlaneEquation(float a, float b, float c, float d);
+public:
+	/// @name Constructors
+	/// @{
+
+	/// Default constructor
+	Plane()
+		: CollisionShape(CST_PLANE)
+	{}
+
+	/// Copy constructor
+	Plane(const Plane& b);
+
+	/// Constructor
+	Plane(const Vec3& normal_, float offset_);
+
+	/// @see setFrom3Points
+	Plane(const Vec3& p0, const Vec3& p1, const Vec3& p2)
+		: CollisionShape(CST_PLANE)
+	{
+		setFrom3Points(p0, p1, p2);
+	}
+
+	/// @see setFromPlaneEquation
+	Plane(float a, float b, float c, float d)
+		: CollisionShape(CST_PLANE)
+	{
+		setFromPlaneEquation(a, b, c, d);
+	}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	const Vec3& getNormal() const
+	{
+		return normal;
+	}
+	Vec3& getNormal()
+	{
+		return normal;
+	}
+	void setNormal(const Vec3& x)
+	{
+		normal = x;
+	}
+
+	float getOffset() const
+	{
+		return offset;
+	}
+	float& getOffset()
+	{
+		return offset;
+	}
+	void setOffset(const float x)
+	{
+		offset = x;
+	}
+	/// @}
+
+	/// Implements CollisionShape::accept
+	void accept(MutableVisitor& v)
+	{
+		v.visit(*this);
+	}
+	/// Implements CollisionShape::accept
+	void accept(ConstVisitor& v) const
+	{
+		v.visit(*this);
+	}
+
+	/// Implements CollisionShape::testPlane
+	float testPlane(const Plane& p) const;
+
+	/// Implements CollisionShape::transform
+	void transform(const Transform& trf)
+	{
+		*this = getTransformed(trf);
+	}
+
+	/// Return the transformed
+	Plane getTransformed(const Transform& trf) const;
+
+	/// It gives the distance between a point and a plane. if returns >0
+	/// then the point lies in front of the plane, if <0 then it is behind
+	/// and if =0 then it is co-planar
+	float test(const Vec3& point) const
+	{
+		return normal.dot(point) - offset;
+	}
+
+	/// Get the distance from a point to this plane
+	float getDistance(const Vec3& point) const
+	{
+		return fabs(test(point));
+	}
+
+	/// Returns the perpedicular point of a given point in this plane.
+	/// Plane's normal and returned-point are perpedicular
+	Vec3 getClosestPoint(const Vec3& point) const
+	{
+		return point - normal * test(point);
+	}
+
+	/// Test a CollisionShape
+	template<typename T>
+	float testShape(const T& x) const
+	{
+		return x.testPlane(*this, x);
+	}
+
+private:
+	/// @name Data
+	/// @{
+	Vec3 normal;
+	float offset;
+	/// @}
+
+	/// Set the plane from 3 points
+	void setFrom3Points(const Vec3& p0, const Vec3& p1, const Vec3& p2);
+
+	/// Set from plane equation is ax+by+cz+d
+	void setFromPlaneEquation(float a, float b, float c, float d);
 };
 /// @}
 

+ 75 - 84
anki/collision/Ray.h

@@ -14,94 +14,85 @@ namespace anki {
 /// Ray collision shape. It has a starting point but the end extends to infinity
 class Ray: public CollisionShape
 {
-	public:
-		/// @name Constructors
-		/// @{
-
-		/// Default constructor
-		Ray()
-		:	CollisionShape(CST_RAY)
-		{}
-
-		/// Copy constructor
-		Ray(const Ray& other);
-
-		/// Constructor
-		Ray(const Vec3& origin, const Vec3& direction);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		const Vec3& getOrigin() const
-		{
-			return origin;
-		}
-		Vec3& getOrigin()
-		{
-			return origin;
-		}
-		void setOrigin(const Vec3& x)
-		{
-			origin = x;
-		}
-
-		const Vec3& getDirection() const
-		{
-			return dir;
-		}
-		Vec3& getDirection()
-		{
-			return dir;
-		}
-		void setDirection(const Vec3& x)
-		{
-			dir = x;
-		}
-		/// @}
-
-		/// Implements CollisionShape::accept
-		void accept(MutableVisitor& v)
-		{
-			v.visit(*this);
-		}
-		/// Implements CollisionShape::accept
-		void accept(ConstVisitor& v) const
-		{
-			v.visit(*this);
-		}
-
-		/// Implements CollisionShape::testPlane
-		float testPlane(const Plane& p) const;
-
-		/// Implements CollisionShape::transform
-		void transform(const Transform& trf)
-		{
-			*this = getTransformed(trf);
-		}
-
-		Ray getTransformed(const Transform& transform) const;
-
-	private:
-		Vec3 origin;
-		Vec3 dir;
+public:
+	/// @name Constructors
+	/// @{
+
+	/// Default constructor
+	Ray()
+		: CollisionShape(CST_RAY)
+	{}
+
+	/// Copy constructor
+	Ray(const Ray& b)
+		: CollisionShape(CST_RAY), origin(b.origin), dir(b.dir)
+	{}
+
+
+	/// Constructor
+	Ray(const Vec3& origin_, const Vec3& direction_)
+		: CollisionShape(CST_RAY), origin(origin_), dir(direction_)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	const Vec3& getOrigin() const
+	{
+		return origin;
+	}
+	Vec3& getOrigin()
+	{
+		return origin;
+	}
+	void setOrigin(const Vec3& x)
+	{
+		origin = x;
+	}
+
+	const Vec3& getDirection() const
+	{
+		return dir;
+	}
+	Vec3& getDirection()
+	{
+		return dir;
+	}
+	void setDirection(const Vec3& x)
+	{
+		dir = x;
+	}
+	/// @}
+
+	/// Implements CollisionShape::accept
+	void accept(MutableVisitor& v)
+	{
+		v.visit(*this);
+	}
+	/// Implements CollisionShape::accept
+	void accept(ConstVisitor& v) const
+	{
+		v.visit(*this);
+	}
+
+	/// Implements CollisionShape::testPlane
+	float testPlane(const Plane& p) const;
+
+	/// Implements CollisionShape::transform
+	void transform(const Transform& trf)
+	{
+		*this = getTransformed(trf);
+	}
+
+	Ray getTransformed(const Transform& transform) const;
+
+private:
+	Vec3 origin;
+	Vec3 dir;
 };
 /// @}
 
 
-inline Ray::Ray(const Ray& other)
-:	CollisionShape(CST_RAY),
-	origin(other.origin),
-	dir(other.dir)
-{}
-
-
-inline Ray::Ray(const Vec3& origin_, const Vec3& direction_)
-:	CollisionShape(CST_RAY),
-	origin(origin_),
-	dir(direction_)
-{}
-
-
 } // end namespace
 
 

+ 120 - 84
anki/collision/Sphere.h

@@ -14,106 +14,142 @@ namespace anki {
 /// Sphere collision shape
 class Sphere: public CollisionShape
 {
-	public:
-		/// @name Constructors
-		/// @{
+public:
+	/// @name Constructors
+	/// @{
+
+	/// Default constructor
+	Sphere()
+		: CollisionShape(CST_SPHERE)
+	{}
+
+	/// Copy constructor
+	Sphere(const Sphere& b)
+		: CollisionShape(CST_SPHERE), center(b.center), radius(b.radius)
+	{}
+
+	/// Constructor
+	Sphere(const Vec3& center_, float radius_)
+		: CollisionShape(CST_SPHERE), center(center_), radius(radius_)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	const Vec3& getCenter() const
+	{
+		return center;
+	}
+	Vec3& getCenter()
+	{
+		return center;
+	}
+	void setCenter(const Vec3& x)
+	{
+		center = x;
+	}
+
+	float getRadius() const
+	{
+		return radius;
+	}
+	float& getRadius()
+	{
+		return radius;
+	}
+	void setRadius(const float x)
+	{
+		radius = x;
+	}
+	/// @}
+
+	/// Implements CollisionShape::accept
+	void accept(MutableVisitor& v)
+	{
+		v.visit(*this);
+	}
+	/// Implements CollisionShape::accept
+	void accept(ConstVisitor& v) const
+	{
+		v.visit(*this);
+	}
+
+	/// Implements CollisionShape::testPlane
+	float testPlane(const Plane& p) const;
+
+	/// Implements CollisionShape::transform
+	void transform(const Transform& trf)
+	{
+		*this = getTransformed(trf);
+	}
+
+	Sphere getTransformed(const Transform& transform) const;
+
+	/// Get the sphere that includes this sphere and the given. See a
+	/// drawing in the docs dir for more info about the algorithm
+	Sphere getCompoundShape(const Sphere& b) const;
+
+	/// Calculate from a set of points
+	template<typename Container>
+	void set(const Container& container);
+
+private:
+	Vec3 center;
+	float radius;
+};
+/// @}
 
-		/// Default constructor
-		Sphere()
-		:	CollisionShape(CST_SPHERE)
-		{}
 
-		/// Copy constructor
-		Sphere(const Sphere& other);
+//==============================================================================
+template<typename Container>
+void Sphere::set(const Container& container)
+{
+	ANKI_ASSERT(container.size() >= 1);
 
-		/// Constructor
-		Sphere(const Vec3& center_, float radius_);
-		/// @}
+	Vec3 min(container.front());
+	Vec3 max(container.front());
 
-		/// @name Accessors
-		/// @{
-		const Vec3& getCenter() const
-		{
-			return center;
-		}
-		Vec3& getCenter()
-		{
-			return center;
-		}
-		void setCenter(const Vec3& x)
-		{
-			center = x;
-		}
+	// for all the Vec3 calc the max and min
+	typename Container::const_iterator it = container.begin() + 1;
+	for(; it != container.end(); ++it)
+	{
+		const Vec3& v = *it;
 
-		float getRadius() const
-		{
-			return radius;
-		}
-		float& getRadius()
+		for(int j = 0; j < 3; j++)
 		{
-			return radius;
+			if(v[j] > max[j])
+			{
+				max[j] = v[j];
+			}
+			else if(v[j] < min[j])
+			{
+				min[j] = v[j];
+			}
 		}
-		void setRadius(const float x)
-		{
-			radius = x;
-		}
-		/// @}
+	}
 
-		/// Implements CollisionShape::accept
-		void accept(MutableVisitor& v)
-		{
-			v.visit(*this);
-		}
-		/// Implements CollisionShape::accept
-		void accept(ConstVisitor& v) const
-		{
-			v.visit(*this);
-		}
+	center = (min + max) * 0.5; // average
 
-		/// Implements CollisionShape::testPlane
-		float testPlane(const Plane& p) const;
+	// max distance between center and the vec3 arr
+	float maxDist = (container.front() - center).getLengthSquared();
 
-		/// Implements CollisionShape::transform
-		void transform(const Transform& trf)
+	typename Container::const_iterator it_ = container.begin() + 1;
+	for(; it_ != container.end(); ++it_)
+	{
+		const Vec3& v = *it_;
+
+		float dist = (v - center).getLengthSquared();
+		if(dist > maxDist)
 		{
-			*this = getTransformed(trf);
+			maxDist = dist;
 		}
+	}
 
-		Sphere getTransformed(const Transform& transform) const;
-
-		/// Get the sphere that includes this sphere and the given. See a
-		/// drawing in the docs dir for more info about the algorithm
-		Sphere getCompoundShape(const Sphere& b) const;
-
-		/// Calculate from a set of points
-		template<typename Container>
-		void set(const Container& container);
-
-	private:
-		Vec3 center;
-		float radius;
-};
-/// @}
-
-
-inline Sphere::Sphere(const Sphere& b)
-:	CollisionShape(CST_SPHERE),
-	center(b.center),
-	radius(b.radius)
-{}
-
-
-inline Sphere::Sphere(const Vec3& center_, float radius_)
-:	CollisionShape(CST_SPHERE),
-	center(center_),
-	radius(radius_)
-{}
+	radius = Math::sqrt(maxDist);
+}
 
 
 } // end namespace
 
 
-#include "anki/collision/Sphere.inl.h"
-
-
 #endif

+ 0 - 56
anki/collision/Sphere.inl.h

@@ -1,56 +0,0 @@
-#include <boost/foreach.hpp>
-#include <boost/range/iterator_range.hpp>
-#include "anki/util/Assert.h"
-
-
-namespace anki {
-
-
-//==============================================================================
-// set                                                                         =
-//==============================================================================
-template<typename Container>
-void Sphere::set(const Container& container)
-{
-	ANKI_ASSERT(container.size() >= 1);
-
-	Vec3 min(container.front());
-	Vec3 max(container.front());
-
-	// for all the Vec3 calc the max and min
-	BOOST_FOREACH(const Vec3& v,
-		boost::make_iterator_range(container.begin() + 1, container.end()))
-	{
-		for(int j = 0; j < 3; j++)
-		{
-			if(v[j] > max[j])
-			{
-				max[j] = v[j];
-			}
-			else if(v[j] < min[j])
-			{
-				min[j] = v[j];
-			}
-		}
-	}
-
-	center = (min + max) * 0.5; // average
-
-	// max distance between center and the vec3 arr
-	float maxDist = (container.front() - center).getLengthSquared();
-
-	BOOST_FOREACH(const Vec3& v,
-		boost::make_iterator_range(container.begin() + 1, container.end()))
-	{
-		float dist = (v - center).getLengthSquared();
-		if(dist > maxDist)
-		{
-			maxDist = dist;
-		}
-	}
-
-	radius = Math::sqrt(maxDist);
-}
-
-
-} // end namespace

+ 99 - 97
anki/core/App.h

@@ -23,103 +23,105 @@ class Input;
 /// - It manipulates the main loop timer
 class App
 {
-	public:
-		App() {}
-		~App() {}
-
-		/// This method:
-		/// - Initialize the window
-		/// - Initialize the main renderer
-		/// - Initialize and start the stdin listener
-		/// - Initialize the scripting engine
-		void init(int argc, char* argv[]);
-
-		/// What it does:
-		/// - Destroy the window
-		/// - call exit()
-		void quit(int code);
-
-		/// Self explanatory
-		void togleFullScreen();
-
-		/// Wrapper for an SDL function that swaps the buffers
-		void swapBuffers();
-
-		static void printAppInfo();
-
-		uint getDesktopWidth() const;
-		uint getDesktopHeight() const;
-
-		/// @name Accessors
-		/// @{
-		Camera* getActiveCam()
-		{
-			return activeCam;
-		}
-		void setActiveCam(Camera* cam)
-		{
-			activeCam = cam;
-		}
-
-		float getTimerTick() const
-		{
-			return timerTick;
-		}
-		float& getTimerTick()
-		{
-			return timerTick;
-		}
-		void setTimerTick(const float x)
-		{
-			timerTick = x;
-		}
-
-		uint getWindowWidth() const
-		{
-			return windowW;
-		}
-
-		uint getWindowHeight() const
-		{
-			return windowH;
-		}
-
-		const boost::filesystem::path& getSettingsPath() const
-		{
-			return settingsPath;
-		}
-
-		const boost::filesystem::path& getCachePath() const
-		{
-			return cachePath;
-		}
-		/// @}
-
-	private:
-		uint windowW; ///< The main window width
-		uint windowH; ///< The main window height
-		/// The path that holds the configuration
-		boost::filesystem::path settingsPath;
-		/// This is used as a cache
-		boost::filesystem::path cachePath;
-		float timerTick;
-		/// Terminal coloring for Unix terminals. Default on
-		bool terminalColoringEnabled;
-		SDL_WindowID windowId;
-		SDL_GLContext glContext;
-		SDL_Surface* iconImage;
-		bool fullScreenFlag;
-		Camera* activeCam; ///< Pointer to the current camera
-
-		void parseCommandLineArgs(int argc, char* argv[]);
-
-		/// A slot to handle the messageHandler's signal
-		void handleMessageHanlderMsgs(const char* file, int line,
-			const char* func, Logger::MessageType, const char* msg);
-
-		void initWindow();
-		void initDirs();
-		void initRenderer();
+public:
+	App()
+	{}
+	~App()
+	{}
+
+	/// This method:
+	/// - Initialize the window
+	/// - Initialize the main renderer
+	/// - Initialize and start the stdin listener
+	/// - Initialize the scripting engine
+	void init(int argc, char* argv[]);
+
+	/// What it does:
+	/// - Destroy the window
+	/// - call exit()
+	void quit(int code);
+
+	/// Self explanatory
+	void togleFullScreen();
+
+	/// Wrapper for an SDL function that swaps the buffers
+	void swapBuffers();
+
+	static void printAppInfo();
+
+	uint getDesktopWidth() const;
+	uint getDesktopHeight() const;
+
+	/// @name Accessors
+	/// @{
+	Camera* getActiveCam()
+	{
+		return activeCam;
+	}
+	void setActiveCam(Camera* cam)
+	{
+		activeCam = cam;
+	}
+
+	float getTimerTick() const
+	{
+		return timerTick;
+	}
+	float& getTimerTick()
+	{
+		return timerTick;
+	}
+	void setTimerTick(const float x)
+	{
+		timerTick = x;
+	}
+
+	uint getWindowWidth() const
+	{
+		return windowW;
+	}
+
+	uint getWindowHeight() const
+	{
+		return windowH;
+	}
+
+	const boost::filesystem::path& getSettingsPath() const
+	{
+		return settingsPath;
+	}
+
+	const boost::filesystem::path& getCachePath() const
+	{
+		return cachePath;
+	}
+	/// @}
+
+private:
+	uint windowW; ///< The main window width
+	uint windowH; ///< The main window height
+	/// The path that holds the configuration
+	boost::filesystem::path settingsPath;
+	/// This is used as a cache
+	boost::filesystem::path cachePath;
+	float timerTick;
+	/// Terminal coloring for Unix terminals. Default on
+	bool terminalColoringEnabled;
+	SDL_WindowID windowId;
+	SDL_GLContext glContext;
+	SDL_Surface* iconImage;
+	bool fullScreenFlag;
+	Camera* activeCam; ///< Pointer to the current camera
+
+	void parseCommandLineArgs(int argc, char* argv[]);
+
+	/// A slot to handle the messageHandler's signal
+	void handleMessageHanlderMsgs(const char* file, int line,
+		const char* func, Logger::MessageType, const char* msg);
+
+	void initWindow();
+	void initDirs();
+	void initRenderer();
 };
 
 

+ 60 - 56
anki/core/AsyncLoader.h

@@ -19,63 +19,67 @@ namespace anki {
 /// not meant to be destroyed because of a deadlock.
 class AsyncLoader
 {
-	public:
-		/// Type of the callback function that the async loader wants
-		typedef void (*LoadCallback)(const char*, void*);
+public:
+	/// Type of the callback function that the async loader wants
+	typedef void (*LoadCallback)(const char*, void*);
+
+	/// Default constructor starts the thread
+	AsyncLoader()
+	{
+		start();
+	}
 	
-		/// Default constructor starts the thread
-		AsyncLoader() {start();}
-		
-		/// Do nothing
-		~AsyncLoader() {}
-
-		/// Tell me what to load, how to load it and where to store it. This
-		/// puts a new loading request in the stack
-		/// @param filename The file to load
-		/// @param loadCallback How to load the file. The function should gets
-		/// a filename (const char*) and the storage.
-		/// It can throw an exception in case of a loading error
-		/// @param storage This points to the storage that the loader will
-		/// store the data. The storage should not be destroyed from other
-		/// threads
-		void load(const char* filename, LoadCallback loadCallback,
-			void* storage);
-
-		/// Query the loader and see if its got something
-		/// @param[out] filename The file that finished loading
-		/// @param[out] storage The data are stored in this buffer
-		/// @param[out] ok Its true if the loading of the resource was ok
-		/// @return Return true if there is something that finished loading
-		bool pollForFinished(std::string& filename, void* storage, bool& ok);
-
-	private:
-		/// A loading request
-		struct Request
-		{
-			std::string filename;
-			LoadCallback loadCallback;
-			void* storage;
-		};
-
-		/// It contains a few things to identify the response
-		struct Response
-		{
-			std::string filename;
-			void* storage;
-			bool ok; ///< True if the loading was successful
-		};
-
-		std::list<Request> requests;
-		std::list<Response> responses;
-		boost::mutex mutexReq; ///< Protect the requests container
-		boost::mutex mutexResp; ///< Protect the responses container
-		boost::thread thread;
-		boost::condition_variable condVar;
-
-		/// The thread function. It waits for something in the requests
-		/// container
-		void workingFunc();
-		void start(); ///< Start thread
+	/// Do nothing
+	~AsyncLoader()
+	{}
+
+	/// Tell me what to load, how to load it and where to store it. This
+	/// puts a new loading request in the stack
+	/// @param filename The file to load
+	/// @param loadCallback How to load the file. The function should gets
+	/// a filename (const char*) and the storage.
+	/// It can throw an exception in case of a loading error
+	/// @param storage This points to the storage that the loader will
+	/// store the data. The storage should not be destroyed from other
+	/// threads
+	void load(const char* filename, LoadCallback loadCallback,
+		void* storage);
+
+	/// Query the loader and see if its got something
+	/// @param[out] filename The file that finished loading
+	/// @param[out] storage The data are stored in this buffer
+	/// @param[out] ok Its true if the loading of the resource was ok
+	/// @return Return true if there is something that finished loading
+	bool pollForFinished(std::string& filename, void* storage, bool& ok);
+
+private:
+	/// A loading request
+	struct Request
+	{
+		std::string filename;
+		LoadCallback loadCallback;
+		void* storage;
+	};
+
+	/// It contains a few things to identify the response
+	struct Response
+	{
+		std::string filename;
+		void* storage;
+		bool ok; ///< True if the loading was successful
+	};
+
+	std::list<Request> requests;
+	std::list<Response> responses;
+	boost::mutex mutexReq; ///< Protect the requests container
+	boost::mutex mutexResp; ///< Protect the responses container
+	boost::thread thread;
+	boost::condition_variable condVar;
+
+	/// The thread function. It waits for something in the requests
+	/// container
+	void workingFunc();
+	void start(); ///< Start thread
 };
 
 

+ 163 - 102
anki/core/Logger.h

@@ -14,113 +14,174 @@ namespace anki {
 /// exceptions, it has to recover somehow. Its thread safe
 class Logger
 {
-	public:
-		enum MessageType
-		{
-			MT_NORMAL,
-			MT_ERROR,
-			MT_WARNING
-		};
-
-		/// Record the sender
-		struct Info
-		{
-			const char* file;
-			int line;
-			const char* func;
-			MessageType type;
-		};
-
-		typedef boost::signals2::signal<void (const char*, int, const char*,
-			MessageType, const char*)> Signal; ///< Signal type
-
-		Logger() {execCommonConstructionCode();}
-
-		/// Accessor
-		Signal& getSignal() {return sig;}
-
-		/// @name Operators for numbers
-		/// @{
-		Logger& operator<<(const bool& val);
-		Logger& operator<<(const short& val);
-		Logger& operator<<(const unsigned short& val);
-		Logger& operator<<(const int& val);
-		Logger& operator<<(const unsigned int& val);
-		Logger& operator<<(const long& val);
-		Logger& operator<<(const unsigned long& val);
-		Logger& operator<<(const float& val);
-		Logger& operator<<(const double& val);
-		Logger& operator<<(const long double& val);
-		/// @}
-
-		/// @name Operators for other types
-		/// @{
-		Logger& operator<<(const void* val);
-		Logger& operator<<(const char* val);
-		Logger& operator<<(const std::string& val);
-		Logger& operator<<(Logger& (*funcPtr)(Logger&));
-		Logger& operator<<(const Info& sender);
-		/// @}
-
-		/// @name IO manipulation
-		/// @{
-
-		/// Help the Logger to set the sender
-		static Info setInfo(const char* file, int line,
-			const char* func, MessageType type);
-
-		/// Add a new line and flush the Logger
-		static Logger& endl(Logger& logger) {return logger;}
-
-		/// Flush the Logger
-		static Logger& flush(Logger& logger) {return logger;}
-
-		/// @}
-
-		/// An alternative method to write in the Logger
-		void write(const char* file, int line, const char* func,
-			MessageType type, const char* msg);
-
-		/// Connect to signal
-		template<typename F, typename T>
-		void connect(F f, T t);
-
-		/// Mutex lock
-		void lock() {mutex.lock();}
-
-		/// Mutex unlock
-		void unlock() {mutex.unlock();}
-
-	private:
-		static const int STREAM_SIZE = 2048;
-		boost::array<char, STREAM_SIZE> streamBuf;
-		char* sptr; ///< Pointer to streamBuf
-		Signal sig; ///< The signal
-		const char* func; ///< Sender info
-		const char* file; ///< Sender info
-		int line; ///< Sender info
-		MessageType type; ///< The type of the message
-		boost::mutex mutex; ///< For thread safety
-
-		/// Called by all the constructors
-		void execCommonConstructionCode();
-
-		/// Appends to streamBuf. On overflow it writes what it can and flushes
-		void append(const char* cstr, int len);
-
-		/// Append finalize streamBuf and send the signal
-		void realFlush();
-
-		/// Because we are bored to write
-		template<typename Type>
-		Logger& appendUsingLexicalCast(const Type& val);
+public:
+	enum MessageType
+	{
+		MT_NORMAL,
+		MT_ERROR,
+		MT_WARNING
+	};
+
+	/// Record the sender
+	struct Info
+	{
+		const char* file;
+		int line;
+		const char* func;
+		MessageType type;
+	};
+
+	typedef boost::signals2::signal<void (const char*, int, const char*,
+		MessageType, const char*)> Signal; ///< Signal type
+
+	Logger()
+	{
+		execCommonConstructionCode();
+	}
+
+	/// Accessor
+	Signal& getSignal() {return sig;}
+
+	/// @name Operators for numbers
+	/// @{
+	Logger& operator<<(const bool& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const short& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const unsigned short& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const int& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const unsigned int& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const long& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const unsigned long& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const float& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const double& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	Logger& operator<<(const long double& val)
+	{
+		return appendUsingLexicalCast(val);
+	}
+	/// @}
+
+	/// @name Operators for other types
+	/// @{
+	Logger& operator<<(const void* val);
+	Logger& operator<<(const char* val);
+	Logger& operator<<(const std::string& val);
+	Logger& operator<<(Logger& (*funcPtr)(Logger&));
+	Logger& operator<<(const Info& sender);
+	/// @}
+
+	/// @name IO manipulation
+	/// @{
+
+	/// Help the Logger to set the sender
+	static Info setInfo(const char* file, int line,
+		const char* func, MessageType type)
+	{
+		Info sender = {file, line, func, type};
+		return sender;
+	}
+
+	/// Add a new line and flush the Logger
+	static Logger& endl(Logger& logger) {return logger;}
+
+	/// Flush the Logger
+	static Logger& flush(Logger& logger) {return logger;}
+
+	/// @}
+
+	/// An alternative method to write in the Logger
+	void write(const char* file, int line, const char* func,
+		MessageType type, const char* msg);
+
+	/// Connect to signal
+	template<typename F, typename T>
+	void connect(F f, T t)
+	{
+		sig.connect(boost::bind(f, t, _1, _2, _3, _4, _5));
+	}
+
+	/// Mutex lock
+	void lock()
+	{
+		mutex.lock();
+	}
+
+	/// Mutex unlock
+	void unlock()
+	{
+		mutex.unlock();
+	}
+
+private:
+	static const int STREAM_SIZE = 2048;
+	boost::array<char, STREAM_SIZE> streamBuf;
+	char* sptr; ///< Pointer to streamBuf
+	Signal sig; ///< The signal
+	const char* func; ///< Sender info
+	const char* file; ///< Sender info
+	int line; ///< Sender info
+	MessageType type; ///< The type of the message
+	boost::mutex mutex; ///< For thread safety
+
+	/// Called by all the constructors
+	void execCommonConstructionCode();
+
+	/// Appends to streamBuf. On overflow it writes what it can and flushes
+	void append(const char* cstr, int len);
+
+	/// Append finalize streamBuf and send the signal
+	void realFlush();
+
+	/// Because we are bored to write
+	template<typename Type>
+	Logger& appendUsingLexicalCast(const Type& val);
 };
 
 
-} // end namespace
+//==============================================================================
+template<typename Type>
+Logger& Logger::appendUsingLexicalCast(const Type& val)
+{
+	std::string out;
+	try
+	{
+		out = boost::lexical_cast<std::string>(val);
+	}
+	catch(...)
+	{
+		out = "*error*";
+	}
+	append(out.c_str(), out.length());
+	return *this;
+}
 
 
-#include "anki/core/Logger.inl.h"
+} // end namespace
 
 
 //==============================================================================

+ 0 - 97
anki/core/Logger.inl.h

@@ -1,97 +0,0 @@
-
-namespace anki {
-
-
-inline Logger& Logger::operator<<(const bool& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const short& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const unsigned short& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const int& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const unsigned int& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const long& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const unsigned long& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const float& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const double& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger& Logger::operator<<(const long double& val)
-{
-	return appendUsingLexicalCast(val);
-}
-
-
-inline Logger::Info Logger::setInfo(const char* file, int line,
-	const char* func, MessageType type)
-{
-	Info sender = {file, line, func, type};
-	return sender;
-}
-
-
-template<typename Type>
-Logger& Logger::appendUsingLexicalCast(const Type& val)
-{
-	std::string out;
-	try
-	{
-		out = boost::lexical_cast<std::string>(val);
-	}
-	catch(...)
-	{
-		out = "*error*";
-	}
-	append(out.c_str(), out.length());
-	return *this;
-}
-
-
-template<typename F, typename T>
-void Logger::connect(F f, T t)
-{
-	sig.connect(boost::bind(f, t, _1, _2, _3, _4, _5));
-}
-
-
-} // end namespace

+ 37 - 25
anki/core/Object.h

@@ -12,31 +12,43 @@ namespace anki {
 /// object that has not created dynamically
 class Object
 {
-	public:
-		typedef std::vector<Object*> Container;
-
-		/// Calls addChild if parent is not NULL
-		/// @exception Exception
-		Object(Object* parent);
-
-		/// Delete childs from the last entered to the first and update parent
-		virtual ~Object();
-
-	protected:
-		/// @name Accessors
-		/// @{
-		const Object* getObjParent() const {return objParent;}
-		Object* getObjParent() {return objParent;}
-		const Container& getObjChildren() const {return objChilds;}
-		Container& getObjChildren() {return objChilds;}
-		/// @}
-
-		void addChild(Object* child);
-		void removeChild(Object* child);
-
-	private:
-		Object* objParent; ///< May be nullptr
-		Container objChilds;
+public:
+	typedef std::vector<Object*> Container;
+
+	/// Calls addChild if parent is not NULL
+	/// @exception Exception
+	Object(Object* parent);
+
+	/// Delete childs from the last entered to the first and update parent
+	virtual ~Object();
+
+protected:
+	/// @name Accessors
+	/// @{
+	const Object* getObjParent() const
+	{
+		return objParent;
+	}
+	Object* getObjParent()
+	{
+		return objParent;
+	}
+	const Container& getObjChildren() const
+	{
+		return objChilds;
+	}
+	Container& getObjChildren()
+	{
+		return objChilds;
+	}
+	/// @}
+
+	void addChild(Object* child);
+	void removeChild(Object* child);
+
+private:
+	Object* objParent; ///< May be nullptr
+	Container objChilds;
 };
 
 

+ 41 - 41
anki/core/ParallelJob.h

@@ -23,47 +23,47 @@ typedef void (*ParallelJobCallback)(ParallelJobParameters&, const ParallelJob&);
 /// The thread that executes a ParallelJobCallback
 class ParallelJob
 {
-	public:
-		/// Constructor
-		ParallelJob(int id, const ParallelManager& manager,
-			boost::barrier& barrier);
-
-		/// @name Accessors
-		/// @{
-		uint getId() const
-		{
-			return id;
-		}
-
-		const ParallelManager& getManager() const
-		{
-			return manager;
-		}
-		/// @}
-
-		/// Assign new job to the thread
-		void assignNewJob(ParallelJobCallback callback,
-			ParallelJobParameters& jobParams);
-
-	private:
-		uint id; ///< An ID
-		boost::thread thread; ///< Runs the workingFunc
-		boost::mutex mutex; ///< Protect the ParallelJob::job
-		boost::condition_variable condVar; ///< To wake up the thread
-		boost::barrier& barrier; ///< For synchronization
-		ParallelJobCallback callback; ///< Its NULL if there are no pending job
-		ParallelJobParameters* params;
-		/// Know your father and pass him to the jobs
-		const ParallelManager& manager;
-
-		/// Start thread
-		void start()
-		{
-			thread = boost::thread(&ParallelJob::workingFunc, this);
-		}
-
-		/// Thread loop
-		void workingFunc();
+public:
+	/// Constructor
+	ParallelJob(int id, const ParallelManager& manager,
+		boost::barrier& barrier);
+
+	/// @name Accessors
+	/// @{
+	uint getId() const
+	{
+		return id;
+	}
+
+	const ParallelManager& getManager() const
+	{
+		return manager;
+	}
+	/// @}
+
+	/// Assign new job to the thread
+	void assignNewJob(ParallelJobCallback callback,
+		ParallelJobParameters& jobParams);
+
+private:
+	uint id; ///< An ID
+	boost::thread thread; ///< Runs the workingFunc
+	boost::mutex mutex; ///< Protect the ParallelJob::job
+	boost::condition_variable condVar; ///< To wake up the thread
+	boost::barrier& barrier; ///< For synchronization
+	ParallelJobCallback callback; ///< Its NULL if there are no pending job
+	ParallelJobParameters* params;
+	/// Know your father and pass him to the jobs
+	const ParallelManager& manager;
+
+	/// Start thread
+	void start()
+	{
+		thread = boost::thread(&ParallelJob::workingFunc, this);
+	}
+
+	/// Thread loop
+	void workingFunc();
 };
 
 

+ 35 - 35
anki/core/ParallelManager.h

@@ -12,41 +12,41 @@ namespace anki {
 /// The job manager
 class ParallelManager
 {
-	public:
-		/// Default constructor
-		ParallelManager()
-		{}
-
-		/// Constructor #2
-		ParallelManager(uint threadsNum)
-		{
-			init(threadsNum);
-		}
-
-		/// Init the manager
-		void init(uint threadsNum);
-
-		/// Assign a job to a working thread
-		void assignNewJob(uint jobId, ParallelJobCallback callback,
-			ParallelJobParameters& jobParams)
-		{
-			jobs[jobId].assignNewJob(callback, jobParams);
-		}
-
-		/// Wait for all jobs to finish
-		void waitForAllJobsToFinish()
-		{
-			barrier->wait();
-		}
-
-		uint getThreadsNum() const
-		{
-			return jobs.size();
-		}
-
-	private:
-		boost::ptr_vector<ParallelJob> jobs; ///< Worker threads
-		boost::scoped_ptr<boost::barrier> barrier; ///< Synchronization barrier
+public:
+	/// Default constructor
+	ParallelManager()
+	{}
+
+	/// Constructor #2
+	ParallelManager(uint threadsNum)
+	{
+		init(threadsNum);
+	}
+
+	/// Init the manager
+	void init(uint threadsNum);
+
+	/// Assign a job to a working thread
+	void assignNewJob(uint jobId, ParallelJobCallback callback,
+		ParallelJobParameters& jobParams)
+	{
+		jobs[jobId].assignNewJob(callback, jobParams);
+	}
+
+	/// Wait for all jobs to finish
+	void waitForAllJobsToFinish()
+	{
+		barrier->wait();
+	}
+
+	uint getThreadsNum() const
+	{
+		return jobs.size();
+	}
+
+private:
+	boost::ptr_vector<ParallelJob> jobs; ///< Worker threads
+	boost::scoped_ptr<boost::barrier> barrier; ///< Synchronization barrier
 };
 
 

+ 10 - 10
anki/core/StdinListener.h

@@ -15,19 +15,19 @@ namespace anki {
 /// in a queue
 class StdinListener
 {
-	public:
-		/// Get line from the queue or return an empty string
-		std::string getLine();
+public:
+	/// Get line from the queue or return an empty string
+	std::string getLine();
 
-		/// Start reading
-		void start();
+	/// Start reading
+	void start();
 
-	private:
-		std::queue<std::string> q;
-		boost::mutex mtx; ///< Protect the queue
-		boost::thread thrd; ///< The thread
+private:
+	std::queue<std::string> q;
+	boost::mutex mtx; ///< Protect the queue
+	boost::thread thrd; ///< The thread
 
-		void workingFunc(); ///< The thread function
+	void workingFunc(); ///< The thread function
 };
 
 

+ 59 - 56
anki/event/Event.h

@@ -19,62 +19,65 @@ enum EventType
 /// Abstract class for all events. All Event derived classes should be copy-able
 class Event
 {
-	public:
-		/// Constructor
-		Event(EventType type, float startTime, float duration);
-
-		/// Copy constructor
-		Event(const Event& b) {*this = b;}
-
-		/// @name Accessors
-		/// @{
-		float getStartTime() const
-		{
-			return startTime;
-		}
-
-		float getDuration() const
-		{
-			return duration;
-		}
-
-		EventType getEventType() const
-		{
-			return type;
-		}
-
-		bool isDead(float crntTime) const
-		{
-			return crntTime >= startTime + duration;
-		}
-		/// @}
-
-		/// Copy
-		Event& operator=(const Event& b);
-
-		/// @param[in] prevUpdateTime The time of the previous update (sec)
-		/// @param[in] crntTime The current time (sec)
-		void update(float prevUpdateTime, float crntTime);
-
-	protected:
-		/// This method should be implemented by the derived classes
-		virtual void updateSp(float prevUpdateTime, float crntTime) = 0;
-
-		/// Linear interpolation between values
-		/// @param[in] from Starting value
-		/// @param[in] to Ending value
-		/// @param[in] delta The percentage from the from "from" value. Values
-		/// from [0.0, 1.0]
-		template<typename Type>
-		static Type interpolate(const Type& from, const Type& to, float delta)
-		{
-			return from * (1.0 - delta) + to * delta;
-		}
-
-	private:
-		EventType type; ///< Self explanatory
-		float startTime; ///< The time the event will start. Eg 23:00
-		float duration; ///< The duration of the event
+public:
+	/// Constructor
+	Event(EventType type, float startTime, float duration);
+
+	/// Copy constructor
+	Event(const Event& b)
+	{
+		*this = b;
+	}
+
+	/// @name Accessors
+	/// @{
+	float getStartTime() const
+	{
+		return startTime;
+	}
+
+	float getDuration() const
+	{
+		return duration;
+	}
+
+	EventType getEventType() const
+	{
+		return type;
+	}
+
+	bool isDead(float crntTime) const
+	{
+		return crntTime >= startTime + duration;
+	}
+	/// @}
+
+	/// Copy
+	Event& operator=(const Event& b);
+
+	/// @param[in] prevUpdateTime The time of the previous update (sec)
+	/// @param[in] crntTime The current time (sec)
+	void update(float prevUpdateTime, float crntTime);
+
+protected:
+	/// This method should be implemented by the derived classes
+	virtual void updateSp(float prevUpdateTime, float crntTime) = 0;
+
+	/// Linear interpolation between values
+	/// @param[in] from Starting value
+	/// @param[in] to Ending value
+	/// @param[in] delta The percentage from the from "from" value. Values
+	/// from [0.0, 1.0]
+	template<typename Type>
+	static Type interpolate(const Type& from, const Type& to, float delta)
+	{
+		return from * (1.0 - delta) + to * delta;
+	}
+
+private:
+	EventType type; ///< Self explanatory
+	float startTime; ///< The time the event will start. Eg 23:00
+	float duration; ///< The duration of the event
 };
 
 

+ 17 - 17
anki/event/EventManager.h

@@ -11,28 +11,28 @@ namespace anki {
 /// This manager creates the events ands keeps tracks of them
 class EventManager
 {
-	public:
-		typedef boost::ptr_deque<Event> EventsContainer;
+public:
+	typedef boost::ptr_deque<Event> EventsContainer;
 
-		/// Create a new event
-		template<typename EventType>
-		EventType& createEvent(const EventType& event);
+	/// Create a new event
+	template<typename EventType>
+	EventType& createEvent(const EventType& event);
 
-		/// Update
-		void updateAllEvents(float prevUpdateTime, float crntTime);
+	/// Update
+	void updateAllEvents(float prevUpdateTime, float crntTime);
 
-	private:
-		enum
-		{
-			MAX_EVENTS_SIZE = 1000
-		};
+private:
+	enum
+	{
+		MAX_EVENTS_SIZE = 1000
+	};
 
-		EventsContainer events;
-		float prevUpdateTime;
-		float crntTime;
+	EventsContainer events;
+	float prevUpdateTime;
+	float crntTime;
 
-		/// Find a dead event of a certain type
-		EventsContainer::iterator findADeadEvent(EventType type);
+	/// Find a dead event of a certain type
+	EventsContainer::iterator findADeadEvent(EventType type);
 };
 
 

+ 24 - 24
anki/event/MainRendererPpsHdrEvent.h

@@ -10,30 +10,30 @@ namespace anki {
 /// Change the HDR properties
 class MainRendererPpsHdrEvent: public Event
 {
-	public:
-		/// Constructor
-		MainRendererPpsHdrEvent(float startTime, float duration,
-			float exposure, uint blurringIterationsNum, float blurringDist);
-
-		/// Copy constructor
-		MainRendererPpsHdrEvent(const MainRendererPpsHdrEvent& b);
-
-		/// Copy
-		MainRendererPpsHdrEvent& operator=(const MainRendererPpsHdrEvent& b);
-
-	private:
-		struct Data
-		{
-			float exposure; ///< @see Hdr::exposure
-			uint blurringIterationsNum; ///< @see Hdr::blurringIterationsNum
-			float blurringDist; ///< @see Hdr::blurringDist
-		};
-
-		Data originalData; ///< From where do we start
-		Data finalData; ///< Where do we want to go
-
-		/// Implements Event::updateSp
-		void updateSp(float prevUpdateTime, float crntTime);
+public:
+	/// Constructor
+	MainRendererPpsHdrEvent(float startTime, float duration,
+		float exposure, uint blurringIterationsNum, float blurringDist);
+
+	/// Copy constructor
+	MainRendererPpsHdrEvent(const MainRendererPpsHdrEvent& b);
+
+	/// Copy
+	MainRendererPpsHdrEvent& operator=(const MainRendererPpsHdrEvent& b);
+
+private:
+	struct Data
+	{
+		float exposure; ///< @see Hdr::exposure
+		uint blurringIterationsNum; ///< @see Hdr::blurringIterationsNum
+		float blurringDist; ///< @see Hdr::blurringDist
+	};
+
+	Data originalData; ///< From where do we start
+	Data finalData; ///< Where do we want to go
+
+	/// Implements Event::updateSp
+	void updateSp(float prevUpdateTime, float crntTime);
 };
 
 

+ 13 - 13
anki/event/SceneColorEvent.h

@@ -11,23 +11,23 @@ namespace anki {
 /// Change the scene color
 class SceneColorEvent: public Event
 {
-	public:
-		/// Constructor
-		SceneColorEvent(float startTime, float duration,
-			const Vec3& finalColor);
+public:
+	/// Constructor
+	SceneColorEvent(float startTime, float duration,
+		const Vec3& finalColor);
 
-		/// Copy constructor
-		SceneColorEvent(const SceneColorEvent& b);
+	/// Copy constructor
+	SceneColorEvent(const SceneColorEvent& b);
 
-		/// Copy
-		SceneColorEvent& operator=(const SceneColorEvent& b);
+	/// Copy
+	SceneColorEvent& operator=(const SceneColorEvent& b);
 
-	private:
-		Vec3 originalColor; ///< Original scene color. The constructor sets it
-		Vec3 finalColor;
+private:
+	Vec3 originalColor; ///< Original scene color. The constructor sets it
+	Vec3 finalColor;
 
-		/// Implements Event::updateSp
-		void updateSp(float prevUpdateTime, float crntTime);
+	/// Implements Event::updateSp
+	void updateSp(float prevUpdateTime, float crntTime);
 };
 
 

+ 104 - 128
anki/gl/BufferObject.h

@@ -13,137 +13,113 @@ namespace anki {
 /// to prevent us from making idiotic errors
 class BufferObject
 {
-	public:
-		BufferObject(): glId(0) {}
-
-		/// Default constructor @see create
-		BufferObject(GLenum target, uint sizeInBytes,
-			const void* dataPtr, GLenum usage);
-
-		/// It deletes the BO from the GL context
-		virtual ~BufferObject();
-
-		/// @name Accessors
-		/// @{
-		uint getGlId() const;
-		GLenum getBufferTarget() const;
-		GLenum getBufferUsage() const;
-		size_t getSizeInBytes() const;
-		/// @]
-
-		/// Bind BO
-		void bind() const;
-
-		/// Unbind BO
-		void unbind() const;
-
-		/// Creates a new BO with the given parameters and checks if everything
-		/// went OK. Throws exception if fails
-		/// @param target Depends on the BO
-		/// @param sizeInBytes The size of the buffer that we will allocate in
-		/// bytes
-		/// @param dataPtr Points to the data buffer to copy to the VGA memory.
-		/// Put NULL if you want just to allocate memory
-		/// @param usage It should be: GL_STREAM_DRAW or GL_STATIC_DRAW or
-		/// GL_DYNAMIC_DRAW only!!!!!!!!!
-		/// @exception Exception
-		void create(GLenum target, uint sizeInBytes, const void* dataPtr,
-			GLenum usage);
-
-		/// Delete the BO
-		void deleteBuff();
-
-		/// Write data to buffer. This means that maps the BO to local memory,
-		/// writes the local memory and unmaps it. Throws exception if the
-		/// given size and the BO size are not equal. It throws an exception if
-		/// the usage is GL_STATIC_DRAW
-		/// @param[in] buff The buffer to copy to BO
-		void write(void* buff);
-
-		/// The same as the other write but it maps only a subset of the data
-		/// @param[in] buff The buffer to copy to BO
-		/// @param[in] offset The offset
-		/// @param[in] size The size in bytes we want to write
-		void write(void* buff, size_t offset, size_t size);
-
-		/// If created is run successfully it returns true
-		bool isCreated() const {return glId != 0;}
-
-	private:
-		uint glId; ///< The OpenGL id of the BO
-
-		/// Used in glBindBuffer(target, glId) and its for easy access so we
-		/// wont have to query the GL driver. Its the type of the buffer eg
-		/// GL_TEXTURE_BUFFER or GL_ELEMENT_ARRAY_BUFFER etc
-		GLenum target;
-
-		GLenum usage; ///< GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW
-		size_t sizeInBytes; ///< The size of the buffer
+public:
+	BufferObject()
+		: glId(0)
+	{}
+
+	/// Default constructor @see create
+	BufferObject(GLenum target, uint sizeInBytes,
+		const void* dataPtr, GLenum usage)
+		: glId(0)
+	{
+		create(target, sizeInBytes, dataPtr, usage);
+	}
+
+	/// It deletes the BO from the GL context
+	virtual ~BufferObject();
+
+	/// @name Accessors
+	/// @{
+	uint getGlId() const
+	{
+		ANKI_ASSERT(isCreated());
+		return glId;
+	}
+
+	GLenum getBufferTarget() const
+	{
+		ANKI_ASSERT(isCreated());
+		return target;
+	}
+
+	GLenum getBufferUsage() const
+	{
+		ANKI_ASSERT(isCreated());
+		return usage;
+	}
+
+	size_t getSizeInBytes() const
+	{
+		ANKI_ASSERT(isCreated());
+		return sizeInBytes;
+	}
+	/// @]
+
+	/// Bind BO
+	void bind() const
+	{
+		ANKI_ASSERT(isCreated());
+		glBindBuffer(target, glId);
+	}
+
+	/// Unbind BO
+	void unbind() const
+	{
+		ANKI_ASSERT(isCreated());
+		glBindBuffer(target, 0);
+	}
+
+	/// Creates a new BO with the given parameters and checks if everything
+	/// went OK. Throws exception if fails
+	/// @param target Depends on the BO
+	/// @param sizeInBytes The size of the buffer that we will allocate in
+	/// bytes
+	/// @param dataPtr Points to the data buffer to copy to the VGA memory.
+	/// Put NULL if you want just to allocate memory
+	/// @param usage It should be: GL_STREAM_DRAW or GL_STATIC_DRAW or
+	/// GL_DYNAMIC_DRAW only!!!!!!!!!
+	/// @exception Exception
+	void create(GLenum target, uint sizeInBytes, const void* dataPtr,
+		GLenum usage);
+
+	/// Delete the BO
+	void deleteBuff()
+	{
+		ANKI_ASSERT(isCreated());
+		glDeleteBuffers(1, &glId);
+		glId = 0;
+	}
+
+	/// Write data to buffer. This means that maps the BO to local memory,
+	/// writes the local memory and unmaps it. Throws exception if the
+	/// given size and the BO size are not equal. It throws an exception if
+	/// the usage is GL_STATIC_DRAW
+	/// @param[in] buff The buffer to copy to BO
+	void write(void* buff);
+
+	/// The same as the other write but it maps only a subset of the data
+	/// @param[in] buff The buffer to copy to BO
+	/// @param[in] offset The offset
+	/// @param[in] size The size in bytes we want to write
+	void write(void* buff, size_t offset, size_t size);
+
+	/// If created is run successfully it returns true
+	bool isCreated() const {return glId != 0;}
+
+private:
+	uint glId; ///< The OpenGL id of the BO
+
+	/// Used in glBindBuffer(target, glId) and its for easy access so we
+	/// wont have to query the GL driver. Its the type of the buffer eg
+	/// GL_TEXTURE_BUFFER or GL_ELEMENT_ARRAY_BUFFER etc
+	GLenum target;
+
+	GLenum usage; ///< GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW
+	size_t sizeInBytes; ///< The size of the buffer
 };
 
 
-//==============================================================================
-// Inlines                                                                     =
-//==============================================================================
-
-inline BufferObject::BufferObject(GLenum target, uint sizeInBytes,
-	const void* dataPtr, GLenum usage)
-:	glId(0)
-{
-	create(target, sizeInBytes, dataPtr, usage);
-}
-
-
-inline uint BufferObject::getGlId() const
-{
-	ANKI_ASSERT(isCreated());
-	return glId;
-}
-
-
-inline GLenum BufferObject::getBufferTarget() const
-{
-	ANKI_ASSERT(isCreated());
-	return target;
-}
-
-
-inline GLenum BufferObject::getBufferUsage() const
-{
-	ANKI_ASSERT(isCreated());
-	return usage;
-}
-
-
-inline size_t BufferObject::getSizeInBytes() const
-{
-	ANKI_ASSERT(isCreated());
-	return sizeInBytes;
-}
-
-
-inline void BufferObject::bind() const
-{
-	ANKI_ASSERT(isCreated());
-	glBindBuffer(target, glId);
-}
-
-
-inline void BufferObject::unbind() const
-{
-	ANKI_ASSERT(isCreated());
-	glBindBuffer(target, 0);
-}
-
-
-inline void BufferObject::deleteBuff()
-{
-	ANKI_ASSERT(isCreated());
-	glDeleteBuffers(1, &glId);
-	glId = 0;
-}
-
-
 } // end namespace
 
 

+ 62 - 79
anki/gl/Fbo.h

@@ -13,88 +13,71 @@ namespace anki {
 /// The class is actually a wrapper to avoid common mistakes
 class Fbo
 {
-	public:
-		/// Constructor
-		Fbo(): glId(0) {}
-
-		/// Destructor
-		~Fbo();
-
-		uint getGlId() const;
-
-		/// Binds FBO
-		void bind(GLenum target = GL_FRAMEBUFFER);
-
-		/// Unbinds the FBO
-		void unbind();
-
-		/// Checks the status of an initialized FBO and if fails throw exception
-		/// @exception Exception
-		void checkIfGood() const;
-
-		/// Set the number of color attachments of the FBO
-		void setNumOfColorAttachements(uint num) const;
-
-		/// Returns the GL id of the current attached FBO
-		/// @return Returns the GL id of the current attached FBO
-		static uint getCurrentFbo();
-
-		/// Creates a new FBO
-		void create();
-
-		/// Destroy it
-		void destroy();
-
-	private:
-		uint glId; ///< OpenGL identification
-		GLenum target; ///< How the buffer is bind
-
-		bool isCreated() const {return glId != 0;}
+public:
+	/// Constructor
+	Fbo()
+		: glId(0)
+	{}
+
+	/// Destructor
+	~Fbo();
+
+	uint getGlId() const
+	{
+		ANKI_ASSERT(!isCreated());
+		return glId;
+	}
+
+	/// Binds FBO
+	void bind(GLenum target_ = GL_FRAMEBUFFER)
+	{
+		ANKI_ASSERT(isCreated());
+		target = target_;
+		ANKI_ASSERT(target == GL_DRAW_FRAMEBUFFER ||
+			target == GL_READ_FRAMEBUFFER ||
+			target == GL_FRAMEBUFFER);
+		glBindFramebuffer(target, glId);
+	}
+
+	/// Unbinds the FBO
+	void unbind()
+	{
+		glBindFramebuffer(target, 0);
+	}
+
+	/// Checks the status of an initialized FBO and if fails throw exception
+	/// @exception Exception
+	void checkIfGood() const;
+
+	/// Set the number of color attachments of the FBO
+	void setNumOfColorAttachements(uint num) const;
+
+	/// Returns the GL id of the current attached FBO
+	/// @return Returns the GL id of the current attached FBO
+	static uint getCurrentFbo();
+
+	/// Creates a new FBO
+	void create()
+	{
+		ANKI_ASSERT(!isCreated());
+		glGenFramebuffers(1, &glId);
+	}
+
+	/// Destroy it
+	void destroy()
+	{
+		ANKI_ASSERT(isCreated());
+		glDeleteFramebuffers(1, &glId);
+	}
+
+private:
+	uint glId; ///< OpenGL identification
+	GLenum target; ///< How the buffer is bind
+
+	bool isCreated() const {return glId != 0;}
 };
 
 
-//==============================================================================
-// Inlines                                                                     =
-//==============================================================================
-
-inline void Fbo::create()
-{
-	ANKI_ASSERT(!isCreated());
-	glGenFramebuffers(1, &glId);
-}
-
-
-inline uint Fbo::getGlId() const
-{
-	ANKI_ASSERT(!isCreated());
-	return glId;
-}
-
-
-inline void Fbo::bind(GLenum target_)
-{
-	ANKI_ASSERT(isCreated());
-	target = target_;
-	ANKI_ASSERT(target == GL_DRAW_FRAMEBUFFER ||
-		target == GL_READ_FRAMEBUFFER ||
-		target == GL_FRAMEBUFFER);
-	glBindFramebuffer(target, glId);
-}
-
-
-inline void Fbo::unbind()
-{
-	glBindFramebuffer(target, 0);
-}
-
-
-inline void Fbo::destroy()
-{
-	ANKI_ASSERT(isCreated());
-	glDeleteFramebuffers(1, &glId);
-}
-
-
 } // end namespace
 
 

+ 36 - 33
anki/gl/GlStateMachine.h

@@ -13,39 +13,42 @@ namespace anki {
 /// This class saves us from calling the GL functions
 class GlStateMachine
 {
-	public:
-		GlStateMachine() {sync();}
-
-		/// Sync the local members with the opengl ones
-		void sync();
-
-		/// @name Set the Fixed Function Pipeline, Call the OpenGL functions
-		/// only when needed
-		/// @{
-		void enable(GLenum flag, bool enable = true);
-		void disable(GLenum flag) {enable(flag, false);}
-		bool isEnabled(GLenum flag);
-
-		void useShaderProg(GLuint id);
-
-		void setViewport(uint x, uint y, uint w, uint h);
-
-		static GLuint getCurrentProgramGlId();
-		/// @}
-
-	private:
-		/// @name The GL state
-		/// @{
-		GLuint sProgGlId; ///< Last used SProg ID
-
-		boost::unordered_map<GLenum, bool> flags;
-		static GLenum flagEnums[];
-
-		GLint viewportX;
-		GLint viewportY;
-		GLsizei viewportW;
-		GLsizei viewportH;
-		/// @}
+public:
+	GlStateMachine()
+	{
+		sync();
+	}
+
+	/// Sync the local members with the opengl ones
+	void sync();
+
+	/// @name Set the Fixed Function Pipeline, Call the OpenGL functions
+	/// only when needed
+	/// @{
+	void enable(GLenum flag, bool enable = true);
+	void disable(GLenum flag) {enable(flag, false);}
+	bool isEnabled(GLenum flag);
+
+	void useShaderProg(GLuint id);
+
+	void setViewport(uint x, uint y, uint w, uint h);
+
+	static GLuint getCurrentProgramGlId();
+	/// @}
+
+private:
+	/// @name The GL state
+	/// @{
+	GLuint sProgGlId; ///< Last used SProg ID
+
+	boost::unordered_map<GLenum, bool> flags;
+	static GLenum flagEnums[];
+
+	GLint viewportX;
+	GLint viewportY;
+	GLsizei viewportW;
+	GLsizei viewportH;
+	/// @}
 };
 
 

+ 22 - 22
anki/gl/TimeQuery.h

@@ -14,28 +14,28 @@ namespace anki {
 /// that it is slow and its not recommended for use in production code.
 class TimeQuery
 {
-	public:
-		TimeQuery();
-		~TimeQuery();
-
-		/// Begin
-		void begin();
-
-		/// End and get elapsed time. In seconds
-		double end();
-
-	private:
-		/// The query state
-		enum State
-		{
-			S_CREATED,
-			S_STARTED,
-			S_ENDED
-		};
-
-		boost::array<GLuint, 2> glIds; ///< GL IDs
-		State state; ///< The query state. It saves us from improper use of the
-		             ///< the class
+public:
+	TimeQuery();
+	~TimeQuery();
+
+	/// Begin
+	void begin();
+
+	/// End and get elapsed time. In seconds
+	double end();
+
+private:
+	/// The query state
+	enum State
+	{
+		S_CREATED,
+		S_STARTED,
+		S_ENDED
+	};
+
+	boost::array<GLuint, 2> glIds; ///< GL IDs
+	/// The query state. It saves us from improper use of the the class
+	State state;
 };
 
 

+ 99 - 103
anki/gl/Vao.h

@@ -18,112 +18,108 @@ class Vbo;
 /// Vertex array object
 class Vao
 {
-	public:
-		/// Default constructor
-		Vao(): glId(0) {}
-
-		/// Destroy VAO from the OpenGL context
-		~Vao();
-
-		/// Accessor
-		uint getGlId() const;
-
-		/// Create
-		void create();
-
-		/// Destroy
-		void destroy();
-
-		/// Attach an array buffer VBO. See @link
-		/// http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml
-		/// @endlink
-		/// @param vbo The VBO to attach
-		/// @param attribVar For the shader attribute location
-		/// @param size Specifies the number of components per generic vertex
-		/// attribute. Must be 1, 2, 3, 4
-		/// @param type GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT etc
-		/// @param normalized Specifies whether fixed-point data values should
-		/// be normalized
-		/// @param stride Specifies the byte offset between consecutive generic
-		/// vertex attributes
-		/// @param pointer Specifies a offset of the first component of the
-		/// first generic vertex attribute in the array
-		void attachArrayBufferVbo(
-			const Vbo& vbo,
-			const ShaderProgramAttributeVariable& attribVar,
-			GLint size,
-			GLenum type,
-			GLboolean normalized,
-			GLsizei stride,
-			const GLvoid* pointer);
-
-		/// Attach an array buffer VBO. See @link
-		/// http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml
-		/// @endlink
-		/// @param vbo The VBO to attach
-		/// @param attribVarLocation Shader attribute location
-		/// @param size Specifies the number of components per generic vertex
-		/// attribute. Must be 1, 2, 3, 4
-		/// @param type GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT etc
-		/// @param normalized Specifies whether fixed-point data values should
-		/// be normalized
-		/// @param stride Specifies the byte offset between consecutive generic
-		/// vertex attributes
-		/// @param pointer Specifies a offset of the first component of the
-		/// first generic vertex attribute in the array
-		void attachArrayBufferVbo(
-			const Vbo& vbo,
-			uint attribVarLocation,
-			GLint size,
-			GLenum type,
-			GLboolean normalized,
-			GLsizei stride,
-			const GLvoid* pointer);
-
-		/// Attach an element array buffer VBO
-		void attachElementArrayBufferVbo(const Vbo& vbo);
-
-		/// Bind it
-		void bind() const
-		{
-			glBindVertexArray(glId);
-		}
-
-		/// Unbind all VAOs
-		static void unbind()
-		{
-			glBindVertexArray(0);
-		}
-
-	private:
-		uint glId; ///< The OpenGL id
-
-		bool isCreated() const {return glId != 0;}
+public:
+	/// Default constructor
+	Vao()
+		: glId(0)
+	{}
+
+	/// Destroy VAO from the OpenGL context
+	~Vao();
+
+	/// Accessor
+	uint getGlId() const
+	{
+		ANKI_ASSERT(isCreated());
+		return glId;
+	}
+
+	/// Create
+	void create()
+	{
+		ANKI_ASSERT(!isCreated());
+		glGenVertexArrays(1, &glId);
+		ANKI_CHECK_GL_ERROR();
+	}
+
+	/// Destroy
+	void destroy()
+	{
+		ANKI_ASSERT(isCreated());
+		glDeleteVertexArrays(1, &glId);
+	}
+
+	/// Attach an array buffer VBO. See @link
+	/// http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml
+	/// @endlink
+	/// @param vbo The VBO to attach
+	/// @param attribVar For the shader attribute location
+	/// @param size Specifies the number of components per generic vertex
+	/// attribute. Must be 1, 2, 3, 4
+	/// @param type GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT etc
+	/// @param normalized Specifies whether fixed-point data values should
+	/// be normalized
+	/// @param stride Specifies the byte offset between consecutive generic
+	/// vertex attributes
+	/// @param pointer Specifies a offset of the first component of the
+	/// first generic vertex attribute in the array
+	void attachArrayBufferVbo(
+		const Vbo& vbo,
+		const ShaderProgramAttributeVariable& attribVar,
+		GLint size,
+		GLenum type,
+		GLboolean normalized,
+		GLsizei stride,
+		const GLvoid* pointer);
+
+	/// Attach an array buffer VBO. See @link
+	/// http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml
+	/// @endlink
+	/// @param vbo The VBO to attach
+	/// @param attribVarLocation Shader attribute location
+	/// @param size Specifies the number of components per generic vertex
+	/// attribute. Must be 1, 2, 3, 4
+	/// @param type GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT etc
+	/// @param normalized Specifies whether fixed-point data values should
+	/// be normalized
+	/// @param stride Specifies the byte offset between consecutive generic
+	/// vertex attributes
+	/// @param pointer Specifies a offset of the first component of the
+	/// first generic vertex attribute in the array
+	void attachArrayBufferVbo(
+		const Vbo& vbo,
+		uint attribVarLocation,
+		GLint size,
+		GLenum type,
+		GLboolean normalized,
+		GLsizei stride,
+		const GLvoid* pointer);
+
+	/// Attach an element array buffer VBO
+	void attachElementArrayBufferVbo(const Vbo& vbo);
+
+	/// Bind it
+	void bind() const
+	{
+		glBindVertexArray(glId);
+	}
+
+	/// Unbind all VAOs
+	static void unbind()
+	{
+		glBindVertexArray(0);
+	}
+
+private:
+	uint glId; ///< The OpenGL id
+
+	bool isCreated() const
+	{
+		return glId != 0;
+	}
 };
 
 
-inline void Vao::create()
-{
-	ANKI_ASSERT(!isCreated());
-	glGenVertexArrays(1, &glId);
-	ANKI_CHECK_GL_ERROR();
-}
-
-
-inline void Vao::destroy()
-{
-	ANKI_ASSERT(isCreated());
-	glDeleteVertexArrays(1, &glId);
-}
-
-
-inline uint Vao::getGlId() const
-{
-	ANKI_ASSERT(isCreated());
-	return glId;
-}
-
-
 } // end namespace
 
 

+ 30 - 39
anki/gl/Vbo.h

@@ -11,48 +11,39 @@ namespace anki {
 /// idiotic errors
 class Vbo: public BufferObject
 {
-	public:
-		Vbo() {}
-
-		/// Adds an extra check in target_ @see BufferObject::BufferObject
-		Vbo(GLenum target_, uint sizeInBytes, const void* dataPtr,
-			GLenum usage_);
-
-		/// Unbinds all VBOs, meaning both GL_ARRAY_BUFFER and
-		/// GL_ELEMENT_ARRAY_BUFFER targets
-		static void unbindAllTargets();
-
-		/// The same as BufferObject::create but it only accepts
-		/// GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER in target
-		/// @see BufferObject::create
-		void create(GLenum target, uint sizeInBytes, const void* dataPtr,
-			GLenum usage);
+public:
+	Vbo()
+	{}
+
+	/// Adds an extra check in target_ @see BufferObject::BufferObject
+	Vbo(GLenum target_, uint sizeInBytes_, const void* dataPtr_,
+		GLenum usage_)
+	{
+		create(target_, sizeInBytes_, dataPtr_, usage_);
+	}
+
+	/// Unbinds all VBOs, meaning both GL_ARRAY_BUFFER and
+	/// GL_ELEMENT_ARRAY_BUFFER targets
+	static void unbindAllTargets()
+	{
+		glBindBufferARB(GL_ARRAY_BUFFER, 0);
+		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
+	}
+
+	/// The same as BufferObject::create but it only accepts
+	/// GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER in target
+	/// @see BufferObject::create
+	void create(GLenum target, uint sizeInBytes, const void* dataPtr,
+		GLenum usage)
+	{
+		// unacceptable target_
+		ANKI_ASSERT(target == GL_ARRAY_BUFFER ||
+			target == GL_ELEMENT_ARRAY_BUFFER);
+		BufferObject::create(target, sizeInBytes, dataPtr, usage);
+	}
 };
 
 
-inline Vbo::Vbo(GLenum target_, uint sizeInBytes_, const void* dataPtr_,
-	GLenum usage_)
-{
-	create(target_, sizeInBytes_, dataPtr_, usage_);
-}
-
-
-inline void Vbo::create(GLenum target_, uint sizeInBytes_,
-	const void* dataPtr_, GLenum usage_)
-{
-	// unacceptable target_
-	ANKI_ASSERT(target_ == GL_ARRAY_BUFFER || target_ == GL_ELEMENT_ARRAY_BUFFER);
-	BufferObject::create(target_, sizeInBytes_, dataPtr_, usage_);
-}
-
-
-inline void Vbo::unbindAllTargets()
-{
-	glBindBufferARB(GL_ARRAY_BUFFER, 0);
-	glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
-}
-
-
 } // end namespace
 
 

+ 1 - 0
anki/renderer/Ez.cpp

@@ -3,6 +3,7 @@
 #include "anki/core/App.h"
 #include "anki/scene/Scene.h"
 #include "anki/renderer/RendererInitializer.h"
+#include <boost/foreach.hpp>
 
 
 namespace anki {

+ 1 - 0
anki/renderer/SceneDrawer.cpp

@@ -9,6 +9,7 @@
 #include "anki/scene/MaterialRuntime.h"
 #include "anki/scene/MaterialRuntimeVariable.h"
 #include "anki/gl/GlStateMachine.h"
+#include <boost/foreach.hpp>
 
 
 namespace anki {

+ 4 - 4
anki/resource/Mesh.h

@@ -20,7 +20,7 @@ class MeshBase
 	public:
 		MeshBase()
 		{
-			pVbo = nVbo = tVbo = vwVbo = NULL;
+			pVbo = nVbo = tVbo = wVbo = NULL;
 		}
 
 		virtual ~MeshBase()
@@ -92,12 +92,12 @@ class MeshBase
 		/// @{
 		bool hasTexCoords() const
 		{
-			return texVbo != NULL;
+			return texVbo.size() > 0;
 		}
 
 		bool hasWeights() const
 		{
-			return vwVbo != NULL;
+			return wVbo != NULL;
 		}
 		/// @}
 
@@ -107,7 +107,7 @@ class MeshBase
 		Vbo* tVbo; ///< Mandatory
 		std::vector<Vbo*> texVbo; ///< Optional. Tex coords per channel
 		std::vector<Vbo*> iVbo; ///< Mandatory. Indices VBO per LOD
-		Vbo* vwVbo; ///< Optional
+		Vbo* wVbo; ///< Optional
 
 		std::vector<uint> idsNum; ///< Indices count per LOD
 		std::vector<uint> vertsNum; ///< Vertex count per LOD

+ 1 - 0
anki/resource/Model.cpp

@@ -9,6 +9,7 @@
 #include "anki/resource/SkelAnim.h"
 #include "anki/resource/MeshData.h"
 #include "anki/resource/Skeleton.h"
+#include <boost/foreach.hpp>
 
 
 namespace anki {

+ 1 - 0
anki/scene/SceneNode.cpp

@@ -3,6 +3,7 @@
 #include "anki/util/Exception.h"
 #include <algorithm>
 #include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
 
 
 namespace anki {