Browse Source

Adding vector wrapper

Panagiotis Christopoulos Charitos 13 years ago
parent
commit
56941d181f

+ 5 - 5
include/anki/gl/ShaderProgram.h

@@ -220,7 +220,7 @@ public:
 	void init(ShaderProgram& prog, const char* blockName);
 
 private:
-	std::vector<ShaderProgramUniformVariable*> uniforms;
+	Vector<ShaderProgramUniformVariable*> uniforms;
 	GLuint index = GL_INVALID_INDEX;
 	uint32_t size = 0; ///< In bytes
 	std::string name;
@@ -232,13 +232,13 @@ private:
 class ShaderProgram: public NonCopyable
 {
 public:
-	typedef std::vector<std::shared_ptr<ShaderProgramVariable>>
+	typedef Vector<std::shared_ptr<ShaderProgramVariable>>
 		VariablesContainer;
-	typedef std::vector<ShaderProgramUniformVariable*>
+	typedef Vector<ShaderProgramUniformVariable*>
 		UniformVariablesContainer;
-	typedef std::vector<ShaderProgramAttributeVariable*>
+	typedef Vector<ShaderProgramAttributeVariable*>
 		AttributeVariablesContainer;
-	typedef std::vector<ShaderProgramUniformBlock>
+	typedef Vector<ShaderProgramUniformBlock>
 		UniformBlocksContainer;
 
 	/// @name Constructors/Destructor

+ 1 - 1
include/anki/gl/Texture.h

@@ -113,7 +113,7 @@ private:
 	};
 
 	/// Texture units
-	std::vector<Unit> units;
+	Vector<Unit> units;
 	/// The active texture unit
 	int activeUnit;
 	/// How many times the @a choseUnit has been called. Used to set the 

+ 1 - 1
include/anki/physics/PhysWorld.h

@@ -58,7 +58,7 @@ class PhysWorld
 		/// Keep here for garbage collection
 		boost::scoped_ptr<btIDebugDraw> debugDrawer;
 		float defaultContactProcessingThreshold;
-		std::vector<Character*> characters;
+		Vector<Character*> characters;
 };
 
 

+ 1 - 1
include/anki/renderer/Drawer.h

@@ -64,7 +64,7 @@ private:
 	/// This is a container of some precalculated spheres. Its a map that
 	/// from sphere complexity it returns a vector of lines (Vec3s in
 	/// pairs)
-	std::map<uint, std::vector<Vec3>> complexityToPreCalculatedSphere;
+	std::map<uint, Vector<Vec3>> complexityToPreCalculatedSphere;
 };
 
 

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

@@ -89,7 +89,7 @@ private:
 	uint32_t width = 0; ///< Image width
 	uint32_t height = 0; ///< Image height
 	ColorType type; ///< Image color type
-	std::vector<uint8_t> data; ///< Image data
+	Vector<uint8_t> data; ///< Image data
 	DataCompression dataCompression;
 
 	/// @name TGA headers

+ 0 - 133
include/anki/resource/LightRsrc.h

@@ -1,133 +0,0 @@
-#ifndef ANKI_RESOURCE_LIGHT_PROPS_H
-#define ANKI_RESOURCE_LIGHT_PROPS_H
-
-#include "anki/math/Math.h"
-#include "anki/resource/Resource.h"
-#include "anki/resource/TextureResource.h"
-
-
-namespace anki {
-
-
-/// Properties common for all lights
-struct LightProps
-{
-	/// @name Common light properties
-	/// @{
-	Vec3 diffuseCol;
-	Vec3 specularCol;
-	bool castsShadowFlag; ///< Currently only for spot lights
-	/// @}
-
-	/// @name Point light properties
-	/// @{
-	float radius; ///< Sphere radius
-	/// @}
-
-	/// @name Spot light properties
-	/// @{
-	float distance; ///< AKA camera's zFar
-	float fovX; ///< For perspective camera
-	float fovY; ///< For perspective camera
-	float width; ///< For orthographic camera
-	float height; ///< For orthographic camera
-	/// @}
-};
-
-
-/// Light properties Resource
-class LightRsrc: private LightProps
-{
-public:
-	enum LightType
-	{
-		LT_POINT,
-		LT_SPOT,
-		LT_NUM
-	};
-
-	enum SpotLightCameraType
-	{
-		SLCT_PERSPECTIVE,
-		SLCT_ORTHOGRAPHIC
-	};
-
-	LightRsrc();
-	~LightRsrc()
-	{}
-
-	/// @name Accessors
-	/// @{
-	const Vec3& getDiffuseColor() const
-	{
-		return diffuseCol;
-	}
-
-	const Vec3& getSpecularColor() const
-	{
-		return specularCol;
-	}
-
-	bool getCastShadow() const
-	{
-		return castsShadowFlag;
-	}
-
-	LightType getType() const
-	{
-		return type;
-	}
-
-	float getRadius() const
-	{
-		return radius;
-	}
-
-	float getDistance() const
-	{
-		return distance;
-	}
-
-	float getFovX() const
-	{
-		return fovX;
-	}
-
-	float getFovY() const
-	{
-		return fovY;
-	}
-
-	float getWidth() const
-	{
-		return width;
-	}
-
-	float getHeight() const
-	{
-		return height;
-	}
-
-	const Texture& getTexture() const;
-	/// @}
-
-	void load(const char* filename);
-
-private:
-	LightType type;
-	SpotLightCameraType spotLightCameraType;
-	TextureResourcePointer texture;
-};
-
-
-inline const Texture& LightRsrc::getTexture() const
-{
-	ANKI_ASSERT(texture.get() != NULL);
-	return *texture;
-}
-
-
-} // end namespace
-
-
-#endif

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

