Browse Source

Same as prev

Panagiotis Christopoulos Charitos 13 years ago
parent
commit
dba7502117

+ 10 - 5
include/anki/collision/Aabb.h

@@ -4,10 +4,8 @@
 #include "anki/collision/CollisionShape.h"
 #include "anki/math/Vec3.h"
 
-
 namespace anki {
 
-
 /// @addtogroup Collision
 /// @{
 
@@ -61,6 +59,16 @@ public:
 	}
 	/// @}
 
+	/// @name Operators
+	/// @{
+	Aabb& operator=(const Aabb& b)
+	{
+		min = b.min;
+		max = b.max;
+		return *this;
+	}
+	/// @}
+
 	/// Implements CollisionShape::accept
 	void accept(MutableVisitor& v)
 	{
@@ -107,7 +115,6 @@ private:
 };
 /// @}
 
-
 //==============================================================================
 template<typename Container>
 void Aabb::set(const Container& container)
@@ -135,8 +142,6 @@ void Aabb::set(const Container& container)
 	}
 }
 
-
 } // end namespace
 
-
 #endif

+ 0 - 3
include/anki/collision/CollisionAlgorithmsMatrix.h

@@ -3,10 +3,8 @@
 
 #include "anki/collision/Forward.h"
 
-
 namespace anki {
 
-
 /// @addtogroup Collision
 /// @{
 
@@ -173,7 +171,6 @@ private:
 };
 /// @}
 
-
 } // end namespace
 
 

+ 0 - 6
include/anki/collision/Frustum.h

@@ -7,10 +7,8 @@
 #include "anki/math/Math.h"
 #include <array>
 
-
 namespace anki {
 
-
 /// @addtogroup Collision
 /// @{
 
@@ -119,7 +117,6 @@ private:
 	FrustumType type;
 };
 
-
 /// Frustum shape for perspective cameras
 class PerspectiveFrustum: public Frustum
 {
@@ -221,7 +218,6 @@ private:
 	void recalculate();
 };
 
-
 /// Frustum shape for orthographic cameras
 class OrthographicFrustum: public Frustum
 {
@@ -343,8 +339,6 @@ private:
 };
 /// @}
 
-
 } // end namespace
 
-
 #endif

+ 10 - 4
include/anki/collision/LineSegment.h

@@ -4,10 +4,8 @@
 #include "anki/collision/CollisionShape.h"
 #include "anki/math/Vec3.h"
 
-
 namespace anki {
 
-
 /// @addtogroup Collision
 /// @{
 
@@ -60,6 +58,16 @@ public:
 	}
 	/// @}
 
+	/// @name Operators
+	/// @{
+	LineSegment& operator=(const LineSegment& b)
+	{
+		origin = b.origin;
+		dir = b.dir;
+		return *this;
+	}
+	/// @}
+
 	/// Implements CollisionShape::accept
 	void accept(MutableVisitor& v)
 	{
@@ -94,8 +102,6 @@ private:
 };
 /// @}
 
-
 } // end namespace
 
-
 #endif

+ 11 - 5
include/anki/collision/Obb.h

@@ -5,10 +5,8 @@
 #include "anki/math/Math.h"
 #include <array>
 
-
 namespace anki {
 
-
 /// @addtogroup Collision
 /// @{
 
@@ -69,6 +67,17 @@ public:
 	}
 	/// @}
 
+	/// @name Operators
+	/// @{
+	Obb& operator=(const Obb& b)
+	{
+		center = b.center;
+		rotation = b.rotation;
+		extends = b.extends;
+		return *this;
+	}
+	/// @}
+
 	/// Implements CollisionShape::accept
 	void accept(MutableVisitor& v)
 	{
@@ -117,7 +126,6 @@ public:
 };
 /// @}
 
-
 //==============================================================================
 template<typename Container>
 void Obb::set(const Container& container)
@@ -152,8 +160,6 @@ void Obb::set(const Container& container)
 	extends = max - center;
 }
 
-
 } // end namespace
 
-
 #endif

+ 10 - 4
include/anki/collision/Plane.h

@@ -4,10 +4,8 @@
 #include "anki/collision/CollisionShape.h"
 #include "anki/math/Math.h"
 
-
 namespace anki {
 
-
 /// @addtogroup Collision
 /// @{
 
@@ -73,6 +71,16 @@ public:
 	}
 	/// @}
 
+	/// @name Operators
+	/// @{
+	Plane& operator=(const Plane& b)
+	{
+		normal = b.normal;
+		offset = b.offset;
+		return *this;
+	}
+	/// @}
+
 	/// Implements CollisionShape::accept
 	void accept(MutableVisitor& v)
 	{
@@ -142,8 +150,6 @@ private:
 };
 /// @}
 
