瀏覽代碼

Many bug fixes and changes

Panagiotis Christopoulos Charitos 13 年之前
父節點
當前提交
7c2b56c44f

+ 18 - 7
include/anki/collision/Frustum.h

@@ -93,11 +93,14 @@ public:
 	/// Calculate the projection matrix
 	virtual Mat4 calculateProjectionMatrix() const = 0;
 
+	/// XXX
+	virtual void setTransform(const Transform& trf) = 0;
+
 protected:
 	/// @name Viewing variables
 	/// @{
-	float near;
-	float far;
+	float near = 0.0;
+	float far = 0.0;
 	/// @}
 
 	/// Used to check against the frustum
@@ -201,6 +204,9 @@ public:
 	/// Re-implements Frustum::transform
 	void transform(const Transform& trf);
 
+	/// Implements Frustum::setTransform
+	void setTransform(const Transform& trf);
+
 	/// Implements Frustum::calculateProjectionMatrix
 	Mat4 calculateProjectionMatrix() const;
 
@@ -210,8 +216,8 @@ public:
 private:
 	/// @name Viewing variables
 	/// @{
-	float fovX;
-	float fovY;
+	float fovX = 0.0;
+	float fovY = 0.0;
 	/// @}
 
 	/// @name Shape
@@ -220,8 +226,10 @@ private:
 	std::array<Vec3, 4> dirs; ///< Directions
 	/// @}
 
-	/// Implements CollisionShape::recalculate. Recalculate @a planes, @a eye
-	/// and @a dirs
+	/// Implements CollisionShape::recalculate. Recalculate:
+	/// @li planes
+	/// @li eye
+	/// @li dirs
 	void recalculate();
 
 	/// Transform the @a eye and @a dirs using @a Frustrum::trf
@@ -330,6 +338,9 @@ public:
 	/// Override Frustum::transform
 	void transform(const Transform& trf);
 
+	/// Implements Frustum::setTransform
+	void setTransform(const Transform& trf);
+
 	/// Implements CollisionShape::getAabb
 	void getAabb(Aabb& aabb) const
 	{
@@ -350,7 +361,7 @@ public:
 private:
 	/// @name Viewing variables
 	/// @{
-	float left, right, top, bottom;
+	float left = 0.0, right = 0.0, top = 0.0, bottom = 0.0;
 	/// @}
 
 	/// @name Shape

+ 7 - 0
include/anki/gl/Fbo.h

@@ -71,6 +71,13 @@ private:
 		return glId != 0;
 	}
 
