Ver código fonte

Port Vector to NMF

Daniele Bartolini 12 anos atrás
pai
commit
f0e3aeb488

+ 4 - 4
engine/compilers/BundleCompiler.cpp

@@ -95,11 +95,11 @@ bool BundleCompiler::compile(const char* bundle_dir, const char* source_dir, con
 	{
 	{
 		DynamicString filename(default_allocator());
 		DynamicString filename(default_allocator());
 		filename = resource;
 		filename = resource;
-		files.push_back(filename);
+		vector::push_back(files, filename);
 	}
 	}
 
 
 	// Compile all resources
 	// Compile all resources
-	for (uint32_t i = 0; i < files.size(); i++)
+	for (uint32_t i = 0; i < vector::size(files); i++)
 	{
 	{
 		const char* filename = files[i].c_str();
 		const char* filename = files[i].c_str();
 
 
@@ -196,7 +196,7 @@ void BundleCompiler::scan(const char* source_dir, const char* cur_dir, Vector<Dy
 	DiskFilesystem fs(source_dir);
 	DiskFilesystem fs(source_dir);
 	fs.list_files(cur_dir, my_files);
 	fs.list_files(cur_dir, my_files);
 
 
-	for (uint32_t i = 0; i < my_files.size(); i++)
+	for (uint32_t i = 0; i < vector::size(my_files); i++)
 	{
 	{
 		DynamicString file_i(default_allocator());
 		DynamicString file_i(default_allocator());
 
 
@@ -213,7 +213,7 @@ void BundleCompiler::scan(const char* source_dir, const char* cur_dir, Vector<Dy
 		}
 		}
 		else // Assume a regular file
 		else // Assume a regular file
 		{
 		{
-			files.push_back(file_i);
+			vector::push_back(files, file_i);
 		}
 		}
 	}
 	}
 }
 }

+ 23 - 0
engine/core/containers/ContainerTypes.h

@@ -61,6 +61,29 @@ struct Array
 	T* m_array;
 	T* m_array;
 };
 };
 
 
+/// Dynamic array of objects.
+/// @note
+/// Calls constructors and destructors, not suitable for performance-critical stuff.
+/// If your data is POD, use Array<T> instead.
+///
+/// @ingroup Containers
+template <typename T>
+struct Vector
+{
+	Vector(Allocator& allocator);
+	Vector(Allocator& allocator, uint32_t capacity);
+	Vector(const Vector<T>& other);
+	~Vector();
+
+	/// Random access by index
+	T& operator[](uint32_t index);
+	const T& operator[](uint32_t index) const;
+
+	const Vector<T>& operator=(const Vector<T>& other);
+
+	Array<T> m_array;
+};
+
 /// Circular buffer double-ended queue of POD items.
 /// Circular buffer double-ended queue of POD items.
 /// @note
 /// @note
 /// Does not call constructors/destructors so it is not very suitable for non-POD items.
 /// Does not call constructors/destructors so it is not very suitable for non-POD items.

+ 182 - 273
engine/core/containers/Vector.h

@@ -26,391 +26,300 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 
 #pragma once
 #pragma once
 
 
-#include "Allocator.h"
 #include "Types.h"
 #include "Types.h"
 #include "Assert.h"
 #include "Assert.h"