-
 } // end namespace
 
-
 #endif

+ 10 - 5
include/anki/collision/Ray.h

@@ -4,10 +4,8 @@
 #include "anki/collision/CollisionShape.h"
 #include "anki/math/Math.h"
 
-
 namespace anki {
 
-
 /// @addtogroup Collision
 /// @{
 
@@ -28,7 +26,6 @@ public:
 		: CollisionShape(CST_RAY), origin(b.origin), dir(b.dir)
 	{}
 
-
 	/// Constructor
 	Ray(const Vec3& origin_, const Vec3& direction_)
 		: CollisionShape(CST_RAY), origin(origin_), dir(direction_)
@@ -64,6 +61,16 @@ public:
 	}
 	/// @}
 
+	/// @name Operators
+	/// @{
+	Ray& operator=(const Ray& b)
+	{
+		origin = b.origin;
+		dir = b.dir;
+		return *this;
+	}
+	/// @}
+
 	/// Implements CollisionShape::accept
 	void accept(MutableVisitor& v)
 	{
@@ -95,8 +102,6 @@ private:
 };
 /// @}
 
-
 } // end namespace
 
-
 #endif

+ 10 - 2
include/anki/collision/Sphere.h

@@ -4,10 +4,8 @@
 #include "anki/collision/CollisionShape.h"
 #include "anki/math/Math.h"
 
-
 namespace anki {
 
-
 /// @addtogroup Collision
 /// @{
 
@@ -63,6 +61,16 @@ public:
 	}
 	/// @}
 
+	/// @name Operators
+	/// @{
+	Sphere& operator=(const Sphere& b)
+	{
+		center = b.center;
+		radius = b.radius;
+		return *this;
+	}
+	/// @}
+
 	/// Implements CollisionShape::accept
 	void accept(MutableVisitor& v)
 	{

+ 26 - 163
include/anki/core/Logger.h

@@ -1,189 +1,53 @@
 #ifndef ANKI_CORE_LOGGER_H
 #define ANKI_CORE_LOGGER_H
 
-#include <boost/array.hpp>
-#include <boost/signals2.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/thread/mutex.hpp>
-
+#include "anki/util/Observer.h"
+#include "anki/util/Singleton.h"
+#include <array>
+#include <mutex>
 
 namespace anki {
 
+/// @addtogroup Core
+/// @{
 
 /// The logger singleton class. The logger cannot print errors or throw
 /// exceptions, it has to recover somehow. Its thread safe
 class Logger
 {
 public:
-	enum MessageType
+	enum LoggerMessageType
 	{
-		MT_NORMAL,
-		MT_ERROR,
-		MT_WARNING
+		LMT_NORMAL,
+		LMT_ERROR,
+		LMT_WARNING
 	};
 
-	/// Record the sender
+	/// XXX
 	struct Info
 	{
 		const char* file;
 		int line;
 		const char* func;
-		MessageType type;
+		LoggerMessageType type;
+		const char* msg;
 	};
 
-	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
+	/// Send a message
 	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();
-	}
+		LoggerMessageType type, const char* msg);
 
-	/// Mutex unlock
-	void unlock()
-	{
-		mutex.unlock();
-	}
+	ANKI_SIGNAL(const Info&, messageRecieved)
 
 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);
+	std::mutex mutex; ///< For thread safety
 };
 
-
-//==============================================================================
-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;
-}
-
+typedef Singleton<Logger> LoggerSingleton;
+/// @}
 
 } // end namespace
 
-
 //==============================================================================
 // Macros                                                                      =
 //==============================================================================
@@ -191,17 +55,16 @@ Logger& Logger::appendUsingLexicalCast(const Type& val)
 #define ANKI_LOGGER_MESSAGE(t, msg) \
 	do \
 	{ \
-		LoggerSingleton::get().lock(); \
-		LoggerSingleton::get()  << Logger::setInfo(__FILE__, \
-			__LINE__, __func__, t) << msg << Logger::endl; \
-		LoggerSingleton::get().unlock(); \
+		std::stringstream ss; \
+		ss << msg; \
+		LoggerSingleton::get().write(__FILE__, __LINE__, __func__, \
+			t, msg.str().c_str()); \
 	} while(false);
 
-#define ANKI_INFO(x) ANKI_LOGGER_MESSAGE(Logger::MT_NORMAL, x)
-
-#define ANKI_WARNING(x) ANKI_LOGGER_MESSAGE(Logger::MT_WARNING, x)
+#define ANKI_INFO(x) ANKI_LOGGER_MESSAGE(Logger::FMT_NORMAL, x)
 
-#define ANKI_ERROR(x) ANKI_LOGGER_MESSAGE(Logger::MT_ERROR, x)
+#define ANKI_WARNING(x) ANKI_LOGGER_MESSAGE(Logger::FMT_WARNING, x)
 
