Browse Source

Scene rework. WONT COMPILE

Panagiotis Christopoulos Charitos 12 years ago
parent
commit
8fa1e169c8
3 changed files with 14 additions and 3 deletions
  1. 6 0
      include/anki/scene/SceneNode.h
  2. 5 1
      src/scene/Camera.cpp
  3. 3 2
      src/scene/SceneGraph.cpp

+ 6 - 0
include/anki/scene/SceneNode.h

@@ -139,6 +139,12 @@ public:
 		(void)frame;
 	}
 
+	/// Called when a component got updated
+	virtual void componentUpdated(SceneComponent& component)
+	{
+		(void)component;
+	}
+
 	/// Return the last frame the node was updated. It checks all components
 	U32 getLastUpdateFrame() const;
 

+ 5 - 1
src/scene/Camera.cpp

@@ -20,6 +20,10 @@ Camera::Camera(
 	sceneNodeProtected.moveC = this;
 	sceneNodeProtected.spatialC = this;
 	sceneNodeProtected.frustumC = this;
+
+	// Init components
+	newComponent<MoveComponent>(this);
+	newComponent<SpatialComponent>(this, frustum);
 }
 
 //==============================================================================
@@ -57,4 +61,4 @@ OrthographicCamera::OrthographicCamera(const char* name, SceneGraph* scene)
 	: Camera(name, scene, &frustum, CT_ORTHOGRAPHIC)
 {}
 
-} // end namespace
+} // end namespace anki

+ 3 - 2
src/scene/SceneGraph.cpp

@@ -41,8 +41,6 @@ struct UpdateMoveComponentsJob: ThreadpoolTask
 static void updateSceneNode(SceneNode& sn, F32 prevUpdateTime,
 	F32 crntTime, SectorGroup& sectorGroup)
 {
-	sn.frameUpdate(prevUpdateTime, crntTime, getGlobTimestamp());
-
 	// Movable
 	MoveComponent* m = sn.getMoveComponent();
 	if(m)
@@ -74,6 +72,9 @@ static void updateSceneNode(SceneNode& sn, F32 prevUpdateTime,
 		r->reset();
 		r->updateReal(sn, prevUpdateTime, crntTime);
 	}
+
+	// Update the node
+	sn.frameUpdate(prevUpdateTime, crntTime, getGlobTimestamp());
 }
 
 //==============================================================================