Browse Source

Physics work + containers refactoring

Panagiotis Christopoulos Charitos 11 years ago
parent
commit
5fdef1f44e
49 changed files with 775 additions and 503 deletions
  1. 7 0
      include/anki/core/App.h
  2. 1 1
      include/anki/core/StdinListener.h
  3. 1 1
      include/anki/event/EventManager.h
  4. 0 4
      include/anki/gl/GlShader.h
  5. 1 1
      include/anki/misc/Xml.h
  6. 0 2
      include/anki/physics/Common.h
  7. 3 4
      include/anki/physics/PhysicsBody.h
  8. 70 20
      include/anki/physics/PhysicsCollisionShape.h
  9. 48 0
      include/anki/physics/PhysicsObject.h
  10. 67 2
      include/anki/physics/PhysicsWorld.h
  11. 1 4
      include/anki/resource/Common.h
  12. 2 2
      include/anki/resource/MaterialProgramCreator.h
  13. 1 2
      include/anki/resource/Mesh.h
  14. 1 1
      include/anki/resource/MeshLoader.h
  15. 1 2
      include/anki/resource/ResourceManager.h
  16. 56 0
      include/anki/scene/BodyComponent.h
  17. 3 6
      include/anki/scene/Common.h
  18. 1 1
      include/anki/scene/SceneGraph.h
  19. 2 2
      include/anki/scene/SceneNode.h
  20. 3 3
      include/anki/scene/Visibility.h
  21. 50 68
      include/anki/util/Allocator.h
  22. 16 18
      include/anki/util/DArray.h
  23. 8 6
      include/anki/util/Hierarchy.h
  24. 17 14
      include/anki/util/Hierarchy.inl.h
  25. 18 14
      include/anki/util/List.h
  26. 47 42
      include/anki/util/List.inl.h
  27. 22 14
      include/anki/util/Memory.h
  28. 1 1
      include/anki/util/String.h
  29. 1 1
      include/anki/util/String.inl.h
  30. 2 2
      include/anki/util/StringList.h
  31. 2 2
      include/anki/util/StringList.inl.h
  32. 24 8
      src/core/App.cpp
  33. 2 4
      src/gl/GlTexture.cpp
  34. 7 11
      src/misc/Xml.cpp
  35. 3 3
      src/physics/PhysicsBody.cpp
  36. 16 10
      src/physics/PhysicsCollisionShape.cpp
  37. 22 0
      src/physics/PhysicsObject.cpp
  38. 13 8
      src/physics/PhysicsWorld.cpp
  39. 2 2
      src/renderer/Is.cpp
  40. 24 31
      src/resource/MeshLoader.cpp
  41. 6 6
      src/script/Event.cpp
  42. 113 113
      src/script/Math.cpp
  43. 2 2
      src/script/Renderer.cpp
  44. 32 32
      src/script/Scene.cpp
  45. 9 9
      src/script/lua_glue_gen.py
  46. 15 17
      src/util/Memory.cpp
  47. 5 5
      tests/util/Allocator.cpp
  48. 26 1
      tests/util/Memory.cpp
  49. 1 1
      thirdparty

+ 7 - 0
include/anki/core/App.h

@@ -25,6 +25,7 @@ class NativeWindow;
 class Input;
 class GlDevice;
 class MainRenderer;
+class PhysicsWorld;
 class SceneGraph;
 class ScriptManager;
 class ResourceManager;
@@ -114,6 +115,11 @@ public:
 		return *m_script;
 	}
 