+#define ANKI_ERROR(x) ANKI_LOGGER_MESSAGE(Logger::FMT_ERROR, x)
 
 #endif

+ 21 - 15
include/anki/util/Observer.h

@@ -3,20 +3,20 @@
 
 #include <boost/ptr_container/ptr_vector.hpp>
 
-
 namespace anki {
 
-
 /// The observer interface template
 template<typename T>
 struct Observer
 {
 	typedef T Value; ///< The type of the notification value
 
+	virtual ~Observer()
+	{}
+
 	virtual void notify(Value notificationVal) = 0;
 };
 
-
 /// An over-qualified observer
 template<typename ObservingType, typename Value,
 	void (ObservingType::*method)(Value)>
@@ -34,7 +34,6 @@ struct SuperObserver: Observer<Value>
 	}
 };
 
-
 /// Basically a container of observers
 template<typename T>
 class Observable
@@ -71,33 +70,40 @@ private:
 	Container observers;
 };
 
-
 /// If a class has slots it should include this
+/// @code
+/// class Foo {
+/// 	ANKI_OBSERVING(Foo)
+/// };
+/// @endcode
 #define ANKI_OBSERVING(_class) \
 	typedef _class ObservingType;
 
+/// Define a slot. This should follow the method declaration
+/// @code
+/// class Foo {
+/// 	ANKI_OBSERVING(Foo)
+///
+/// 	void slot(const float&)
+/// 	{...}
+/// 	ANKI_SLOT(updateZFar, const float&)
+/// };
+/// @endcode
+#define ANKI_SLOT(_name, _type) \
+	typedef SuperObserver<ObservingType, _type, &ObservingType::_name> \
+		Observing_##_name;
 
 /// Define a signal
 #define ANKI_SIGNAL(_type, _name) \
 	Observable<_type> _name;
 
-
 /// It doesn't do anything. Its purpose is to make the code more understandable
 #define ANKI_EMIT this->
 
-
-/// Define a slot. This should follow the method declaration
-#define ANKI_SLOT(_name, _type) \
-	typedef SuperObserver<ObservingType, _type, &ObservingType::_name> \
-		Observing_##_name;
-
-
 /// Connect a signal to a slot
 #define ANKI_CONNECT(_sender, _signal, _reveiver, _slot) \
 	 (_sender)->_signal.addNewObserver(new Observing_##_slot(_reveiver))
 
-
 } // namespace anki
 
-
 #endif

+ 0 - 2
include/anki/util/Singleton.h

@@ -6,7 +6,6 @@ namespace anki {
 /// @addtogroup util
 /// @{
 
-//==============================================================================
 /// This template makes a class singleton
 template<typename T>
 class Singleton
@@ -35,7 +34,6 @@ private:
 template <typename T>
 typename Singleton<T>::Value* Singleton<T>::instance = nullptr;
 
-//==============================================================================
 /// This template makes a class singleton with thread local instance
 template<typename T>
 class SingletonThreadSafe

+ 1 - 6
src/collision/Aabb.cpp

@@ -1,12 +1,10 @@
 #include "anki/collision/Aabb.h"
 #include "anki/collision/Plane.h"
 #include "anki/collision/Obb.h"
-#include <boost/array.hpp>
-
+#include <array>
 
 namespace anki {
 
-
 //==============================================================================
 Aabb Aabb::getTransformed(const Transform& transform) const
 {
@@ -25,7 +23,6 @@ Aabb Aabb::getTransformed(const Transform& transform) const
 	return Aabb(newC - newE, newC + newE);
 }
 
-
 //==============================================================================
 float Aabb::testPlane(const Plane& p) const
 {
@@ -66,7 +63,6 @@ float Aabb::testPlane(const Plane& p) const
 	}
 }
 
-
 //==============================================================================
 Aabb Aabb::getCompoundShape(const Aabb& b) const
 {
@@ -81,5 +77,4 @@ Aabb Aabb::getCompoundShape(const Aabb& b) const
 	return out;
 }
 
-
 } // namespace anki

+ 42 - 74
src/collision/CollisionAlgorithmsMatrix.cpp

@@ -4,10 +4,8 @@
 #include "anki/math/Math.h"
 #include <limits>
 
