Panagiotis Christopoulos Charitos 13 years ago
parent
commit
cf6c235c15

+ 5 - 3
include/anki/scene/Camera.h

@@ -175,10 +175,11 @@ public:
 	/// @name Frustumable virtuals
 	/// @{
 
-	/// Implements Frustumable::frustumUpdate(). Calculate the projection
+	/// Overrides Frustumable::frustumUpdate(). Calculate the projection
 	/// matrix
 	void frustumUpdate()
 	{
+		Frustumable::frustumUpdate();
 		projectionMat = frustum.calculateProjectionMatrix();
 		invProjectionMat = projectionMat.getInverse();
 		updateViewProjectionMatrix();
@@ -247,10 +248,11 @@ public:
 	/// @name Frustumable virtuals
 	/// @{
 
-	/// Implements Frustumable::frustumUpdate(). Calculate the projection
+	/// Overrides Frustumable::frustumUpdate(). Calculate the projection
 	/// matrix
 	void frustumUpdate()
 	{
+		Frustumable::frustumUpdate();
 		projectionMat = frustum.calculateProjectionMatrix();
 		invProjectionMat = projectionMat.getInverse();
 		updateViewProjectionMatrix();
@@ -268,6 +270,6 @@ private:
 };
 /// @}
 
-} // end namespace
+} // end namespace anki
 
 #endif

+ 5 - 5
include/anki/scene/Frustumable.h

@@ -29,10 +29,6 @@ public:
 	{
 		return *frustum;
 	}
-	Frustum& getFrustum()
-	{
-		return *frustum;
-	}
 
 	float getNear() const
 	{
@@ -65,7 +61,10 @@ public:
 	/// @}
 
 	/// Called when a frustum parameter changes
-	virtual void frustumUpdate() = 0;
+	virtual void frustumUpdate()
+	{
+		lastUpdateFrame = SceneSingleton::get().getFramesCount();
+	}
 
 	/// Is a spatial inside the frustum?
 	bool insideFrustum(const Spatial& sp) const
@@ -82,6 +81,7 @@ public:
 protected:
 	Frustum* frustum = nullptr;
 	VisibilityInfo vinfo;
+	uint32_t lastUpdateFrame = SceneSingleton::get().getFramesCount();
 };
 
 /// Perspective prustumable interface for scene nodes

+ 2 - 1
include/anki/scene/Light.h

@@ -246,10 +246,11 @@ public:
 	/// @name Frustumable virtuals
 	/// @{
 
-	/// Implements Frustumable::frustumUpdate(). Calculate the projection
+	/// Overrides Frustumable::frustumUpdate(). Calculate the projection
 	/// matrix
 	void frustumUpdate()
 	{
+		Frustumable::frustumUpdate();
 		projectionMat = frustum.calculateProjectionMatrix();
 	}
 	/// @}

+ 8 - 35
include/anki/scene/Spatial.h

@@ -2,19 +2,18 @@
 #define ANKI_SCENE_SPATIAL_H
 
 #include "anki/collision/Collision.h"
-
+#include "anki/util/Flags.h"
+#include "anki/scene/Scene.h"
 
 namespace anki {
 
-
 /// @addtogroup Scene
 /// @{
 
-/// Spatial "interface" for scene nodes
-///
-/// It indicates scene nodes that need to be placed in the scene's octree and
-/// they participate in the visibility tests
-class Spatial
+/// Spatial "interface" for scene nodes. It indicates scene nodes that need to 
+/// be placed in the scene's octree and they participate in the visibility 
+/// tests
+class Spatial: public Flags<uint32_t>
 {
 public:
 	/// Spatial flags
@@ -26,7 +25,7 @@ public:
 
 	/// Pass the collision shape here so we can avoid the virtuals
 	Spatial(CollisionShape* cs)
-		: spatialCs(cs), flags(SF_NONE)
+		: spatialCs(cs)
 	{}
 
 	/// @name Accessors
@@ -35,40 +34,14 @@ public:
 	{
 		return *spatialCs;
 	}
-	CollisionShape& getSpatialCollisionShape()
-	{
-		return *spatialCs;
-	}
-	/// @}
-
-	/// @name Flag manipulation
-	/// @{
-	void enableFlag(SpatialFlag flag, bool enable = true)
-	{
-		flags = enable ? flags | flag : flags & ~flag;
-	}
-	void disableFlag(SpatialFlag flag)
-	{
-		enableFlag(flag, false);
-	}
-	bool isFlagEnabled(SpatialFlag flag) const
-	{
-		return flags & flag;
-	}
-	uint getFlagsBitmask() const
-	{
-		return flags;
-	}
 	/// @}
 
 protected:
 	CollisionShape* spatialCs;
-	uint flags;
+	uint32_t lastFrameUpdate = SceneSingleton::get().getFramesCount();
 };
 /// @}
 
-
 } // namespace anki
 
-
 #endif