+	PhysicsWorld& getPhysicsWorld()
+	{
+		return *m_physics;
+	}
+
 	HeapAllocator<U8> getAllocator() const
 	{
 		return m_heapAlloc;
@@ -129,6 +135,7 @@ private:
 	NativeWindow* m_window = nullptr;
 	Input* m_input = nullptr;
 	GlDevice* m_gl = nullptr;
+	PhysicsWorld* m_physics = nullptr;
 	ResourceManager* m_resources = nullptr;
 	MainRenderer* m_renderer = nullptr;
 	SceneGraph* m_scene = nullptr;

+ 1 - 1
include/anki/core/StdinListener.h

@@ -34,7 +34,7 @@ public:
 
 private:
 	HeapAllocator<U8> m_alloc;
-	List<String, HeapAllocator<String>> m_q;
+	List<String> m_q;
 	Mutex m_mtx; ///< Protect the queue
 	Thread m_thrd; ///< The thread
 	Bool8 m_quit = false;

+ 1 - 1
include/anki/event/EventManager.h

@@ -24,7 +24,7 @@ class SceneGraph;
 class EventManager
 {
 public:
-	using EventsContainer = List<Event*, SceneAllocator<Event*>>;
+	using EventsContainer = List<Event*>;
 
 	EventManager();
 	~EventManager();

+ 0 - 4
include/anki/gl/GlShader.h

@@ -8,7 +8,6 @@
 
 #include "anki/gl/GlObject.h"
 #include "anki/util/Dictionary.h"
-#include "anki/util/DArray.h"
 
 namespace anki {
 
@@ -25,9 +24,6 @@ class GlShader: public GlObject
 public:
 	using Base = GlObject;
 
-	template<typename T>
-	using DArray = DArray<T, GlAllocator<T>>;
-
 	GlShader() = default;
 
 	~GlShader()

+ 1 - 1
include/anki/misc/Xml.h

@@ -61,7 +61,7 @@ public:
 
 	/// Get a number of floats
 	ANKI_USE_RESULT Error getFloats(
-		DArray<F64, StackAllocator<F64>>& out) const;
+		DArrayAuto<F64, StackAllocator<F64>>& out) const;
 
 	/// Return the text inside as a Mat4
 	ANKI_USE_RESULT Error getMat4(Mat4& out) const;

+ 0 - 2
include/anki/physics/Common.h

@@ -16,7 +16,6 @@ namespace anki {
 // Forward
 class PhysicsWorld;
 class PhysicsCollisionShape;
-class SceneGraph;
 
 /// @addtogroup physics
 /// @{
@@ -31,7 +30,6 @@ enum class PhysicsMaterialBit: U16
 	PARTICLES = 1 << 3
 };
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(PhysicsMaterialBit, inline)
-
 /// @}
 
 } // end namespace anki

+ 3 - 4
include/anki/physics/PhysicsBody.h

@@ -6,7 +6,7 @@
 #ifndef ANKI_PHYSICS_PHYSICS_BODY_H
 #define ANKI_PHYSICS_PHYSICS_BODY_H
 
-#include "anki/physics/Common.h"
+#include "anki/physics/PhysicsObject.h"
 
 namespace anki {
 
@@ -16,7 +16,6 @@ namespace anki {
 /// Initializer for PhysicsBody.
 struct PhysicsBodyInitializer
 {
-	PhysicsWorld* m_world = nullptr;
 	PhysicsCollisionShape* m_shape = nullptr;
 	F32 m_mass = 0.0;
 	Transform m_startTrf = Transform::getIdentity();
@@ -25,12 +24,12 @@ struct PhysicsBodyInitializer
 };
 
 /// Rigid body.
-class PhysicsBody
+class PhysicsBody: public PhysicsObject
 {
 public:
 	using Initializer = PhysicsBodyInitializer;
 
-	PhysicsBody();
+	PhysicsBody(PhysicsWorld* world);
 
 	~PhysicsBody();
 

+ 70 - 20
include/anki/physics/PhysicsCollisionShape.h

@@ -6,7 +6,7 @@
 #ifndef ANKI_PHYSICS_PHYSICS_COLLISION_SHAPE_H
 #define ANKI_PHYSICS_PHYSICS_COLLISION_SHAPE_H
 
-#include "anki/physics/Common.h"
+#include "anki/physics/PhysicsObject.h"
 
 namespace anki {
 
@@ -14,7 +14,7 @@ namespace anki {
 /// @{
 
 /// The base of all collision shapes.
-class PhysicsCollisionShape
+class PhysicsCollisionShape: public PhysicsObject
 {
 public:
 	/// Type of supported physics collision shapes.
@@ -28,35 +28,85 @@ public:
 	/// Standard initializer for all collision shapes.
 	struct Initializer
 	{
-		PhysicsWorld* m_world = nullptr;
+		// Empty for now
 	};
 
-	PhysicsCollisionShape();
-	~PhysicsCollisionShape();
-
-	/// Create sphere.
-	ANKI_USE_RESULT Error createSphere(Initializer& init, F32 radius);
-
-	/// Create box.
-	ANKI_USE_RESULT Error createBox(Initializer& init, const Vec3& extend);
-
-	/// Create convex hull.
-	ANKI_USE_RESULT Error createConvexHull(Initializer& init, 
-		const Vec3* positions, U32 positionsCount, U32 positionsStride);
+	PhysicsCollisionShape(PhysicsWorld* world)
+	:	PhysicsObject(world)
+	{}
 
-	/// Create face soup.
-	ANKI_USE_RESULT Error createStaticTriangleSoup(Initializer& init,
-		const Vec3* positions, U32 positionsStride, U16* indices);
+	~PhysicsCollisionShape();
 
+	/// @privatesection
+	/// @{
 	NewtonCollision* _getNewtonShape()
 	{
 		ANKI_ASSERT(m_shape);
 		return m_shape;
 	}
+	/// @}
 
-private:
+protected:
 	NewtonCollision* m_shape = nullptr;
-	static I32 id;
+	static I32 m_gid;
+};
+
+/// Sphere collision shape.
+class PhysicsSphere: public PhysicsCollisionShape
+{
+public:
+	PhysicsSphere(PhysicsWorld* world)
+	:	PhysicsCollisionShape(world)
+	{}
+
+	~PhysicsSphere() final
+	{}
+
+	ANKI_USE_RESULT Error create(Initializer& init, F32 radius);
+};
+
+/// Box collision shape.
+class PhysicsBox: public PhysicsCollisionShape
+{
+public:
+	PhysicsBox(PhysicsWorld* world)
+	:	PhysicsCollisionShape(world)
+	{}
+
+	~PhysicsBox() final
+	{}
+
+	ANKI_USE_RESULT Error create(Initializer& init, const Vec3& extend);
+};
+
+/// Convex hull collision shape.
+class PhysicsConvexHull: public PhysicsCollisionShape
+{
+public:
+	PhysicsConvexHull(PhysicsWorld* world)
+	:	PhysicsCollisionShape(world)
+	{}
+
+	~PhysicsConvexHull() final
+	{}
+
+	ANKI_USE_RESULT Error create(Initializer& init, 
+		const Vec3* positions, U32 positionsCount, U32 positionsStride);
+};
+
+/// Static triangle mesh shape.
+class PhysicsTriangleSoup: public PhysicsCollisionShape
+{
+public:
+	PhysicsTriangleSoup(PhysicsWorld* world)
+	:	PhysicsCollisionShape(world)
+	{}
+
+	~PhysicsTriangleSoup() final
+	{}
+
+	ANKI_USE_RESULT Error createStaticTriangleSoup(Initializer& init,
+		const Vec3* positions, U32 positionsStride, U16* indices);
 };
 /// @}
 

+ 48 - 0
include/anki/physics/PhysicsObject.h

@@ -0,0 +1,48 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#ifndef ANKI_PHYSICS_PHYSICS_OBJECT_H
+#define ANKI_PHYSICS_PHYSICS_OBJECT_H
+
+#include "anki/physics/Common.h"
+
+namespace anki {
+
+/// @addtogroup physics
+/// @{
+
+/// Base of all physics objects.
+class PhysicsObject
+{
+public:
+	PhysicsObject(PhysicsWorld* world)
+	:	m_world(world)
+	{
+		ANKI_ASSERT(m_world);
+	}
+
+	virtual ~PhysicsObject()
+	{
+		ANKI_ASSERT(m_markedForDeletion == true);
+	}
+
+	void setMarkedForDeletion();
+
+	Bool getMarkedForDeletion() const
+	{
+		return m_markedForDeletion;
+	}
+
+protected:
+	PhysicsWorld* m_world = nullptr;
+
+private:
+	Bool8 m_markedForDeletion = false;
+};
+/// @}
+
+} // end namespace anki
+
+#endif

+ 67 - 2
include/anki/physics/PhysicsWorld.h

@@ -7,6 +7,9 @@
 #define ANKI_PHYSICS_PHYSICS_WORLD_H
 
 #include "anki/physics/Common.h"
+#include "anki/physics/PhysicsCollisionShape.h"
+#include "anki/physics/PhysicsBody.h"
+#include "anki/util/List.h"
 
 namespace anki {
 
@@ -20,19 +23,81 @@ public:
 	PhysicsWorld();
 	~PhysicsWorld();
 
-	ANKI_USE_RESULT Error create(SceneGraph* scene);
+	ANKI_USE_RESULT Error create(
+		AllocAlignedCallback allocCb, void* allocCbData);
 
+	template<typename T, typename... TArgs>
+	T* newCollisionShape(TArgs&&... args)
+	{
+		return newObjectInternal(m_collisions, std::forward<TArgs>(args)...);
+	}
+
+	template<typename T, typename... TArgs>
+	T* newBody(TArgs&&... args)
+	{
+		return newObjectInternal(m_bodies, std::forward<TArgs>(args)...);
+	}
+
+	/// @privatesection
+	/// @{
 	NewtonWorld* _getNewtonWorld()
 	{
 		ANKI_ASSERT(m_world);
 		return m_world;
 	}
 
+	void _increaseObjectsMarkedForDeletion()
+	{
+		++m_markedForDeletionCount;
+	}
+	/// @}
+
 private:
-	SceneGraph* m_scene = nullptr;
+	ChainAllocator<U8> m_alloc;
+	List<PhysicsCollisionShape*> m_collisions;
+	List<PhysicsBody*> m_bodies;
+	AtomicU32 m_markedForDeletionCount = {0};
 	NewtonWorld* m_world = nullptr;
+
+	template<typename T, typename TContainer, typename... TArgs>
+	T* newObjectInternal(TContainer& cont, TArgs&&... args);
 };
 
+//==============================================================================
+template<typename T, typename TContainer, typename... TArgs>
+inline T* PhysicsWorld::newObjectInternal(TContainer& cont, TArgs&&... args)
+{
+	Error err = ErrorCode::NONE;
+	ChainAllocator<T> al = m_alloc;
+
+	T* ptr = al.template newInstance<T>(this);
+	if(ptr)
+	{
+		err = ptr->create(std::forward<TArgs>(args)...);
+	}
+	else
+	{
+		err = ErrorCode::OUT_OF_MEMORY;
+	}
+
+	if(!err)
+	{
+		err = cont.pushBack(m_alloc, ptr);
+	}
+
+	if(err)
+	{
+		ANKI_LOGE("Failed to create physics object");
+
+		if(ptr)
+		{
+			al.deleteInstance(ptr);
+			ptr = nullptr;
+		}
+	}
+
+	return ptr;
+}
 /// @}
 
 } // end namespace anki

+ 1 - 4
include/anki/resource/Common.h

@@ -23,16 +23,13 @@ template<typename T>
 using ResourceAllocator = HeapAllocator<T>;
 
 template<typename T>
-using ResourceDArray = DArray<T, ResourceAllocator<T>>;
+using ResourceDArray = DArray<T>;
 
 using ResourceString = StringBase<ResourceAllocator<char>>;
 
 template<typename T>
 using TempResourceAllocator = StackAllocator<T>;
 
-template<typename T>
-using TempResourceDArray = DArray<T, TempResourceAllocator<T>>;
-
 template<typename T>
 using TempResourceDArrayAuto = DArrayAuto<T, TempResourceAllocator<T>>;
 

+ 2 - 2
include/anki/resource/MaterialProgramCreator.h

@@ -128,7 +128,7 @@ public:
 		return m_sourceBaked[shaderType];
 	}
 
-	const List<Input, TempResourceAllocator<U8>>& getInputVariables() const
+	const List<Input>& getInputVariables() const
 	{
 		return m_inputs;
 	}
@@ -147,7 +147,7 @@ private:
 	TempResourceAllocator<char> m_alloc; 
 	Array<MPStringList, 5> m_source; ///< Shader program final source
 	Array<MPString, 5> m_sourceBaked; ///< Final source baked
-	List<Input, TempResourceAllocator<U8>> m_inputs;
+	List<Input> m_inputs;
 	MPStringList m_uniformBlock;
 	GLbitfield m_uniformBlockReferencedMask = 0;
 	U32 m_blockSize = 0;

+ 1 - 2
include/anki/resource/Mesh.h

@@ -98,9 +98,8 @@ public:
 
 protected:
 	/// Per sub mesh data
-	class SubMesh
+	struct SubMesh
 	{
-	public:
 		U32 m_indicesCount;
 		U32 m_indicesOffset;
 		Obb m_obb;

+ 1 - 1
include/anki/resource/MeshLoader.h

@@ -47,7 +47,7 @@ class MeshLoader
 {
 public:
 	template<typename T>
-	using MLDArray = TempResourceDArray<T>;
+	using MLDArray = TempResourceDArrayAuto<T>;
 
 	/// If two vertices have the same position and normals under the angle 
 	/// specified by this constant then combine those normals

+ 1 - 2
include/anki/resource/ResourceManager.h

@@ -48,8 +48,7 @@ class TypeResourceManager
 {
 public:
 	using ResourcePointerType = ResourcePointer<Type, TResourceManager>;
-	using Container = 
-		List<ResourcePointerType, ResourceAllocator<ResourcePointerType>>;
+	using Container = List<ResourcePointerType>;
 
 	TypeResourceManager()
 	{}

+ 56 - 0
include/anki/scene/BodyComponent.h

@@ -0,0 +1,56 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#ifndef ANKI_SCENE_BODY_COMPONENT_H
+#define ANKI_SCENE_BODY_COMPONENT_H
+
+#include "anki/scene/Common.h"
+#include "anki/scene/SceneComponent.h"
+
+namespace anki {
+
+/// @addtogroup scene
+/// @{
+
+/// Rigid body component.
+class BodyComponent: public SceneComponent
+{
+public:
+	BodyComponent(SceneNode* node, PhysicsBody* body)
+	:	SceneComponent(Type::BODY, node), 
+		m_body(body)
+	{
+		ANKI_ASSERT(m_body);
+	}
+
+	const Transform& getTransform() const
+	{
+		return m_trf;
+	}
+
+	/// @name SceneComponent overrides
+	/// @{
+	ANKI_USE_RESULT Error update(SceneNode&, F32, F32, Bool& updated) override
+	{
+		m_trf = m_body->getTransform(updated);
+		return ErrorCode::NONE;
+	}
+	/// @}
+
+	static constexpr Type getClassType()
+	{
+		return Type::BODY;
+	}
+
+private:
+	PhysicsBody* m_body;
+	Transform m_trf;
+};
+/// @}
+
+} // end namespace anki
+
+#endif
+

+ 3 - 6
include/anki/scene/Common.h

@@ -20,21 +20,18 @@ class SceneNode;
 
 /// The type of the scene's allocator
 template<typename T>
-using SceneAllocator = ChainAllocator<T, true>;
+using SceneAllocator = ChainAllocator<T>;
 
 /// The type of the scene's frame allocator
 template<typename T>
-using SceneFrameAllocator = StackAllocator<T, false>;
+using SceneFrameAllocator = StackAllocator<T>;
 
 /// Scene string
 using SceneString = StringBase<SceneAllocator<char>>;
 
 /// Scene array
 template<typename T>
-using SceneDArray = DArray<T, SceneAllocator<T>>;
-
-template<typename T>
-using SceneFrameDArray = DArray<T, SceneFrameAllocator<T>>;
+using SceneDArray = DArray<T>;
 
 template<typename T>
 using SceneFrameDArrayAuto = DArrayAuto<T, SceneFrameAllocator<T>>;

+ 1 - 1
include/anki/scene/SceneGraph.h

@@ -181,7 +181,7 @@ private:
 	SceneAllocator<U8> m_alloc;
 	SceneFrameAllocator<U8> m_frameAlloc;
 
-	List<SceneNode*, SceneAllocator<SceneNode*>> m_nodes;
+	List<SceneNode*> m_nodes;
 	U32 m_nodesCount = 0;
 	//SceneDictionary<SceneNode*> m_dict;
 

+ 2 - 2
include/anki/scene/SceneNode.h

@@ -19,10 +19,10 @@ class ResourceManager;
 /// @{
 
 /// Interface class backbone of scene
-class SceneNode: public Hierarchy<SceneNode, SceneAllocator<SceneNode>>
+class SceneNode: public Hierarchy<SceneNode>
 {
 public:
-	using Base = Hierarchy<SceneNode, SceneAllocator<SceneNode>>;
+	using Base = Hierarchy<SceneNode>;
 
 	/// The one and only constructor
 	SceneNode(SceneGraph* scene);

+ 3 - 3
include/anki/scene/Visibility.h

@@ -79,7 +79,7 @@ public:
 class VisibilityTestResults
 {
 public:
-	using Container = SceneFrameDArray<VisibleNode>;
+	using Container = DArray<VisibleNode>;
 
 	~VisibilityTestResults()
 	{
@@ -196,7 +196,7 @@ class DistanceSortJob: public Threadpool::Task
 {
 public:
 	U32 m_nodesCount;
-	VisibilityTestResults::Container::iterator m_nodes;
+	VisibilityTestResults::Container::Iterator m_nodes;
 	Vec4 m_origin;
 
 	Error operator()(U32 /*threadId*/, PtrSize /*threadsCount*/)
@@ -213,7 +213,7 @@ class MaterialSortJob: public Threadpool::Task
 {
 public:
 	U32 m_nodesCount;
-	VisibilityTestResults::Container::iterator m_nodes;
+	VisibilityTestResults::Container::Iterator m_nodes;
 
 	Error operator()(U32 /*threadId*/, PtrSize /*threadsCount*/)
 	{

+ 50 - 68
include/anki/util/Allocator.h

@@ -29,20 +29,13 @@ namespace anki {
 /// This is a template that accepts memory pools with a specific interface
 ///
 /// @tparam T The type
-/// @tparam checkFree If false then the allocator will throw an exception
-///                   if the free() method of the memory pool returns false.
-///                   It is extremely important to understand when it should be 
-///                   true. See the notes.
-///
-/// @note The checkFree can brake the allocator when used with stack pools 
-///       and the deallocations are not in the correct order.
 ///
 /// @note Don't ever EVER remove the double copy constructor and the double
 ///       operator=. The compiler will create defaults
-template<typename T, typename TPool, Bool checkFree = false>
+template<typename T, typename TPool>
 class GenericPoolAllocator
 {
-	template<typename Y, typename TPool_, Bool checkFree_>
+	template<typename Y, typename TPool_>
 	friend class GenericPoolAllocator;
 
 public:
@@ -64,7 +57,7 @@ public:
 	template<typename Y>
 	struct rebind
 	{
-		using other = GenericPoolAllocator<Y, TPool, checkFree>;
+		using other = GenericPoolAllocator<Y, TPool>;
 	};
 
 	/// Default constructor
@@ -79,8 +72,7 @@ public:
 
 	/// Copy constructor
 	template<typename Y>
-	GenericPoolAllocator(const GenericPoolAllocator<
-		Y, TPool, checkFree>& b)
+	GenericPoolAllocator(const GenericPoolAllocator<Y, TPool>& b)
 	{
 		*this = b;
 	}
@@ -126,8 +118,7 @@ public:
 
 	/// Copy
 	template<typename U>
-	GenericPoolAllocator& operator=(const GenericPoolAllocator<
-		U, TPool, checkFree>& b)
+	GenericPoolAllocator& operator=(const GenericPoolAllocator<U, TPool>& b)
 	{
 		copy(b);
 		return *this;
@@ -175,13 +166,7 @@ public:
 	void deallocate(void* p, size_type n)
 	{
 		(void)n;
-
-		Bool ok = m_pool->free(p);
-
-		if(checkFree && !ok)
-		{
-			ANKI_LOGE("Freeing wrong pointer. Pool's free() returned false");
-		}
+		m_pool->free(p);
 	}
 
 	/// Call constructor
@@ -243,13 +228,13 @@ public:
 	{
 		typename rebind<U>::other alloc(*this);
 
-		U* x = alloc.allocate(1);
-		if(x)
+		U* ptr = alloc.allocate(1);
+		if(ptr)
 		{
-			alloc.construct(x, std::forward<Args>(args)...);
+			alloc.construct(ptr, std::forward<Args>(args)...);
 		}
 
-		return x;
+		return ptr;
 	}
 
 	/// Allocate a new array of objects and call their constructor
@@ -259,17 +244,17 @@ public:
 	{
 		typename rebind<U>::other alloc(*this);
 
-		U* x = alloc.allocate(n);
-		if(x)
+		U* ptr = alloc.allocate(n);
+		if(ptr)
 		{
 			// Call the constuctors
 			for(size_type i = 0; i < n; i++)
 			{
-				alloc.construct(&x[i]);
+				alloc.construct(&ptr[i]);
 			}
 		}
 
-		return x;
+		return ptr;
 	}
 
 	/// Allocate a new array of objects and call their constructor
@@ -279,49 +264,49 @@ public:
 	{
 		typename rebind<U>::other alloc(*this);
 
-		U* x = alloc.allocate(n);
-		if(x)
+		U* ptr = alloc.allocate(n);
+		if(ptr)
 		{
 			// Call the constuctors
 			for(size_type i = 0; i < n; i++)
 			{
-				alloc.construct(&x[i], v);
+				alloc.construct(&ptr[i], v);
 			}
 		}
 
-		return x;
+		return ptr;
 	}
 
 	/// Call the destructor and deallocate an object
 	/// @note This is AnKi specific
 	template<typename U>
-	void deleteInstance(U* x)
+	void deleteInstance(U* ptr)
 	{
 		typename rebind<U>::other alloc(*this);
 
-		if(x != nullptr)
+		if(ptr != nullptr)
 		{
-			alloc.destroy(x);
-			alloc.deallocate(x, 1);
+			alloc.destroy(ptr);
+			alloc.deallocate(ptr, 1);
 		}
 	}
 
 	/// Call the destructor and deallocate an array of objects
 	/// @note This is AnKi specific
 	template<typename U>
-	void deleteArray(U* x, size_type n)
+	void deleteArray(U* ptr, size_type n)
 	{
 		typename rebind<U>::other alloc(*this);
 
-		if(x != nullptr)
+		if(ptr != nullptr)
 		{
 			// Call the destructors
 			for(size_type i = 0; i < n; i++)
 			{
-				alloc.destroy(&x[i]);
+				alloc.destroy(&ptr[i]);
 			}
 
-			alloc.deallocate(x, n);
+			alloc.deallocate(ptr, n);
 		}
 		else
 		{
@@ -333,7 +318,7 @@ private:
 	TPool* m_pool = nullptr;
 
 	template<typename Y>
-	void copy(const GenericPoolAllocator<Y, TPool, checkFree>& b)
+	void copy(const GenericPoolAllocator<Y, TPool>& b)
 	{
 		clear();
 		if(b.m_pool)
@@ -366,61 +351,58 @@ private:
 /// @{
 
 /// Another allocator of the same type can deallocate from this one
-template<typename T1, typename T2, typename TPool, Bool checkFree>
-inline bool operator==(
-	const GenericPoolAllocator<T1, TPool, checkFree>&,
-	const GenericPoolAllocator<T2, TPool, checkFree>&)
+template<typename T1, typename T2, typename TPool>
+inline Bool operator==(
+	const GenericPoolAllocator<T1, TPool>&,
+	const GenericPoolAllocator<T2, TPool>&)
 {
 	return true;
 }
 
 /// Another allocator of the another type cannot deallocate from this one
-template<typename T1, typename AnotherAllocator, typename TPool, 
-	Bool checkFree>
-inline bool operator==(
-	const GenericPoolAllocator<T1, TPool, checkFree>&,
+template<typename T1, typename AnotherAllocator, typename TPool>
+inline Bool operator==(
+	const GenericPoolAllocator<T1, TPool>&,
 	const AnotherAllocator&)
 {
 	return false;
 }
 
 /// Another allocator of the same type can deallocate from this one
-template<typename T1, typename T2, typename TPool, Bool checkFree>
-inline bool operator!=(
-	const GenericPoolAllocator<T1, TPool, checkFree>&,
-	const GenericPoolAllocator<T2, TPool, checkFree>&)
+template<typename T1, typename T2, typename TPool>
+inline Bool operator!=(
+	const GenericPoolAllocator<T1, TPool>&,
+	const GenericPoolAllocator<T2, TPool>&)
 {
 	return false;
 }
 
 /// Another allocator of the another type cannot deallocate from this one
-template<typename T1, typename AnotherAllocator, typename TPool, 
-	Bool checkFree>
-inline bool operator!=(
-	const GenericPoolAllocator<T1, TPool, checkFree>&,
+template<typename T1, typename AnotherAllocator, typename TPool>
+inline Bool operator!=(
+	const GenericPoolAllocator<T1, TPool>&,
 	const AnotherAllocator&)
 {
 	return true;
 }
-
 /// @}
 
+/// Allocator using the base memory pool.
+template<typename T>
+using GenericMemoryPoolAllocator = GenericPoolAllocator<T, BaseMemoryPool>;
+
 /// Heap based allocator. The default allocator. It uses malloc and free for 
 /// allocations/deallocations
 template<typename T>
-using HeapAllocator = 
-	GenericPoolAllocator<T, HeapMemoryPool, true>;
+using HeapAllocator = GenericPoolAllocator<T, HeapMemoryPool>;
 
 /// Allocator that uses a StackMemoryPool
-template<typename T, Bool checkFree = false>
-using StackAllocator = 
-	GenericPoolAllocator<T, StackMemoryPool, checkFree>;
+template<typename T>
+using StackAllocator = GenericPoolAllocator<T, StackMemoryPool>;
 
 /// Allocator that uses a ChainMemoryPool
-template<typename T, Bool checkFree = true>
-using ChainAllocator = 
-	GenericPoolAllocator<T, ChainMemoryPool, checkFree>;
-
+template<typename T>
+using ChainAllocator = GenericPoolAllocator<T, ChainMemoryPool>;
 /// @}
 
 } // end namespace anki

+ 16 - 18
include/anki/util/DArray.h

@@ -8,6 +8,7 @@
 
 #include "anki/util/Allocator.h"
 #include "anki/util/NonCopyable.h"
+#include "anki/util/Functions.h"
 
 namespace anki {
 
@@ -17,23 +18,16 @@ namespace anki {
 /// Dynamic array with manual destruction. It doesn't hold the allocator and 
 /// that makes it compact. At the same time that requires manual destruction. 
 /// Used in permanent classes.
-template<typename T, typename TAlloc = HeapAllocator<T>>
+template<typename T>
 class DArray: public NonCopyable
 {
 public:
 	using Value = T;
-	using Allocator = TAlloc;
 	using Iterator = Value*;
 	using ConstIterator = const Value*;
 	using Reference = Value&;
 	using ConstReference = const Value&;
 
-	// STL compatible
-	using iterator = Iterator;
-	using const_iterator = ConstIterator;
-	using reference = Reference;
-	using const_reference = ConstReference;
-
 	DArray()
 	:	m_data(nullptr),
 		m_size(0)
@@ -159,7 +153,8 @@ public:
 	}
 
 	/// Create the array.
-	ANKI_USE_RESULT Error create(Allocator alloc, PtrSize size)
+	template<typename TAllocator>
+	ANKI_USE_RESULT Error create(TAllocator alloc, PtrSize size)
 	{
 		ANKI_ASSERT(m_data == nullptr && m_size == 0);
 		Error err = ErrorCode::NONE;
@@ -183,7 +178,8 @@ public:
 	}
 
 	/// Create the array.
-	ANKI_USE_RESULT Error create(Allocator alloc, PtrSize size, const Value& v)
+	template<typename TAllocator>
+	ANKI_USE_RESULT Error create(TAllocator alloc, PtrSize size, const Value& v)
 	{
 		ANKI_ASSERT(m_data == nullptr && m_size == 0);
 		Error err = ErrorCode::NONE;
@@ -205,7 +201,8 @@ public:
 	}
 
 	/// Grow the array.
-	ANKI_USE_RESULT Error resize(Allocator alloc, PtrSize size)
+	template<typename TAllocator>
+	ANKI_USE_RESULT Error resize(TAllocator alloc, PtrSize size)
 	{
 		ANKI_ASSERT(size > 0);
 		DArray newArr;
@@ -213,7 +210,7 @@ public:
 
 		if(!err)
 		{
-			PtrSize minSize = std::min<PtrSize>(size, m_size);
+			PtrSize minSize = min<PtrSize>(size, m_size);
 			for(U i = 0; i < minSize; i++)
 			{
 				newArr[i] = std::move((*this)[i]);
@@ -227,7 +224,8 @@ public:
 	}
 
 	/// Destroy the array.
-	void destroy(Allocator alloc)
+	template<typename TAllocator>
+	void destroy(TAllocator alloc)
 	{
 		if(m_data)
 		{
@@ -241,7 +239,7 @@ public:
 		ANKI_ASSERT(m_data == nullptr && m_size == 0);
 	}
 
-private:
+protected:
 	Value* m_data;
 	U32 m_size;
 
@@ -260,12 +258,12 @@ private:
 /// holds the allocator in order to perform automatic destruction. Use it for
 /// temp operations and on transient classes.
 template<typename T, typename TAlloc = HeapAllocator<T>>
-class DArrayAuto: public DArray<T, TAlloc>
+class DArrayAuto: public DArray<T>
 {
 public:
-	using Base = DArray<T, TAlloc>;
-	using Value = typename Base::Value;
-	using Allocator = typename Base::Allocator;
+	using Base = DArray<T>;
+	using Value = T;
+	using Allocator = TAlloc;
 
 	DArrayAuto(Allocator alloc)
 	:	Base(),

+ 8 - 6
include/anki/util/Hierarchy.h

@@ -19,13 +19,12 @@ namespace anki {
 /// @{
 
 /// A hierarchical object
-template<typename T, typename TAlloc = HeapAllocator<T>>
+template<typename T>
 class Hierarchy: public NonCopyable
 {
 public:
 	using Value = T;
-	using Allocator = TAlloc;
-	using Container = List<Value*, Allocator>;
+	using Container = List<Value*>;
 
 	Hierarchy()
 	:	m_parent(nullptr)
@@ -38,7 +37,8 @@ public:
 			&& "Requires manual desruction");
 	}
 
-	void destroy(Allocator alloc);
+	template<typename TAllocator>
+	void destroy(TAllocator alloc);
 
 	const Value* getParent() const
 	{
@@ -61,10 +61,12 @@ public:
 	}
 
 	/// Add a new child.
-	ANKI_USE_RESULT Error addChild(Allocator alloc, Value* child);
+	template<typename TAllocator>
+	ANKI_USE_RESULT Error addChild(TAllocator alloc, Value* child);
 
 	/// Remove a child.
-	void removeChild(Allocator alloc, Value* child);
+	template<typename TAllocator>
+	void removeChild(TAllocator alloc, Value* child);
 
 	/// Visit the children and the children's children. Use it with lambda
 	template<typename VisitorFunc>

+ 17 - 14
include/anki/util/Hierarchy.inl.h

@@ -6,8 +6,9 @@
 namespace anki {
 
 //==============================================================================
-template<typename T, typename TAlloc>
-void Hierarchy<T, TAlloc>::destroy(Allocator alloc)
+template<typename T>
+template<typename TAllocator>
+void Hierarchy<T>::destroy(TAllocator alloc)
 {
 	if(m_parent != nullptr)
 	{
@@ -28,8 +29,9 @@ void Hierarchy<T, TAlloc>::destroy(Allocator alloc)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-Error Hierarchy<T, TAlloc>::addChild(Allocator alloc, Value* child)
+template<typename T>
+template<typename TAllocator>
+Error Hierarchy<T>::addChild(TAllocator alloc, Value* child)
 {
 	ANKI_ASSERT(child != nullptr && "Null arg");
 	ANKI_ASSERT(child != getSelf() && "Cannot put itself");
@@ -46,8 +48,9 @@ Error Hierarchy<T, TAlloc>::addChild(Allocator alloc, Value* child)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-void Hierarchy<T, TAlloc>::removeChild(Allocator alloc, Value* child)
+template<typename T>
+template<typename TAllocator>
+void Hierarchy<T>::removeChild(TAllocator alloc, Value* child)
 {
 	ANKI_ASSERT(child != nullptr && "Null arg");
 	ANKI_ASSERT(child->m_parent == getSelf() && "Child has other parent");
@@ -61,9 +64,9 @@ void Hierarchy<T, TAlloc>::removeChild(Allocator alloc, Value* child)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
+template<typename T>
 template<typename VisitorFunc>
-Error Hierarchy<T, TAlloc>::visitChildren(VisitorFunc vis)
+Error Hierarchy<T>::visitChildren(VisitorFunc vis)
 {
 	Error err = ErrorCode::NONE;
 	typename Container::Iterator it = m_children.getBegin();
@@ -81,9 +84,9 @@ Error Hierarchy<T, TAlloc>::visitChildren(VisitorFunc vis)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
+template<typename T>
 template<typename VisitorFunc>
-Error Hierarchy<T, TAlloc>::visitThisAndChildren(VisitorFunc vis)
+Error Hierarchy<T>::visitThisAndChildren(VisitorFunc vis)
 {
 	Error err = vis(*getSelf());
 
@@ -96,9 +99,9 @@ Error Hierarchy<T, TAlloc>::visitThisAndChildren(VisitorFunc vis)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
+template<typename T>
 template<typename VisitorFunc>
-Error Hierarchy<T, TAlloc>::visitTree(VisitorFunc vis)
+Error Hierarchy<T>::visitTree(VisitorFunc vis)
 {
 	// Move to root
 	Value* root = getSelf();
@@ -111,9 +114,9 @@ Error Hierarchy<T, TAlloc>::visitTree(VisitorFunc vis)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
+template<typename T>
 template<typename VisitorFunc>
-Error Hierarchy<T, TAlloc>::visitChildrenMaxDepth(I maxDepth, VisitorFunc vis)
+Error Hierarchy<T>::visitChildrenMaxDepth(I maxDepth, VisitorFunc vis)
 {
 	ANKI_ASSERT(maxDepth >= 0);
 	Error err = ErrorCode::NONE;

+ 18 - 14
include/anki/util/List.h

@@ -12,7 +12,7 @@
 namespace anki {
 
 // Forward
-template<typename T, typename TAlloc>
+template<typename T>
 class List;
 
 /// @addtogroup util_private
@@ -161,7 +161,7 @@ public:
 /// @{
 
 /// Double linked list.
-template<typename T, typename TAlloc = HeapAllocator<T>>
+template<typename T>
 class List: public NonCopyable
 {
 	template<typename TNodePointer, typename TValuePointer, 
@@ -170,7 +170,6 @@ class List: public NonCopyable
 
 public:
 	using Value = T;
-	using Allocator = TAlloc;
 	using Node = ListNode<Value>;
 	using Reference = Value&;
 	using ConstReference = const Value&;
@@ -207,7 +206,8 @@ public:
 	Bool operator==(const List& b) const;
 
 	/// Destroy the list.
-	void destroy(Allocator alloc);
+	template<typename TAllocator>
+	void destroy(TAllocator alloc);
 
 	/// Get first element.
 	ConstReference getFront() const
@@ -294,29 +294,33 @@ public:
 	}
 
 	/// Copy an element at the end of the list.
-	ANKI_USE_RESULT Error pushBack(Allocator alloc, const Value& x);
+	template<typename TAllocator>
+	ANKI_USE_RESULT Error pushBack(TAllocator alloc, const Value& x);
 
 	/// Construct an element at the end of the list.
-	template<typename... TArgs>
-	ANKI_USE_RESULT Error emplaceBack(Allocator alloc, TArgs&&... args);
+	template<typename TAllocator, typename... TArgs>
+	ANKI_USE_RESULT Error emplaceBack(TAllocator alloc, TArgs&&... args);
 
 	/// Construct element at the beginning of the list.
-	template<typename... TArgs>
-	ANKI_USE_RESULT Error emplaceFront(Allocator alloc, TArgs&&... args);
+	template<typename TAllocator, typename... TArgs>
+	ANKI_USE_RESULT Error emplaceFront(TAllocator alloc, TArgs&&... args);
 
 	/// Construct element at the the given position.
-	template<typename... TArgs>
+	template<typename TAllocator, typename... TArgs>
 	ANKI_USE_RESULT Error emplace(
-		Allocator alloc, Iterator pos, TArgs&&... args);
+		TAllocator alloc, Iterator pos, TArgs&&... args);
 
 	/// Pop a value from the back of the list.
-	void popBack(Allocator alloc);
+	template<typename TAllocator>
+	void popBack(TAllocator alloc);
 
 	/// Pop a value from the front of the list.
-	void popFront(Allocator alloc);
+	template<typename TAllocator>
+	void popFront(TAllocator alloc);
 
 	/// Erase an element.
-	void erase(Allocator alloc, Iterator position);
+	template<typename TAllocator>
+	void erase(TAllocator alloc, Iterator position);
 
 	/// Iterate the list using lambda.
 	template<typename TFunc>

+ 47 - 42
include/anki/util/List.inl.h

@@ -35,8 +35,8 @@ ListIterator<TNodePointer, TValuePointer, TValueReference, TList>&
 //==============================================================================
 
 //==============================================================================
-template<typename T, typename TAlloc>
-Bool List<T, TAlloc>::operator==(const List& b) const
+template<typename T>
+Bool List<T>::operator==(const List& b) const
 {
 	Bool same = true;
 	ConstIterator ita = getBegin();
@@ -58,8 +58,8 @@ Bool List<T, TAlloc>::operator==(const List& b) const
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-void List<T, TAlloc>::pushBackNode(Node* node)
+template<typename T>
+void List<T>::pushBackNode(Node* node)
 {
 	ANKI_ASSERT(node);
 
@@ -78,8 +78,9 @@ void List<T, TAlloc>::pushBackNode(Node* node)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-Error List<T, TAlloc>::pushBack(Allocator alloc, const Value& x)
+template<typename T>
+template<typename TAllocator>
+Error List<T>::pushBack(TAllocator alloc, const Value& x)
 {
 	Error err = ErrorCode::NONE;
 	
@@ -97,9 +98,9 @@ Error List<T, TAlloc>::pushBack(Allocator alloc, const Value& x)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-template<typename... TArgs>
-Error List<T, TAlloc>::emplaceBack(Allocator alloc, TArgs&&... args)
+template<typename T>
+template<typename TAllocator, typename... TArgs>
+Error List<T>::emplaceBack(TAllocator alloc, TArgs&&... args)
 {
 	Error err = ErrorCode::NONE;
 	
@@ -117,9 +118,9 @@ Error List<T, TAlloc>::emplaceBack(Allocator alloc, TArgs&&... args)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-template<typename... TArgs>
-Error List<T, TAlloc>::emplaceFront(Allocator alloc, TArgs&&... args)
+template<typename T>
+template<typename TAllocator, typename... TArgs>
+Error List<T>::emplaceFront(TAllocator alloc, TArgs&&... args)
 {
 	Error err = ErrorCode::NONE;
 
@@ -148,9 +149,9 @@ Error List<T, TAlloc>::emplaceFront(Allocator alloc, TArgs&&... args)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-template<typename... TArgs>
-Error List<T, TAlloc>::emplace(Allocator alloc, Iterator pos, TArgs&&... args)
+template<typename T>
+template<typename TAllocator, typename... TArgs>
+Error List<T>::emplace(TAllocator alloc, Iterator pos, TArgs&&... args)
 {
 	ANKI_ASSERT(pos.m_list == this);
 	Error err = ErrorCode::NONE;
@@ -199,8 +200,9 @@ Error List<T, TAlloc>::emplace(Allocator alloc, Iterator pos, TArgs&&... args)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-void List<T, TAlloc>::destroy(Allocator alloc)
+template<typename T>
+template<typename TAllocator>
+void List<T>::destroy(TAllocator alloc)
 {
 	Node* el = m_head;
 	while(el)
@@ -214,9 +216,9 @@ void List<T, TAlloc>::destroy(Allocator alloc)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
+template<typename T>
 template<typename TFunc>
-Error List<T, TAlloc>::iterateForward(TFunc func)
+Error List<T>::iterateForward(TFunc func)
 {
 	Error err = ErrorCode::NONE;
 	Node* el = m_head;
@@ -230,9 +232,9 @@ Error List<T, TAlloc>::iterateForward(TFunc func)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
+template<typename T>
 template<typename TFunc>
-Error List<T, TAlloc>::iterateBackward(TFunc func)
+Error List<T>::iterateBackward(TFunc func)
 {
 	Error err = ErrorCode::NONE;
 	Node* el = m_tail;
@@ -246,9 +248,9 @@ Error List<T, TAlloc>::iterateBackward(TFunc func)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
+template<typename T>
 template<typename TCompFunc>
-void List<T, TAlloc>::sort(TCompFunc compFunc)
+void List<T>::sort(TCompFunc compFunc)
 {
 	Node* sortPtr;
 	Node* newTail = m_tail;
@@ -257,7 +259,7 @@ void List<T, TAlloc>::sort(TCompFunc compFunc)
 	{
 		sortPtr = m_head;
 		Bool swapped = false;
-		Bool end = false;
+		Bool finished = false;
 
 		do
 		{
@@ -286,15 +288,15 @@ void List<T, TAlloc>::sort(TCompFunc compFunc)
 					newTail = m_head;
 				}
 
-				end = true;
+				finished = true;
 			}
-		} while(!end);
+		} while(!finished);
 	}
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-typename List<T, TAlloc>::Node* List<T, TAlloc>::swap(Node* one, Node* two)
+template<typename T>
+typename List<T>::Node* List<T>::swap(Node* one, Node* two)
 {
 	if(one->m_prev == nullptr)
 	{
@@ -325,8 +327,9 @@ typename List<T, TAlloc>::Node* List<T, TAlloc>::swap(Node* one, Node* two)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-void List<T, TAlloc>::erase(Allocator alloc, Iterator pos)
+template<typename T>
+template<typename TAllocator>
+void List<T>::erase(TAllocator alloc, Iterator pos)
 {
 	ANKI_ASSERT(pos.m_node);
 	ANKI_ASSERT(pos.m_list == this);
@@ -359,28 +362,30 @@ void List<T, TAlloc>::erase(Allocator alloc, Iterator pos)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-void List<T, TAlloc>::popBack(Allocator alloc)
+template<typename T>
+template<typename TAllocator>
+void List<T>::popBack(TAllocator alloc)
 {
 	ANKI_ASSERT(m_tail);
 	erase(alloc, Iterator(m_tail, this));
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-void List<T, TAlloc>::popFront(Allocator alloc)
+template<typename T>
+template<typename TAllocator>
+void List<T>::popFront(TAllocator alloc)
 {
 	ANKI_ASSERT(m_tail);
 	erase(alloc, Iterator(m_head, this));
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-typename List<T, TAlloc>::Iterator List<T, TAlloc>::find(const Value& a)
+template<typename T>
+typename List<T>::Iterator List<T>::find(const Value& a)
 {
 	Iterator it = getBegin();
-	Iterator end = getEnd();
-	while(it != end)
+	Iterator endit = getEnd();
+	while(it != endit)
 	{
 		if(*it == a)
 		{
@@ -394,13 +399,13 @@ typename List<T, TAlloc>::Iterator List<T, TAlloc>::find(const Value& a)
 }
 
 //==============================================================================
-template<typename T, typename TAlloc>
-PtrSize List<T, TAlloc>::getSize() const
+template<typename T>
+PtrSize List<T>::getSize() const
 {
 	PtrSize size = 0;
 	ConstIterator it = getBegin();
-	ConstIterator end = getEnd();
-	for(; it != end; it++)
+	ConstIterator endit = getEnd();
+	for(; it != endit; it++)
 	{
 		++size;
 	}

+ 22 - 14
include/anki/util/Memory.h

@@ -9,6 +9,8 @@
 #include "anki/util/StdTypes.h"
 #include "anki/util/NonCopyable.h"
 #include "anki/util/Atomic.h"
+#include "anki/util/Assert.h"
+#include <utility> // For forward
 
 namespace anki {
 
@@ -76,8 +78,7 @@ public:
 	/// Free memory. If the ptr is not the last allocation of the chunk
 	/// then nothing happens and the method returns false
 	/// @param[in, out] ptr Memory block to deallocate
-	/// @return True if the deallocation actually happened and false otherwise
-	Bool free(void* ptr);
+	void free(void* ptr);
 
 	/// Get refcount.
 	AtomicU32& getRefcount()
@@ -139,7 +140,7 @@ public:
 	HeapMemoryPool();
 
 	/// Destroy
-	~HeapMemoryPool();
+	~HeapMemoryPool() final;
 
 	/// The real constructor.
 	/// @param allocCb The allocation function callback
@@ -149,8 +150,9 @@ public:
 	/// Allocate memory
 	void* allocate(PtrSize size, PtrSize alignment);
 
-	/// Free memory
-	Bool free(void* ptr);
+	/// Free memory.
+	/// @param[in, out] ptr Memory block to deallocate.
+	void free(void* ptr);
 
 private:
 #if ANKI_MEM_USE_SIGNATURES
@@ -173,17 +175,23 @@ public:
 	StackMemoryPool();
 
 	/// Destroy
-	~StackMemoryPool();
+	~StackMemoryPool() final;
 
 	/// Create with parameters
 	/// @param allocCb The allocation function callback
 	/// @param allocCbUserData The user data to pass to the allocation function
 	/// @param size The size of the pool
+	/// @param ignoreDeallocationErrors Method free() may fail if the ptr is
+	///        not in the top of the stack. Set that to true to suppress such
+	///        errors
 	/// @param alignmentBytes The maximum supported alignment for returned
-	///                       memory
+	///        memory
 	Error create(
-		AllocAlignedCallback allocCb, void* allocCbUserData,
-		PtrSize size, PtrSize alignmentBytes = ANKI_SAFE_ALIGNMENT);
+		AllocAlignedCallback allocCb, 
+		void* allocCbUserData,
+		PtrSize size, 
+		Bool ignoreDeallocationErrors = true,
+		PtrSize alignmentBytes = ANKI_SAFE_ALIGNMENT);
 
 	/// Allocate aligned memory. The operation is thread safe
 	/// @param size The size to allocate
@@ -195,8 +203,7 @@ public:
 	/// then nothing happens and the method returns false. The operation is
 	/// threadsafe
 	/// @param[in, out] ptr Memory block to deallocate
-	/// @return True if the deallocation actually happened and false otherwise
-	Bool free(void* ptr);
+	void free(void* ptr);
 
 	/// Get the total size.
 	PtrSize getTotalSize() const
@@ -247,6 +254,8 @@ private:
 
 	/// Points to the memory and more specifically to the top of the stack
 	Atomic<U8*> m_top = {nullptr};
+
+	Bool8 m_ignoreDeallocationErrors = false;
 };
 
 /// Chain memory pool. Almost similar to StackMemoryPool but more flexible and 
@@ -269,7 +278,7 @@ public:
 	ChainMemoryPool();
 
 	/// Destroy
-	~ChainMemoryPool();
+	~ChainMemoryPool() final;
 
 	/// Constructor with parameters
 	/// @param allocCb The allocation function callback
@@ -299,8 +308,7 @@ public:
 	/// Free memory. If the ptr is not the last allocation of the chunk
 	/// then nothing happens and the method returns false
 	/// @param[in, out] ptr Memory block to deallocate
-	/// @return True if the deallocation actually happened and false otherwise
-	Bool free(void* ptr);
+	void free(void* ptr);
 
 	/// @name Methods used for optimizing future chains.
 	/// @{

+ 1 - 1
include/anki/util/String.h

@@ -559,7 +559,7 @@ public:
 	}
 
 private:
-	DArray<Char, Allocator> m_data;
+	DArray<Char> m_data;
 
 	void checkInit() const
 	{

+ 1 - 1
include/anki/util/String.inl.h

@@ -76,7 +76,7 @@ Error StringBase<TAlloc>::appendInternal(
 		size = 1;
 	}
 
-	DArray<Char, Allocator> newData;	
+	DArray<Char> newData;	
 	Error err = newData.create(alloc, size + strSize - 1);
 
 	if(!err)

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

@@ -30,14 +30,14 @@ using StringListBaseScopeDestroyer =
 
 /// A simple convenience class for string lists
 template<typename TAlloc>
-class StringListBase: public List<StringBase<TAlloc>, TAlloc>
+class StringListBase: public List<StringBase<TAlloc>>
 {
 public:
 	using Self = StringListBase; ///< Self type
 	using Char = char; ///< Char type
 	using Allocator = TAlloc;
 	using String = StringBase<Allocator>; ///< String type
-	using Base = List<String, Allocator>; ///< Base
+	using Base = List<String>; ///< Base
 
 	using ScopeDestroyer = StringListBaseScopeDestroyer<Allocator>;
 

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

@@ -13,8 +13,8 @@ template<typename TAlloc>
 void StringListBase<TAlloc>::destroy(Allocator alloc)
 {
 	auto it = Base::getBegin();
-	auto end = Base::getEnd();
-	for(; it != end; ++it)
+	auto endit = Base::getEnd();
+	for(; it != endit; ++it)
 	{
 		(*it).destroy(alloc);
 	}

+ 24 - 8
src/core/App.cpp

@@ -14,6 +14,7 @@
 #include "anki/core/NativeWindow.h"
 #include "anki/input/Input.h"
 #include "anki/scene/SceneGraph.h"
+#include "anki/physics/PhysicsWorld.h"
 #include "anki/renderer/MainRenderer.h"
 #include "anki/script/ScriptManager.h"
 
@@ -44,49 +45,55 @@ App::~App()
 //==============================================================================
 void App::cleanup()
 {
-	if (m_script != nullptr)
+	if(m_script != nullptr)
 	{
 		m_heapAlloc.deleteInstance(m_script);
 		m_script = nullptr;
 	}
 
-	if (m_scene != nullptr)
+	if(m_scene != nullptr)
 	{
 		m_heapAlloc.deleteInstance(m_scene);
 		m_scene = nullptr;
 	}
 
-	if (m_renderer != nullptr)
+	if(m_renderer != nullptr)
 	{
 		m_heapAlloc.deleteInstance(m_renderer);
 		m_renderer = nullptr;
 	}
 
-	if (m_resources != nullptr)
+	if(m_resources != nullptr)
 	{
 		m_heapAlloc.deleteInstance(m_resources);
 		m_resources = nullptr;
 	}
 
-	if (m_gl != nullptr)
+	if(m_physics)
+	{
+		m_heapAlloc.deleteInstance(m_physics);
+		m_physics = nullptr;
+	}
+
+	if(m_gl != nullptr)
 	{
 		m_heapAlloc.deleteInstance(m_gl);
 		m_gl = nullptr;
 	}
 
-	if (m_threadpool != nullptr)
+	if(m_threadpool != nullptr)
 	{
 		m_heapAlloc.deleteInstance(m_threadpool);
 		m_threadpool = nullptr;
 	}
 
-	if (m_input != nullptr)
+	if(m_input != nullptr)
 	{
 		m_heapAlloc.deleteInstance(m_input);
 		m_input = nullptr;
 	}
 
-	if (m_window != nullptr)
+	if(m_window != nullptr)
 	{
 		m_heapAlloc.deleteInstance(m_window);
 		m_window = nullptr;
@@ -200,6 +207,15 @@ Error App::createInternal(const ConfigSet& config_,
 		nwinit.m_debugContext);
 	if(err) return err;
 
+	//
+	// Physics
+	//
+	m_physics = m_heapAlloc.newInstance<PhysicsWorld>();
+	if(!m_gl) return ErrorCode::OUT_OF_MEMORY;
+
+	err = m_physics->create(m_allocCb, m_allocCbData);
+	if(err) return err;
+
 	//
 	// Resources
 	//

+ 2 - 4
src/gl/GlTexture.cpp

@@ -147,14 +147,14 @@ Error GlTexture::create(const Initializer& init,
 				ANKI_ASSERT(m_depth > 0);
 
 				// Gather the data
-				DArray<U8, GlAllocator<U8>> data;
+				DArrayAuto<U8, GlAllocator<U8>> data(alloc);
 
 				// Check if there are data
 				if(init.m_data[level][0].m_ptr != nullptr)
 				{
 					PtrSize layerSize = init.m_data[level][0].m_size;
 					ANKI_ASSERT(layerSize > 0);
-					Error err = data.create(alloc, layerSize * m_depth);
+					Error err = data.create(layerSize * m_depth);
 					if(err)
 					{
 						return err;
@@ -200,8 +200,6 @@ Error GlTexture::create(const Initializer& init,
 						data.getSize(), 
 						(data.getSize() > 0) ? &data[0] : nullptr);
 				}
-
-				data.destroy(alloc);
 			}
 			break;
 #if ANKI_GL == ANKI_GL_DESKTOP

+ 7 - 11
src/misc/Xml.cpp

@@ -87,7 +87,7 @@ Error XmlElement::getF64(F64& out) const
 }
 
 //==============================================================================V
-Error XmlElement::getFloats(DArray<F64, StackAllocator<F64>>& out) const
+Error XmlElement::getFloats(DArrayAuto<F64, StackAllocator<F64>>& out) const
 {
 	Error err = check();
 	
@@ -107,9 +107,11 @@ Error XmlElement::getFloats(DArray<F64, StackAllocator<F64>>& out) const
 		err = list.splitString(m_alloc, txt, ' ');
 	}
 
+	out = std::move(DArrayAuto<F64, StackAllocator<F64>>(m_alloc));
+
 	if(!err)
 	{
-		err = out.create(m_alloc, list.getSize());
+		err = out.create(list.getSize());
 	}
 
 	auto it = list.getBegin();
@@ -132,7 +134,7 @@ Error XmlElement::getFloats(DArray<F64, StackAllocator<F64>>& out) const
 //==============================================================================
 Error XmlElement::getMat4(Mat4& out) const
 {
-	DArray<F64, StackAllocator<F64>> arr;
+	DArrayAuto<F64, StackAllocator<F64>> arr(m_alloc);
 	Error err = getFloats(arr);	
 
 	if(!err && arr.getSize() != 16)
@@ -149,8 +151,6 @@ Error XmlElement::getMat4(Mat4& out) const
 		}
 	}
 
-	arr.destroy(m_alloc);
-
 	if(err)
 	{
 		ANKI_LOGE("Failed to return Mat4. Element: %s", m_el->Value());
@@ -162,7 +162,7 @@ Error XmlElement::getMat4(Mat4& out) const
 //==============================================================================
 Error XmlElement::getVec3(Vec3& out) const
 {
-	DArray<F64, StackAllocator<F64>> arr;
+	DArrayAuto<F64, StackAllocator<F64>> arr(m_alloc);
 	Error err = getFloats(arr);
 	
 	if(!err && arr.getSize() != 3)
@@ -179,8 +179,6 @@ Error XmlElement::getVec3(Vec3& out) const
 		}
 	}
 
-	arr.destroy(m_alloc);
-
 	if(err)
 	{
 		ANKI_LOGE("Failed to return Vec3. Element: %s", m_el->Value());
@@ -191,7 +189,7 @@ Error XmlElement::getVec3(Vec3& out) const
 //==============================================================================
 Error XmlElement::getVec4(Vec4& out) const
 {
-	DArray<F64, StackAllocator<F64>> arr;
+	DArrayAuto<F64, StackAllocator<F64>> arr(m_alloc);
 	Error err = getFloats(arr);
 	
 	if(!err && arr.getSize() != 4)
@@ -208,8 +206,6 @@ Error XmlElement::getVec4(Vec4& out) const
 		}
 	}
 
-	arr.destroy(m_alloc);
-
 	if(err)
 	{
 		ANKI_LOGE("Failed to return Vec4. Element: %s", m_el->Value());

+ 3 - 3
src/physics/PhysicsBody.cpp

@@ -10,7 +10,8 @@
 namespace anki {
 
 //==============================================================================
-PhysicsBody::PhysicsBody()
+PhysicsBody::PhysicsBody(PhysicsWorld* world)
+:	PhysicsObject(world)
 {}
 
 //==============================================================================
@@ -25,7 +26,6 @@ PhysicsBody::~PhysicsBody()
 //==============================================================================
 Error PhysicsBody::create(const Initializer& init)
 {
-	ANKI_ASSERT(init.m_world);
 	ANKI_ASSERT(init.m_shape);
 
 	// Create
@@ -36,7 +36,7 @@ Error PhysicsBody::create(const Initializer& init)
 	}
 	else
 	{
-		m_body = NewtonCreateDynamicBody(init.m_world->_getNewtonWorld(),
+		m_body = NewtonCreateDynamicBody(m_world->_getNewtonWorld(),
 			init.m_shape->_getNewtonShape(), &trf(0, 0));
 	}
 

+ 16 - 10
src/physics/PhysicsCollisionShape.cpp

@@ -9,11 +9,11 @@
 namespace anki {
 
 //==============================================================================
-I32 PhysicsCollisionShape::id = 0;
+// PhysicsCollisionShape                                                       =
+//==============================================================================
 
 //==============================================================================
-PhysicsCollisionShape::PhysicsCollisionShape()
-{}
+I32 PhysicsCollisionShape::m_gid = 0;
 
 //==============================================================================
 PhysicsCollisionShape::~PhysicsCollisionShape()
@@ -25,13 +25,16 @@ PhysicsCollisionShape::~PhysicsCollisionShape()
 }
 
 //==============================================================================
-Error PhysicsCollisionShape::createSphere(Initializer& init, F32 radius)
+// PhysicsSphere                                                               =
+//==============================================================================
+
+//==============================================================================
+Error PhysicsSphere::create(Initializer& init, F32 radius)
 {
-	ANKI_ASSERT(init.m_world);
 	Error err = ErrorCode::NONE;
 
 	m_shape = NewtonCreateSphere(
-		init.m_world->_getNewtonWorld(), radius, id++, nullptr);
+		m_world->_getNewtonWorld(), radius, m_gid++, nullptr);
 	if(!m_shape)
 	{
 		ANKI_LOGE("NewtonCreateSphere() failed");
@@ -42,14 +45,17 @@ Error PhysicsCollisionShape::createSphere(Initializer& init, F32 radius)
 }
 
 //==============================================================================
-Error PhysicsCollisionShape::createBox(Initializer& init, const Vec3& extend)
+// PhysicsBox                                                                  =
+//==============================================================================
+
+//==============================================================================
+Error PhysicsBox::create(Initializer& init, const Vec3& extend)
 {
-	ANKI_ASSERT(init.m_world);
 	Error err = ErrorCode::NONE;
 
 	m_shape = NewtonCreateBox(
-		init.m_world->_getNewtonWorld(), extend.x(), extend.y(), extend.z(),
-		id++, nullptr);
+		m_world->_getNewtonWorld(), extend.x(), extend.y(), extend.z(),
+		m_gid++, nullptr);
 	if(!m_shape)
 	{
 		ANKI_LOGE("NewtonCreateBox() failed");

+ 22 - 0
src/physics/PhysicsObject.cpp

@@ -0,0 +1,22 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#include "anki/physics/PhysicsObject.h"
+#include "anki/physics/PhysicsWorld.h"
+
+namespace anki {
+
+//==============================================================================
+void PhysicsObject::setMarkedForDeletion()
+{
+	if(!m_markedForDeletion)
+	{
+		m_markedForDeletion = true;
+		m_world->_increaseObjectsMarkedForDeletion();
+	}
+}
+
+} // end namespace anki
+

+ 13 - 8
src/physics/PhysicsWorld.cpp

@@ -4,22 +4,21 @@
 // http://www.anki3d.org/LICENSE
 
 #include "anki/physics/PhysicsWorld.h"
-#include "anki/scene/SceneGraph.h"
 
 namespace anki {
 
 //==============================================================================
 // Ugly but there is no other way
-static SceneGraph* gScene = nullptr;
+static ChainAllocator<U8>* gAlloc = nullptr;
 
 static void* newtonAlloc(int size)
 {
-	return gScene->getAllocator().allocate(size);
+	return gAlloc->allocate(size);
 }
 
 static void newtonFree(void* const ptr, int size)
 {
-	gScene->getAllocator().deallocate(ptr, size);
+	gAlloc->deallocate(ptr, size);
 }
 
 //==============================================================================
@@ -33,18 +32,24 @@ PhysicsWorld::~PhysicsWorld()
 	{
 		NewtonDestroy(m_world);
 	}
+
+	gAlloc = nullptr;
 }
 
 //==============================================================================
-Error PhysicsWorld::create(SceneGraph* scene)
+Error PhysicsWorld::create(AllocAlignedCallback allocCb, void* allocCbData)
 {
 	Error err = ErrorCode::NONE;
 
-	ANKI_ASSERT(scene);
-	m_scene = scene;
+	m_alloc = ChainAllocator<U8>(
+		allocCb, allocCbData, 
+		1024 * 10,
+		1024 * 1024,
+		ChainMemoryPool::ChunkGrowMethod::MULTIPLY,
+		2);
 	
 	// Set allocators
-	gScene = scene;
+	gAlloc = &m_alloc;
 	NewtonSetMemorySystem(newtonAlloc, newtonFree);
 
 	// Initialize world

+ 2 - 2
src/renderer/Is.cpp

@@ -79,8 +79,8 @@ public:
 
 	U8* m_tileBuffer = nullptr;
 
-	VisibilityTestResults::Container::const_iterator m_lightsBegin;
-	VisibilityTestResults::Container::const_iterator m_lightsEnd;
+	VisibilityTestResults::Container::ConstIterator m_lightsBegin;
+	VisibilityTestResults::Container::ConstIterator m_lightsEnd;
 
 	AtomicU32* m_pointLightsCount = nullptr;
 	AtomicU32* m_spotLightsCount = nullptr;

+ 24 - 31
src/resource/MeshLoader.cpp

@@ -56,29 +56,22 @@ using FixNormalsMap = std::unordered_map<
 
 //==============================================================================
 MeshLoader::MeshLoader(TempResourceAllocator<U8>& alloc)
-:	m_alloc(alloc)
+:	m_alloc(alloc),
+	m_positions(alloc),
+	m_normals(alloc),
+	m_normalsF16(alloc),
+	m_tangents(alloc),
+	m_tangentsF16(alloc),
+	m_texCoords(alloc),
+	m_texCoordsF16(alloc),
+	m_weights(alloc),
+	m_tris(alloc),
+	m_vertIndices(alloc)
 {}
 
 //==============================================================================
 MeshLoader::~MeshLoader()
-{
-	m_positions.destroy(m_alloc);
-
-	m_normals.destroy(m_alloc);
-	m_normalsF16.destroy(m_alloc);
-
-	m_tangents.destroy(m_alloc);
-	m_tangentsF16.destroy(m_alloc);
-
-	m_texCoords.destroy(m_alloc);
-	m_texCoordsF16.destroy(m_alloc);
-
-	m_weights.destroy(m_alloc);
-
-	m_tris.destroy(m_alloc);
-
-	m_vertIndices.destroy(m_alloc);
-}
+{}
 
 //==============================================================================
 Error MeshLoader::load(const CString& filename)
@@ -112,7 +105,7 @@ Error MeshLoader::load(const CString& filename)
 	U32 vertsNum;
 	ANKI_CHECK(file.readU32(vertsNum));
 
-	ANKI_CHECK(m_positions.create(m_alloc, vertsNum));
+	ANKI_CHECK(m_positions.create(vertsNum));
 
 	// Vert coords
 	for(Vec3& vertCoord : m_positions)
@@ -127,7 +120,7 @@ Error MeshLoader::load(const CString& filename)
 	U32 facesNum;
 	ANKI_CHECK(file.readU32(facesNum));
 
-	ANKI_CHECK(m_tris.create(m_alloc, facesNum));
+	ANKI_CHECK(m_tris.create(facesNum));
 
 	// Faces IDs
 	for(Triangle& tri : m_tris)
@@ -148,7 +141,7 @@ Error MeshLoader::load(const CString& filename)
 	// Tex coords num
 	U32 texCoordsNum;
 	ANKI_CHECK(file.readU32(texCoordsNum));
-	ANKI_CHECK(m_texCoords.create(m_alloc, texCoordsNum));
+	ANKI_CHECK(m_texCoords.create(texCoordsNum));
 
 	// Tex coords
 	for(Vec2& texCoord : m_texCoords)
@@ -162,7 +155,7 @@ Error MeshLoader::load(const CString& filename)
 	// Vert weights num
 	U32 weightsNum;
 	ANKI_CHECK(file.readU32(weightsNum));
-	ANKI_CHECK(m_weights.create(m_alloc, weightsNum));
+	ANKI_CHECK(m_weights.create(weightsNum));
 
 	// Vert weights
 	for(VertexWeight& vw : m_weights)
@@ -256,7 +249,7 @@ Error MeshLoader::doPostLoad()
 //==============================================================================
 Error MeshLoader::createVertIndeces()
 {
-	Error err = m_vertIndices.create(m_alloc, m_tris.getSize() * 3);
+	Error err = m_vertIndices.create(m_tris.getSize() * 3);
 	if(err)
 	{
 		return err;
@@ -302,7 +295,7 @@ Error MeshLoader::createFaceNormals()
 //==============================================================================
 Error MeshLoader::createVertNormals()
 {
-	Error err = m_normals.create(m_alloc, m_positions.getSize());
+	Error err = m_normals.create(m_positions.getSize());
 	if(err)
 	{
 		return err;
@@ -334,14 +327,14 @@ Error MeshLoader::createVertNormals()
 //==============================================================================
 Error MeshLoader::createVertTangents()
 {
-	Error err = m_tangents.create(m_alloc, m_positions.getSize(), Vec4(0.0));
+	Error err = m_tangents.create(m_positions.getSize(), Vec4(0.0));
 	if(err)
 	{
 		return err;
 	}
 
-	MLDArray<Vec3> bitagents;
-	err = bitagents.create(m_alloc, m_positions.getSize(), Vec3(0.0));
+	MLDArray<Vec3> bitagents(m_alloc);
+	err = bitagents.create(m_positions.getSize(), Vec3(0.0));
 	if(err)
 	{
 		return err;
@@ -525,7 +518,7 @@ Error MeshLoader::compressBuffers()
 	Error err = ErrorCode::NONE;
 
 	// Normals
-	ANKI_CHECK(m_normalsF16.create(m_alloc, m_normals.getSize()));
+	ANKI_CHECK(m_normalsF16.create(m_normals.getSize()));
 
 	for(U i = 0; i < m_normals.getSize(); i++)
 	{
@@ -536,7 +529,7 @@ Error MeshLoader::compressBuffers()
 	}
 
 	// Tangents
-	ANKI_CHECK(m_tangentsF16.create(m_alloc, m_tangents.getSize()));
+	ANKI_CHECK(m_tangentsF16.create(m_tangents.getSize()));
 
 	for(U i = 0; i < m_tangents.getSize(); i++)
 	{
@@ -547,7 +540,7 @@ Error MeshLoader::compressBuffers()
 	}
 
 	// Texture coords
-	ANKI_CHECK(m_texCoordsF16.create(m_alloc, m_texCoords.getSize()));
+	ANKI_CHECK(m_texCoordsF16.create(m_texCoords.getSize()));
 
 	for(U i = 0; i < m_texCoords.getSize(); i++)
 	{

+ 6 - 6
src/script/Event.cpp

@@ -99,7 +99,7 @@ static inline int pwrapEventManagernewSceneAmbientColorEvent(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameEventManager, -6959305329499243407, ud)) return -1;
-	EventManager* self = reinterpret_cast<EventManager*>(ud->m_data);
+	EventManager* self = static_cast<EventManager*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -110,7 +110,7 @@ static inline int pwrapEventManagernewSceneAmbientColorEvent(lua_State* l)
 	if(LuaBinder::checkNumber(l, 3, arg1)) return -1;
 	
 	if(LuaBinder::checkUserData(l, 4, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg2 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg2 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg2(*iarg2);
 	
 	// Call the method
@@ -124,9 +124,9 @@ static inline int pwrapEventManagernewSceneAmbientColorEvent(lua_State* l)
 	}
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "SceneAmbientColorEvent");
-	ud->m_data = reinterpret_cast<void*>(ret);
+	ud->m_data = static_cast<void*>(ret);
 	ud->m_gc = false;
 	ud->m_sig = -2736282921550252951;
 	
@@ -174,9 +174,9 @@ static inline int pwrapgetEventManager(lua_State* l)
 	}
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "EventManager");
-	ud->m_data = reinterpret_cast<void*>(ret);
+	ud->m_data = static_cast<void*>(ret);
 	ud->m_gc = false;
 	ud->m_sig = -6959305329499243407;
 	

+ 113 - 113
src/script/Math.cpp

@@ -51,7 +51,7 @@ static inline int pwrapVec2Ctor(lua_State* l)
 	::new(inst) Vec2();
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	ud->m_data = inst;
 	ud->m_gc = true;
 	ud->m_sig = 6804478823655046388;
@@ -83,7 +83,7 @@ static int wrapVec2Dtor(lua_State* l)
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
 	if(ud->m_gc)
 	{
-		Vec2* inst = reinterpret_cast<Vec2*>(ud->m_data);
+		Vec2* inst = static_cast<Vec2*>(ud->m_data);
 		inst->~Vec2();
 		LuaBinder::luaFree(l, inst);
 	}
@@ -104,7 +104,7 @@ static inline int pwrapVec2getX(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -139,7 +139,7 @@ static inline int pwrapVec2getY(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -174,7 +174,7 @@ static inline int pwrapVec2setX(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -210,7 +210,7 @@ static inline int pwrapVec2setY(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -246,7 +246,7 @@ static inline int pwrapVec2setAll(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -285,7 +285,7 @@ static inline int pwrapVec2getAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -324,7 +324,7 @@ static inline int pwrapVec2setAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -363,12 +363,12 @@ static inline int pwrapVec2copy(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec2", 6804478823655046388, ud)) return -1;
-	Vec2* iarg0 = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* iarg0 = static_cast<Vec2*>(ud->m_data);
 	const Vec2& arg0(*iarg0);
 	
 	// Call the method
@@ -400,12 +400,12 @@ static inline int pwrapVec2__add(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec2", 6804478823655046388, ud)) return -1;
-	Vec2* iarg0 = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* iarg0 = static_cast<Vec2*>(ud->m_data);
 	const Vec2& arg0(*iarg0);
 	
 	// Call the method
@@ -413,7 +413,7 @@ static inline int pwrapVec2__add(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec2");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec2));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -453,12 +453,12 @@ static inline int pwrapVec2__sub(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec2", 6804478823655046388, ud)) return -1;
-	Vec2* iarg0 = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* iarg0 = static_cast<Vec2*>(ud->m_data);
 	const Vec2& arg0(*iarg0);
 	
 	// Call the method
@@ -466,7 +466,7 @@ static inline int pwrapVec2__sub(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec2");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec2));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -506,12 +506,12 @@ static inline int pwrapVec2__mul(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec2", 6804478823655046388, ud)) return -1;
-	Vec2* iarg0 = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* iarg0 = static_cast<Vec2*>(ud->m_data);
 	const Vec2& arg0(*iarg0);
 	
 	// Call the method
@@ -519,7 +519,7 @@ static inline int pwrapVec2__mul(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec2");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec2));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -559,12 +559,12 @@ static inline int pwrapVec2__div(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec2", 6804478823655046388, ud)) return -1;
-	Vec2* iarg0 = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* iarg0 = static_cast<Vec2*>(ud->m_data);
 	const Vec2& arg0(*iarg0);
 	
 	// Call the method
@@ -572,7 +572,7 @@ static inline int pwrapVec2__div(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec2");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec2));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -612,12 +612,12 @@ static inline int pwrapVec2__eq(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec2", 6804478823655046388, ud)) return -1;
-	Vec2* iarg0 = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* iarg0 = static_cast<Vec2*>(ud->m_data);
 	const Vec2& arg0(*iarg0);
 	
 	// Call the method
@@ -652,7 +652,7 @@ static inline int pwrapVec2getLength(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -687,7 +687,7 @@ static inline int pwrapVec2getNormalized(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -695,7 +695,7 @@ static inline int pwrapVec2getNormalized(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec2");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec2));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -735,7 +735,7 @@ static inline int pwrapVec2normalize(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -767,12 +767,12 @@ static inline int pwrapVec2dot(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec2, 6804478823655046388, ud)) return -1;
-	Vec2* self = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* self = static_cast<Vec2*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec2", 6804478823655046388, ud)) return -1;
-	Vec2* iarg0 = reinterpret_cast<Vec2*>(ud->m_data);
+	Vec2* iarg0 = static_cast<Vec2*>(ud->m_data);
 	const Vec2& arg0(*iarg0);
 	
 	// Call the method
@@ -862,7 +862,7 @@ static inline int pwrapVec3Ctor(lua_State* l)
 	::new(inst) Vec3();
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	ud->m_data = inst;
 	ud->m_gc = true;
 	ud->m_sig = 6804478823655046389;
@@ -894,7 +894,7 @@ static int wrapVec3Dtor(lua_State* l)
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
 	if(ud->m_gc)
 	{
-		Vec3* inst = reinterpret_cast<Vec3*>(ud->m_data);
+		Vec3* inst = static_cast<Vec3*>(ud->m_data);
 		inst->~Vec3();
 		LuaBinder::luaFree(l, inst);
 	}
@@ -915,7 +915,7 @@ static inline int pwrapVec3getX(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -950,7 +950,7 @@ static inline int pwrapVec3getY(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -985,7 +985,7 @@ static inline int pwrapVec3getZ(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -1020,7 +1020,7 @@ static inline int pwrapVec3setX(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -1056,7 +1056,7 @@ static inline int pwrapVec3setY(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -1092,7 +1092,7 @@ static inline int pwrapVec3setZ(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -1128,7 +1128,7 @@ static inline int pwrapVec3setAll(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -1170,7 +1170,7 @@ static inline int pwrapVec3getAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -1209,7 +1209,7 @@ static inline int pwrapVec3setAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -1248,12 +1248,12 @@ static inline int pwrapVec3copy(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec3", 6804478823655046389, ud)) return -1;
-	Vec3* iarg0 = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* iarg0 = static_cast<Vec3*>(ud->m_data);
 	const Vec3& arg0(*iarg0);
 	
 	// Call the method
@@ -1285,12 +1285,12 @@ static inline int pwrapVec3__add(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec3", 6804478823655046389, ud)) return -1;
-	Vec3* iarg0 = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* iarg0 = static_cast<Vec3*>(ud->m_data);
 	const Vec3& arg0(*iarg0);
 	
 	// Call the method
@@ -1298,7 +1298,7 @@ static inline int pwrapVec3__add(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec3");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec3));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -1338,12 +1338,12 @@ static inline int pwrapVec3__sub(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec3", 6804478823655046389, ud)) return -1;
-	Vec3* iarg0 = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* iarg0 = static_cast<Vec3*>(ud->m_data);
 	const Vec3& arg0(*iarg0);
 	
 	// Call the method
@@ -1351,7 +1351,7 @@ static inline int pwrapVec3__sub(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec3");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec3));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -1391,12 +1391,12 @@ static inline int pwrapVec3__mul(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec3", 6804478823655046389, ud)) return -1;
-	Vec3* iarg0 = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* iarg0 = static_cast<Vec3*>(ud->m_data);
 	const Vec3& arg0(*iarg0);
 	
 	// Call the method
@@ -1404,7 +1404,7 @@ static inline int pwrapVec3__mul(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec3");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec3));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -1444,12 +1444,12 @@ static inline int pwrapVec3__div(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec3", 6804478823655046389, ud)) return -1;
-	Vec3* iarg0 = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* iarg0 = static_cast<Vec3*>(ud->m_data);
 	const Vec3& arg0(*iarg0);
 	
 	// Call the method
@@ -1457,7 +1457,7 @@ static inline int pwrapVec3__div(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec3");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec3));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -1497,12 +1497,12 @@ static inline int pwrapVec3__eq(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec3", 6804478823655046389, ud)) return -1;
-	Vec3* iarg0 = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* iarg0 = static_cast<Vec3*>(ud->m_data);
 	const Vec3& arg0(*iarg0);
 	
 	// Call the method
@@ -1537,7 +1537,7 @@ static inline int pwrapVec3getLength(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -1572,7 +1572,7 @@ static inline int pwrapVec3getNormalized(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -1580,7 +1580,7 @@ static inline int pwrapVec3getNormalized(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec3");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec3));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -1620,7 +1620,7 @@ static inline int pwrapVec3normalize(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -1652,12 +1652,12 @@ static inline int pwrapVec3dot(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec3, 6804478823655046389, ud)) return -1;
-	Vec3* self = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* self = static_cast<Vec3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec3", 6804478823655046389, ud)) return -1;
-	Vec3* iarg0 = reinterpret_cast<Vec3*>(ud->m_data);
+	Vec3* iarg0 = static_cast<Vec3*>(ud->m_data);
 	const Vec3& arg0(*iarg0);
 	
 	// Call the method
@@ -1749,7 +1749,7 @@ static inline int pwrapVec4Ctor(lua_State* l)
 	::new(inst) Vec4();
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	ud->m_data = inst;
 	ud->m_gc = true;
 	ud->m_sig = 6804478823655046386;
@@ -1781,7 +1781,7 @@ static int wrapVec4Dtor(lua_State* l)
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
 	if(ud->m_gc)
 	{
-		Vec4* inst = reinterpret_cast<Vec4*>(ud->m_data);
+		Vec4* inst = static_cast<Vec4*>(ud->m_data);
 		inst->~Vec4();
 		LuaBinder::luaFree(l, inst);
 	}
@@ -1802,7 +1802,7 @@ static inline int pwrapVec4getX(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -1837,7 +1837,7 @@ static inline int pwrapVec4getY(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -1872,7 +1872,7 @@ static inline int pwrapVec4getZ(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -1907,7 +1907,7 @@ static inline int pwrapVec4getW(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -1942,7 +1942,7 @@ static inline int pwrapVec4setX(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -1978,7 +1978,7 @@ static inline int pwrapVec4setY(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2014,7 +2014,7 @@ static inline int pwrapVec4setZ(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2050,7 +2050,7 @@ static inline int pwrapVec4setW(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2086,7 +2086,7 @@ static inline int pwrapVec4setAll(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2131,7 +2131,7 @@ static inline int pwrapVec4getAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2170,7 +2170,7 @@ static inline int pwrapVec4setAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2209,12 +2209,12 @@ static inline int pwrapVec4copy(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg0 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg0 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg0(*iarg0);
 	
 	// Call the method
@@ -2246,12 +2246,12 @@ static inline int pwrapVec4__add(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg0 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg0 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg0(*iarg0);
 	
 	// Call the method
@@ -2259,7 +2259,7 @@ static inline int pwrapVec4__add(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec4");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec4));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -2299,12 +2299,12 @@ static inline int pwrapVec4__sub(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg0 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg0 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg0(*iarg0);
 	
 	// Call the method
@@ -2312,7 +2312,7 @@ static inline int pwrapVec4__sub(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec4");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec4));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -2352,12 +2352,12 @@ static inline int pwrapVec4__mul(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg0 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg0 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg0(*iarg0);
 	
 	// Call the method
@@ -2365,7 +2365,7 @@ static inline int pwrapVec4__mul(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec4");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec4));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -2405,12 +2405,12 @@ static inline int pwrapVec4__div(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg0 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg0 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg0(*iarg0);
 	
 	// Call the method
@@ -2418,7 +2418,7 @@ static inline int pwrapVec4__div(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec4");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec4));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -2458,12 +2458,12 @@ static inline int pwrapVec4__eq(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg0 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg0 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg0(*iarg0);
 	
 	// Call the method
@@ -2498,7 +2498,7 @@ static inline int pwrapVec4getLength(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -2533,7 +2533,7 @@ static inline int pwrapVec4getNormalized(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -2541,7 +2541,7 @@ static inline int pwrapVec4getNormalized(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec4");
 	ud->m_data = LuaBinder::luaAlloc(l, sizeof(Vec4));
 	if(ANKI_UNLIKELY(ud->m_data == nullptr))
@@ -2581,7 +2581,7 @@ static inline int pwrapVec4normalize(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -2613,12 +2613,12 @@ static inline int pwrapVec4dot(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameVec4, 6804478823655046386, ud)) return -1;
-	Vec4* self = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* self = static_cast<Vec4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg0 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg0 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg0(*iarg0);
 	
 	// Call the method
@@ -2712,7 +2712,7 @@ static inline int pwrapMat3Ctor(lua_State* l)
 	::new(inst) Mat3();
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	ud->m_data = inst;
 	ud->m_gc = true;
 	ud->m_sig = 6306819796139686981;
@@ -2744,7 +2744,7 @@ static int wrapMat3Dtor(lua_State* l)
 	if(LuaBinder::checkUserData(l, 1, classnameMat3, 6306819796139686981, ud)) return -1;
 	if(ud->m_gc)
 	{
-		Mat3* inst = reinterpret_cast<Mat3*>(ud->m_data);
+		Mat3* inst = static_cast<Mat3*>(ud->m_data);
 		inst->~Mat3();
 		LuaBinder::luaFree(l, inst);
 	}
@@ -2765,12 +2765,12 @@ static inline int pwrapMat3copy(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMat3, 6306819796139686981, ud)) return -1;
-	Mat3* self = reinterpret_cast<Mat3*>(ud->m_data);
+	Mat3* self = static_cast<Mat3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Mat3", 6306819796139686981, ud)) return -1;
-	Mat3* iarg0 = reinterpret_cast<Mat3*>(ud->m_data);
+	Mat3* iarg0 = static_cast<Mat3*>(ud->m_data);
 	const Mat3& arg0(*iarg0);
 	
 	// Call the method
@@ -2802,7 +2802,7 @@ static inline int pwrapMat3getAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMat3, 6306819796139686981, ud)) return -1;
-	Mat3* self = reinterpret_cast<Mat3*>(ud->m_data);
+	Mat3* self = static_cast<Mat3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2844,7 +2844,7 @@ static inline int pwrapMat3setAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMat3, 6306819796139686981, ud)) return -1;
-	Mat3* self = reinterpret_cast<Mat3*>(ud->m_data);
+	Mat3* self = static_cast<Mat3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2886,7 +2886,7 @@ static inline int pwrapMat3setAll(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMat3, 6306819796139686981, ud)) return -1;
-	Mat3* self = reinterpret_cast<Mat3*>(ud->m_data);
+	Mat3* self = static_cast<Mat3*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -2988,7 +2988,7 @@ static inline int pwrapMat3x4Ctor(lua_State* l)
 	::new(inst) Mat3x4();
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	ud->m_data = inst;
 	ud->m_gc = true;
 	ud->m_sig = -2654194732934255869;
@@ -3020,7 +3020,7 @@ static int wrapMat3x4Dtor(lua_State* l)
 	if(LuaBinder::checkUserData(l, 1, classnameMat3x4, -2654194732934255869, ud)) return -1;
 	if(ud->m_gc)
 	{
-		Mat3x4* inst = reinterpret_cast<Mat3x4*>(ud->m_data);
+		Mat3x4* inst = static_cast<Mat3x4*>(ud->m_data);
 		inst->~Mat3x4();
 		LuaBinder::luaFree(l, inst);
 	}
@@ -3041,12 +3041,12 @@ static inline int pwrapMat3x4copy(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMat3x4, -2654194732934255869, ud)) return -1;
-	Mat3x4* self = reinterpret_cast<Mat3x4*>(ud->m_data);
+	Mat3x4* self = static_cast<Mat3x4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Mat3x4", -2654194732934255869, ud)) return -1;
-	Mat3x4* iarg0 = reinterpret_cast<Mat3x4*>(ud->m_data);
+	Mat3x4* iarg0 = static_cast<Mat3x4*>(ud->m_data);
 	const Mat3x4& arg0(*iarg0);
 	
 	// Call the method
@@ -3078,7 +3078,7 @@ static inline int pwrapMat3x4getAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMat3x4, -2654194732934255869, ud)) return -1;
-	Mat3x4* self = reinterpret_cast<Mat3x4*>(ud->m_data);
+	Mat3x4* self = static_cast<Mat3x4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -3120,7 +3120,7 @@ static inline int pwrapMat3x4setAt(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMat3x4, -2654194732934255869, ud)) return -1;
-	Mat3x4* self = reinterpret_cast<Mat3x4*>(ud->m_data);
+	Mat3x4* self = static_cast<Mat3x4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -3162,7 +3162,7 @@ static inline int pwrapMat3x4setAll(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMat3x4, -2654194732934255869, ud)) return -1;
-	Mat3x4* self = reinterpret_cast<Mat3x4*>(ud->m_data);
+	Mat3x4* self = static_cast<Mat3x4*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments

+ 2 - 2
src/script/Renderer.cpp

@@ -42,7 +42,7 @@ static inline int pwrapDbggetEnabled(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameDbg, -2784798555522127122, ud)) return -1;
-	Dbg* self = reinterpret_cast<Dbg*>(ud->m_data);
+	Dbg* self = static_cast<Dbg*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -77,7 +77,7 @@ static inline int pwrapDbgsetEnabled(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameDbg, -2784798555522127122, ud)) return -1;
-	Dbg* self = reinterpret_cast<Dbg*>(ud->m_data);
+	Dbg* self = static_cast<Dbg*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments

+ 32 - 32
src/script/Scene.cpp

@@ -72,12 +72,12 @@ static inline int pwrapMoveComponentsetLocalOrigin(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMoveComponent, 2038493110845313445, ud)) return -1;
-	MoveComponent* self = reinterpret_cast<MoveComponent*>(ud->m_data);
+	MoveComponent* self = static_cast<MoveComponent*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Vec4", 6804478823655046386, ud)) return -1;
-	Vec4* iarg0 = reinterpret_cast<Vec4*>(ud->m_data);
+	Vec4* iarg0 = static_cast<Vec4*>(ud->m_data);
 	const Vec4& arg0(*iarg0);
 	
 	// Call the method
@@ -109,7 +109,7 @@ static inline int pwrapMoveComponentgetLocalOrigin(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMoveComponent, 2038493110845313445, ud)) return -1;
-	MoveComponent* self = reinterpret_cast<MoveComponent*>(ud->m_data);
+	MoveComponent* self = static_cast<MoveComponent*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -117,9 +117,9 @@ static inline int pwrapMoveComponentgetLocalOrigin(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Vec4");
-	ud->m_data = const_cast<void*>(reinterpret_cast<const void*>(&ret));
+	ud->m_data = const_cast<void*>(static_cast<const void*>(&ret));
 	ud->m_gc = false;
 	ud->m_sig = 6804478823655046386;
 	
@@ -149,12 +149,12 @@ static inline int pwrapMoveComponentsetLocalRotation(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMoveComponent, 2038493110845313445, ud)) return -1;
-	MoveComponent* self = reinterpret_cast<MoveComponent*>(ud->m_data);
+	MoveComponent* self = static_cast<MoveComponent*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "Mat3x4", -2654194732934255869, ud)) return -1;
-	Mat3x4* iarg0 = reinterpret_cast<Mat3x4*>(ud->m_data);
+	Mat3x4* iarg0 = static_cast<Mat3x4*>(ud->m_data);
 	const Mat3x4& arg0(*iarg0);
 	
 	// Call the method
@@ -186,7 +186,7 @@ static inline int pwrapMoveComponentgetLocalRotation(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMoveComponent, 2038493110845313445, ud)) return -1;
-	MoveComponent* self = reinterpret_cast<MoveComponent*>(ud->m_data);
+	MoveComponent* self = static_cast<MoveComponent*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -194,9 +194,9 @@ static inline int pwrapMoveComponentgetLocalRotation(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "Mat3x4");
-	ud->m_data = const_cast<void*>(reinterpret_cast<const void*>(&ret));
+	ud->m_data = const_cast<void*>(static_cast<const void*>(&ret));
 	ud->m_gc = false;
 	ud->m_sig = -2654194732934255869;
 	
@@ -226,7 +226,7 @@ static inline int pwrapMoveComponentsetLocalScale(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMoveComponent, 2038493110845313445, ud)) return -1;
-	MoveComponent* self = reinterpret_cast<MoveComponent*>(ud->m_data);
+	MoveComponent* self = static_cast<MoveComponent*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -262,7 +262,7 @@ static inline int pwrapMoveComponentgetLocalScale(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameMoveComponent, 2038493110845313445, ud)) return -1;
-	MoveComponent* self = reinterpret_cast<MoveComponent*>(ud->m_data);
+	MoveComponent* self = static_cast<MoveComponent*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -330,7 +330,7 @@ static inline int pwrapSceneNodegetName(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameSceneNode, -2220074417980276571, ud)) return -1;
-	SceneNode* self = reinterpret_cast<SceneNode*>(ud->m_data);
+	SceneNode* self = static_cast<SceneNode*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -365,12 +365,12 @@ static inline int pwrapSceneNodeaddChild(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameSceneNode, -2220074417980276571, ud)) return -1;
-	SceneNode* self = reinterpret_cast<SceneNode*>(ud->m_data);
+	SceneNode* self = static_cast<SceneNode*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
 	if(LuaBinder::checkUserData(l, 2, "SceneNode", -2220074417980276571, ud)) return -1;
-	SceneNode* iarg0 = reinterpret_cast<SceneNode*>(ud->m_data);
+	SceneNode* iarg0 = static_cast<SceneNode*>(ud->m_data);
 	SceneNode* arg0(iarg0);
 	
 	// Call the method
@@ -411,7 +411,7 @@ static inline int pwrapSceneNodegetMoveComponent(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameSceneNode, -2220074417980276571, ud)) return -1;
-	SceneNode* self = reinterpret_cast<SceneNode*>(ud->m_data);
+	SceneNode* self = static_cast<SceneNode*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -425,9 +425,9 @@ static inline int pwrapSceneNodegetMoveComponent(lua_State* l)
 	}
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "MoveComponent");
-	ud->m_data = reinterpret_cast<void*>(ret);
+	ud->m_data = static_cast<void*>(ret);
 	ud->m_gc = false;
 	ud->m_sig = 2038493110845313445;
 	
@@ -487,7 +487,7 @@ static inline int pwrapModelNodegetSceneNodeBase(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameModelNode, -1856316251880904290, ud)) return -1;
-	ModelNode* self = reinterpret_cast<ModelNode*>(ud->m_data);
+	ModelNode* self = static_cast<ModelNode*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -495,9 +495,9 @@ static inline int pwrapModelNodegetSceneNodeBase(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "SceneNode");
-	ud->m_data = reinterpret_cast<void*>(&ret);
+	ud->m_data = static_cast<void*>(&ret);
 	ud->m_gc = false;
 	ud->m_sig = -2220074417980276571;
 	
@@ -555,7 +555,7 @@ static inline int pwrapInstanceNodegetSceneNodeBase(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameInstanceNode, -2063375830923741403, ud)) return -1;
-	InstanceNode* self = reinterpret_cast<InstanceNode*>(ud->m_data);
+	InstanceNode* self = static_cast<InstanceNode*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Call the method
@@ -563,9 +563,9 @@ static inline int pwrapInstanceNodegetSceneNodeBase(lua_State* l)
 	
 	// Push return value
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "SceneNode");
-	ud->m_data = reinterpret_cast<void*>(&ret);
+	ud->m_data = static_cast<void*>(&ret);
 	ud->m_gc = false;
 	ud->m_sig = -2220074417980276571;
 	
@@ -623,7 +623,7 @@ static inline int pwrapSceneGraphnewModelNode(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameSceneGraph, -7754439619132389154, ud)) return -1;
-	SceneGraph* self = reinterpret_cast<SceneGraph*>(ud->m_data);
+	SceneGraph* self = static_cast<SceneGraph*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -644,9 +644,9 @@ static inline int pwrapSceneGraphnewModelNode(lua_State* l)
 	}
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "ModelNode");
-	ud->m_data = reinterpret_cast<void*>(ret);
+	ud->m_data = static_cast<void*>(ret);
 	ud->m_gc = false;
 	ud->m_sig = -1856316251880904290;
 	
@@ -676,7 +676,7 @@ static inline int pwrapSceneGraphnewInstanceNode(lua_State* l)
 	
 	// Get "this" as "self"
 	if(LuaBinder::checkUserData(l, 1, classnameSceneGraph, -7754439619132389154, ud)) return -1;
-	SceneGraph* self = reinterpret_cast<SceneGraph*>(ud->m_data);
+	SceneGraph* self = static_cast<SceneGraph*>(ud->m_data);
 	ANKI_ASSERT(self != nullptr);
 	
 	// Pop arguments
@@ -694,9 +694,9 @@ static inline int pwrapSceneGraphnewInstanceNode(lua_State* l)
 	}
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "InstanceNode");
-	ud->m_data = reinterpret_cast<void*>(ret);
+	ud->m_data = static_cast<void*>(ret);
 	ud->m_gc = false;
 	ud->m_sig = -2063375830923741403;
 	
@@ -745,9 +745,9 @@ static inline int pwrapgetSceneGraph(lua_State* l)
 	}
 	
 	voidp = lua_newuserdata(l, sizeof(UserData));
-	ud = reinterpret_cast<UserData*>(voidp);
+	ud = static_cast<UserData*>(voidp);
 	luaL_setmetatable(l, "SceneGraph");
-	ud->m_data = reinterpret_cast<void*>(ret);
+	ud->m_data = static_cast<void*>(ret);
 	ud->m_gc = false;
 	ud->m_sig = -7754439619132389154;
 	

+ 9 - 9
src/script/lua_glue_gen.py

@@ -132,22 +132,22 @@ def ret(ret_el):
 		wglue("lua_pushnumber(l, ret);")
 	else:
 	 	wglue("voidp = lua_newuserdata(l, sizeof(UserData));")
-		wglue("ud = reinterpret_cast<UserData*>(voidp);")
+		wglue("ud = static_cast<UserData*>(voidp);")
 		wglue("luaL_setmetatable(l, \"%s\");" % type)
 
 		if is_ptr:
 			if is_const:
 				wglue("ud->m_data = const_cast<void*>(" \
-					"reinterpret_cast<const void*>(ret));")
+					"static_cast<const void*>(ret));")
 			else:
-				wglue("ud->m_data = reinterpret_cast<void*>(ret);")
+				wglue("ud->m_data = static_cast<void*>(ret);")
 			wglue("ud->m_gc = false;")
 		elif is_ref:
 			if is_const:
 				wglue("ud->m_data = const_cast<void*>(" \
-					"reinterpret_cast<const void*>(&ret));")
+					"static_cast<const void*>(&ret));")
 			else:
-				wglue("ud->m_data = reinterpret_cast<void*>(&ret);")
+				wglue("ud->m_data = static_cast<void*>(&ret);")
 			wglue("ud->m_gc = false;")
 		else:
 			wglue("ud->m_data = LuaBinder::luaAlloc(l, sizeof(%s));" % type)
@@ -185,7 +185,7 @@ def arg(arg_txt, stack_index, index):
 	else:
 		wglue("if(LuaBinder::checkUserData(l, %d, \"%s\", %d, ud)) return -1;" \
 			% (stack_index, type, type_sig(type)))
-		wglue("%s* iarg%d = reinterpret_cast<%s*>(ud->m_data);" \
+		wglue("%s* iarg%d = static_cast<%s*>(ud->m_data);" \
 			% (type, index, type))
 
 		if is_ptr:
@@ -295,7 +295,7 @@ def method(class_name, meth_el):
 	wglue("// Get \"this\" as \"self\"")
 	wglue("if(LuaBinder::checkUserData(l, 1, classname%s, %d, ud)) return -1;" \
 		% (class_name, type_sig(class_name)))
-	wglue("%s* self = reinterpret_cast<%s*>(ud->m_data);" \
+	wglue("%s* self = static_cast<%s*>(ud->m_data);" \
 		% (class_name, class_name))
 	wglue("ANKI_ASSERT(self != nullptr);")
 	wglue("")
@@ -432,7 +432,7 @@ def constructor(constr_el, class_name):
 	wglue("")
 
 	wglue("voidp = lua_newuserdata(l, sizeof(UserData));")
-	wglue("ud = reinterpret_cast<UserData*>(voidp);")
+	wglue("ud = static_cast<UserData*>(voidp);")
 	wglue("ud->m_data = inst;")
 	wglue("ud->m_gc = true;")
 	wglue("ud->m_sig = %d;" % type_sig(class_name))
@@ -478,7 +478,7 @@ def destructor(class_name):
 	wglue("if(ud->m_gc)")
 	wglue("{")
 	ident(1)
-	wglue("%s* inst = reinterpret_cast<%s*>(ud->m_data);" \
+	wglue("%s* inst = static_cast<%s*>(ud->m_data);" \
 		% (class_name, class_name))
 	wglue("inst->~%s();" % class_name)
 	wglue("LuaBinder::luaFree(l, inst);")

+ 15 - 17
src/util/Memory.cpp

@@ -175,25 +175,22 @@ void* BaseMemoryPool::allocate(PtrSize size, PtrSize alignmentBytes)
 }
 
 //==============================================================================
-Bool BaseMemoryPool::free(void* ptr)
+void BaseMemoryPool::free(void* ptr)
 {
-	Bool out = false;
 	switch(m_type)
 	{
 	case Type::HEAP:
-		out = static_cast<HeapMemoryPool*>(this)->free(ptr);
+		static_cast<HeapMemoryPool*>(this)->free(ptr);
 		break;
 	case Type::STACK:
-		out = static_cast<StackMemoryPool*>(this)->free(ptr);
+		static_cast<StackMemoryPool*>(this)->free(ptr);
 		break;
 	case Type::CHAIN:
-		out = static_cast<ChainMemoryPool*>(this)->free(ptr);
+		static_cast<ChainMemoryPool*>(this)->free(ptr);
 		break;
 	default:
 		ANKI_ASSERT(0);
 	}
-
-	return out;
 }
 
 //==============================================================================
@@ -264,7 +261,7 @@ void* HeapMemoryPool::allocate(PtrSize size, PtrSize alignment)
 }
 
 //==============================================================================
-Bool HeapMemoryPool::free(void* ptr)
+void HeapMemoryPool::free(void* ptr)
 {
 	ANKI_ASSERT(isCreated());
 
@@ -280,8 +277,6 @@ Bool HeapMemoryPool::free(void* ptr)
 #endif
 	--m_allocationsCount;
 	m_allocCb(m_allocCbUserData, ptr, 0, 0);
-
-	return true;
 }
 
 //==============================================================================
@@ -309,7 +304,7 @@ StackMemoryPool::~StackMemoryPool()
 //==============================================================================
 Error StackMemoryPool::create(
 	AllocAlignedCallback allocCb, void* allocCbUserData,
-	PtrSize size, PtrSize alignmentBytes)
+	PtrSize size, Bool ignoreDeallocationErrors, PtrSize alignmentBytes)
 {
 	ANKI_ASSERT(!isCreated());
 	ANKI_ASSERT(allocCb);
@@ -322,6 +317,7 @@ Error StackMemoryPool::create(
 	m_allocCbUserData = allocCbUserData;
 	m_alignmentBytes = alignmentBytes;
 	m_memsize = getAlignedRoundUp(alignmentBytes, size);
+	m_ignoreDeallocationErrors = ignoreDeallocationErrors;
 
 	m_memory = reinterpret_cast<U8*>(m_allocCb(
 		m_allocCbUserData, nullptr, m_memsize, m_alignmentBytes));
@@ -394,7 +390,7 @@ void* StackMemoryPool::allocate(PtrSize size, PtrSize alignment)
 }
 
 //==============================================================================
-Bool StackMemoryPool::free(void* ptr)
+void StackMemoryPool::free(void* ptr)
 {
 	ANKI_ASSERT(isCreated());
 
@@ -435,7 +431,11 @@ Bool StackMemoryPool::free(void* ptr)
 	// Decrease count
 	--m_allocationsCount;
 
-	return exchange;
+	// Error if needed
+	if(!m_ignoreDeallocationErrors && !exchange)
+	{
+		ANKI_LOGW("Not top of stack. Deallocation failed. Silently ignoring");
+	}
 }
 
 //==============================================================================
@@ -602,12 +602,12 @@ void* ChainMemoryPool::allocate(PtrSize size, PtrSize alignment)
 }
 
 //==============================================================================
-Bool ChainMemoryPool::free(void* ptr)
+void ChainMemoryPool::free(void* ptr)
 {
 	ANKI_ASSERT(isCreated());
 	if(ptr == nullptr)
 	{
-		return true;
+		return;
 	}
 
 	LockGuard<SpinLock> lock(*m_lock);
@@ -660,8 +660,6 @@ Bool ChainMemoryPool::free(void* ptr)
 	}
 
 	--m_allocationsCount;
-
-	return true;
 }
 
 //==============================================================================

+ 5 - 5
tests/util/Allocator.cpp

@@ -14,9 +14,9 @@ ANKI_TEST(Util, StackAllocator)
 
 	// With simple string
 	{
-		StackAllocator<char, false> alloc(allocAligned, nullptr, 128);
-		typedef std::basic_string<char, std::char_traits<char>, 
-			StackAllocator<char, false>> Str;
+		StackAllocator<char> alloc(allocAligned, nullptr, 128);
+		using Str = std::basic_string<char, std::char_traits<char>, 
+			StackAllocator<char>>;
 
 		Str str(alloc);
 
@@ -26,7 +26,7 @@ ANKI_TEST(Util, StackAllocator)
 
 	// With vector
 	{
-		typedef StackAllocator<Foo, false> All;
+		using All = StackAllocator<Foo>;
 		All alloc(allocAligned, nullptr, 
 			(sizeof(Foo) + 1) * 10, alignof(Foo));
 		std::vector<Foo, All> vec(alloc);
@@ -53,7 +53,7 @@ ANKI_TEST(Util, StackAllocator)
 
 	// Copy around
 	{
-		typedef StackAllocator<Foo, false> Alloc;
+		typedef StackAllocator<Foo> Alloc;
 
 		Alloc a(allocAligned, nullptr, 
 			(sizeof(Foo) + 1) * 10, alignof(Foo));

+ 26 - 1
tests/util/Memory.cpp

@@ -8,6 +8,31 @@
 #include "anki/util/Memory.h"
 #include <type_traits>
 
+ANKI_TEST(Util, HeapMemoryPool)
+{
+	// Simple
+	{
+		HeapMemoryPool pool;
+		ANKI_TEST_EXPECT_NO_ERR(pool.create(allocAligned, nullptr));
+
+		void* ptr = pool.allocate(123, 1);
+		ANKI_TEST_EXPECT_NEQ(ptr, nullptr);
+
+		pool.free(ptr);
+	}
+
+	// Simple array
+	{
+		HeapMemoryPool pool;
+		ANKI_TEST_EXPECT_NO_ERR(pool.create(allocAligned, nullptr));
+
+		void* ptr = pool.allocate(2, 1);
+		ANKI_TEST_EXPECT_NEQ(ptr, nullptr);
+
+		pool.free(ptr);
+	}
+}
+
 ANKI_TEST(Util, StackMemoryPool)
 {
 	// Create/destroy test
@@ -33,7 +58,7 @@ ANKI_TEST(Util, StackMemoryPool)
 		ANKI_TEST_EXPECT_EQ(pool.getAllocationsCount(), 1);
 		ANKI_TEST_EXPECT_GEQ(pool.getAllocatedSize(), 25);
 
-		ANKI_TEST_EXPECT_EQ(pool.free(a), true);
+		pool.free(a);
 		ANKI_TEST_EXPECT_EQ(pool.getAllocationsCount(), 0);
 
 		// Allocate a few

+ 1 - 1
thirdparty

@@ -1 +1 @@
-Subproject commit dd8c7dda33e36e6b3105e617876f2dd9d5abc7d7
+Subproject commit 09349de128a289385c6a226b005b90c59757509d