-
 namespace anki {
 
-
 //==============================================================================
 template<typename T>
 bool CollisionAlgorithmsMatrix::tcollide(const CollisionShape& a,
@@ -18,28 +16,27 @@ bool CollisionAlgorithmsMatrix::tcollide(const CollisionShape& a,
 
 	switch(b.getCollisionShapeType())
 	{
-		case CollisionShape::CST_LINE_SEG:
-			out = collide(t, static_cast<const LineSegment&>(b));
-		case CollisionShape::CST_RAY:
-			out = collide(t, static_cast<const Ray&>(b));
-		case CollisionShape::CST_PLANE:
-			out = collide(t, static_cast<const Plane&>(b));
-		case CollisionShape::CST_SPHERE:
-			out = collide(t, static_cast<const Sphere&>(b));
-		case CollisionShape::CST_AABB:
-			out = collide(t, static_cast<const Aabb&>(b));
-		case CollisionShape::CST_OBB:
-			out = collide(t, static_cast<const Obb&>(b));
-		case CollisionShape::CST_FRUSTUM:
-			out = collide(t, static_cast<const Frustum&>(b));
-		default:
-			ANKI_ASSERT(0 && "Forgot something");
+	case CollisionShape::CST_LINE_SEG:
+		out = collide(t, static_cast<const LineSegment&>(b));
+	case CollisionShape::CST_RAY:
+		out = collide(t, static_cast<const Ray&>(b));
+	case CollisionShape::CST_PLANE:
+		out = collide(t, static_cast<const Plane&>(b));
+	case CollisionShape::CST_SPHERE:
+		out = collide(t, static_cast<const Sphere&>(b));
+	case CollisionShape::CST_AABB:
+		out = collide(t, static_cast<const Aabb&>(b));
+	case CollisionShape::CST_OBB:
+		out = collide(t, static_cast<const Obb&>(b));
+	case CollisionShape::CST_FRUSTUM:
+		out = collide(t, static_cast<const Frustum&>(b));
+	default:
+		ANKI_ASSERT(0 && "Forgot something");
 	}
 
 	return out;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const CollisionShape& a,
 	const CollisionShape& b)
@@ -47,28 +44,27 @@ bool CollisionAlgorithmsMatrix::collide(const CollisionShape& a,
 	bool out;
 	switch(a.getCollisionShapeType())
 	{
-		case CollisionShape::CST_LINE_SEG:
-			out = tcollide<LineSegment>(a, b);
-		case CollisionShape::CST_RAY:
-			out = tcollide<Ray>(a, b);
-		case CollisionShape::CST_PLANE:
-			out = tcollide<Plane>(a, b);
-		case CollisionShape::CST_SPHERE:
-			out = tcollide<Sphere>(a, b);
-		case CollisionShape::CST_AABB:
-			out = tcollide<Aabb>(a, b);
-		case CollisionShape::CST_OBB:
-			out = tcollide<Obb>(a, b);
-		case CollisionShape::CST_FRUSTUM:
-			out = tcollide<Frustum>(a, b);
-		default:
-			ANKI_ASSERT(0 && "Forgot something");
+	case CollisionShape::CST_LINE_SEG:
+		out = tcollide<LineSegment>(a, b);
+	case CollisionShape::CST_RAY:
+		out = tcollide<Ray>(a, b);
+	case CollisionShape::CST_PLANE:
+		out = tcollide<Plane>(a, b);
+	case CollisionShape::CST_SPHERE:
+		out = tcollide<Sphere>(a, b);
+	case CollisionShape::CST_AABB:
+		out = tcollide<Aabb>(a, b);
+	case CollisionShape::CST_OBB:
+		out = tcollide<Obb>(a, b);
+	case CollisionShape::CST_FRUSTUM:
+		out = tcollide<Frustum>(a, b);
+	default:
+		ANKI_ASSERT(0 && "Forgot something");
 	}
 
 	return out;
 }
 
-
 //==============================================================================
 // 1st row                                                                     =
 //==============================================================================
@@ -80,7 +76,6 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& /*a*/, const Ls& /*b*/)
 	return false;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Obb& obb)
 {
@@ -143,21 +138,18 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Obb& obb)
 	return true;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Ls& a, const Frustum& b)
 {
 	return b.insideFrustum(a);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Plane& p)
 {
 	return ls.testPlane(p) == 0.0;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Ls& /*a*/, const Ray& /*b*/)
 {
@@ -165,7 +157,6 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& /*a*/, const Ray& /*b*/)
 	return false;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Sphere& s)
 {
@@ -192,7 +183,6 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Sphere& s)
 	return tmp.getLengthSquared() <= rsq;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Aabb& aabb)
 {
@@ -206,8 +196,8 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Aabb& aabb)
 		if(Math::isZero(ls.getDirection()[i]))
 		{
 			// segment passes by box
-			if(ls.getOrigin()[i] < aabb.getMin()[i] ||
-			   ls.getOrigin()[i] > aabb.getMax()[i])
+			if(ls.getOrigin()[i] < aabb.getMin()[i] 
+				|| ls.getOrigin()[i] > aabb.getMax()[i])
 			{
 				return false;
 			}
@@ -215,10 +205,10 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Aabb& aabb)
 		else
 		{
 			// compute intersection parameters and sort
-			float s = (aabb.getMin()[i] - ls.getOrigin()[i]) /
-				ls.getDirection()[i];
-			float t = (aabb.getMax()[i] - ls.getOrigin()[i]) /
-				ls.getDirection()[i];
+			float s = (aabb.getMin()[i] - ls.getOrigin()[i]) 
+				/ ls.getDirection()[i];
+			float t = (aabb.getMax()[i] - ls.getOrigin()[i]) 
+				/ ls.getDirection()[i];
 			if(s > t)
 			{
 				float temp = s;
@@ -248,7 +238,6 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Aabb& aabb)
 	return true;
 }
 
