Create a new scene organisation that follows some rules:
- Be extendable from outside AnKi
- Has a simple interface and correct containers
- Be able to fast cast and fast check type (llvm isa<>)

Every scene node has a few properties that are actually interfaces. This interfaces are:

+========================+==================+===================================+=====================+
| Class name             | Base class       | Interface                         | Used                |
+========================+==================+===================================+=====================+
| BaseRenderable         | -                | - getVao(level, type)             | -                   |
|                        |                  | - getVertIdsNum(level, type)      |                     |
|                        |                  | - getModelMatrix(level, type)     |                     |
+------------------------+------------------+-----------------------------------+---------------------+
| Renderable             | BaseRenderable   | - getMaterial                     | PatchNode           |
|                        | VisibleCheckable | - getMaterialRuntime (Mutable)    |                     |
|                        |                  | - getMaterialRuntime (Const)      |                     |
|                        |                  | - renderInMs (its not virtual)    |                     |
+------------------------+------------------+-----------------------------------+---------------------+
| DebugRenderable        | BaseRenderable   | -                                 | Camera, Light       |
+------------------------+------------------+-----------------------------------+---------------------+
| IsRenderable           | BaseRenderable   | getShaderProgram                  | Light               |
+------------------------+------------------+-----------------------------------+---------------------+
| VisiblesContainable    | -                | - getVisiblesInfo                 | Camera, Light       |
|                        |                  | - testFrustum(VisibleCheckable)   |                     |
+------------------------+------------------+-----------------------------------+---------------------+
| VisibleCheckable       | -                | getCollisionShape                 | Camera, Light,      |
|                        |                  |                                   | ModelNode, SkinNode,|
|                        |                  |                                   | PatchNode           |
+------------------------+------------------+-----------------------------------+---------------------+
| RenderablesContainable | -                | - getRenderables                  | ModelNode, SkinNode |
|                        |                  | - nodesInheritCollisionShape      |                     |
+------------------------+------------------+-----------------------------------+---------------------+
| Projectable            | -                | - getViewMatrix                   | Light, Camera       |
|                        |                  | - getProjectionMatrix             |                     |
+------------------------+------------------+-----------------------------------+---------------------+


- VisibleCheckable
	- getCollisionShape [virtual]
	- getVisible
	- setVisible
	- getVisibilityGroup
	
- Renderable
	- material [virtual]
	- getVao(level, passType) [virtual]
	
- Light (aka IsRenderable)
	- getMaterialRuntime [virtual]
	- getVao() [virtual]
	
- VisiblesContainable
	- N * M sceneNodes where N is 4 (renderables and lights) and M is the number of the scene nodes
	- testFrustum(VisibleCheckable)
	
- RenderablesContainable
	- N * SceneNode
	- nodesInheritCollisionShape



PatchNode: Renderable, VisibleCheckable

Light: IsRenderable, VisibleCheckable, VisiblesContainable

Camera: VisibleCheckable, VisiblesContainable

ModelNode: VisibleCheckable, RenderablesContainable



Rendering passes:
	- Level n
		- Color
		- Depth
		- DepthParaboloid	
	- Debug


Other classes:
	

**BaseRenderableInfo**: Contains a class with public interface of:

	- 

**VisiblesInfo**: Contains the lists of:

	- Renderables
		- renderables in MS
		- renderables in BS
	- IsRenderables
		- point lights
		- spot lights
		
==================
Visibility testing
==================

In visibility testing we gather the visible renderables of MS and BS and the lights for IS. Also for every visible light we gather the renderables.

Real flow:

	function test(cam)
		for 
	endfunction

::

	function test(Camera cam)
		for node in scene's nodes
			set node not visible
		endfor
		
		for rcn in all scene's renderablesContainableNodes

				if rcn not inside cam's frustum
					break
				endif
			
				set rcn to visible
			
				# eg skin
				if rcn renderablesInheritContainingCollisionShape
					for renderable in rcn's renderables
						set renderable visible
						put renderable in cam's container
					endfor
				# eg model node
				else
					for renderable in rcn's renderables
						if renderable inside cam frustum
							put renderable in cam's container
						endif
					endfor
				endif
			endif
		endfor
		
		for l in all scene's lights
			if l inside cam's frustum
				put l in cam's container
				
				if l is shadow caster
					test(l)
				endif
				
			endfor
		endfor
		
	endfunction
	
	
- Find all the octree nodes that are inside the given frustum
- Norrow down them using the Renderer and other tests
- For all those octree nodes get the scene nodes
- Resolve buckets
- Finaly call SceneNode::visibleUpdate() for all visibles

Method declaration: void performVisibilityTests(const Octree&, const Frustum&, const Renderer&, uint passMask);

The Renderer is for hardware occlusion queries

=========
Rendering
=========

::
	function render(VisiblesContainable obj, PassType pt)	
		for renderable obj's renderables
			level = calc from distance of obj and renderable
		
			setupShaderProgram for obj in pt and level
			render using vao of level
		endfor
	endfunction

========
Problems
========

- All properties should contain the world transform
- What happens in a second pass for other camera (for split screen for example). Now the renderings happen sequential so no problem. It may fuck up the visibility vectors

====
ToDo
====

- Move update redesign
	- First update the world transforms for all nodes
	- then for the nodes that have moved (we allready keep the previ world transform) call the SceneNode::moveUpdate
	
	
===
xxx
===

Scene
	- N x SceneNode
	- 1 x Octree
	
	- Update transforms
	- Call move updates if moved

SceneObject

StaticObject: SceneObject

SceneNode: SceneObject
	- static | moving
	- TRF
	- parent & children
	
Renderable
	- stage? MS | BS | LS | DBG
	- material
	- world transform [for moving]
	- collision shape [for moving]
	
Frustum
	- N x renderables