@@ -75,37 +75,37 @@ public:
 
 	/// @name Accessors
 	/// @{
-	const std::vector<Vec3>& getVertCoords() const
+	const Vector<Vec3>& getVertCoords() const
 	{
 		return vertCoords;
 	}
 
-	const std::vector<Vec3>& getVertNormals() const
+	const Vector<Vec3>& getVertNormals() const
 	{
 		return vertNormals;
 	}
 
-	const std::vector<Vec4>& getVertTangents() const
+	const Vector<Vec4>& getVertTangents() const
 	{
 		return vertTangents;
 	}
 
-	const std::vector<Vec2>& getTexCoords() const
+	const Vector<Vec2>& getTexCoords() const
 	{
 		return texCoords;
 	}
 
-	const std::vector<VertexWeight>& getVertWeights() const
+	const Vector<VertexWeight>& getVertWeights() const
 	{
 		return vertWeights;
 	}
 
-	const std::vector<Triangle>& getTris() const
+	const Vector<Triangle>& getTris() const
 	{
 		return tris;
 	}
 
-	const std::vector<ushort>& getVertIndeces() const
+	const Vector<ushort>& getVertIndeces() const
 	{
 		return vertIndeces;
 	}
@@ -114,15 +114,15 @@ public:
 private:
 	/// @name Data
 	/// @{
-	std::vector<Vec3> vertCoords; ///< Loaded from file
-	std::vector<Vec3> vertNormals; ///< Generated
-	std::vector<Vec4> vertTangents; ///< Generated
+	Vector<Vec3> vertCoords; ///< Loaded from file
+	Vector<Vec3> vertNormals; ///< Generated
+	Vector<Vec4> vertTangents; ///< Generated
 	/// Optional. One for every vert so we can use vertex arrays & VBOs
-	std::vector<Vec2> texCoords;
-	std::vector<VertexWeight> vertWeights; ///< Optional
-	std::vector<Triangle> tris; ///< Required
+	Vector<Vec2> texCoords;
+	Vector<VertexWeight> vertWeights; ///< Optional
+	Vector<Triangle> tris; ///< Required
 	/// Generated. Used for vertex arrays & VBOs
-	std::vector<ushort> vertIndeces;
+	Vector<ushort> vertIndeces;
 	/// @}
 
 	/// Load the mesh data from a binary file

+ 3 - 3
include/anki/resource/Path.h

@@ -11,9 +11,9 @@ namespace anki {
 class Path
 {
 	public:
-		std::vector<Vec3> positions; ///< AKA translations
-		std::vector<Mat3> rotations;
-		std::vector<float>  scales;
+		Vector<Vec3> positions; ///< AKA translations
+		Vector<Mat3> rotations;
+		Vector<float>  scales;
 		float         step;
 
 		Path() {}

+ 12 - 12
include/anki/resource/ShaderProgramPrePreprocessor.h

@@ -47,7 +47,7 @@ public:
 
 	/// @name Accessors
 	/// @{
-	const std::vector<std::string>& getTranformFeedbackVaryings() const
+	const Vector<std::string>& getTranformFeedbackVaryings() const
 	{
 		return trffbVaryings;
 	}
@@ -111,14 +111,14 @@ protected:
 		friend class PrePreprocessor;
 
 		/// Names and and ids for transform feedback varyings
-		std::vector<TrffbVaryingPragma> trffbVaryings;
+		Vector<TrffbVaryingPragma> trffbVaryings;
 		boost::array<std::string, ST_NUM> shaderSources;
 	};
 
 	Output output; ///< The most important variable
-	std::vector<std::string> trffbVaryings;
+	Vector<std::string> trffbVaryings;
 	/// The parseFileForPragmas fills this
-	std::vector<std::string> sourceLines;
+	Vector<std::string> sourceLines;
 	boost::array<CodeBeginningPragma, ST_NUM> shaderStarts;
 	static boost::array<const char*, ST_NUM> startTokens; ///< XXX
 
@@ -140,17 +140,17 @@ protected:
 	/// @todo
 	void parseStartPragma(scanner::Scanner& scanner,
 		const std::string& filename, uint depth,
-		const std::vector<std::string>& lines);
+		const Vector<std::string>& lines);
 
 	/// @todo
 	void parseIncludePragma(scanner::Scanner& scanner,
 		const std::string& filename, uint depth,
-		const std::vector<std::string>& lines);
+		const Vector<std::string>& lines);
 
 	/// @todo
 	void parseTrffbVarying(scanner::Scanner& scanner,
 		const std::string& filename, uint depth,
-		const std::vector<std::string>& lines);
+		const Vector<std::string>& lines);
 
 	/// Searches inside the Output::attributes or Output::trffbVaryings
 	/// vectors