-
 //==============================================================================
 // 2nd row                                                                     =
 //==============================================================================
@@ -284,8 +273,8 @@ bool CollisionAlgorithmsMatrix::collide(const Obb& o0, const Obb& o1)
 	}
 
 	// relative translation (in A's frame)
-	Vec3 c = o0.getRotation().getTransposed() *
-		(o1.getCenter() - o0.getCenter());
+	Vec3 c = o0.getRotation().getTransposed() 
+		* (o1.getCenter() - o0.getCenter());
 
 	// separating axis A0
 	cTest = fabs(c.x());
@@ -432,21 +421,18 @@ bool CollisionAlgorithmsMatrix::collide(const Obb& o0, const Obb& o1)
 	return true;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Obb& a, const Frustum& b)
 {
 	return b.insideFrustum(a);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Obb& a, const Plane& b)
 {
 	return a.testPlane(b) == 0.0;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Obb& obb, const Ray& r)
 {
@@ -460,19 +446,17 @@ bool CollisionAlgorithmsMatrix::collide(const Obb& obb, const Ray& r)
 	return collide(newray, aabb_);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Obb& obb, const Sphere& s)
 {
 	Aabb aabb_(-obb.getExtend(), obb.getExtend()); // aabb_ is in "this" frame
-	Vec3 newCenter = obb.getRotation().getTransposed() *
-		(s.getCenter() - obb.getCenter());
+	Vec3 newCenter = obb.getRotation().getTransposed() 
+		* (s.getCenter() - obb.getCenter());
 	Sphere sphere_(newCenter, s.getRadius()); // sphere1 to "this" fame
 
 	return collide(sphere_, aabb_);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Obb& obb, const Aabb& aabb)
 {
@@ -483,7 +467,6 @@ bool CollisionAlgorithmsMatrix::collide(const Obb& obb, const Aabb& aabb)
 	return collide(obb, obb_);
 }
 
-
 //==============================================================================
 // 3rd line (PCS)                                                              =
 //==============================================================================
@@ -494,35 +477,30 @@ bool CollisionAlgorithmsMatrix::collide(const Frustum& a, const Frustum& b)
 	return b.insideFrustum(a);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Frustum& a, const Plane& b)
 {
 	return a.insideFrustum(b);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Frustum& a, const Ray& b)
 {
 	return a.insideFrustum(b);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Frustum& a, const Sphere& b)
 {
 	return a.insideFrustum(b);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Frustum& a, const Aabb& b)
 {
 	return a.insideFrustum(b);
 }
 
-
 //==============================================================================
 // 4th line (P)                                                                =
 //==============================================================================
@@ -533,28 +511,24 @@ bool CollisionAlgorithmsMatrix::collide(const Plane& p0, const Plane& p1)
 	return p0.getNormal() != p1.getNormal();
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Plane& p, const Ray& r)
 {
 	return r.testPlane(p) == 0.0;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Plane& p, const Sphere& s)
 {
 	return s.testPlane(p) == 0.0;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Plane& p, const Aabb& aabb)
 {
 	return aabb.testPlane(p) == 0.0;
 }
 
-
 //==============================================================================
 // 5th line (R)                                                                =
 //==============================================================================
@@ -566,7 +540,6 @@ bool CollisionAlgorithmsMatrix::collide(const Ray& a, const Ray& b)
 	return false;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Ray& r, const Sphere& s)
 {
@@ -586,7 +559,6 @@ bool CollisionAlgorithmsMatrix::collide(const Ray& r, const Sphere& s)
 	return (vsq * wsq - proj * proj <= vsq * rsq);
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Ray& r, const Aabb& aabb)
 {
@@ -643,7 +615,6 @@ bool CollisionAlgorithmsMatrix::collide(const Ray& r, const Aabb& aabb)
 	return true;
 }
 
-
 //==============================================================================
 // 6th line (S)                                                                =
 //==============================================================================
@@ -655,7 +626,6 @@ bool CollisionAlgorithmsMatrix::collide(const Sphere& a, const Sphere& b)
 	return (a.getCenter() - b.getCenter()).getLengthSquared() <= tmp * tmp;
 }
 
