Panagiotis Christopoulos Charitos 13 éve
szülő
commit
157abf0145

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

@@ -59,9 +59,9 @@ public:
 		return vinfo;
 	}
 
-	uint32_t getFrustumableLastUpdateFrame() const
+	uint32_t getFrustumableTimestamp() const
 	{
-		return lastUpdateFrame;
+		return timestamp;
 	}
 	/// @}
 
@@ -73,7 +73,7 @@ public:
 
 	void frustumableMarkUpdated()
 	{
-		lastUpdateFrame = SceneSingleton::get().getFramesCount();
+		timestamp = Timestamp::getTimestamp();
 	}
 
 	/// Is a spatial inside the frustum?
@@ -93,7 +93,7 @@ protected:
 	VisibilityInfo vinfo;
 
 private:
-	uint32_t lastUpdateFrame = SceneSingleton::get().getFramesCount();
+	uint32_t timestamp = Timestamp::getTimestamp();
 };
 
 /// Perspective prustumable interface for scene nodes

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

@@ -4,7 +4,7 @@
 #include "anki/util/Object.h"
 #include "anki/util/Flags.h"
 #include "anki/math/Math.h"
-#include "anki/scene/Scene.h"
+#include "anki/scene/Timestamp.h"
 
 namespace anki {
 
@@ -74,9 +74,9 @@ public:
 		return prevWTrf;
 	}
 
-	uint32_t getMovableLastUpdateFrame() const
+	uint32_t getMovableTimestamp() const
 	{
-		return lastUpdateFrame;
+		return timestamp;
 	}
 	/// @}
 
@@ -146,7 +146,7 @@ protected:
 	Transform prevWTrf = Transform::getIdentity();
 
 	/// The frame where it was last moved
-	uint32_t lastUpdateFrame = SceneSingleton::get().getFramesCount();
+	uint32_t timestamp = Timestamp::getTimestamp();
 
 	/// Called for every frame. It updates the @a wTrf if @a shouldUpdateWTrf
 	/// is true. Then it moves to the children.
@@ -154,7 +154,7 @@ protected:
 
 	void movableMarkUpdated()
 	{
-		lastUpdateFrame = SceneSingleton::get().getFramesCount();
+		timestamp = Timestamp::getTimestamp();
 	}
 };
 /// @}

+ 0 - 14
include/anki/scene/Scene.h

@@ -79,27 +79,14 @@ public:
 	{
 		return nodes.end();
 	}
-
-	uint32_t getFramesCount() const
-	{
-		return frame;
-	}
 	/// @}
 
 	/// Put a node in the appropriate containers
 	void registerNode(SceneNode* node);
 	void unregisterNode(SceneNode* node);
 
-	void updateFrameStart()
-	{}
-
 	void update(float prevUpdateTime, float crntTime);
 
-	void updateFrameEnd()
-	{
-		++frame;
-	}
-
 	void doVisibilityTests(Camera& cam);
 
 	SceneNode* findSceneNode(const char* name)
@@ -116,7 +103,6 @@ private:
 	Vec3 ambientCol = Vec3(1.0); ///< The global ambient color
 	Camera* mainCam = nullptr;
 	VisibilityTester vtester;
-	uint32_t frame = 1;
 
 	/// Add to a container
 	template<typename T>

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

@@ -3,7 +3,7 @@
 
 #include "anki/collision/Collision.h"
 #include "anki/util/Flags.h"
-#include "anki/scene/Scene.h"
+#include "anki/scene/Timestamp.h"
 
 namespace anki {
 
@@ -42,9 +42,9 @@ public:
 		return aabb;
 	}
 
-	uint32_t getSpatialLastUpdateFrame() const
+	uint32_t getSpatialTimestamp() const
 	{
-		return lastUpdateFrame;
+		return timestamp;
 	}
 
 	OctreeNode* getOctreeNode()
@@ -65,7 +65,7 @@ public:
 	/// updated
 	void spatialMarkUpdated()
 	{
-		lastUpdateFrame = SceneSingleton::get().getFramesCount();
+		timestamp = Timestamp::getTimestamp();
 		spatialCs->getAabb(aabb);
 	}
 
@@ -73,7 +73,7 @@ protected:
 	CollisionShape* spatialCs = nullptr;
 
 private:
-	uint32_t lastUpdateFrame = SceneSingleton::get().getFramesCount();
+	uint32_t timestamp = Timestamp::getTimestamp();
 	OctreeNode* octreeNode = nullptr; ///< What octree node includes this
 	Aabb aabb; ///< A faster shape
 };

+ 6 - 4
include/anki/scene/Timestamp.h

@@ -1,27 +1,29 @@
 #ifndef ANKI_SCENE_TIMESTAMP_H
 #define ANKI_SCENE_TIMESTAMP_H
 
