Panagiotis Christopoulos Charitos 10 anos atrás
pai
commit
9e1b91ecac
1 arquivos alterados com 32 adições e 45 exclusões
  1. 32 45
      include/anki/scene/Sector.h

+ 32 - 45
include/anki/scene/Sector.h

@@ -23,13 +23,19 @@ class Renderer;
 /// @{
 /// @{
 
 
 /// 2 way Portal
 /// 2 way Portal
-struct Portal
+class Portal
 {
 {
-	Array<Sector*, 2> sectors;
-	Obb shape;
-	Bool8 open;
-
+public:
 	Portal();
 	Portal();
+
+	~Portal();
+
+	ANKI_USE_RESULT Error create(const SArray<Vec4>& vertPositions);
+
+private:
+	Array<Sector*, 2> m_sectors = {{nullptr, nullptr}};
+	CollisionShape* m_shape = nullptr;
+	Bool8 m_open = true;
 };
 };
 
 
 /// A sector. It consists of an octree and some portals
 /// A sector. It consists of an octree and some portals
@@ -39,44 +45,37 @@ class Sector
 
 
 public:
 public:
 	/// Used to reserve some space on the portals vector to save memory
 	/// Used to reserve some space on the portals vector to save memory
-	static const U AVERAGE_PORTALS_PER_SECTOR = 3;
+	static const U AVERAGE_PORTALS_PER_SECTOR = 4;
 
 
 	/// Default constructor
 	/// Default constructor
-	Sector(SectorGroup* group, const Aabb& box);
+	Sector(SectorGroup* group);
+
+	ANKI_USE_RESULT Error create(const SArray<Vec4>& vertPositions);
 
 
-	const Aabb& getAabb() const
+	const CollisionShape& getShape() const
 	{
 	{
-		return aabb;
+		return *m_shape;
 	}
 	}
 
 
 	const SectorGroup& getSectorGroup() const
 	const SectorGroup& getSectorGroup() const
 	{
 	{
-		return *group;
+		return *m_group;
 	}
 	}
 	SectorGroup& getSectorGroup()
 	SectorGroup& getSectorGroup()
 	{
 	{
-		return *group;
-	}
-
-	U8 getVisibleByMask() const
-	{
-		return visibleBy;
+		return *m_group;
 	}
 	}
 
 
-	/// Called when a node was moved or a change in shape happened
-	Bool placeSceneNode(SceneNode* sp);
-
-private:
-	SectorGroup* group; ///< Know your father
-	SceneVector<Portal*> portals;
-	U8 visibleBy;
-	Aabb aabb;
-
 	/// Sector does not take ownership of the portal
 	/// Sector does not take ownership of the portal
 	void addNewPortal(Portal* portal);
 	void addNewPortal(Portal* portal);
 
 
 	/// Remove a Portal from the portals container
 	/// Remove a Portal from the portals container
 	void removePortal(Portal* portal);
 	void removePortal(Portal* portal);
+
+private:
+	SectorGroup* m_group; ///< Know your father
+	DArray<Portal*> m_portals;
+	CollisionShape* m_shape;
 };
 };
 
 
 /// Sector group. This is supposed to represent the whole scene
 /// Sector group. This is supposed to represent the whole scene
@@ -89,48 +88,36 @@ public:
 	/// Destructor
 	/// Destructor
 	~SectorGroup();
 	~SectorGroup();
 
 
-	/// @name Accessors
-	/// @{
 	const SceneGraph& getSceneGraph() const
 	const SceneGraph& getSceneGraph() const
 	{
 	{
 		return *scene;
 		return *scene;
 	}
 	}
+
 	SceneGraph& getSceneGraph()
 	SceneGraph& getSceneGraph()
 	{
 	{
 		return *scene;
 		return *scene;
 	}
 	}
 
 
-	const SceneVector<Portal*>& getPortals() const
+	const List<Portal*>& getPortals() const
 	{
 	{
 		return portals;
 		return portals;
 	}
 	}
 
 
-	const SceneVector<Sector*>& getSectors() const
+	const List<Sector*>& getSectors() const
 	{
 	{
 		return sectors;
 		return sectors;
 	}
 	}
-	/// @}
-
-	/// Called when a node was moved or a change in shape happened. The node 
-	/// must be Spatial
-	void placeSceneNode(SceneNode* sp);
-
-	/// XXX
-	void doVisibilityTests(SceneNode& fr, VisibilityTest test, Renderer* r);
 
 
 	/// The owner of the pointer is the sector group
 	/// The owner of the pointer is the sector group
-	Sector* createNewSector(const Aabb& aabb);
+	Sector* createNewSector(const SArray<Vec4>& vertexPositions);
 
 
 	/// The owner of the pointer is the sector group
 	/// The owner of the pointer is the sector group
-	Portal* createNewPortal(Sector* a, Sector* b, const Obb& collisionShape);
+	Portal* createNewPortal(const SArray<Vec4>& vertexPositions);
 
 
 private:
 private:
-	SceneGraph* scene; ///< Keep it here to access various allocators
-	SceneVector<Sector*> sectors;
-	SceneVector<Portal*> portals;
-
-	void doVisibilityTestsInternal(SceneNode& fr, VisibilityTest test,
-		Renderer* r, VisibleBy visibleBy);
+	SceneGraph* m_scene; ///< Keep it here to access various allocators
+	List<Sector*> m_sectors;
+	List<Portal*> m_portals;
 };
 };
 /// @}
 /// @}