-
 //==============================================================================
 bool CollisionAlgorithmsMatrix::collide(const Sphere& s, const Aabb& aabb)
 {
@@ -697,7 +667,6 @@ bool CollisionAlgorithmsMatrix::collide(const Sphere& s, const Aabb& aabb)
 	return false;
 }
 
-
 //==============================================================================
 // 7th line (AABB)                                                             =
 //==============================================================================
@@ -727,5 +696,4 @@ bool CollisionAlgorithmsMatrix::collide(const Aabb& a, const Aabb& b)
 	return true;
 }
 
-
 } // end namespace

+ 0 - 16
src/collision/Frustum.cpp

@@ -2,10 +2,8 @@
 #include "anki/collision/LineSegment.h"
 #include "anki/collision/Aabb.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 // Frustum                                                                     =
 //==============================================================================
@@ -19,7 +17,6 @@ Frustum& Frustum::operator=(const Frustum& b)
 	return *this;
 }
 
-
 //==============================================================================
 bool Frustum::insideFrustum(const CollisionShape& b) const
 {
@@ -34,7 +31,6 @@ bool Frustum::insideFrustum(const CollisionShape& b) const
 	return true;
 }
 
-
 //==============================================================================
 void Frustum::transform(const Transform& trf)
 {
@@ -45,7 +41,6 @@ void Frustum::transform(const Transform& trf)
 	}
 }
 
-
 //==============================================================================
 // PerspectiveFrustum                                                          =
 //==============================================================================
@@ -61,7 +56,6 @@ PerspectiveFrustum& PerspectiveFrustum::operator=(const PerspectiveFrustum& b)
 	return *this;
 }
 
-
 //==============================================================================
 float PerspectiveFrustum::testPlane(const Plane& p) const
 {
@@ -89,7 +83,6 @@ float PerspectiveFrustum::testPlane(const Plane& p) const
 	return o;
 }
 
-
 //==============================================================================
 void PerspectiveFrustum::transform(const Transform& trf)
 {
@@ -103,7 +96,6 @@ void PerspectiveFrustum::transform(const Transform& trf)
 	}
 }
 
-
 //==============================================================================
 void PerspectiveFrustum::getAabb(Aabb& aabb) const
 {
@@ -112,7 +104,6 @@ void PerspectiveFrustum::getAabb(Aabb& aabb) const
 	aabb.getMax() += eye;
 }
 
-
 //==============================================================================
 void PerspectiveFrustum::recalculate()
 {
@@ -151,7 +142,6 @@ void PerspectiveFrustum::recalculate()
 	dirs[3] = Vec3(x, -y, z - zNear); // bottom right
 }
 
-
 //==============================================================================
 Mat4 PerspectiveFrustum::calculateProjectionMatrix() const
 {
@@ -179,7 +169,6 @@ Mat4 PerspectiveFrustum::calculateProjectionMatrix() const
 	return projectionMat;
 }
 
-
 //==============================================================================
 // OrthographicFrustum                                                         =
 //==============================================================================
@@ -204,7 +193,6 @@ float OrthographicFrustum::testPlane(const Plane& p) const
 	return obb.testPlane(p);
 }
 
-
 //==============================================================================
 void OrthographicFrustum::transform(const Transform& trf)
 {
@@ -212,14 +200,12 @@ void OrthographicFrustum::transform(const Transform& trf)
 	obb.transform(trf);
 }
 
-
 //==============================================================================
 void OrthographicFrustum::getAabb(Aabb& aabb) const
 {
 	obb.getAabb(aabb);
 }
 
-
 //==============================================================================
 Mat4 OrthographicFrustum::calculateProjectionMatrix() const
 {
@@ -251,7 +237,6 @@ Mat4 OrthographicFrustum::calculateProjectionMatrix() const
 	return m;
 }
 
-
 //==============================================================================
 void OrthographicFrustum::recalculate()
 {
@@ -271,5 +256,4 @@ void OrthographicFrustum::recalculate()
 	obb = Obb(c, Mat3::getIdentity(), e);
 }
 
-
 } // end namespace

+ 0 - 5
src/collision/LineSegment.cpp

@@ -3,10 +3,8 @@
 #include "anki/collision/Aabb.h"
 #include <algorithm>
 
-
 namespace anki {
 
-
 //==============================================================================
 float LineSegment::testPlane(const Plane& p) const
 {
@@ -41,7 +39,6 @@ float LineSegment::testPlane(const Plane& p) const
 	}
 }
 
-
 //==============================================================================
 LineSegment LineSegment::getTransformed(const Transform& transform) const
 {
@@ -51,7 +48,6 @@ LineSegment LineSegment::getTransformed(const Transform& transform) const
 	return out;
 }
 
