Browse Source

Removing the Vector out of some classes

[email protected] 11 years ago
parent
commit
6c14fdd014

+ 2 - 5
include/anki/renderer/DebugDrawer.h

@@ -101,10 +101,7 @@ private:
 	Array<Vertex, MAX_POINTS_PER_DRAW> m_clientLineVerts;
 	Array<Vertex, MAX_POINTS_PER_DRAW> m_clientTriVerts;
 
-	/// 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::unordered_map<U32, Vector<Vec3>> m_complexityToPreCalculatedSphere;
+	DArray<Vec3> m_sphereVerts;
 
 	ANKI_USE_RESULT Error flushInternal(GLenum primitive);
 };
@@ -153,7 +150,7 @@ public:
 
 	void draw(SceneNode& node);
 
-	void draw(const Sector& sector);
+	//void draw(const Sector& sector);
 
 	void setViewProjectionMatrix(const Mat4& m)
 	{

+ 0 - 1
include/anki/renderer/Sm.h

@@ -9,7 +9,6 @@
 #include "anki/renderer/RenderingPass.h"
 #include "anki/Gl.h"
 #include "anki/resource/TextureResource.h"
-#include "anki/util/Vector.h"
 #include "anki/util/Array.h"
 
 namespace anki {

+ 0 - 7
include/anki/resource/Common.h

@@ -7,7 +7,6 @@
 #define ANKI_RESOURCE_COMMON_H
 
 #include "anki/util/Allocator.h"
-#include "anki/util/Vector.h"
 #include "anki/util/DArray.h"
 #include "anki/util/String.h"
 
@@ -23,9 +22,6 @@ class ResourceManager;
 template<typename T>
 using ResourceAllocator = HeapAllocator<T>;
 
-template<typename T>
-using ResourceVector = Vector<T, ResourceAllocator<T>>;
-
 template<typename T>
 using ResourceDArray = DArray<T, ResourceAllocator<T>>;
 
@@ -34,9 +30,6 @@ using ResourceString = StringBase<ResourceAllocator<char>>;
 template<typename T>
 using TempResourceAllocator = StackAllocator<T>;
 
-template<typename T>
-using TempResourceVector = Vector<T, TempResourceAllocator<T>>;
-
 template<typename T>
 using TempResourceDArray = DArray<T, TempResourceAllocator<T>>;
 

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

@@ -367,7 +367,7 @@ private:
 	Dictionary<MaterialVariable*> m_varDict;
 
 	ResourceDArray<ProgramResourcePointer> m_progs;
-	ResourceVector<GlPipelineHandle> m_pplines;
+	ResourceDArray<GlPipelineHandle> m_pplines;
 
 	U32 m_shaderBlockSize;
 

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

@@ -8,7 +8,6 @@
 
 #include "anki/resource/Common.h"
 #include "anki/Math.h"
-#include "anki/util/Vector.h"
 #include "anki/util/Array.h"
 
 namespace anki {

+ 2 - 11
include/anki/scene/Common.h

@@ -7,7 +7,6 @@
 #define ANKI_SCENE_COMMON_H
 
 #include "anki/util/Allocator.h"
-#include "anki/util/Vector.h"
 #include "anki/util/String.h"
 #include "anki/util/Dictionary.h"
 
@@ -30,19 +29,11 @@ using SceneFrameAllocator = StackAllocator<T, false>;
 /// Scene string
 using SceneString = StringBase<SceneAllocator<char>>;
 
-/// Scene vector
-template<typename T>
-using SceneVector = Vector<T, SceneAllocator<T>>;
-
-/// Scene vector
+/// Scene array
 template<typename T>
 using SceneDArray = DArray<T, SceneAllocator<T>>;
 
-/// The same as SceneVector. Different name to show the difference
-template<typename T>
-using SceneFrameVector = Vector<T, SceneFrameAllocator<T>>;
-
-/// The same as SceneVector. Different name to show the difference
+/// The same as SceneDArray. Different name to show the difference
 template<typename T>
 using SceneFrameDArray = DArray<T, SceneFrameAllocator<T>>;
 

+ 0 - 12
include/anki/scene/SceneGraph.h

@@ -15,7 +15,6 @@
 #include "anki/util/HighRezTimer.h"
 #include "anki/core/App.h"
 
-#include "anki/scene/Sector.h"
 #include "anki/physics/PhysicsWorld.h"
 #include "anki/event/EventManager.h"
 
@@ -113,15 +112,6 @@ public:
 		return m_events;
 	}
 
-	SectorGroup& getSectorGroup()
-	{
-		return m_sectorGroup;
-	}
-	const SectorGroup& getSectorGroup() const
-	{
-		return m_sectorGroup;
-	}
-
 	Threadpool& _getThreadpool()
 	{
 		return *m_threadpool;
@@ -202,8 +192,6 @@ private:
 
 	PhysicsWorld m_physics;
 
-	SectorGroup m_sectorGroup;
-
 	EventManager m_events;
 
 	AtomicU32 m_objectsMarkedForDeletionCount;

+ 15 - 0
include/anki/util/Functions.h

@@ -13,6 +13,7 @@
 #include "anki/util/Assert.h"
 #include <cmath>
 #include <utility>
+#include <new>
 
 namespace anki {
 
@@ -33,6 +34,20 @@ extern F64 randRange(F64 min, F64 max);
 
 extern F32 randFloat(F32 max);
 
+/// Get min of two values.
+template<typename T>
+inline T min(T a, T b)
+{
+	return (a < b) ? a : b;
+}
+
+/// Get max of two values.
+template<typename T>
+inline T max(T a, T b)
+{
+	return (a > b) ? a : b;
+}
+
 /// Check if a number os a power of 2
 template<typename Int>
 inline Bool isPowerOfTwo(Int x)

+ 4 - 0
src/renderer/DebugDrawer.cpp

@@ -270,6 +270,7 @@ void DebugDrawer::drawGrid()
 //==============================================================================
 void DebugDrawer::drawSphere(F32 radius, I complexity)
 {
+#if 0
 	Vector<Vec3>* sphereLines;
 
 	// Pre-calculate the sphere points5
@@ -331,6 +332,7 @@ void DebugDrawer::drawSphere(F32 radius, I complexity)
 	// restore
 	m_mMat = oldMMat;
 	m_vpMat = oldVpMat;
+#endif
 }
 
 //==============================================================================
@@ -530,6 +532,7 @@ void SceneDebugDrawer::draw(SpatialComponent& x) const
 }
 
 //==============================================================================
+#if 0
 void SceneDebugDrawer::draw(const Sector& sector)
 {
 	// Draw the sector
@@ -561,6 +564,7 @@ void SceneDebugDrawer::draw(const Sector& sector)
 		}
 	}
 }
+#endif
 
 //==============================================================================
 void SceneDebugDrawer::drawPath(const Path& path) const

+ 3 - 3
src/resource/Material.cpp

@@ -171,8 +171,7 @@ MaterialVariableTemplate<T>* MaterialVariableTemplate<T>::_newInstance(
 //==============================================================================
 Material::Material(ResourceAllocator<U8>& alloc)
 :	m_varDict(10, Dictionary<MaterialVariable*>::hasher(),
-		Dictionary<MaterialVariable*>::key_equal(), alloc),
-	m_pplines(alloc)
+		Dictionary<MaterialVariable*>::key_equal(), alloc)
 {}
 
 //==============================================================================
@@ -493,7 +492,8 @@ Error Material::parseMaterialTag(const XmlElement& materialEl,
 		+ countShaders(ShaderType::FRAGMENT)));
 
 	// Aloc progam descriptors