+#include <cstdint>
+
 namespace anki {
 
-/// Give the current timestamp. It actualy gives the current frame. Normaly it 
+/// 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 int increaseTimestamp()
+	static void increaseTimestamp()
 	{
 		++timestamp;
 	}
 
-	static int getTimestamp()
+	static uint32_t getTimestamp()
 	{
 		return timestamp;
 	}
 
 private:
-	static int timestamp;
+	static uint32_t timestamp;
 };
 
 } // end namespace anki

+ 6 - 6
src/scene/Movable.cpp

@@ -31,12 +31,12 @@ void Movable::updateWorldTransform()
 {
 	prevWTrf = wTrf;
 	Movable* parent = getParent();
-	uint32_t sceneFramesCount = SceneSingleton::get().getFramesCount();
+	uint32_t crntTimestamp = Timestamp::getTimestamp();
 
 	if(parent)
 	{
-		if(parent->lastUpdateFrame == sceneFramesCount
-			|| lastUpdateFrame == sceneFramesCount)
+		if(parent->timestamp == crntTimestamp
+			|| timestamp == crntTimestamp)
 		{
 			if(isFlagEnabled(MF_IGNORE_LOCAL_TRANSFORM))
 			{
@@ -47,15 +47,15 @@ void Movable::updateWorldTransform()
 				wTrf = Transform::combineTransformations(
 					parent->getWorldTransform(), lTrf);
 			}
-			lastUpdateFrame = sceneFramesCount;
+			timestamp = crntTimestamp;
 		}
 	}
-	else if(lastUpdateFrame == sceneFramesCount)
+	else if(timestamp == crntTimestamp)
 	{
 		wTrf = lTrf;
 	}
 
-	if(lastUpdateFrame == sceneFramesCount)
+	if(timestamp == crntTimestamp)
 	{
 		movableUpdate();
 	}

+ 2 - 2
src/scene/Scene.cpp

@@ -45,10 +45,10 @@ void Scene::update(float prevUpdateTime, float crntTime)
 	// Then the rest
 	for(SceneNode* n : nodes)
 	{
-		n->frameUpdate(prevUpdateTime, crntTime, frame);
+		n->frameUpdate(prevUpdateTime, crntTime, Timestamp::getTimestamp());
 
 		Spatial* sp = n->getSpatial();
-		if(sp && sp->getSpatialLastUpdateFrame() == frame)
+		if(sp && sp->getSpatialTimestamp() == Timestamp::getTimestamp())
 		{
 			for(Sector* sector : sectors)
 			{

+ 6 - 6
src/scene/SceneNode.cpp

@@ -28,21 +28,21 @@ uint32_t SceneNode::getLastUpdateFrame()
 	uint32_t max = 0;
 
 	const Movable* m = getMovable();
-	if(m && m->getMovableLastUpdateFrame() > max)
+	if(m && m->getMovableTimestamp() > max)
 	{
-		max = m->getMovableLastUpdateFrame();
+		max = m->getMovableTimestamp();
 	}
 
 	const Frustumable* fr = getFrustumable();
-	if(fr && fr->getFrustumableLastUpdateFrame() > max)
+	if(fr && fr->getFrustumableTimestamp() > max)
 	{
-		max = fr->getFrustumableLastUpdateFrame();
+		max = fr->getFrustumableTimestamp();
 	}
 
 	const Spatial* s = getSpatial();
-	if(s && s->getSpatialLastUpdateFrame() > max)
+	if(s && s->getSpatialTimestamp() > max)
 	{
-		max = s->getSpatialLastUpdateFrame();
+		max = s->getSpatialTimestamp();
 	}
 
 	return max;

+ 1 - 0
src/scene/Sector.cpp

@@ -1,5 +1,6 @@
 #include "anki/scene/Sector.h"
 #include "anki/scene/Spatial.h"
+#include "anki/scene/SceneNode.h"
 #include "anki/collision/CollisionAlgorithmsMatrix.h"
 
 namespace anki {

+ 1 - 1
src/scene/Timestamp.cpp

@@ -2,6 +2,6 @@
 
 namespace anki {
 
-int Timestamp::timestamp = 0;
+uint32_t Timestamp::timestamp = 1;
 
 } // end namespace anki

+ 2 - 3
testapp/Main.cpp

@@ -37,7 +37,7 @@
 #include "anki/resource/ShaderProgramPrePreprocessor.h"
 #include "anki/resource/Material.h"
 #include "anki/core/ParallelManager.h"
-#include "anki/misc/Xml.h"
+#include "anki/scene/Timestamp.h"
 
 using namespace anki;
 
@@ -179,7 +179,6 @@ void mainLoop()
 
 	while(1)
 	{
-		SceneSingleton::get().updateFrameStart();
 		HighRezTimer timer;
 		timer.start();
 
@@ -215,7 +214,7 @@ void mainLoop()
 			break;
 		}
 #endif
-		SceneSingleton::get().updateFrameEnd();
+		Timestamp::increaseTimestamp();
 	}
 
 	ANKI_LOGI("Exiting main loop (" << mainLoopTimer.getElapsedTime()