@@ -158,8 +158,8 @@ protected:
 	/// @param what The name of the varying or attrib
 	/// @return Iterator to the vector
 	template<typename Type>
-	typename std::vector<Type>::const_iterator findNamed(
-		const std::vector<Type>& vec,
+	typename Vector<Type>::const_iterator findNamed(
+		const Vector<Type>& vec,
 		const std::string& what) const;
 
 	void printSourceLines() const;  ///< For debugging
@@ -170,11 +170,11 @@ protected:
 
 
 template<typename Type>
-typename std::vector<Type>::const_iterator
+typename Vector<Type>::const_iterator
 	ShaderProgramPrePreprocessor::findNamed(
-	const std::vector<Type>& vec, const std::string& what) const
+	const Vector<Type>& vec, const std::string& what) const
 {
-	typename std::vector<Type>::const_iterator it = vec.begin();
+	typename Vector<Type>::const_iterator it = vec.begin();
 	while(it != vec.end() && it->name != what)
 	{
 		++it;

+ 6 - 6
include/anki/resource/SkelAnim.h

@@ -54,7 +54,7 @@ class BoneAnim
 public:
 	/// @name Accessors
 	/// @{
-	const std::vector<BonePose>& getBonePoses() const
+	const Vector<BonePose>& getBonePoses() const
 	{
 		return bonePoses;
 	}
@@ -63,7 +63,7 @@ public:
 private:
 	/// The poses for every keyframe. Its empty if the bone doesnt have
 	/// any animation
-	std::vector<BonePose> bonePoses;
+	Vector<BonePose> bonePoses;
 };
 
 
@@ -90,7 +90,7 @@ class SkelAnim
 public:
 	/// @name Accessors
 	/// @{
-	const std::vector<uint>& getKeyframes() const
+	const Vector<uint>& getKeyframes() const
 	{
 		return keyframes;
 	}
@@ -100,7 +100,7 @@ public:
 		return framesNum;
 	}
 
-	const std::vector<BoneAnim>& getBoneAnimations() const
+	const Vector<BoneAnim>& getBoneAnimations() const
 	{
 		return boneAnims;
 	}
@@ -110,9 +110,9 @@ public:
 	void load(const char* filename);
 
 private:
-	std::vector<uint> keyframes;
+	Vector<uint> keyframes;
 	uint framesNum;
-	std::vector<BoneAnim> boneAnims;
+	Vector<BoneAnim> boneAnims;
 };
 
 

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

@@ -128,14 +128,14 @@ public:
 
 	/// @name Accessors
 	/// @{
-	const std::vector<Bone>& getBones() const
+	const Vector<Bone>& getBones() const
 	{
 		return bones;
 	}
 	/// @}
 
 private:
-	std::vector<Bone> bones;
+	Vector<Bone> bones;
 };
 
 

+ 6 - 11
include/anki/resource/Skin.h

@@ -4,17 +4,15 @@
 #include "anki/resource/Resource.h"
 #include "anki/resource/Model.h"
 
-
 namespace anki {
 
-
 class Skeleton;
 class SkelAnim;
 
-
+/// Skin resource
+/// 
 /// XML file format:
-/// @code
-/// <skin>
+/// @code<skin>
 /// 	<model>path/to/model.mdl</model>
 /// 	<skeleton>path/to/skeleton.skel</skeleton>
 /// 	<skelAnims>
@@ -22,12 +20,11 @@ class SkelAnim;
 /// 		...
 /// 		<skelAnim>...</skelAnim>
 /// 	</skelAnims>
-/// </skin>
-/// @endcode
+/// </skin>@endcode
 class Skin
 {
 public:
-	typedef std::vector<SkelAnimResourcePointer> SkeletonAnimationsContainer;
+	typedef Vector<SkelAnimResourcePointer> SkeletonAnimationsContainer;
 
 	Skin();
 	~Skin();
@@ -63,8 +60,6 @@ private:
 	/// @}
 };
 
-
-} // end namespace
-
+} // end namespace anki
 
 #endif

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

@@ -31,7 +31,7 @@ class ParticleEmitterNode: public SceneNode, public ParticleEmitterRsrc
 
 	private:
 		boost::scoped_ptr<btCollisionShape> collShape;
-		std::vector<Particle*> particles;
+		Vector<Particle*> particles;
 		float timeLeftForNextEmission;
 		/// The resource
 		ParticleEmitterRsrcResourcePointer particleEmitterProps;

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