+	static GLuint getCurrentFboGlId()
+	{
+		GLint i;
+		glGetIntegerv(GL_FRAMEBUFFER_BINDING, &i);
+		return i;
+	}
+
 	static GLuint getCurrentDrawFboGlId()
 	{
 		GLint i;

+ 8 - 7
include/anki/gl/Texture.h

@@ -165,7 +165,8 @@ public:
 	/// @{
 
 	/// Default constructor
-	Texture();
+	Texture()
+	{}
 
 	Texture(const Initializer& init)
 	{
@@ -242,12 +243,12 @@ public:
 	void genMipmap();
 
 private:
-	GLuint glId; ///< Identification for OGL
-	GLuint target; ///< GL_TEXTURE_2D, GL_TEXTURE_3D... etc
-	GLuint internalFormat; ///< GL_COMPRESSED_RED, GL_RGB16 etc
-	GLuint format; ///< GL_RED, GL_RG, GL_RGB etc
-	GLuint type; ///< GL_UNSIGNED_BYTE, GL_BYTE etc
-	GLuint width, height;
+	GLuint glId = 0; ///< Identification for OGL
+	GLuint target = 0; ///< GL_TEXTURE_2D, GL_TEXTURE_3D... etc
+	GLuint internalFormat = 0; ///< GL_COMPRESSED_RED, GL_RGB16 etc
+	GLuint format = 0; ///< GL_RED, GL_RG, GL_RGB etc
+	GLuint type = 0; ///< GL_UNSIGNED_BYTE, GL_BYTE etc
+	GLuint width = 0, height = 0;
 
 	bool isCreated() const
 	{

+ 2 - 0
include/anki/math/Mat3.h

@@ -120,6 +120,8 @@ private:
 	{
 		std::array<float, 9> arr1;
 		std::array<std::array<float, 3>, 3> arr2;
+		float carr1[9]; ///< For gdb
+		float carr2[3][3]; ///< For gdb
 	};
 	/// @}
 };

+ 2 - 0
include/anki/math/Mat4.h

@@ -124,6 +124,8 @@ private:
 	{
 		std::array<float, 16> arr1;
 		std::array<std::array<float, 4>, 4> arr2;
+		float carr1[16]; ///< For gdb
+		float carr2[4][4]; ///< For gdb
 #if defined(ANKI_MATH_INTEL_SIMD)
 		std::array<__m128, 4> arrMm;
 #endif

+ 67 - 121
include/anki/scene/Camera.h

@@ -5,6 +5,7 @@
 #include "anki/scene/Spatial.h"
 #include "anki/scene/Movable.h"
 #include "anki/scene/Frustumable.h"
+#include "anki/core/Logger.h"
 
 namespace anki {
 
@@ -12,8 +13,7 @@ namespace anki {
 /// @{
 
 /// Camera SceneNode interface class
-class Camera: public SceneNode, public Movable, public Spatial,
-	public Frustumable
+class Camera: public SceneNode, public Movable, public Spatial
 {
 public:
 	/// @note Don't EVER change the order
@@ -29,9 +29,9 @@ public:
 	Camera(CameraType type_,
 		const char* name, Scene* scene, // SceneNode
 		uint movableFlags, Movable* movParent, // Movable
-		Frustum* frustum) // Spatial &  Frustumable
+		Frustum* frustum) // Spatial
 		: SceneNode(name, scene), Movable(movableFlags, movParent, *this),
-			Spatial(frustum), Frustumable(frustum), type(type_)
+			Spatial(frustum), type(type_)
 	{}
 
 	virtual ~Camera();
@@ -59,25 +59,10 @@ public:
 		return viewMat;
 	}
 
-	float getNear() const
-	{
-		return frustum->getNear();
-	}
-	void setNear(float x)
-	{
-		frustum->setNear(x);
-		frustumUpdate();
-	}
-
-	float getFar() const
-	{
-		return frustum->getFar();
-	}
-	void setFar(float x)
-	{
-		frustum->setFar(x);
-		frustumUpdate();
-	}
+	/// Needed by the renderer
+	virtual float getNear() const = 0;
+	/// Needed by the renderer
+	virtual float getFar() const = 0;
 	/// @}
 
 	/// @name SceneNode virtuals
@@ -89,12 +74,6 @@ public:
 		return this;
 	}
 
-	/// Override SceneNode::getFrustumable()
-	Frustumable* getFrustumable()
-	{
-		return this;
-	}
-
 	/// Override SceneNode::getSpatial()
 	Spatial* getSpatial()
 	{
@@ -105,37 +84,13 @@ public:
 	void frameUpdate(float prevUpdateTime, float crntTime, int frame)
 	{
 		SceneNode::frameUpdate(prevUpdateTime, crntTime, frame);
-		Movable::update();
-	}
-	/// @}
-
-	/// @name Frustumable virtuals
-	/// @{
-
-	/// Implements Frustumable::frustumUpdate(). Calculate the projection
-	/// matrix
-	void frustumUpdate()
-	{
-		projectionMat = getFrustum().calculateProjectionMatrix();
-		invProjectionMat = projectionMat.getInverse();
 	}
 	/// @}
 
 	void lookAtPoint(const Vec3& point);
 
 protected:
-	/// Calculate the @a viewMat. The view matrix is the inverse world 
-	/// transformation
-	void updateViewMatrix()
-	{
-		viewMat = Mat4(getWorldTransform().getInverse());
-	}
-
-private:
-	/// @name Matrices
-	/// @{
 	Mat4 projectionMat;
-	Mat4 viewMat;
 
 	/// Used in deferred shading for the calculation of view vector (see
 	/// CalcViewVector). The reason we store this matrix here is that we
@@ -144,13 +99,22 @@ private:
 	/// the projection params change rarely. Note that the Camera as we all
 	/// know re-calculates the matrices only when the parameters change!!
 	Mat4 invProjectionMat;
-	/// @}
+
+	/// Calculate the @a viewMat. The view matrix is the inverse world 
+	/// transformation
+	void updateViewMatrix()
+	{
+		viewMat = Mat4(getWorldTransform().getInverse());
+	}
+
+private:
+	Mat4 viewMat;
 
 	CameraType type;
 };
 
 /// Perspective camera
-class PerspectiveCamera: public Camera
+class PerspectiveCamera: public Camera, public PerspectiveFrustumable
 {
 public:
 	ANKI_HAS_SLOTS(PerspectiveCamera)
@@ -161,32 +125,23 @@ public:
 		uint movableFlags, Movable* movParent);
 	/// @}
 
-	/// @name Accessors
-	/// @{
-	float getFovX() const
+	float getNear() const
 	{
-		return frustumLocal.getFovX();
-	}
-	void setFovX(float ang)
-	{
-		frustumLocal.setFovX(ang);
-		frustumUpdate();
+		return frustum.getNear();
 	}
 
-	float getFovY() const
-	{
-		return frustumLocal.getFovY();
-	}
-	void setFovY(float ang)
+	float getFar() const
 	{
-		frustumLocal.setFovX(ang);
-		frustumUpdate();
+		return frustum.getFar();
 	}
 
-	void setAll(float fovX_, float fovY_, float zNear_, float zFar_)
+	/// @name SceneNode virtuals
+	/// @{
+
+	/// Override SceneNode::getFrustumable()
+	Frustumable* getFrustumable()
 	{
-		frustumLocal.setAll(fovX_, fovY_, zNear_, zFar_);
-		frustumUpdate();
+		return this;
 	}
 	/// @}
 
@@ -200,13 +155,24 @@ public:
 	{
 		Movable::movableUpdate();
 		updateViewMatrix();
-		frustumWorld = frustumLocal.getTransformed(getWorldTransform());
+		frustum.setTransform(getWorldTransform());
+	}
+	/// @}
+
+	/// @name Frustumable virtuals
+	/// @{
+
+	/// Implements Frustumable::frustumUpdate(). Calculate the projection
+	/// matrix
+	void frustumUpdate()
+	{
+		projectionMat = frustum.calculateProjectionMatrix();
+		invProjectionMat = projectionMat.getInverse();
 	}
 	/// @}
 
 private:
-	PerspectiveFrustum frustumLocal;
-	PerspectiveFrustum frustumWorld;
+	PerspectiveFrustum frustum;
 
 	/// Called when the property changes
 	void updateFrustumSlot(const PerspectiveFrustum&)
@@ -217,7 +183,7 @@ private:
 };
 
 /// Orthographic camera
-class OrthographicCamera: public Camera
+class OrthographicCamera: public Camera, public OrthographicFrustumable
 {
 public:
 	ANKI_HAS_SLOTS(OrthographicCamera)
@@ -228,54 +194,23 @@ public:
 		uint movableFlags, Movable* movParent);
 	/// @}
 
-	/// @name Accessors
-	/// @{
-	float getLeft() const
-	{
-		return frustumLocal.getLeft();
-	}
-	void setLeft(float f)
-	{
-		frustumLocal.setLeft(f);
-		frustumUpdate();
-	}
-
-	float getRight() const
-	{
-		return frustumLocal.getRight();
-	}
-	void setRight(float f)
+	float getNear() const
 	{
-		frustumLocal.setRight(f);
-		frustumUpdate();
+		return frustum.getNear();
 	}
 
-	float getTop() const
-	{
-		return frustumLocal.getTop();
-	}
-	void setTop(float f)
+	float getFar() const
 	{
-		frustumLocal.setTop(f);
-		frustumUpdate();
+		return frustum.getFar();
 	}
 
-	float getBottom() const
-	{
-		return frustumLocal.getBottom();
-	}
-	void setBottom(float f)
-	{
-		frustumLocal.setBottom(f);
-		frustumUpdate();
-	}
+	/// @name SceneNode virtuals
+	/// @{
 
-	/// Set all
-	void setAll(float left_, float right_, float zNear_,
-		float zFar_, float top_, float bottom_)
+	/// Override SceneNode::getFrustumable()
+	Frustumable* getFrustumable()
 	{
-		frustumLocal.setAll(left_, right_, zNear_, zFar_, top_, bottom_);
-		frustumUpdate();
+		return this;
 	}
 	/// @}
 
@@ -289,13 +224,24 @@ public:
 	{
 		Movable::movableUpdate();
 		updateViewMatrix();
-		frustumWorld = frustumLocal.getTransformed(getWorldTransform());
+		frustum.setTransform(getWorldTransform());
+	}
+	/// @}
+
+	/// @name Frustumable virtuals
+	/// @{
+
+	/// Implements Frustumable::frustumUpdate(). Calculate the projection
+	/// matrix
+	void frustumUpdate()
+	{
+		projectionMat = frustum.calculateProjectionMatrix();
+		invProjectionMat = projectionMat.getInverse();
 	}
 	/// @}
 
 private:
-	OrthographicFrustum frustumLocal;
-	OrthographicFrustum frustumWorld;
+	OrthographicFrustum frustum;
 
 	void updateFrustumSlot(const OrthographicFrustum&)
 	{

+ 129 - 0
include/anki/scene/Frustumable.h

@@ -67,6 +67,135 @@ protected:
 	Frustum* frustum;
 };
 
+/// Perspective prustumable interface for scene nodes
+class PerspectiveFrustumable: public Frustumable
+{
+public:
+	/// @name Constructors
+	/// @{
+
+	/// Pass the frustum here so we can avoid the virtuals
+	PerspectiveFrustumable(PerspectiveFrustum* fr)
+		: Frustumable(fr)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float getFovX() const
+	{
+		return get().getFovX();
+	}
+	void setFovX(float ang)
+	{
+		get().setFovX(ang);
+		frustumUpdate();
+	}
+
+	float getFovY() const
+	{
+		return get().getFovY();
+	}
+	void setFovY(float ang)
+	{
+		get().setFovY(ang);
+		frustumUpdate();
+	}
+
+	/// Set all the parameters and recalculate the planes and shape
+	void setAll(float fovX_, float fovY_, float near_, float far_)
+	{
+		get().setAll(fovX_, fovY_, near_, far_);
+		frustumUpdate();
+	}
+	/// @}
+
+private:
+	PerspectiveFrustum& get()
+	{
+		return *static_cast<PerspectiveFrustum*>(frustum);
+	}
+	const PerspectiveFrustum& get() const
+	{
+		return *static_cast<const PerspectiveFrustum*>(frustum);
+	}
+};
+
+/// Orthographic prustumable interface for scene nodes
+class OrthographicFrustumable: public Frustumable
+{
+public:
+	/// @name Constructors
+	/// @{
+
+	/// Pass the frustum here so we can avoid the virtuals
+	OrthographicFrustumable(OrthographicFrustum* fr)
+		: Frustumable(fr)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float getLeft() const
+	{
+		return get().getLeft();
+	}
+	void setLeft(float f)
+	{
+		get().setLeft(f);
+		frustumUpdate();
+	}
+
+	float getRight() const
+	{
+		return get().getRight();
+	}
+	void setRight(float f)
+	{
+		get().setRight(f);
+		frustumUpdate();
+	}
+
+	float getTop() const
+	{
+		return get().getTop();
+	}
+	void setTop(float f)
+	{
+		get().setTop(f);
+		frustumUpdate();
+	}
+
+	float getBottom() const
+	{
+		return get().getBottom();
+	}
+	void setBottom(float f)
+	{
+		get().setBottom(f);
+		frustumUpdate();
+	}
+
+	/// Set all
+	void setAll(float left_, float right_, float near_,
+		float far_, float top_, float bottom_)
+	{
+		get().setAll(left_, right_, near_, far_, top_, bottom_);
+		frustumUpdate();
+	}
+	/// @}
+
+private:
+	OrthographicFrustum& get()
+	{
+		return *static_cast<OrthographicFrustum*>(frustum);
+	}
+	const OrthographicFrustum& get() const
+	{
+		return *static_cast<const OrthographicFrustum*>(frustum);
+	}
+};
+
 } // namespace anki
 
 #endif

+ 13 - 0
include/anki/scene/ModelNode.h

@@ -46,6 +46,12 @@ public:
 	{
 		return this;
 	}
+
+	/// Override SceneNode::frameUpdate
+	void frameUpdate(float prevUpdateTime, float crntTime, int frame)
+	{
+		SceneNode::frameUpdate(prevUpdateTime, crntTime, frame);
+	}
 	/// @}
 
 	// @name Movable virtuals
@@ -123,6 +129,12 @@ public:
 	{
 		return this;
 	}
+
+	/// Override SceneNode::frameUpdate
+	void frameUpdate(float prevUpdateTime, float crntTime, int frame)
+	{
+		SceneNode::frameUpdate(prevUpdateTime, crntTime, frame);
+	}
 	/// @}
 
 	/// @name Movable virtuals
@@ -132,6 +144,7 @@ public:
 	/// - Update collision shape
 	void movableUpdate()
 	{
+		Movable::movableUpdate();
 		obb = model->getVisibilityShape().getTransformed(
 			getWorldTransform());
 	}

+ 1 - 0
include/anki/scene/Scene.h

@@ -50,6 +50,7 @@ public:
 
 	Camera& getActiveCamera()
 	{
+		ANKI_ASSERT(mainCam != nullptr);
 		return *mainCam;
 	}
 	const Camera& getActiveCamera() const

+ 2 - 7
include/anki/util/Exception.h

@@ -15,15 +15,10 @@ class Exception: public std::exception
 public:
 	/// Constructor
 	Exception(const char* error, const char* file = "unknown",
-		int line = -1, const char* func = "unknown")
-	{
-		err = synthErr(error, file, line, func);
-	}
+		int line = -1, const char* func = "unknown");
 
 	/// Copy constructor