+#include "Array.h"
 
 
 namespace crown
 namespace crown
 {
 {
 
 
-/// Dynamic array of objects.
-/// @note
-/// Calls constructors and destructors, not suitable for performance-critical stuff.
-/// If your data is POD, use Array<T> instead.
-template <typename T>
-class Vector
+/// Functions to manipulate Vector.
+///
+/// @ingroup Containers
+namespace vector
 {
 {
-public:
-
-	/// Does not allocate memory.
-						Vector(Allocator& allocator);
-
-	/// Allocates capacity * sizeof(T) bytes.
-						Vector(Allocator& allocator, uint32_t capacity);
-						Vector(const Vector<T>& other);
-						~Vector();
-
-	/// Random access by index
-	T&					operator[](uint32_t index);
-
-	/// Random access by index
-	const T&			operator[](uint32_t index) const;
-
-	/// Returns whether the vector is empty
-	bool				empty() const;
+	/// Returns whether the vector @a v is empty.
+	template <typename T> bool empty(const Vector<T>& v);
 
 
-	/// Returns the number of items in the vector
-	uint32_t			size() const;
+	/// Returns the number of items in the vector @a v.
+	template <typename T> uint32_t size(const Vector<T>& v);
 
 
-	/// Returns the maximum number of items the array can hold
-	uint32_t			capacity() const;
+	/// Returns the maximum number of items the vector @a v can hold.
+	template <typename T> uint32_t capacity(const Vector<T>& v);
 
 
-	/// Resizes the vector to the given @a size.
+	/// Resizes the vector @a v to the given @a size.
 	/// @note
 	/// @note
 	/// Old items will be copied to the newly created vector.
 	/// Old items will be copied to the newly created vector.
 	/// If the new capacity is smaller than the previous one, the
 	/// If the new capacity is smaller than the previous one, the
 	/// vector will be truncated.
 	/// vector will be truncated.
-	void				resize(uint32_t size);
+	template <typename T> void resize(Vector<T>& v, uint32_t size);
 
 
-	/// Reserves space in the vector for at least @a capacity items.
-	void				reserve(uint32_t capacity);
+	/// Reserves space in the vector @a v for at least @a capacity items.
+	template <typename T> void reserve(Vector<T>& v, uint32_t capacity);
 
 
-	/// Sets the vector capacity
-	void				set_capacity(uint32_t capacity);
+	/// Sets the capacity of vector @a v.
+	template <typename T> void set_capacity(Vector<T>& v, uint32_t capacity);
 
 
-	/// Grows the vector to contain at least @a min_capacity items
-	void				grow(uint32_t min_capacity);
+	/// Grows the vector @a v to contain at least @a min_capacity items.
+	template <typename T> void grow(Vector<T>& v, uint32_t min_capacity);
 
 
-	/// Condenses the array so that the capacity matches the actual number
+	/// Condenses the vector @a v so that its capacity matches the actual number
 	/// of items in the vector.
 	/// of items in the vector.
-	void				condense();
+	template <typename T> void condense(Vector<T>& v);
 
 
-	/// Appends an item to the vector and returns its index.
-	uint32_t			push_back(const T& item);
+	/// Appends an item to the vector @a v and returns its index.
+	template <typename T> uint32_t push_back(Vector<T>& v, const T& item);
 
 
-	/// Removes the last item from the vector.
-	void				pop_back();
+	/// Removes the last item from the vector @a v.
+	template <typename T> void pop_back(Vector<T>& v);
 
 
-	/// Appends @a count @a items to the vector and returns the number
+	/// Appends @a count @a items to the vector @a v and returns the number
 	/// of items in the vector after the append operation.
 	/// of items in the vector after the append operation.
-	uint32_t			push(const T* items, uint32_t count);
+	template <typename T> uint32_t push(Vector<T>& v, const T* items, uint32_t count);
 
 
-	/// Clears the content of the vector.
+	/// Clears the content of the vector @a v.
 	/// @note
 	/// @note
-	/// Does not free memory nor call destructors, it only zeroes
-	/// the number of items in the vector for efficiency.
-	void				clear();
-
-	/// Copies the content of the @a other vector into this one.
-	const Vector<T>&		operator=(const Vector<T>& other);
-
-	T*					begin();
-	const T*			begin() const;
-	T*					end();
-	const T*			end() const;
-
-	T&					front();
-	const T&			front() const;
-	T&					back();
-	const T&			back() const;
-
-private:
-
-	Allocator*			m_allocator;
-	uint32_t			m_capacity;
-	uint32_t			m_size;
-	T*					m_array;
-};
+	/// Calls destructor on the items.
+	template <typename T> void clear(Vector<T>& v);
 
 
-//-----------------------------------------------------------------------------
-template <typename T>
-inline Vector<T>::Vector(Allocator& allocator)
-	: m_allocator(&allocator), m_capacity(0), m_size(0), m_array(NULL)
-{
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline Vector<T>::Vector(Allocator& allocator, uint32_t capacity)
-	: m_allocator(&allocator), m_capacity(0), m_size(0), m_array(NULL)
-{
-	resize(capacity);
-}
+	template <typename T> T* begin(Vector<T>& v);
+	template <typename T> const T* begin(const Vector<T>& v);
+	template <typename T> T* end(Vector<T>& v);
+	template <typename T> const T* end(const Vector<T>& v);
 
 
-//-----------------------------------------------------------------------------
-template <typename T>
-inline Vector<T>::Vector(const Vector<T>& other)
-	: m_allocator(other.m_allocator), m_capacity(0), m_size(0), m_array(NULL)
-{
-	*this = other;
-}
+	template <typename T> T& front(Vector<T>& v);
+	template <typename T> const T& front(const Vector<T>& v);
+	template <typename T> T& back(Vector<T>& v);
+	template <typename T> const T& back(const Vector<T>& v);
+} // namespace vector
 
 
-//-----------------------------------------------------------------------------
-template <typename T>
-inline Vector<T>::~Vector()
+namespace vector
 {
 {
-	if (m_array)
+	template <typename T>
+	bool empty(const Vector<T>& v)
 	{
 	{
-		for (uint32_t i = 0; i < m_size; i++)
-		{
-			m_array[i].~T();
-		}
-		m_allocator->deallocate(m_array);
+		return array::empty(v.m_array);
 	}
 	}
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline T& Vector<T>::operator[](uint32_t index)
-{
-	CE_ASSERT(index < m_size, "Index out of bounds");
 
 
-	return m_array[index];
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline const T& Vector<T>::operator[](uint32_t index) const
-{
-	CE_ASSERT(index < m_size, "Index out of bounds");
-
-	return m_array[index];
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline bool Vector<T>::empty() const
-{
-	return m_size == 0;
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline uint32_t Vector<T>::size() const
-{
-	return m_size;
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline uint32_t Vector<T>::capacity() const
-{
-	return m_capacity;
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline void Vector<T>::resize(uint32_t size)
-{
-	if (size > m_capacity)
+	template <typename T>
+	uint32_t size(const Vector<T>& v)
 	{
 	{
-		set_capacity(size);
+		return array::size(v.m_array);
 	}
 	}
 
 
-	m_size = size;
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline void Vector<T>::reserve(uint32_t capacity)
-{
-	if (capacity > m_capacity)
+	template <typename T>
+	uint32_t capacity(const Vector<T>& v)
 	{
 	{
-		grow(capacity);
+		return array::capacity(v.m_array);
 	}
 	}
-}
 
 
-//-----------------------------------------------------------------------------
-template <typename T>
-inline void Vector<T>::set_capacity(uint32_t capacity)
-{
-	if (capacity == m_capacity)
+	template <typename T>
+	void resize(Vector<T>& v, uint32_t size)
 	{
 	{
-		return;
+		array::resize(v.m_array, size);
 	}
 	}
 
 
-	if (capacity < m_size)
+	template <typename T>
+	void reserve(Vector<T>& v, uint32_t capacity)
 	{
 	{
-		resize(capacity);
+		array::reserve(v.m_array, capacity);
 	}
 	}
 
 
-	if (capacity > 0)
+	template <typename T>
+	void set_capacity(Vector<T>& v, uint32_t capacity)
 	{
 	{
-		T* tmp = m_array;
-		m_capacity = capacity;
+		if (capacity == v.m_array.m_capacity)
+			return;
 
 
-		m_array = (T*)m_allocator->allocate(capacity * sizeof(T));
+		if (capacity < v.m_array.m_size)
+			resize(v, capacity);
 
 
-		for (uint32_t i = 0; i < m_size; i++)
+		if (capacity > 0)
 		{
 		{
-			new (m_array + i) T(tmp[i]);
-		}
+			Array<T> arr = v.m_array;
 
 
-		if (tmp)
-		{
-			for (uint32_t i = 0; i < m_size; i++)
+			T* tmp = arr.m_array;
+			arr.m_capacity = capacity;
+
+			arr.m_array = (T*)arr.m_allocator->allocate(capacity * sizeof(T));
+
+			for (uint32_t i = 0; i < arr.m_size; i++)
+			{
+				new (arr.m_array + i) T(tmp[i]);
+			}
+
+			if (tmp)
 			{
 			{
-				tmp[i].~T();
+				for (uint32_t i = 0; i < arr.m_size; i++)
+				{
+					tmp[i].~T();
+				}
+				arr.m_allocator->deallocate(tmp);
 			}
 			}
-			m_allocator->deallocate(tmp);
 		}
 		}
 	}
 	}
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline void Vector<T>::grow(uint32_t min_capacity)
-{
-	uint32_t new_capacity = m_capacity * 2 + 1;
 
 
-	if (new_capacity < min_capacity)
+	template <typename T>
+	void grow(Vector<T>& v, uint32_t min_capacity)
 	{
 	{
-		new_capacity = min_capacity;
+		return array::grow(v.m_array, min_capacity);
 	}
 	}
 
 
-	set_capacity(new_capacity);
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline void Vector<T>::condense()
-{
-	resize(m_size);
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline uint32_t Vector<T>::push_back(const T& item)
-{
-	if (m_capacity == m_size)
+	template <typename T>
+	void condense(Vector<T>& v)
 	{
 	{
-		grow(0);
+		return array::condense(v.m_array);
 	}
 	}
 
 
-	new (m_array + m_size) T(item);
-
-	return m_size++;
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline void Vector<T>::pop_back()
-{
-	CE_ASSERT(m_size > 0, "The vector is empty");
+	template <typename T>
+	uint32_t push_back(Vector<T>& v, const T& item)
+	{
+		if (v.m_array.m_capacity == v.m_array.m_size)
+			grow(v, 0);
 
 
-	m_size--;
-}
+		new (v.m_array.m_array + v.m_array.m_size) T(item);
 
 
-//-----------------------------------------------------------------------------
-template <typename T>
-inline uint32_t Vector<T>::push(const T* items, uint32_t count)
-{
-	if (m_capacity <= m_size + count)
-	{
-		grow(m_size + count);
+		return v.m_array.m_size++;
 	}
 	}
 
 
-	T* arr = &m_array[m_size];
-	for (uint32_t i = 0; i < count; i++)
+	template <typename T>
+	void pop_back(Vector<T>& v)
 	{
 	{
-		arr[i] = items[i];
+		CE_ASSERT(vector::size(v) > 0, "The vector is empty");
+
+		v.m_array.m_array[v.m_array.m_size - 1].~T();
+		v.m_array.m_size--;
 	}
 	}
 
 
-	m_size += count;
+	template <typename T>
+	uint32_t push(Vector<T>& v, const T* items, uint32_t count)
+	{
+		if (v.m_array.m_capacity <= v.m_array.m_size + count)
+			grow(v, v.m_array.m_size + count);
 
 
-	return m_size;
-}
+		T* arr = &v.m_array.m_array[v.m_array.m_size];
+		for (uint32_t i = 0; i < count; i++)
+		{
+			arr[i] = items[i];
+		}
 
 
-//-----------------------------------------------------------------------------
-template <typename T>
-inline void Vector<T>::clear()
-{
-	for (uint32_t i = 0; i < m_size; i++)
-	{
-		m_array[i].~T();
+		v.m_array.m_size += count;
+		return v.m_array.m_size;
 	}
 	}
 
 
-	m_size = 0;
-}
+	template <typename T>
+	void clear(Vector<T>& v)
+	{
+		for (uint32_t i = 0; i < v.m_array.m_size; i++)
+		{
+			v.m_array.m_array[i].~T();
+		}
 
 
-//-----------------------------------------------------------------------------
-template <typename T>
-inline const Vector<T>& Vector<T>::operator=(const Vector<T>& other)
-{
-	const uint32_t size = other.m_size;
-	resize(size);
+		v.m_array.m_size = 0;
+	}
 
 
-	for (uint32_t i = 0; i < size; i++)
+	template <typename T>
+	T* begin(Vector<T>& v)
 	{
 	{
-		m_array[i] = other.m_array[i];
+		return array::begin(v.m_array);
+	}
+	template <typename T>
+	const T* begin(const Vector<T>& v)
+	{
+		return array::begin(v.m_array);
+	}
+	template <typename T>
+	T* end(Vector<T>& v)
+	{
+		return array::end(v.m_array);
+	}
+	template <typename T>
+	const T* end(const Vector<T>& v)
+	{
+		return array::end(v.m_array);
 	}
 	}
 
 
-	return *this;
-}
+	template <typename T>
+	T& front(Vector<T>& v)
+	{
+		return array::front(v.m_array);
+	}
+	template <typename T>
+	const T& front(const Vector<T>& v)
+	{
+		return array::front(v.m_array);
+	}
+	template <typename T>
+	T& back(Vector<T>& v)
+	{
+		return array::back(v.m_array);
+	}
+	template <typename T>
+	const T& back(const Vector<T>& v)
+	{
+		return array::back(v.m_array);
+	}
+} // namespace vector
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline const T* Vector<T>::begin() const
+inline Vector<T>::Vector(Allocator& allocator)
+	: m_array(allocator)
 {
 {
-	return m_array;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T* Vector<T>::begin()
+inline Vector<T>::Vector(Allocator& allocator, uint32_t capacity)
+	: m_array(allocator)
 {
 {
-	return m_array;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline const T* Vector<T>::end() const
+inline Vector<T>::Vector(const Vector<T>& other)
+	: m_array(other.m_array.allocator)
 {
 {
-	return m_array + m_size;
+	*this = other;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T* Vector<T>::end()
+inline Vector<T>::~Vector()
 {
 {
-	return m_array + m_size;
+	for (uint32_t i = 0; i < array::size(m_array); i++)
+	{
+		m_array[i].~T();
+	}
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T& Vector<T>::front()
+inline T& Vector<T>::operator[](uint32_t index)
 {
 {
-	CE_ASSERT(m_size > 0, "The vector is empty");
-
-	return m_array[0];
+	return m_array[index];
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline const T& Vector<T>::front() const
+inline const T& Vector<T>::operator[](uint32_t index) const
 {
 {
-	CE_ASSERT(m_size > 0, "The vector is empty");
-
-	return m_array[0];
+	return m_array[index];
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T& Vector<T>::back()
+inline const Vector<T>& Vector<T>::operator=(const Vector<T>& other)
 {
 {
-	CE_ASSERT(m_size > 0, "The vector is empty");
+	const uint32_t size = vector::size(other);
+	vector::resize(*this, size);
 
 
-	return m_array[m_size - 1];
-}
-
-//-----------------------------------------------------------------------------
-template <typename T>
-inline const T& Vector<T>::back() const
-{
-	CE_ASSERT(m_size > 0, "The vector is empty");
+	for (uint32_t i = 0; i < size; i++)
+	{
+		m_array[i] = other.m_array[i];
+	}
 
 
-	return m_array[m_size - 1];
+	return *this;
 }
 }
 
 
 } // namespace crown
 } // namespace crown
-

+ 2 - 2
engine/core/json/JSONParser.cpp

@@ -331,7 +331,7 @@ void JSONElement::to_array(Vector<DynamicString>& array) const
 	{
 	{
 		DynamicString str;
 		DynamicString str;
 		json::parse_string(temp[i], str);
 		json::parse_string(temp[i], str);
-		array.push_back(str);
+		vector::push_back(array, str);
 	}
 	}
 }
 }
 
 
@@ -345,7 +345,7 @@ void JSONElement::to_keys(Vector<DynamicString>& keys) const
 	{
 	{
 		DynamicString key;
 		DynamicString key;
 		json::parse_string(object[i].key, key);
 		json::parse_string(object[i].key, key);
-		keys.push_back(key);
+		vector::push_back(keys, key);
 	}
 	}
 }
 }
 
 

+ 1 - 1
engine/os/posix/Posix.cpp

@@ -162,7 +162,7 @@ void list_files(const char* path, Vector<DynamicString>& files)
 		DynamicString filename(default_allocator());
 		DynamicString filename(default_allocator());
 
 
 		filename = entry->d_name;
 		filename = entry->d_name;
-		files.push_back(filename);
+		vector::push_back(files, filename);
 	}
 	}
 
 
 	closedir(dir);
 	closedir(dir);

+ 1 - 1
engine/os/win/WinOS.cpp

@@ -235,7 +235,7 @@ void list_files(const char* path, Vector<DynamicString>& files)
 		DynamicString filename(default_allocator());
 		DynamicString filename(default_allocator());
 
 
 		filename = ffd.cFileName;
 		filename = ffd.cFileName;
-		files.push_back(filename);
+		vector::push_back(files, filename);
 	}
 	}
 	while (FindNextFile(file, &ffd) != 0);
 	while (FindNextFile(file, &ffd) != 0);
 
 

+ 9 - 9
engine/resource/PhysicsResource.cpp

@@ -90,7 +90,7 @@ void parse_shapes(JSONElement e, Array<PhysicsShape>& shapes)
 	Vector<DynamicString> keys(default_allocator());
 	Vector<DynamicString> keys(default_allocator());
 	e.to_keys(keys);
 	e.to_keys(keys);
 
 
-	for (uint32_t k = 0; k < keys.size(); k++)
+	for (uint32_t k = 0; k < vector::size(keys); k++)
 	{
 	{
 		JSONElement shape 		= e.key(keys[k].c_str());
 		JSONElement shape 		= e.key(keys[k].c_str());
 		JSONElement clasz		= shape.key("class");
 		JSONElement clasz		= shape.key("class");
@@ -174,7 +174,7 @@ void parse_actors(JSONElement e, Array<PhysicsActor>& actors, Array<PhysicsShape
 	Vector<DynamicString> keys(default_allocator());
 	Vector<DynamicString> keys(default_allocator());
 	e.to_keys(keys);
 	e.to_keys(keys);
 
 
-	for (uint32_t k = 0; k < keys.size(); k++)
+	for (uint32_t k = 0; k < vector::size(keys); k++)
 	{
 	{
 		JSONElement actor 	= e.key(keys[k].c_str());
 		JSONElement actor 	= e.key(keys[k].c_str());
 		JSONElement node 	= actor.key("node");
 		JSONElement node 	= actor.key("node");
@@ -200,7 +200,7 @@ void parse_joints(JSONElement e, Array<PhysicsJoint>& joints)
 	Vector<DynamicString> keys(default_allocator());
 	Vector<DynamicString> keys(default_allocator());
 	e.to_keys(keys);
 	e.to_keys(keys);
 
 
-	for (uint32_t k = 0; k < keys.size(); k++)
+	for (uint32_t k = 0; k < vector::size(keys); k++)
 	{
 	{
 		JSONElement joint			= e.key(keys[k].c_str());
 		JSONElement joint			= e.key(keys[k].c_str());
 		JSONElement type 			= joint.key("type");
 		JSONElement type 			= joint.key("type");
@@ -385,7 +385,7 @@ namespace physics_config_resource
 	{
 	{
 		uint32_t mask = 0;
 		uint32_t mask = 0;
 
 
-		for (uint32_t i = 0; i < collides_with.size(); i++)
+		for (uint32_t i = 0; i < vector::size(collides_with); i++)
 		{
 		{
 			StringId32 cur_name = collides_with[i].to_string_id();
 			StringId32 cur_name = collides_with[i].to_string_id();
 			for (uint32_t j = 0; j < array::size(name_to_mask); j++)
 			for (uint32_t j = 0; j < array::size(name_to_mask); j++)
@@ -414,7 +414,7 @@ namespace physics_config_resource
 		Vector<DynamicString> keys(default_allocator());
 		Vector<DynamicString> keys(default_allocator());
 		e.to_keys(keys);
 		e.to_keys(keys);
 
 
-		for (uint32_t i = 0; i < keys.size(); i++)
+		for (uint32_t i = 0; i < vector::size(keys); i++)
 		{
 		{
 			JSONElement material 			= e.key(keys[i].c_str());
 			JSONElement material 			= e.key(keys[i].c_str());
 			JSONElement static_friction 	= material.key("static_friction");
 			JSONElement static_friction 	= material.key("static_friction");
@@ -442,7 +442,7 @@ namespace physics_config_resource
 		Vector<DynamicString> keys(default_allocator());
 		Vector<DynamicString> keys(default_allocator());
 		e.to_keys(keys);
 		e.to_keys(keys);
 
 
-		for (uint32_t i = 0; i < keys.size(); i++)
+		for (uint32_t i = 0; i < vector::size(keys); i++)
 		{
 		{
 			JSONElement shape				= e.key(keys[i].c_str());
 			JSONElement shape				= e.key(keys[i].c_str());
 			JSONElement collision_filter 	= shape.key("collision_filter");
 			JSONElement collision_filter 	= shape.key("collision_filter");
@@ -469,7 +469,7 @@ namespace physics_config_resource
 		Vector<DynamicString> keys(default_allocator());
 		Vector<DynamicString> keys(default_allocator());
 		e.to_keys(keys);
 		e.to_keys(keys);
 
 
-		for (uint32_t i = 0; i < keys.size(); i++)
+		for (uint32_t i = 0; i < vector::size(keys); i++)
 		{
 		{
 			JSONElement actor			= e.key(keys[i].c_str());
 			JSONElement actor			= e.key(keys[i].c_str());
 			JSONElement linear_damping	= actor.key_or_nil("linear_damping");
 			JSONElement linear_damping	= actor.key_or_nil("linear_damping");
@@ -513,7 +513,7 @@ namespace physics_config_resource
 		e.to_keys(keys);
 		e.to_keys(keys);
 
 
 		// Assign a unique mask to each collision filter
 		// Assign a unique mask to each collision filter
-		for (uint32_t i = 0; i < keys.size(); i++)
+		for (uint32_t i = 0; i < vector::size(keys); i++)
 		{
 		{
 			NameToMask ntm;
 			NameToMask ntm;
 			ntm.name = keys[i].to_string_id();
 			ntm.name = keys[i].to_string_id();
@@ -521,7 +521,7 @@ namespace physics_config_resource
 			array::push_back(name_to_mask, ntm);
 			array::push_back(name_to_mask, ntm);
 		}
 		}
 
 
-		for (uint32_t i = 0; i < keys.size(); i++)
+		for (uint32_t i = 0; i < vector::size(keys); i++)
 		{
 		{
 			JSONElement filter			= e.key(keys[i].c_str());
 			JSONElement filter			= e.key(keys[i].c_str());
 			JSONElement collides_with	= filter.key("collides_with");
 			JSONElement collides_with	= filter.key("collides_with");

+ 3 - 3
engine/resource/UnitResource.cpp

@@ -124,7 +124,7 @@ void parse_nodes(JSONElement e, Array<GraphNode>& nodes, Array<GraphNodeDepth>&
 	Vector<DynamicString> keys(default_allocator());
 	Vector<DynamicString> keys(default_allocator());
 	e.to_keys(keys);
 	e.to_keys(keys);
 
 
-	for (uint32_t k = 0; k < keys.size(); k++)
+	for (uint32_t k = 0; k < vector::size(keys); k++)
 	{
 	{
 		const char* node_name = keys[k].c_str();
 		const char* node_name = keys[k].c_str();
 		JSONElement node = e.key(node_name);
 		JSONElement node = e.key(node_name);
@@ -161,7 +161,7 @@ void parse_cameras(JSONElement e, Array<UnitCamera>& cameras, const Array<GraphN
 	Vector<DynamicString> keys(default_allocator());
 	Vector<DynamicString> keys(default_allocator());
 	e.to_keys(keys);
 	e.to_keys(keys);
 
 
-	for (uint32_t k = 0; k < keys.size(); k++)
+	for (uint32_t k = 0; k < vector::size(keys); k++)
 	{
 	{
 		const char* camera_name = keys[k].c_str();
 		const char* camera_name = keys[k].c_str();
 		JSONElement camera = e.key(camera_name);
 		JSONElement camera = e.key(camera_name);
@@ -185,7 +185,7 @@ void parse_renderables(JSONElement e, Array<UnitRenderable>& renderables, const
 	Vector<DynamicString> keys(default_allocator());
 	Vector<DynamicString> keys(default_allocator());
 	e.to_keys(keys);
 	e.to_keys(keys);
 
 
-	for (uint32_t k = 0; k < keys.size(); k++)
+	for (uint32_t k = 0; k < vector::size(keys); k++)
 	{
 	{
 		const char* renderable_name = keys[k].c_str();
 		const char* renderable_name = keys[k].c_str();
 		JSONElement renderable = e.key(renderable_name);
 		JSONElement renderable = e.key(renderable_name);