-
 //==============================================================================
 void LineSegment::getAabb(Aabb& aabb) const
 {
@@ -72,5 +68,4 @@ void LineSegment::getAabb(Aabb& aabb) const
 	aabb.setMax(max);
 }
 
-
 } // end namespace

+ 1 - 10
src/collision/Obb.cpp

@@ -2,10 +2,8 @@
 #include "anki/collision/Plane.h"
 #include "anki/collision/Aabb.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 Obb::Obb(const Obb& b)
 	: CollisionShape(CST_OBB), center(b.center), rotation(b.rotation),
@@ -16,9 +14,7 @@ Obb::Obb(const Obb& b)
 Obb::Obb(const Vec3& center_, const Mat3& rotation_, const Vec3& extends_)
 	: CollisionShape(CST_OBB), center(center_), rotation(rotation_),
 		extends(extends_)
-{
-}
-
+{}
 
 //==============================================================================
 float Obb::testPlane(const Plane& p) const
@@ -49,7 +45,6 @@ float Obb::testPlane(const Plane& p) const
 	}
 }
 
-
 //==============================================================================
 Obb Obb::getTransformed(const Transform& transform) const
 {
@@ -60,7 +55,6 @@ Obb Obb::getTransformed(const Transform& transform) const
 	return out;
 }
 
-
 //==============================================================================
 Obb Obb::getCompoundShape(const Obb& b) const
 {
@@ -83,7 +77,6 @@ Obb Obb::getCompoundShape(const Obb& b) const
 	return out;
 }
 
-
 //==============================================================================
 void Obb::getExtremePoints(std::array<Vec3, 8>& points) const
 {
@@ -126,7 +119,6 @@ void Obb::getExtremePoints(std::array<Vec3, 8>& points) const
 	}
 }
 
-
 //==============================================================================
 void Obb::getAabb(Aabb& aabb) const
 {
@@ -141,5 +133,4 @@ void Obb::getAabb(Aabb& aabb) const
 	aabb = Aabb(center - newE, center + newE);
 }
 
-
 } // end namespace

+ 0 - 9
src/collision/Plane.cpp

@@ -1,22 +1,18 @@
 #include "anki/collision/Plane.h"
 #include "anki/util/Assert.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 Plane::Plane(const Plane& b)
 	: CollisionShape(CST_PLANE), normal(b.normal), offset(b.offset)
 {}
 
-
 //==============================================================================
 Plane::Plane(const Vec3& normal_, float offset_)
 	: CollisionShape(CST_PLANE), normal(normal_), offset(offset_)
 {}
 
-
 //==============================================================================
 float Plane::testPlane(const Plane& /*p*/) const
 {
@@ -24,7 +20,6 @@ float Plane::testPlane(const Plane& /*p*/) const
 	return 0.0;
 }
 
-
 //==============================================================================
 void Plane::setFrom3Points(const Vec3& p0, const Vec3& p1, const Vec3& p2)
 {
@@ -41,7 +36,6 @@ void Plane::setFrom3Points(const Vec3& p0, const Vec3& p1, const Vec3& p2)
 	offset = normal.dot(p0); // XXX: correct??
 }
 
-
 //==============================================================================
 void Plane::setFromPlaneEquation(float a, float b, float c, float d)
 {
@@ -64,7 +58,6 @@ void Plane::setFromPlaneEquation(float a, float b, float c, float d)
 	}
 }
 
-
 //==============================================================================
 Plane Plane::getTransformed(const Transform& trf) const
 {
@@ -80,12 +73,10 @@ Plane Plane::getTransformed(const Transform& trf) const
 	return plane;
 }
 
-
 //==============================================================================
 void Plane::getAabb(Aabb&) const
 {
 	ANKI_ASSERT(0 && "Can't do that");
 }
 
-
 } // end namespace

+ 0 - 5
src/collision/Ray.cpp

@@ -1,10 +1,8 @@
 #include "anki/collision/Ray.h"
 #include "anki/collision/Plane.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 Ray Ray::getTransformed(const Transform& transform) const
 {
@@ -14,7 +12,6 @@ Ray Ray::getTransformed(const Transform& transform) const
 	return out;
 }
 
-
 //==============================================================================
 float Ray::testPlane(const Plane& p) const
 {
@@ -46,12 +43,10 @@ float Ray::testPlane(const Plane& p) const
 	}
 }
 
-
 //==============================================================================
 void Ray::getAabb(Aabb&) const
 {
 	ANKI_ASSERT(0 && "Can't do that");
 }
 
-
 } // end namespace

+ 0 - 6
src/collision/Sphere.cpp