-	m_pplines.resize(m_passesCount * m_lodsCount * tessCount);
+	ANKI_CHECK(m_pplines.create(rinit.m_alloc,
+		m_passesCount * m_lodsCount * tessCount));
 
 	m_hash = 0;
 	for(ShaderType shader = ShaderType::VERTEX; 

+ 2 - 1
src/resource/Mesh.cpp

@@ -89,7 +89,8 @@ Error Mesh::createBuffers(const MeshLoader& loader,
 	U32 vbosize = vertexsize * m_vertsCount;
 
 	// Create a temp buffer and populate it
-	TempResourceVector<U8> buff(vbosize, 0, init.m_tempAlloc);
+	TempResourceDArray<U8> buff;
+	ANKI_CHECK(buff.create(init.m_tempAlloc, vbosize, 0));
 
 	U8* ptra = &buff[0];
 	for(U i = 0; i < m_vertsCount; i++)

+ 2 - 0
src/scene/Grid.cpp

@@ -3,6 +3,7 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#if 0
 #include "anki/scene/Grid.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/scene/SceneNode.h"
@@ -72,3 +73,4 @@ void Grid::getVisible(const Frustumable& cam,
 }
 
 } // end namespace anki
+#endif

+ 2 - 4
src/scene/Octree.cpp

@@ -3,6 +3,7 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#if 0
 #include "anki/scene/Octree.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/scene/FrustumComponent.h"
@@ -14,8 +15,6 @@
 
 namespace anki {
 
-#if 0
-
 //==============================================================================
 // OctreeNode                                                                  =
 //==============================================================================
@@ -346,6 +345,5 @@ void Octree::doVisibilityTestsInternal(SceneNode& fsn,
 	}
 }
 
-#endif
-
 } // end namespace anki
+#endif

+ 0 - 2
src/scene/SceneGraph.cpp

@@ -89,8 +89,6 @@ public:
 
 //==============================================================================
 SceneGraph::SceneGraph()
-:	m_physics(),
-	m_sectorGroup(this)
 {}
 
 //==============================================================================

+ 3 - 0
src/scene/Sector.cpp

@@ -3,6 +3,7 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#if 0
 #include "anki/scene/Sector.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/scene/SceneNode.h"
@@ -426,3 +427,5 @@ void SectorGroup::doVisibilityTestsInternal(SceneNode& sn, VisibilityTest test,
 }
 
 } // end namespace anki
+
+#endif

+ 2 - 3
src/util/Memory.cpp

@@ -8,7 +8,6 @@
 #include "anki/util/Assert.h"
 #include "anki/util/NonCopyable.h"
 #include "anki/util/Thread.h"
-#include "anki/util/Vector.h"
 #include "anki/util/Atomic.h"
 #include "anki/util/Logger.h"
 #include <cstdlib>
@@ -858,10 +857,10 @@ public:
 			ANKI_ASSERT(crntMaxSize > 0);
 
 			// Fix the size
-			crntMaxSize = std::min(crntMaxSize, (PtrSize)m_maxSize);
+			crntMaxSize = min(crntMaxSize, (PtrSize)m_maxSize);
 		}
 
-		size = std::max(crntMaxSize, size) + 16;
+		size = max(crntMaxSize, size) + 16;
 
 		//
 		// Create the chunk