@@ -57,7 +57,7 @@ private:
 class Renderable
 {
 public:
-	typedef std::vector<PropertyBase*> MaterialVariableProperties;
+	typedef Vector<PropertyBase*> MaterialVariableProperties;
 
 	Renderable()
 	{}

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

@@ -22,7 +22,7 @@ public:
 	template<typename T>
 	struct Types
 	{
-		typedef std::vector<T*> Container;
+		typedef Vector<T*> Container;
 		typedef typename Container::iterator Iterator;
 		typedef typename Container::const_iterator ConstIterator;
 		typedef typename ConstCharPtrHashMap<T*>::Type NameToItemMap;
@@ -108,7 +108,7 @@ public:
 		return (it == nameToNode.end()) ? nullptr : it->second;
 	}
 
-	std::vector<Sector> sectors;
+	Vector<Sector> sectors;
 
 private:
 	Types<SceneNode>::Container nodes;

+ 13 - 13
include/anki/scene/SkinNode.h

@@ -242,22 +242,22 @@ public:
 
 	/// @name Accessors
 	/// @{
-	const std::vector<Vec3>& getHeads() const
+	const Vector<Vec3>& getHeads() const
 	{
 		return heads;
 	}
 
-	const std::vector<Vec3>& getTails() const
+	const Vector<Vec3>& getTails() const
 	{
 		return tails;
 	}
 
-	const std::vector<Mat3>& getBoneRotations() const
+	const Vector<Mat3>& getBoneRotations() const
 	{
 		return boneRotations;
 	}
 
-	const std::vector<Vec3>& getBoneTranslations() const
+	const Vector<Vec3>& getBoneTranslations() const
 	{
 		return boneTranslations;
 	}
@@ -322,10 +322,10 @@ private:
 
 	/// @name Bone data
 	/// @{
-	std::vector<Vec3> heads;
-	std::vector<Vec3> tails;
-	std::vector<Mat3> boneRotations;
-	std::vector<Vec3> boneTranslations;
+	Vector<Vec3> heads;
+	Vector<Vec3> tails;
+	Vector<Mat3> boneRotations;
+	Vector<Vec3> boneTranslations;
 	/// @}
 
 	/// Interpolate
@@ -334,17 +334,17 @@ private:
 	/// @param[out] translations Translations vector
 	/// @param[out] rotations Rotations vector
 	static void interpolate(const SkelAnim& animation, float frame,
-		std::vector<Vec3>& translations, std::vector<Mat3>& rotations);
+		Vector<Vec3>& translations, std::vector<Mat3>& rotations);
 
 	/// Calculate the global pose
 	static void updateBoneTransforms(const Skeleton& skel,
-		std::vector<Vec3>& translations, std::vector<Mat3>& rotations);
+		Vector<Vec3>& translations, std::vector<Mat3>& rotations);
 
 	/// Deform the heads and tails
 	static void deformHeadsTails(const Skeleton& skeleton,
-		const std::vector<Vec3>& boneTranslations,
-		const std::vector<Mat3>& boneRotations,
-		std::vector<Vec3>& heads, std::vector<Vec3>& tails);
+		const Vector<Vec3>& boneTranslations,
+		const Vector<Mat3>& boneRotations,
+		Vector<Vec3>& heads, std::vector<Vec3>& tails);
 };
 
 } // end namespace

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

@@ -22,8 +22,8 @@ class VisibilityInfo
 	friend class VisibilityTester;
 
 public:
-	typedef std::vector<Renderable*> Renderables;
-	typedef std::vector<Light*> Lights;
+	typedef Vector<Renderable*> Renderables;
+	typedef Vector<Light*> Lights;
 
 	Renderables::iterator getRenderablesBegin()
 	{

+ 4 - 4
include/anki/ui/UiFtFontLoader.h

@@ -56,10 +56,10 @@ public:
 		return imgSize;
 	}
 