@@ -2,10 +2,8 @@
 #include "anki/collision/Plane.h"
 #include "anki/collision/Aabb.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 float Sphere::testPlane(const Plane& p) const
 {
@@ -26,7 +24,6 @@ float Sphere::testPlane(const Plane& p) const
 	}
 }
 
-
 //==============================================================================
 Sphere Sphere::getTransformed(const Transform& transform) const
 {
@@ -41,7 +38,6 @@ Sphere Sphere::getTransformed(const Transform& transform) const
 	return newSphere;
 }
 
-
 //==============================================================================
 Sphere Sphere::getCompoundShape(const Sphere& b) const
 {
@@ -95,7 +91,6 @@ Sphere Sphere::getCompoundShape(const Sphere& b) const
 	return Sphere((ca + cb) / 2.0, (ca - cb).getLength() / 2.0);
 }
 
-
 //==============================================================================
 void Sphere::getAabb(Aabb& aabb) const
 {
@@ -103,5 +98,4 @@ void Sphere::getAabb(Aabb& aabb) const
 	aabb.setMax(center + radius);
 }
 
-
 } // end namespace

+ 7 - 131
src/core/Logger.cpp

@@ -1,142 +1,18 @@
-#include <cstring>
 #include "anki/core/Logger.h"
-
+#include <cstring>
 
 namespace anki {
 
-
 //==============================================================================
-// operator<< [const void*]                                                    =
-//==============================================================================
-Logger& Logger::operator<<(const void* val)
+void Logger::write(const char* file, int line, const char* func,
+	LoggerMessageType type, const char* msg)
 {
-	return appendUsingLexicalCast(val);
-}
+	mutex.lock();
 
+	Info inf = {file, line, func, type, msg};
+	ANKI_EMIT messageRecieved(inf);
 
-//==============================================================================
-// operator<< [const char*]                                                    =
-//==============================================================================
-Logger& Logger::operator<<(const char* val)
-{
-	append(val, strlen(val));
-	return *this;
-}
-
-
-//==============================================================================
-// operator<< [std::string]                                                    =
-//==============================================================================
-Logger& Logger::operator<<(const std::string& val)
-{
-	append(val.c_str(), val.length());
-	return *this;
+	mutex.unlock();
 }
 
-
-//==============================================================================
-// operator<< [Logger& (*funcPtr)(Logger&)]                                    =
-//==============================================================================
-Logger& Logger::operator<<(Logger& (*funcPtr)(Logger&))
-{
-	if(funcPtr == endl)
-	{
-		append("\n", 1);
-		realFlush();
-	}
-	else if(funcPtr == flush)
-	{
-		realFlush();
-	}
-
-	return *this;
-}
-
-
-//==============================================================================
-// operator<< [Info]                                                           =
-//==============================================================================
-Logger& Logger::operator<<(const Info& sender)
-{
-	file = sender.file;
-	line = sender.line;
-	func = sender.func;
-	type = sender.type;
-	return *this;
-}
-
-
-//==============================================================================
-// write                                                                       =
-//==============================================================================
-void Logger::write(const char* file_, int line_, const char* func_,
-	MessageType type_, const char* msg)
-{
-	file = file_;
-	line = line_;
-	func = func_;
-	type = type_;
-	append(msg, strlen(msg));
-	realFlush();
-}
-
-
-//==============================================================================
-// execCommonConstructionCode                                                  =
-//==============================================================================
-void Logger::execCommonConstructionCode()
-{
-	sptr = &streamBuf[0];
-	memset(sptr, '?', STREAM_SIZE);
-	func = file = "error";
-	line = -1;
-}
-
-
-//==============================================================================
-// append                                                                      =
-//==============================================================================
-void Logger::append(const char* cstr, int len)
-{
-	if(len > STREAM_SIZE - 1)
-	{
-		const char ERR[] = "**logger buffer overflow**";
-		cstr = ERR;
-		len = sizeof(ERR);
-	}
-
-	int charsLeft = &streamBuf[STREAM_SIZE - 1] - sptr; // Leaving an extra
-	                                                    // char for the '\0'
-
-	// Overflow
-	if(len > charsLeft)
-	{
-		// Handle overflow
-		memcpy(sptr, cstr, charsLeft);
-		sptr += charsLeft;
-		realFlush();
-		append(cstr + charsLeft, len - charsLeft);
-		return;
-	}
-
-	memcpy(sptr, cstr, len);
-	sptr += len;
-}
-
-
-//==============================================================================
-// realFlush                                                                   =
-//==============================================================================
-void Logger::realFlush()
-{
-	*sptr = '\0';
-	sig(file, line, func, type, &streamBuf[0]);
-
-	// Reset
-	sptr = &streamBuf[0];
-	func = file = "error";
-	line = -1;
-}
-
-
 } // end namespace