浏览代码

IS and timestamp refactoring

Panagiotis Christopoulos Charitos 13 年之前
父节点
当前提交
1eed932c98

+ 29 - 0
include/anki/core/Timestamp.h

@@ -0,0 +1,29 @@
+#ifndef ANKI_CORE_TIMESTAMP_H
+#define ANKI_CORE_TIMESTAMP_H
+
+#include "anki/util/StdTypes.h"
+
+namespace anki {
+
+/// Give the current timestamp. It actualy gives the current frame. Used to 
+/// indicate updates. It is actualy returning the current frame
+class Timestamp
+{
+public:
+	static void increaseTimestamp()
+	{
+		++timestamp;
+	}
+
+	static U32 getTimestamp()
+	{
+		return timestamp;
+	}
+
+private:
+	static U32 timestamp;
+};
+
+} // end namespace anki
+
+#endif

+ 12 - 0
include/anki/renderer/Is.h

@@ -11,6 +11,7 @@
 #include "anki/renderer/Smo.h"
 #include "anki/renderer/Smo.h"
 #include "anki/util/StdTypes.h"
 #include "anki/util/StdTypes.h"
 #include "anki/util/Array.h"
 #include "anki/util/Array.h"
+#include "anki/core/Timestamp.h"
 
 
 namespace anki {
 namespace anki {
 
 
@@ -71,8 +72,13 @@ private:
 
 
 		Array<U32, MAX_LIGHTS_PER_TILE> lightIndices;
 		Array<U32, MAX_LIGHTS_PER_TILE> lightIndices;
 		U lightsCount = 0;
 		U lightsCount = 0;
+
+		/// Frustum planes
+		Array<Plane, 6> planes;
 	};
 	};
 
 
+	U32 planesUpdateTimestamp = Timestamp::getTimestamp();
+
 	/// @note The [0][0] is the bottom left tile
 	/// @note The [0][0] is the bottom left tile
 	Tile tiles[TILES_Y_COUNT][TILES_X_COUNT];
 	Tile tiles[TILES_Y_COUNT][TILES_X_COUNT];
 
 
@@ -120,6 +126,12 @@ private:
 	static Bool triangleIntersects(const Tile& tile, 
 	static Bool triangleIntersects(const Tile& tile, 
 		const Array<Vec2, 3>& coords);
 		const Array<Vec2, 3>& coords);
 
 
+	/// Updates all the planes except the near and far plane. Near and far 
+	/// planes will be updated in min max pass when the depth is known
+	void updateAllTilesPlanes();
+
+	void updateAllTilesPlanes(const PerspectiveCamera& pcam);
+
 	/// Fill the minMaxFai
 	/// Fill the minMaxFai
 	void minMaxPass();
 	void minMaxPass();
 
 

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

@@ -4,7 +4,7 @@
 #include "anki/util/Object.h"
 #include "anki/util/Object.h"
 #include "anki/util/Flags.h"
 #include "anki/util/Flags.h"
 #include "anki/math/Math.h"
 #include "anki/math/Math.h"
-#include "anki/scene/Timestamp.h"
+#include "anki/core/Timestamp.h"
 
 
 namespace anki {
 namespace anki {
 
 

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

@@ -3,7 +3,7 @@
 
 
 #include "anki/collision/Collision.h"
 #include "anki/collision/Collision.h"
 #include "anki/util/Flags.h"
 #include "anki/util/Flags.h"
-#include "anki/scene/Timestamp.h"
+#include "anki/core/Timestamp.h"
 
 
 namespace anki {
 namespace anki {
 
 

+ 0 - 31
include/anki/scene/Timestamp.h

@@ -1,31 +0,0 @@
-#ifndef ANKI_SCENE_TIMESTAMP_H
-#define ANKI_SCENE_TIMESTAMP_H
-
-#include <cstdint>
-
-namespace anki {
-
-/// Give the current timestamp. It actualy gives the current frame. Normally it
-/// should have been part of the Scene class but its a different class because 
-/// we don't want to include the whole Scene.h in those classes that just need 
-/// the timestamp
-class Timestamp
-{
-public:
-	static void increaseTimestamp()
-	{
-		++timestamp;
-	}
-
-	static uint32_t getTimestamp()
-	{
-		return timestamp;
-	}
-
-private:
-	static uint32_t timestamp;
-};
-
-} // end namespace anki
-
-#endif

+ 7 - 0
src/core/Timestamp.cpp

@@ -0,0 +1,7 @@
+#include "anki/core/Timestamp.h"
+
+namespace anki {
+
+U32 Timestamp::timestamp = 1;
+
+} // end namespace anki

+ 36 - 0
src/renderer/Is.cpp

@@ -245,6 +245,42 @@ Bool Is::cullLight(const PointLight& plight, const Tile& tile)
 	return circleIntersects(tile, cc, rad);
 	return circleIntersects(tile, cc, rad);
 }
 }
 
 
+//==============================================================================
+void Is::updateAllTilesPlanes(const PerspectiveCamera& pcam)
+{
+	//F32 fovXFragment = cam.getFov
+
+	for(U j = 0; j < TILES_Y_COUNT; j++)
+	{
+		for(U i = 0; i < TILES_X_COUNT; i++)
+		{
+	
+		}
+	}
+}
+
+//==============================================================================
+void Is::updateAllTilesPlanes()
+{
+	Camera& cam = r->getScene().getActiveCamera();
+	U32 camTimestamp = cam.getFrustumable()->getFrustumableTimestamp();
+
+	if(camTimestamp <= planesUpdateTimestamp)
+	{
+		return;
+	}
+
+	switch(cam.getCameraType())
+	{
+		case Camera::CT_PERSPECTIVE:
+			updateAllTilesPlanes(static_cast<const PerspectiveCamera&>(cam));
+			break;
+		default:
+			ANKI_ASSERT(0 && "Unimplemented");
+			break;
+	}
+}
+
 //==============================================================================
 //==============================================================================
 void Is::minMaxPass()
 void Is::minMaxPass()
 {
 {

+ 0 - 7
src/scene/Timestamp.cpp

@@ -1,7 +0,0 @@
-#include "anki/scene/Timestamp.h"
-
-namespace anki {
-
-uint32_t Timestamp::timestamp = 1;
-
-} // end namespace anki

+ 1 - 1
testapp/Main.cpp

@@ -37,7 +37,7 @@
 #include "anki/resource/ShaderProgramPrePreprocessor.h"
 #include "anki/resource/ShaderProgramPrePreprocessor.h"
 #include "anki/resource/Material.h"
 #include "anki/resource/Material.h"
 #include "anki/core/ParallelManager.h"
 #include "anki/core/ParallelManager.h"
-#include "anki/scene/Timestamp.h"
+#include "anki/core/Timestamp.h"
 
 
 using namespace anki;
 using namespace anki;