-	boost::iterator_range<std::vector<Glyph>::const_iterator>
+	boost::iterator_range<Vector<Glyph>::const_iterator>
 		getGlyphs() const
 	{
-		return boost::iterator_range<std::vector<Glyph>::const_iterator>(
+		return boost::iterator_range<Vector<Glyph>::const_iterator>(
 			glyphs.begin(), glyphs.end());
 	}
 
@@ -82,8 +82,8 @@ private:
 	/// @{
 	FT_Library library;
 	FT_Face face;
-	std::vector<Glyph> glyphs;
-	std::vector<uint8_t> img;
+	Vector<Glyph> glyphs;
+	Vector<uint8_t> img;
 	FT_Vector imgSize;
 	uint32_t lineHeight; ///< Calculated as the max height among all glyphs
 	/// @}

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

@@ -16,7 +16,7 @@ class Object
 {
 public:
 	typedef T Value;
-	typedef std::vector<Value*> Container;
+	typedef Vector<Value*> Container;
 	typedef boost::iterator_range<typename Container::const_iterator>
 		ConstIteratorRange;
 	typedef boost::iterator_range<typename Container::iterator>

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

@@ -10,11 +10,11 @@ namespace anki {
 /// @{
 
 /// A simple convenience class for string lists
-class StringList: public std::vector<std::string>
+class StringList: public Vector<std::string>
 {
 public:
 	typedef StringList Self; ///< Self type
-	typedef std::vector<std::string> Base; ///< Its the vector of strings
+	typedef Vector<std::string> Base; ///< Its the vector of strings
 	typedef Base::value_type String; ///< Its string
 	typedef String::value_type Char; ///< Char type
 

+ 75 - 0
include/anki/util/Vector.h

@@ -0,0 +1,75 @@
+#ifndef ANKI_UTIL_VECTOR_H
+#define ANKI_UTIL_VECTOR_H
+
+#include "anki/util/Assert.h"
+#include <vector>
+#include <cassert>
+
+namespace anki {
+
+/// @addtogroup util
+/// @{
+
+/// This is a wrapper of Vector that adds new functionality and assertions
+/// in operator[]
+template<typename Type, typename Allocator = std::allocator<Type>>
+class Vector: public Vector<Type, Allocator>
+{
+public:
+	typedef Vector<Type, Allocator> Base;
+	typedef typename Base::value_type value_type;
+	typedef typename Base::allocator_type allocator_type;
+	typedef typename Base::size_type size_type;
+	typedef typename Base::reference reference;
+	typedef typename Base::const_reference const_reference;
+	typedef typename Base::iterator iterator;
+	typedef typename Base::const_iterator const_iterator;
+	typedef typename Base::pointer pointer;
+
+	/// @name Constructors & destructor
+	/// @{
+	Vector()
+		: Base()
+	{}
+
+	Vector(const allocator_type& a)
+		: Base(a)
+	{}
+
+	Vector(size_type n,
+		const value_type& value = value_type(),
+		const allocator_type& a = allocator_type())
+		: Base(n, value, a)
+	{}
+
+	Vector(const Vector& x)
+		: Base(x)
+	{}
+
+	template<typename InputIterator>
+	Vector(InputIterator first, InputIterator last,
+		const allocator_type& a = allocator_type())
+		: Base(first, last, a)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	reference operator[](size_type n)
+	{
+		ANKI_ASSERT(n < Base::size());
+		return Base::operator[](n);
+	}
+
+	const_reference operator[](size_type n) const
+	{
+		ANKI_ASSERT(n < Base::size());
+		return Base::operator[](n);
+	}
+	/// @}
+};
+/// @}
+
+} // end namespace anki
+
+#endif

+ 1 - 1
src/gl/ShaderProgram.cpp

@@ -358,7 +358,7 @@ GLuint ShaderProgram::createAndCompileShader(const char* sourceCode,
 		// Get info log
 		int infoLen = 0;
 		int charsWritten = 0;
-		std::vector<char> infoLog;
+		Vector<char> infoLog;
 
 		glGetShaderiv(glId, GL_INFO_LOG_LENGTH, &infoLen);
 		infoLog.resize(infoLen + 1);

+ 3 - 3
src/renderer/Drawer.cpp

@@ -100,11 +100,11 @@ void DebugDrawer::drawGrid()
 //==============================================================================
 void DebugDrawer::drawSphere(float radius, int complexity)
 {
-	std::vector<Vec3>* sphereLines;
+	Vector<Vec3>* sphereLines;
 
 	// Pre-calculate the sphere points5
 	//
-	std::map<uint, std::vector<Vec3> >::iterator it =
+	std::map<uint, Vector<Vec3> >::iterator it =
 		complexityToPreCalculatedSphere.find(complexity);
 
 	if(it != complexityToPreCalculatedSphere.end()) // Found
@@ -113,7 +113,7 @@ void DebugDrawer::drawSphere(float radius, int complexity)
 	}
 	else // Not found
 	{
-		complexityToPreCalculatedSphere[complexity] = std::vector<Vec3>();
+		complexityToPreCalculatedSphere[complexity] = Vector<Vec3>();
 		sphereLines = &complexityToPreCalculatedSphere[complexity];
 
 		float fi = Math::PI / complexity;

+ 0 - 1
src/renderer/Sm.cpp

@@ -1,7 +1,6 @@
 #include "anki/renderer/Sm.h"
 #include "anki/renderer/Renderer.h"
 #include "anki/core/App.h"
-#include "anki/resource/LightRsrc.h"
 #include "anki/scene/Scene.h"
 #include "anki/scene/Camera.h"
 #include "anki/scene/Light.h"

+ 1 - 1
src/resource/Image.cpp

@@ -255,7 +255,7 @@ bool Image::loadPng(const char* filename, std::string& err) throw()
 	uint channels;
 	uint rowbytes;
 	uint colorType;
-	std::vector<png_bytep> rowPointers;
+	Vector<png_bytep> rowPointers;
 
 	// Open file
 	//

+ 0 - 223
src/resource/LightRsrc.cpp

@@ -1,223 +0,0 @@
-#include "anki/resource/LightRsrc.h"
-#include "anki/resource/TextureResource.h"
-#include "anki/misc/PropertyTree.h"
-#include "anki/core/Logger.h"
-#include <cstring>
-#include <string>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lexical_cast.hpp>
-
-
-namespace anki {
-
-
-//==============================================================================
-LightRsrc::LightRsrc()
-{
-	diffuseCol = Vec3(0.5);
-	specularCol = Vec3(0.5);
-	castsShadowFlag = false;
-	radius = 1.0;
-	distance = 3.0;
-	fovX = fovY = Math::PI / 4.0;
-	width = height = 1.0;
-	spotLightCameraType = SLCT_PERSPECTIVE;
-}
-
-
-//==============================================================================
-void LightRsrc::load(const char* filename)
-{
-	try
-	{
-		using namespace boost::property_tree;
-		ptree rpt;
-		read_xml(filename, rpt);
-
-		const ptree& pt = rpt.get_child("light");
-
-		//
-		// type
-		//
-		std::string type_ = pt.get<std::string>("type");
-		if(type_ == "POINT")
-		{
-			type = LT_POINT;
-		}
-		else if(type_ == "SPOT")
-		{
-			type = LT_SPOT;
-		}
-		else
-		{
-			throw ANKI_EXCEPTION("Incorrect type: " + type_);
-		}
-
-		//
-		// diffuseCol
-		//
-		boost::optional<const ptree&> diffColTree =
-			pt.get_child_optional("diffuseCol");
-		if(diffColTree)
-		{
-			diffuseCol = PropertyTree::getVec3(diffColTree.get());
-		}
-
-		//
-		// specularCol
-		//
-		boost::optional<const ptree&> specColTree =
-			pt.get_child_optional("specularCol");
-		if(specColTree)
-		{
-			specularCol = PropertyTree::getVec3(specColTree.get());
-		}
-
-		//
-		// castsShadow
-		//
-		boost::optional<bool> castsShadow_ =
-			PropertyTree::getBoolOptional(pt, "castsShadow");
-		if(castsShadow_)
-		{
-			castsShadowFlag = castsShadow_.get();
-		}
-
-		//
-		// radius
-		//
-		boost::optional<float> radius_ = pt.get_optional<float>("radius");
-		if(radius_)
-		{
-			radius = radius_.get();
-
-			if(type == LT_SPOT)
-			{
-				ANKI_LOGW("File \"" << filename <<
-					"\": No radius for spot lights");
-			}
-		}
-
-		//
-		// distance
-		//
-		boost::optional<float> distance_ = pt.get_optional<float>("distance");
-		if(distance_)
-		{
-			distance = distance_.get();
-
-			if(type == LT_POINT)
-			{
-				ANKI_LOGW("File \"" << filename <<
-					"\": No distance for point lights");
-			}
-		}
-
-		//
-		// fovX
-		//
-		boost::optional<float> fovX_ = pt.get_optional<float>("fovX");
-		if(fovX_)
-		{
-			fovX = fovX_.get();
-
-			if(type == LT_POINT)
-			{
-				ANKI_LOGW("File \"" << filename <<
-					"\": No fovX for point lights");
-			}
-		}
-
-		//
-		// fovY
-		//
-		boost::optional<float> fovY_ = pt.get_optional<float>("fovY");
-		if(fovY_)
-		{
-			fovY = fovY_.get();
-
-			if(type == LT_POINT)
-			{
-				ANKI_LOGW("File \"" << filename <<
-					"\": No fovY for point lights");
-			}
-		}
-
-		//
-		// width
-		//
-		boost::optional<float> width_ = pt.get_optional<float>("width");
-		if(width_)
-		{
-			width = width_.get();
-
-			if(type == LT_POINT)
-			{
-				ANKI_LOGW("File \"" << filename <<
-					"\": No width for point lights");
-			}
-		}
-
-		//
-		// height
-		//
-		boost::optional<float> height_ = pt.get_optional<float>("height");
-		if(height_)
-		{
-			height = height_.get();
-
-			if(type == LT_POINT)
-			{
-				ANKI_LOGW("File \"" << filename <<
-					"\": No height for point lights");
-			}
-		}
-
-		//
-		// texture
-		//
-		boost::optional<std::string> tex =
-			pt.get_optional<std::string>("texture");
-		if(tex)
-		{
-			texture.load(tex.get().c_str());
-
-			if(type == LT_POINT)
-			{
-				ANKI_LOGW("File \"" << filename <<
-					"\": No texture for point lights");
-			}
-		}
-
-		//
-		// cameraType
-		//
-		boost::optional<std::string> cam =
-			pt.get_optional<std::string>("cameraType");
-		if(cam)
-		{
-			if(cam.get() == "PERSPECTIVE")
-			{
-				spotLightCameraType = SLCT_PERSPECTIVE;
-			}
-			else if(cam.get() == "ORTHOGRAPHIC")
-			{
-				spotLightCameraType = SLCT_ORTHOGRAPHIC;
-			}
-			else
-			{
-				throw ANKI_EXCEPTION("Incorrect cameraYype: " + cam.get());
-			}
-		}
-
-	}
-	catch(std::exception& e)
-	{
-		throw ANKI_EXCEPTION("Material \"" + filename + "\"") << e;
-	}
-}
-
-
-} // end namespace

+ 2 - 2
src/resource/MaterialShaderProgramCreator.cpp

@@ -46,7 +46,7 @@ void MaterialShaderProgramCreator::parseShaderTag(
 
 	// <includes></includes>
 	//
-	std::vector<std::string> includeLines;
+	Vector<std::string> includeLines;
 
 	XmlElement includesEl = shaderEl.getChildElement("includes");
 	XmlElement includeEl = includesEl.getChildElement("include");
@@ -69,7 +69,7 @@ void MaterialShaderProgramCreator::parseShaderTag(
 	if(inputsEl)
 	{
 		// Store the source of the uniform vars
-		std::vector<std::string> uniformsLines;
+		Vector<std::string> uniformsLines;
 	
 		XmlElement inputEl = inputsEl.getChildElement("input");
 		do

+ 1 - 1
src/resource/MeshLoader.cpp

@@ -211,7 +211,7 @@ void MeshLoader::createVertNormals()
 void MeshLoader::createVertTangents()
 {
 	vertTangents.resize(vertCoords.size(), Vec4(0.0)); // alloc
-	std::vector<Vec3> bitagents(vertCoords.size(), Vec3(0.0));
+	Vector<Vec3> bitagents(vertCoords.size(), Vec3(0.0));
 
 	for(uint i = 0; i < tris.size(); i++)
 	{

+ 4 - 4
src/resource/ShaderProgramPrePreprocessor.cpp

@@ -255,7 +255,7 @@ void ShaderProgramPrePreprocessor::parseFile(const char* filename)
 //==============================================================================
 void ShaderProgramPrePreprocessor::parseStartPragma(scanner::Scanner& scanner,
 	const std::string& filename, uint depth,
-	const std::vector<std::string>& lines)
+	const Vector<std::string>& lines)
 {
 	const scanner::Token* token = &scanner.getNextToken();
 
@@ -306,7 +306,7 @@ void ShaderProgramPrePreprocessor::parseStartPragma(scanner::Scanner& scanner,
 //==============================================================================
 void ShaderProgramPrePreprocessor::parseIncludePragma(
 	scanner::Scanner& scanner, const std::string& /*filename*/, uint depth,
-	const std::vector<std::string>& lines)
+	const Vector<std::string>& lines)
 {
 	const scanner::Token* token = &scanner.getNextToken();
 
@@ -335,7 +335,7 @@ void ShaderProgramPrePreprocessor::parseIncludePragma(
 //==============================================================================
 void ShaderProgramPrePreprocessor::parseTrffbVarying(scanner::Scanner& scanner,
 	const std::string& filename, uint /*depth*/,
-	const std::vector<std::string>& lines)
+	const Vector<std::string>& lines)
 {
 	const scanner::Token* token = &scanner.getNextToken();
 
@@ -344,7 +344,7 @@ void ShaderProgramPrePreprocessor::parseTrffbVarying(scanner::Scanner& scanner,
 		std::string varName = token->getValue().getString();
 
 		// check if already defined and for circular includance
-		std::vector<TrffbVaryingPragma>::const_iterator var =
+		Vector<TrffbVaryingPragma>::const_iterator var =
 			findNamed(output.trffbVaryings, varName);
 
 		// Throw the correct exception

+ 23 - 40
src/resource/Skin.cpp

@@ -6,98 +6,81 @@
 #include "anki/resource/PassLevelKey.h"
 #include "anki/resource/Model.h"
 #include "anki/resource/Material.h"
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
-#include <boost/foreach.hpp>
-
+#include "anki/misc/Xml.h"
 
 namespace anki {
 
-
 //==============================================================================
 
 Skin::Skin()
 {}
 
-
 Skin::~Skin()
 {}
 
-
 //==============================================================================
 void Skin::load(const char* filename)
 {
 	try
 	{
-		//
 		// Load
 		//
-		using namespace boost::property_tree;
-		ptree pt_;
-		read_xml(filename, pt_);
+		XmlDocument doc;
+		doc.loadFile(filename);
 
-		const ptree& pt = pt_.get_child("skin");
+		XmlElement skinEl = doc.getChildElement("skin");
 
 		// model
-		model.load(pt.get<std::string>("model").c_str());
+		model.load(skinEl.getChildElement("model").getText());
 
 		// skeleton
-		skeleton.load(pt.get<std::string>("skeleton").c_str());
+		skeleton.load(skinEl.getChildElement("skeleton").getText());
 
 		// Anims
-		boost::optional<const ptree&> skelAnimsTree =
-			pt.get_child_optional("skelAnims");
-		if(skelAnimsTree)
+		XmlElement skelAnimsEl = skinEl.getChildElementOptional("skelAnims");
+		if(skelAnimsEl)
 		{
-			BOOST_FOREACH(const ptree::value_type& v, skelAnimsTree.get())
-			{
-				if(v.first != "skelAnim")
-				{
-					throw ANKI_EXCEPTION("Expected skelAnim and no " + v.first);
-				}
+			XmlElement skelAnimEl = skelAnimsEl.getChildElement("skelAnim");
 
-				const std::string& name = v.second.data();
+			do
+			{
 				skelAnims.push_back(SkelAnimResourcePointer());
-				skelAnims.back().load(name.c_str());
-			}
+				skelAnims.back().load(skelAnimEl.getText());
+
+				skelAnimEl = skelAnimEl.getNextSiblingElement("skelAnim");
+			} while(skelAnimEl);
 		}
 
-		//
 		// Sanity checks
 		//
 
 		// Anims and skel bones num check
-		BOOST_FOREACH(const SkelAnimResourcePointer& skelAnim, skelAnims)
+		for(const SkelAnimResourcePointer& skelAnim : skelAnims)
 		{
 			// Bone number problem
 			if(skelAnim->getBoneAnimations().size() !=
 				skeleton->getBones().size())
 			{
-				throw ANKI_EXCEPTION("Skeleton animation \"" +
-					skelAnim.getResourceName() + "\" and skeleton \"" +
-					skeleton.getResourceName() +
-					"\" dont have equal bone count");
+				throw ANKI_EXCEPTION("Skeleton animation \"" 
+					+ skelAnim.getResourceName() + "\" and skeleton \"" 
+					+ skeleton.getResourceName() 
+					+ "\" dont have equal bone count");
 			}
 		}
 
 		// All meshes should have vert weights
-		for(Model::ModelPatchesContainer::const_iterator it =
-			model->getModelPatches().begin();
-			it != model->getModelPatches().end(); ++it)
+		for(const ModelPatch& patch : model->getModelPatches())
 		{
-			const ModelPatch& patch = *it;
-
 			if(!patch.getMeshBase().hasWeights())
 			{
 				throw ANKI_EXCEPTION("Mesh does not support HW skinning");
 			}
 		}
-	  }
+	}
 	catch(const std::exception& e)
 	{
 		throw ANKI_EXCEPTION("Skin loading failed: " + filename) << e;
 	}
 }
 
-
-} // end namespace
+} // end namespace anki

+ 0 - 1
src/scene/Light.cpp

@@ -1,5 +1,4 @@
 #include "anki/scene/Light.h"
-#include "anki/resource/LightRsrc.h"
 
 namespace anki {
 

+ 6 - 6
src/scene/SkinNode.cpp

@@ -240,14 +240,14 @@ void SkinNode::frameUpdate(float prevUpdateTime, float crntTime, int f)
 
 //==============================================================================
 void SkinNode::interpolate(const SkelAnim& animation, float frame,
-	std::vector<Vec3>& boneTranslations, std::vector<Mat3>& boneRotations)
+	Vector<Vec3>& boneTranslations, std::vector<Mat3>& boneRotations)
 {
 	ANKI_ASSERT(frame < animation.getFramesNum());
 
 	// calculate the t (used in slerp and lerp) using the keyframs and the
 	// frame and calc the lPose and rPose witch indicate the pose IDs in witch
 	// the frame lies between
-	const std::vector<uint>& keyframes = animation.getKeyframes();
+	const Vector<uint>& keyframes = animation.getKeyframes();
 	float t = 0.0;
 	uint lPose = 0, rPose = 0;
 	for(uint j = 0; j < keyframes.size(); j++)
@@ -305,7 +305,7 @@ void SkinNode::interpolate(const SkelAnim& animation, float frame,
 
 //==============================================================================
 void SkinNode::updateBoneTransforms(const Skeleton& skeleton,
-	std::vector<Vec3>& boneTranslations, std::vector<Mat3>& boneRotations)
+	Vector<Vec3>& boneTranslations, std::vector<Mat3>& boneRotations)
 {
 	std::array<uint, 128> queue;
 	uint head = 0, tail = 0;
@@ -363,9 +363,9 @@ void SkinNode::updateBoneTransforms(const Skeleton& skeleton,
 
 //==============================================================================
 void SkinNode::deformHeadsTails(const Skeleton& skeleton,
-    const std::vector<Vec3>& boneTranslations,
-    const std::vector<Mat3>& boneRotations,
-    std::vector<Vec3>& heads, std::vector<Vec3>& tails)
+    const Vector<Vec3>& boneTranslations,
+    const Vector<Mat3>& boneRotations,
+    Vector<Vec3>& heads, std::vector<Vec3>& tails)
 {
 	for(uint i = 0; i < skeleton.getBones().size(); i++)
 	{

+ 0 - 1
testapp/Main.cpp

@@ -13,7 +13,6 @@
 #include "anki/resource/Material.h"
 #include "anki/scene/Scene.h"
 #include "anki/resource/SkelAnim.h"
-#include "anki/resource/LightRsrc.h"
 #include "anki/misc/Parser.h"
 #include "anki/scene/ParticleEmitterNode.h"
 #include "anki/physics/Character.h"