-	Exception(const Exception& e)
-		: err(e.err)
-	{}
+	Exception(const Exception& e);
 
 	/// Destructor. Do nothing
 	~Exception() throw()

+ 5 - 5
include/anki/util/Object.h

@@ -24,11 +24,11 @@ public:
 		: self(self_)
 	{
 		ANKI_ASSERT(self != nullptr && "Self can't be nullptr");
-		parent = parent_;
-		if(parent != nullptr)
+		if(parent_ != nullptr)
 		{
-			parent->addChild(self);
+			parent_->addChild(self);
 		}
+		parent = parent_;
 	}
 
 	/// Delete children from the last entered to the first and update parent
@@ -98,8 +98,8 @@ public:
 	}
 
 private:
-	Value* self;
-	Value* parent; ///< May be nullptr
+	Value* self = nullptr;
+	Value* parent = nullptr; ///< May be nullptr
 	Container childs;
 };
 

+ 2 - 1
include/anki/util/StringList.h

@@ -29,7 +29,8 @@ public:
 
 	/// Split a string using a list of separators (@a sep) and return these
 	/// strings in a string list
-	static Self splitString(const Char* s, const Char* sep = " ");
+	static Self splitString(const Char* s, const Char sep = ' ',
+		bool keepEmpties = false);
 
 	/// Mainly for the unit tests
 	friend std::ostream& operator<<(std::ostream& s, const Self& a);

+ 8 - 2
shaders/GaussianBlurGeneric.glsl

@@ -34,6 +34,10 @@ void main()
 #	error "See file"
 #endif
 
+#if !defined(IMG_DIMENSION)
+#	error "See file"
+#endif
+
 uniform sampler2D img; ///< Input FAI
 uniform float blurringDist = 0.0;
 
@@ -58,8 +62,10 @@ in vec2 vOffsets;
 #	define TEX_FETCH r
 #endif
 
-const float BLURRING_OFFSET[2] = float[](1.3846153846 / IMG_DIMENSION, 
-	3.2307692308 / IMG_DIMENSION); 
+const float BLURRING_OFFSET_X = 1.3846153846 / IMG_DIMENSION;
+const float BLURRING_OFFSET_Y = 3.2307692308 / IMG_DIMENSION;
+const float BLURRING_OFFSET[2] = float[](BLURRING_OFFSET_X, 
+	BLURRING_OFFSET_Y); 
 
 layout(location = 0) out COL_TYPE fFragColor;
 

+ 19 - 0
src/collision/Frustum.cpp

@@ -94,6 +94,14 @@ void PerspectiveFrustum::transform(const Transform& trf_)
 	transformShape();
 }
 
+//==============================================================================
+void PerspectiveFrustum::setTransform(const Transform& trf_)
+{
+	trf = trf_;
+	transformPlanes();
+	transformShape();
+}
+
 //==============================================================================
 void PerspectiveFrustum::getAabb(Aabb& aabb) const
 {
@@ -148,6 +156,7 @@ void PerspectiveFrustum::recalculate()
 //==============================================================================
 Mat4 PerspectiveFrustum::calculateProjectionMatrix() const
 {
+	ANKI_ASSERT(fovX != 0.0 && fovX != 0.0);
 	Mat4 projectionMat;
 
 	float f = 1.0 / tan(fovY * 0.5); // f = cot(fovY/2)
@@ -197,9 +206,19 @@ void OrthographicFrustum::transform(const Transform& trf_)
 	transformShape();
 }
 
+//==============================================================================
+void OrthographicFrustum::setTransform(const Transform& trf_)
+{
+	trf = trf_;
+	transformPlanes();
+	transformShape();
+}
+
 //==============================================================================
 Mat4 OrthographicFrustum::calculateProjectionMatrix() const
 {
+	ANKI_ASSERT(right != 0.0 && left != 0.0 && top != 0.0 && bottom != 0.0
+		&& near != 0.0 && far != 0.0);
 	float difx = right - left;
 	float dify = top - bottom;
 	float difz = far - near;

+ 1 - 1
src/gl/Fbo.cpp

@@ -77,7 +77,7 @@ void Fbo::unbindAll()
 bool Fbo::isComplete() const
 {
 	ANKI_ASSERT(isCreated());
-	ANKI_ASSERT(glId == getCurrentDrawFboGlId() && "Not binded");
+	ANKI_ASSERT(glId == getCurrentFboGlId() && "Not binded");
 
 	GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 	return status == GL_FRAMEBUFFER_COMPLETE;

+ 23 - 13
src/gl/ShaderProgram.cpp

@@ -30,8 +30,16 @@ ShaderProgramVariable::ShaderProgramVariable(
 		type(type_), fatherSProg(fatherSProg_)
 {
 	name.shrink_to_fit();
-	ANKI_ASSERT(loc == 
-		glGetUniformLocation(fatherSProg->getGlId(), name.c_str()));
+	if(type == SPVT_ATTRIBUTE)
+	{
+		ANKI_ASSERT(loc ==
+			glGetAttribLocation(fatherSProg->getGlId(), name.c_str()));
+	}
+	else
+	{
+		ANKI_ASSERT(loc ==
+			glGetUniformLocation(fatherSProg->getGlId(), name.c_str()));
+	}
 }
 
 //==============================================================================
@@ -59,7 +67,7 @@ void ShaderProgramUniformVariable::set(const Vec2& x) const
 {
 	doCommonSetCode();
 	ANKI_ASSERT(getGlDataType() == GL_FLOAT_VEC2);
-	ANKI_ASSERT(getSize() == 2);
+	ANKI_ASSERT(getSize() == 1);
 
 	glUniform2f(getLocation(), x.x(), x.y());
 }
@@ -79,7 +87,7 @@ void ShaderProgramUniformVariable::set(const Vec2 x[], uint size) const
 {
 	doCommonSetCode();
 	ANKI_ASSERT(getGlDataType() == GL_FLOAT_VEC2);
-	ANKI_ASSERT(getSize() == size * 2);
+	ANKI_ASSERT(getSize() == size);
 
 	glUniform2fv(getLocation(), size, &(const_cast<Vec2&>(x[0]))[0]);
 }
@@ -89,7 +97,7 @@ void ShaderProgramUniformVariable::set(const Vec3 x[], uint size) const
 {
 	doCommonSetCode();
 	ANKI_ASSERT(getGlDataType() == GL_FLOAT_VEC3);
-	ANKI_ASSERT(getSize() == size * 3);
+	ANKI_ASSERT(getSize() == size);
 
 	glUniform3fv(getLocation(), size, &(const_cast<Vec3&>(x[0]))[0]);
 }
@@ -99,7 +107,7 @@ void ShaderProgramUniformVariable::set(const Vec4 x[], uint size) const
 {
 	doCommonSetCode();
 	ANKI_ASSERT(getGlDataType() == GL_FLOAT_VEC4);
-	ANKI_ASSERT(getSize() == size * 4);
+	ANKI_ASSERT(getSize() == size);
 	
 	glUniform4fv(getLocation(), size, &(const_cast<Vec4&>(x[0]))[0]);
 }
@@ -147,7 +155,7 @@ const char* ShaderProgram::stdSourceCode =
 	"#pragma optimize(on)\n"
 	"#pragma debug(off)\n";
 #else
-	"#pragma optimize(of)\n"
+	"#pragma optimize(off)\n"
 	"#pragma debug(on)\n";
 #endif
 
@@ -217,10 +225,9 @@ void ShaderProgram::create(const char* vertSource, const char* tcSource,
 	// 3) set the TRFFB varyings
 	ANKI_ASSERT(transformFeedbackVaryings != nullptr);
 	int count = 0;
-	while(*transformFeedbackVaryings != nullptr)
+	while(transformFeedbackVaryings[count] != nullptr)
 	{
 		++count;
-		++transformFeedbackVaryings;
 	}
 
 	if(count)
@@ -236,6 +243,7 @@ void ShaderProgram::create(const char* vertSource, const char* tcSource,
 	link();
 
 	// init the rest
+	bind();
 	getUniAndAttribVars();
 }
 
@@ -311,15 +319,17 @@ GLuint ShaderProgram::createAndCompileShader(const char* sourceCode,
 		infoLog[charsWritten] = '\0';
 
 		std::stringstream err;
-		err << "Shader compile failed:\n" << padding << "\n" << &infoLog[0]
+		err << "Shader compile failed (0x" << std::hex << type << std::dec
+			<< "):\n" << padding << "\n" << &infoLog[0]
 			<< "\n" << padding << "\nSource:\n" << padding << "\n";
 
 		// Prettyfy source
-		StringList lines = StringList::splitString(sourceCode, "\n");
+		StringList lines = StringList::splitString(sourceCode, '\n', true);
+		int lineno = 0;
 		for(const std::string& line : lines)
 		{
-			err << std::setw(4) << std::setfill('0') << ": " << line 
-				<< std::endl;
+			err << std::setw(4) << std::setfill('0') << ++lineno << ": "
+				<< line << std::endl;
 		}
 
 		err << padding;

+ 2 - 6
src/gl/Texture.cpp

@@ -153,11 +153,6 @@ void TextureUnits::unbindTexture(const Texture& tex)
 // Texture                                                                     =
 //==============================================================================
 
-//==============================================================================
-Texture::Texture()
-	: glId(0), target(GL_TEXTURE_2D)
-{}
-
 //==============================================================================
 Texture::~Texture()
 {
@@ -174,7 +169,8 @@ void Texture::create(const Initializer& init)
 	// Sanity checks
 	//
 	ANKI_ASSERT(!isCreated());
-	ANKI_ASSERT(init.internalFormat <= 4 && "Deprecated internal format");
+	ANKI_ASSERT(init.internalFormat > 4 && "Deprecated internal format");
+	ANKI_ASSERT(init.width > 0 && init.height > 0);
 
 	// Create
 	//

+ 2 - 0
src/renderer/Drawer.cpp

@@ -529,6 +529,8 @@ void RenderableDrawer::setupShaderProg(
 				Mat4(*renderable.getRenderableWorldTransform())
 				* cam.getViewMatrix() * cam.getProjectionMatrix();
 
+			std::cout << mvp << std::endl;
+
 			uni->set(mvp);
 		}
 		else

+ 2 - 2
src/renderer/Hdr.cpp

@@ -52,11 +52,11 @@ void Hdr::init(const Renderer::Initializer& initializer)
 
 	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.glsl";
 
-	std::string pps = "#define HPASS\n#define COL_RGB\n#define IMG_DIMENTION "
+	std::string pps = "#define HPASS\n#define COL_RGB\n#define IMG_DIMENSION "
 		+ std::to_string(width) + ".0\n";
 	hblurSProg.load(SHADER_FILENAME, pps.c_str());
 
-	pps = "#define VPASS\n#define COL_RGB\n#define IMG_DIMENTION "
+	pps = "#define VPASS\n#define COL_RGB\n#define IMG_DIMENSION "
 		+ std::to_string(height) + ".0\n";
 	vblurSProg.load(SHADER_FILENAME, pps.c_str());
 

+ 3 - 5
src/renderer/MainRenderer.cpp

@@ -60,7 +60,7 @@ void MainRenderer::initGl()
 
 	// get max texture units
 	//glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAtachments);
-	glClearColor(0.1, 0.1, 0.0, 1.0);
+	glClearColor(1.0, 0.0, 1.0, 1.0);
 	glClearDepth(1.0);
 	glClearStencil(0);
 	glDepthFunc(GL_LEQUAL);
@@ -113,10 +113,8 @@ void MainRenderer::render(Scene& scene)
 	GlStateSingleton::get().disable(GL_DEPTH_TEST);
 	GlStateSingleton::get().disable(GL_BLEND);
 	sProg->bind();
-	//sProg->findUniformVariableByName("rasterImage").set(ms.getDiffuseFai(), 0);
-	//sProg->findUniformVariableByName("rasterImage").
-	//	set(is.getFai(), 0);
-	sProg->findUniformVariableByName("rasterImage")->set(pps.getPostPassFai());
+	const Texture& finalFai = ms.getDiffuseFai();
+	sProg->findUniformVariableByName("rasterImage")->set(finalFai);
 	drawQuad();
 }
 

+ 2 - 0
src/renderer/Ms.cpp

@@ -2,6 +2,7 @@
 #include "anki/renderer/Ez.h"
 #include "anki/renderer/Renderer.h"
 
+#include "anki/core/Logger.h"
 #include "anki/scene/Camera.h"
 #include "anki/scene/Scene.h"
 
@@ -29,6 +30,7 @@ void Ms::init(const RendererInitializer& initializer)
 		fbo.create();
 		fbo.setColorAttachments({&normalFai, &diffuseFai, &specularFai});
 		fbo.setOtherAttachment(GL_DEPTH_STENCIL_ATTACHMENT, depthFai);
+		ANKI_ASSERT(fbo.isComplete());
 	}
 	catch(std::exception& e)
 	{

+ 1 - 1
src/renderer/Pps.cpp

@@ -59,7 +59,7 @@ void Pps::init(const Renderer::Initializer& initializer)
 
 		postPassFbo.create();
 		postPassFbo.setColorAttachments({&postPassFai});
-		ANKI_ASSERT(prePassFbo.isComplete());
+		ANKI_ASSERT(postPassFbo.isComplete());
 	}
 	catch(std::exception& e)
 	{

+ 2 - 2
src/renderer/Renderer.cpp

@@ -108,10 +108,10 @@ void Renderer::render(Scene& scene_)
 	else
 	{
 		ms.run();
-		is.run();
+		/*is.run();
 		pps.runPrePass();
 		bs.run();
-		pps.runPostPass();
+		pps.runPostPass();*/
 	}
 
 	++framesNum;

+ 6 - 5
src/resource/Material.cpp

@@ -124,7 +124,7 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
 
 	if(pass)
 	{
-		passes = StringList::splitString(pass.get().c_str(), " ");
+		passes = StringList::splitString(pass.get().c_str(), ' ');
 	}
 	else
 	{
@@ -235,7 +235,7 @@ std::string Material::createShaderProgSourceToCache(const std::string& source)
 
 	// Create path
 	std::string newfPathName =
-		AppSingleton::get().getCachePath() + "/" + prefix + ".glsl";
+		AppSingleton::get().getCachePath() + "/mtl_" + prefix + ".glsl";
 	toNativePath(newfPathName.c_str());
 
 	// If file not exists write it
@@ -313,8 +313,9 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
 
 			if(iit == allVarNames.end())
 			{
-				ANKI_LOGW("Input variable \"" << name 
-					<< "\" not used in material \"" << fname << "\"");
+				ANKI_LOGW("Material input variable " << name
+					<< " not used by shader program. Material:"
+					<< fname);
 			}
 		}
 	}
@@ -430,7 +431,7 @@ template<typename Type, size_t n>
 Type Material::setMathType(const char* str)
 {
 	Type out;
-	StringList sl = StringList::splitString(str, " ");
+	StringList sl = StringList::splitString(str, ' ');
 	ANKI_ASSERT(sl.size() == n);
 
 	for(uint i = 0; i < n; ++i)

+ 4 - 3
src/resource/MaterialShaderProgramCreator.cpp

@@ -2,7 +2,6 @@
 #include "anki/util/Assert.h"
 #include "anki/util/Exception.h"
 #include <boost/property_tree/ptree.hpp>
-#include <regex>
 
 namespace anki {
 
@@ -181,10 +180,12 @@ void MaterialShaderProgramCreator::parseOperationTag(
 	std::stringstream line;
 	line << "#if defined(" << funcName << "_DEFINED)";
 
-	std::regex expr("^operationOut[0-9]*$");
+	// XXX Regexpr features still missing
+	//std::regex expr("^operationOut[0-9]*$");
 	for(const std::string& arg : argsList)
 	{
-		if(std::regex_match(arg, expr))
+		//if(std::regex_match(arg, expr))
+		if(arg.find("operationOut") == 0)
 		{
 			line << " && defined(" << arg << "_DEFINED)";
 		}

+ 4 - 4
src/scene/Camera.cpp

@@ -31,11 +31,11 @@ void Camera::lookAtPoint(const Vec3& point)
 PerspectiveCamera::PerspectiveCamera(const char* name, Scene* scene,
 	uint movableFlags, Movable* movParent)
 	: Camera(CT_PERSPECTIVE, name, scene, movableFlags, movParent, 
-		&frustumWorld)
+		&frustum), PerspectiveFrustumable(&frustum)
 {
 	Property<PerspectiveFrustum>* prop =
 		new ReadWritePointerProperty<PerspectiveFrustum>("frustum", 
-		&frustumLocal);
+		&frustum);
 
 	addNewProperty(prop);
 
@@ -50,11 +50,11 @@ PerspectiveCamera::PerspectiveCamera(const char* name, Scene* scene,
 OrthographicCamera::OrthographicCamera(const char* name, Scene* scene,
 	uint movableFlags, Movable* movParent)
 	: Camera(CT_ORTHOGRAPHIC, name, scene, movableFlags, movParent, 
-		&frustumWorld)
+		&frustum), OrthographicFrustumable(&frustum)
 {
 	Property<OrthographicFrustum>* prop =
 		new ReadWritePointerProperty<OrthographicFrustum>("frustum", 
-		&frustumLocal);
+		&frustum);
 
 	addNewProperty(prop);
 

+ 8 - 3
src/scene/Movable.cpp

@@ -1,6 +1,5 @@
 #include "anki/scene/Movable.h"
 #include "anki/scene/Property.h"
-#include <boost/foreach.hpp>
 
 namespace anki {
 
@@ -12,12 +11,18 @@ Movable::Movable(uint flags_, Movable* parent, PropertyMap& pmap)
 		new ReadWritePointerProperty<Transform>("localTransform", &lTrf));
 	pmap.addNewProperty(
 		new ReadPointerProperty<Transform>("worldTransform", &wTrf));
+
+	lTrf.setIdentity();
+	wTrf.setIdentity();
+	// Change the wTrf so it wont be the same as lTrf. This means that in the
+	// updateWorldTransform() the "is moved" check will return true
+	wTrf.setScale(0.0);
 }
 
 //==============================================================================
 void Movable::update()
 {
-	if(getParent() == NULL) // If root
+	if(getParent() == nullptr) // If root
 	{
 		updateWorldTransform();
 	}
@@ -56,7 +61,7 @@ void Movable::updateWorldTransform()
 		disableFlag(MF_MOVED);
 	}
 
-	BOOST_FOREACH(Movable* child, getChildren())
+	for(Movable* child : getChildren())
 	{
 		child->updateWorldTransform();
 	}

+ 10 - 2
src/scene/Scene.cpp

@@ -35,14 +35,22 @@ void Scene::update(float prevUpdateTime, float crntTime, int frame)
 	for(SceneNode* n : nodes)
 	{
 		n->frameUpdate(prevUpdateTime, crntTime, frame);
+		Movable* m = n->getMovable();
+		if(m)
+		{
+			m->update();
+		}
 	}
+
+	doVisibilityTests(*mainCam);
 }
 
 //==============================================================================
 void Scene::doVisibilityTests(Camera& cam)
 {
-	Frustumable& f = cam;
-	vtester.test(f, *this, vinfo);
+	Frustumable* f = cam.getFrustumable();
+	ANKI_ASSERT(f != nullptr);
+	vtester.test(*f, *this, vinfo);
 }
 
 } // end namespace

+ 23 - 1
src/util/Exception.cpp

@@ -1,8 +1,31 @@
 #include "anki/util/Exception.h"
 #include <sstream>
 
+// Instead of throwing abort. Its easier to debug
+#define ANKI_ABORT_ON_THROW 1
+
 namespace anki {
 
+//==============================================================================
+Exception::Exception(const char* error, const char* file,
+	int line, const char* func)
+{
+	err = synthErr(error, file, line, func);
+
+#if defined(ANKI_ABORT_ON_THROW)
+	abort();
+#endif
+}
+
+//==============================================================================
+Exception::Exception(const Exception& e)
+	: err(e.err)
+{
+#if defined(ANKI_ABORT_ON_THROW)
+	abort();
+#endif
+}
+
 //==============================================================================
 std::string Exception::synthErr(const char* error, const char* file,
 	int line, const char* func)
@@ -21,5 +44,4 @@ Exception Exception::operator<<(const std::exception& e) const
 	return out;
 }
 
-
 } // end namespace

+ 11 - 12
src/util/StringList.cpp

@@ -1,6 +1,5 @@
 #include "anki/util/StringList.h"
-#include <iostream> ///XXX
-#include <boost/tokenizer.hpp> /// XXX Remove
+#include <sstream>
 
 namespace anki {
 
@@ -40,19 +39,19 @@ int StringList::getIndexOf(const Char* value) const
 }
 
 //==============================================================================
-StringList StringList::splitString(const Char* s, const Char* seperators)
+StringList StringList::splitString(const Char* s, Char seperator, bool keep)
 {
-	typedef boost::char_separator<Char> Sep;
-	typedef boost::tokenizer<Sep> Tok;
-
-	Sep sep(seperators);
 	StringList out;
-	String str(s);
-	Tok tok(str, sep);
-
-	for(const String& s_ : tok)
+	std::istringstream ss(s);
+	while(!ss.eof())
 	{
-		out.push_back(s_);
+		String field;
+		getline(ss, field, seperator);
+		if(!keep && field.empty())
+		{
+			continue;
+		}
+		out.push_back(field);
 	}
 
 	return out;