Browse Source

Renamed Light/Renderable/Camera so their component and non-component versions have better names

BearishSun 10 years ago
parent
commit
817756bb69
100 changed files with 4030 additions and 4155 deletions
  1. 3 3
      BansheeCore/Include/BsCorePrerequisites.h
  2. 5 5
      BansheeCore/Include/BsCoreRenderer.h
  3. 2 2
      BansheeCore/Source/BsCoreRenderer.cpp
  4. 6 6
      BansheeEditor/Include/BsGizmoManager.h
  5. 3 3
      BansheeEditor/Include/BsHandleDrawManager.h
  6. 3 3
      BansheeEditor/Include/BsHandleManager.h
  7. 5 5
      BansheeEditor/Include/BsHandleSlider.h
  8. 2 2
      BansheeEditor/Include/BsHandleSliderDisc.h
  9. 2 2
      BansheeEditor/Include/BsHandleSliderLine.h
  10. 3 3
      BansheeEditor/Include/BsHandleSliderManager.h
  11. 3 3
      BansheeEditor/Include/BsHandleSliderPlane.h
  12. 4 4
      BansheeEditor/Include/BsSceneGrid.h
  13. 2 2
      BansheeEditor/Include/BsScenePicking.h
  14. 2 2
      BansheeEditor/Include/BsSceneViewHandler.h
  15. 3 3
      BansheeEditor/Include/BsSelectionRenderer.h
  16. 1 1
      BansheeEditor/Source/BsDockManager.cpp
  17. 3 3
      BansheeEditor/Source/BsEditorApplication.cpp
  18. 3 3
      BansheeEditor/Source/BsEditorUtility.cpp
  19. 2 2
      BansheeEditor/Source/BsEditorWindowBase.cpp
  20. 6 6
      BansheeEditor/Source/BsGizmoManager.cpp
  21. 3 3
      BansheeEditor/Source/BsHandleDrawManager.cpp
  22. 4 4
      BansheeEditor/Source/BsHandleManager.cpp
  23. 4 4
      BansheeEditor/Source/BsHandleSlider.cpp
  24. 3 3
      BansheeEditor/Source/BsHandleSliderDisc.cpp
  25. 1 1
      BansheeEditor/Source/BsHandleSliderLine.cpp
  26. 4 4
      BansheeEditor/Source/BsHandleSliderManager.cpp
  27. 4 4
      BansheeEditor/Source/BsHandleSliderPlane.cpp
  28. 4 4
      BansheeEditor/Source/BsSceneGrid.cpp
  29. 6 6
      BansheeEditor/Source/BsScenePicking.cpp
  30. 2 2
      BansheeEditor/Source/BsSceneViewHandler.cpp
  31. 5 5
      BansheeEditor/Source/BsSelectionRenderer.cpp
  32. 18 20
      BansheeEngine/BansheeEngine.vcxproj
  33. 52 58
      BansheeEngine/BansheeEngine.vcxproj.filters
  34. 330 0
      BansheeEngine/Include/BsCCamera.h
  35. 38 0
      BansheeEngine/Include/BsCCameraRTTI.h
  36. 157 0
      BansheeEngine/Include/BsCLight.h
  37. 38 0
      BansheeEngine/Include/BsCLightRTTI.h
  38. 55 55
      BansheeEngine/Include/BsCOverlay.h
  39. 108 0
      BansheeEngine/Include/BsCRenderable.h
  40. 38 0
      BansheeEngine/Include/BsCRenderableRTTI.h
  41. 443 145
      BansheeEngine/Include/BsCamera.h
  42. 0 626
      BansheeEngine/Include/BsCameraHandler.h
  43. 0 125
      BansheeEngine/Include/BsCameraHandlerRTTI.h
  44. 96 9
      BansheeEngine/Include/BsCameraRTTI.h
  45. 290 131
      BansheeEngine/Include/BsLight.h
  46. 0 313
      BansheeEngine/Include/BsLightInternal.h
  47. 0 76
      BansheeEngine/Include/BsLightInternalRTTI.h
  48. 44 6
      BansheeEngine/Include/BsLightRTTI.h
  49. 6 6
      BansheeEngine/Include/BsOverlayManager.h
  50. 20 20
      BansheeEngine/Include/BsPrerequisites.h
  51. 215 40
      BansheeEngine/Include/BsRenderable.h
  52. 0 281
      BansheeEngine/Include/BsRenderableHandler.h
  53. 0 56
      BansheeEngine/Include/BsRenderableHandlerRTTI.h
  54. 27 9
      BansheeEngine/Include/BsRenderableRTTI.h
  55. 6 6
      BansheeEngine/Include/BsRenderer.h
  56. 17 17
      BansheeEngine/Include/BsSceneManager.h
  57. 0 31
      BansheeEngine/Include/BsUpdateCallback.h
  58. 92 0
      BansheeEngine/Source/BsCCamera.cpp
  59. 56 0
      BansheeEngine/Source/BsCLight.cpp
  60. 22 22
      BansheeEngine/Source/BsCOverlay.cpp
  61. 67 0
      BansheeEngine/Source/BsCRenderable.cpp
  62. 778 34
      BansheeEngine/Source/BsCamera.cpp
  63. 0 836
      BansheeEngine/Source/BsCameraHandler.cpp
  64. 1 1
      BansheeEngine/Source/BsGUIViewport.cpp
  65. 1 1
      BansheeEngine/Source/BsGUIWidget.cpp
  66. 212 22
      BansheeEngine/Source/BsLight.cpp
  67. 0 246
      BansheeEngine/Source/BsLightInternal.cpp
  68. 6 6
      BansheeEngine/Source/BsOverlayManager.cpp
  69. 288 21
      BansheeEngine/Source/BsRenderable.cpp
  70. 0 334
      BansheeEngine/Source/BsRenderableHandler.cpp
  71. 12 12
      BansheeEngine/Source/BsSceneManager.cpp
  72. 1 1
      BansheeEngine/Source/BsShapeMeshes2D.cpp
  73. 1 1
      BansheeEngine/Source/BsShapeMeshes3D.cpp
  74. 0 23
      BansheeEngine/Source/BsUpdateCallback.cpp
  75. 2 2
      ExampleProject/CameraFlyer.cpp
  76. 5 5
      ExampleProject/Main/Main.cpp
  77. 1 1
      MBansheeEditor/Scene/SceneViewHandler.cs
  78. 71 71
      MBansheeEngine/Camera.cs
  79. 35 35
      MBansheeEngine/Light.cs
  80. 3 3
      MBansheeEngine/MBansheeEngine.csproj
  81. 3 3
      MBansheeEngine/NativeCamera.cs
  82. 3 3
      MBansheeEngine/NativeLight.cs
  83. 3 3
      MBansheeEngine/NativeRenderable.cs
  84. 2 2
      MBansheeEngine/ProfilerOverlayInternal.cs
  85. 20 20
      MBansheeEngine/Renderable.cs
  86. 2 2
      RenderBeast/Include/BsLitTexRenderableController.h
  87. 14 14
      RenderBeast/Include/BsRenderBeast.h
  88. 23 23
      RenderBeast/Source/BsRenderBeast.cpp
  89. 2 2
      SBansheeEditor/Include/BsScriptSceneViewHandler.h
  90. 1 1
      SBansheeEditor/Source/BsScriptEditorApplication.cpp
  91. 3 3
      SBansheeEditor/Source/BsScriptSceneViewHandler.cpp
  92. 121 0
      SBansheeEngine/Include/BsScriptCamera.h
  93. 0 121
      SBansheeEngine/Include/BsScriptCameraHandler.h
  94. 1 1
      SBansheeEngine/Include/BsScriptEnginePrerequisites.h
  95. 0 70
      SBansheeEngine/Include/BsScriptLightInternal.h
  96. 2 2
      SBansheeEngine/Include/BsScriptProfilerOverlayInternal.h
  97. 51 0
      SBansheeEngine/Include/BsScriptRenderable.h
  98. 0 51
      SBansheeEngine/Include/BsScriptRenderableHandler.h
  99. 6 6
      SBansheeEngine/SBansheeEngine.vcxproj
  100. 18 18
      SBansheeEngine/SBansheeEngine.vcxproj.filters

+ 3 - 3
BansheeCore/Include/BsCorePrerequisites.h

@@ -147,7 +147,7 @@ namespace BansheeEngine
 	class VideoOutputInfo;
 	class VideoModeInfo;
 	class RenderableElement;
-	class CameraHandlerCore;
+	class CameraCore;
 	class MeshCoreBase;
 	class MeshCore;
 	class DrawList;
@@ -171,8 +171,8 @@ namespace BansheeEngine
 	class Prefab;
 	class PrefabDiff;
 	class RendererMeshData;
-	class LightInternalCore;
-	class LightInternal;
+	class LightCore;
+	class Light;
 	// Asset import
 	class SpecificImporter;
 	class Importer;

+ 5 - 5
BansheeCore/Include/BsCoreRenderer.h

@@ -81,7 +81,7 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		virtual void _notifyCameraAdded(const CameraHandlerCore* camera) { }
+		virtual void _notifyCameraAdded(const CameraCore* camera) { }
 
 		/**
 		 * @brief	Called whenever a camera is destroyed.
@@ -89,7 +89,7 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		virtual void _notifyCameraRemoved(const CameraHandlerCore* camera) { }
+		virtual void _notifyCameraRemoved(const CameraCore* camera) { }
 
 		/**
 		 * @brief	Creates a new empty renderer mesh data.
@@ -119,12 +119,12 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		void _registerRenderCallback(const CameraHandlerCore* camera, INT32 index, const std::function<void()>& callback);
+		void _registerRenderCallback(const CameraCore* camera, INT32 index, const std::function<void()>& callback);
 
 		/**
 		 * @brief	Removes a previously registered callback registered with "_registerRenderCallback".
 		 */
-		void _unregisterRenderCallback(const CameraHandlerCore* camera, INT32 index);
+		void _unregisterRenderCallback(const CameraCore* camera, INT32 index);
 
 		/**
 		 * @brief	Sets options used for controlling the rendering.
@@ -161,6 +161,6 @@ namespace BansheeEngine
 		Event<void(const Viewport*, DrawList&)> onRenderViewport;
 
 	protected:
-		UnorderedMap<const CameraHandlerCore*, Map<UINT32, std::function<void()>>> mRenderCallbacks;
+		UnorderedMap<const CameraCore*, Map<UINT32, std::function<void()>>> mRenderCallbacks;
 	};
 }

+ 2 - 2
BansheeCore/Source/BsCoreRenderer.cpp

@@ -26,12 +26,12 @@ namespace BansheeEngine
 			RendererMeshData(meshData));
 	}
 
-	void CoreRenderer::_registerRenderCallback(const CameraHandlerCore* camera, INT32 index, const std::function<void()>& callback)
+	void CoreRenderer::_registerRenderCallback(const CameraCore* camera, INT32 index, const std::function<void()>& callback)
 	{
 		mRenderCallbacks[camera][index] = callback;
 	}
 
-	void CoreRenderer::_unregisterRenderCallback(const CameraHandlerCore* camera, INT32 index)
+	void CoreRenderer::_unregisterRenderCallback(const CameraCore* camera, INT32 index)
 	{
 		auto iterFind = mRenderCallbacks.find(camera);
 		if (iterFind != mRenderCallbacks.end())

+ 6 - 6
BansheeEditor/Include/BsGizmoManager.h

@@ -137,7 +137,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		void update(const CameraHandlerPtr& camera);
+		void update(const CameraPtr& camera);
 
 		/**
 		 * @brief	Queues all gizmos to be rendered for picking. Each gizmo is draw with a separate
@@ -148,7 +148,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		void renderForPicking(const CameraHandlerPtr& camera, std::function<Color(UINT32)> idxToColorCallback);
+		void renderForPicking(const CameraPtr& camera, std::function<Color(UINT32)> idxToColorCallback);
 
 		/**
 		 * @brief	Clears all gizmo data, but doesn't update the meshes
@@ -277,7 +277,7 @@ namespace BansheeEngine
 		 *
 		 * @returns	A mesh containing all of the visible icons. Mesh is allocated using the icon mesh heap and should be deallocated manually.
 		 */
-		TransientMeshPtr buildIconMesh(const CameraHandlerPtr& camera, const Vector<IconData>& iconData, bool forPicking, IconRenderDataVecPtr& renderData);
+		TransientMeshPtr buildIconMesh(const CameraPtr& camera, const Vector<IconData>& iconData, bool forPicking, IconRenderDataVecPtr& renderData);
 
 		/**
 		 * @brief	Resizes the icon width/height so it is always scaled to optimal size (with preserved aspect).
@@ -294,7 +294,7 @@ namespace BansheeEngine
 		 * @param	normalColor	Normal color of the icon.
 		 * @param	fadedColor	Faded color to be used when icon is occluded by geometry.
 		 */
-		void calculateIconColors(const Color& tint, const CameraHandlerPtr& camera, UINT32 iconHeight, bool fixedScale,
+		void calculateIconColors(const Color& tint, const CameraPtr& camera, UINT32 iconHeight, bool fixedScale,
 			Color& normalColor, Color& fadedColor);
 
 		/**
@@ -461,12 +461,12 @@ namespace BansheeEngine
 		 * @param	iconMesh		Mesh containing icon meshes.
 		 * @param	iconRenderData	Icon render data outlining which parts of the icon mesh use which textures.
 		 */
-		void updateData(const SPtr<CameraHandlerCore>& camera, const SPtr<MeshCoreBase>& solidMesh, const SPtr<MeshCoreBase>& wireMesh,
+		void updateData(const SPtr<CameraCore>& camera, const SPtr<MeshCoreBase>& solidMesh, const SPtr<MeshCoreBase>& wireMesh,
 			const SPtr<MeshCoreBase>& iconMesh, const GizmoManager::IconRenderDataVecPtr& iconRenderData);
 
 		static const float PICKING_ALPHA_CUTOFF;
 
-		SPtr<CameraHandlerCore> mCamera;
+		SPtr<CameraCore> mCamera;
 
 		SPtr<MeshCoreBase> mSolidMesh;
 		SPtr<MeshCoreBase> mWireMesh;

+ 3 - 3
BansheeEditor/Include/BsHandleDrawManager.h

@@ -143,7 +143,7 @@ namespace BansheeEngine
 		 * @brief	Queues all the handle draw commands executed so far for rendering. All commands
 		 *			are cleared and will need to be called again to draw them again.
 		 */
-		void draw(const CameraHandlerPtr& camera);
+		void draw(const CameraPtr& camera);
 
 	private:
 		friend class HandleDrawManagerCore;
@@ -240,14 +240,14 @@ namespace BansheeEngine
 		 * @param	camera	Camera to render to.
 		 * @param	meshes	Meshes to render.
 		 */
-		void updateData(const SPtr<CameraHandlerCore>& camera, const Vector<MeshData>& meshes);
+		void updateData(const SPtr<CameraCore>& camera, const Vector<MeshData>& meshes);
 
 		/**
 		 * @brief	Callback triggered by the renderer. Draws the stored meshes.
 		 */
 		void render();
 
-		SPtr<CameraHandlerCore> mCamera;
+		SPtr<CameraCore> mCamera;
 		Vector<MeshData> mMeshes;
 
 		// Immutable

+ 3 - 3
BansheeEditor/Include/BsHandleManager.h

@@ -23,7 +23,7 @@ namespace BansheeEngine
 		 * @param	inputPos	Position of the pointer, relative to the provided camera viewport.
 		 * @param	inputDelta	Determines pointer movement since last call to this method.
 		 */
-		void update(const CameraHandlerPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta);
+		void update(const CameraPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta);
 
 		/**
 		 * @brief	Select a handle slider at the specified location, if there is any under the pointer. Makes
@@ -32,7 +32,7 @@ namespace BansheeEngine
 		 * @param	camera		Camera that the input positions are relative to, and destination to draw the handles to.
 		 * @param	inputPos	Position of the pointer, relative to the provided camera viewport.
 		 */
-		void trySelect(const CameraHandlerPtr& camera, const Vector2I& inputPos);
+		void trySelect(const CameraPtr& camera, const Vector2I& inputPos);
 
 		/**
 		 * @brief	Clears the currently selected/active handle slider.
@@ -59,7 +59,7 @@ namespace BansheeEngine
 		 *			position @p handlePos. The handles will be scaled so that they appear
 		 *			the same size regardless of distance from camera.
 		 */
-		float getHandleSize(const CameraHandlerPtr& camera, const Vector3& handlePos) const;
+		float getHandleSize(const CameraPtr& camera, const Vector3& handlePos) const;
 
 		/**
 		 * @brief	Sets the default handle size. This controls the uniform scale returned from

+ 5 - 5
BansheeEditor/Include/BsHandleSlider.h

@@ -51,14 +51,14 @@ namespace BansheeEngine
 		 * @param	camera		Camera through which we're interacting with the slider.
 		 * @param	inputDelta	Pointer movement since the last time this method was called.
 		 */
-		virtual void handleInput(const CameraHandlerPtr& camera, const Vector2I& inputDelta) = 0;
+		virtual void handleInput(const CameraPtr& camera, const Vector2I& inputDelta) = 0;
 
 		/**
 		 * @brief	Updates the state of the slider. Must be called every frame.
 		 *
 		 * @param	camera	Camera through which we're interacting with the slider.
 		 */
-		void update(const CameraHandlerPtr& camera);
+		void update(const CameraPtr& camera);
 
 		/**
 		 * @brief	Returns the state the slider is currently in.
@@ -117,7 +117,7 @@ namespace BansheeEngine
 		 * @param	camera		Camera through which the slider was activated.
 		 * @param	pointerPos	Position of the pointer when the slider was activated.
 		 */
-		void setActive(const CameraHandlerPtr& camera, const Vector2I& pointerPos);
+		void setActive(const CameraPtr& camera, const Vector2I& pointerPos);
 
 		/**
 		 * @brief	Toggles the slider state to hovered.
@@ -138,7 +138,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Triggered when the slider state is changed to active.
 		 */
-		virtual void activate(const CameraHandlerPtr& camera, const Vector2I& pointerPos) { }
+		virtual void activate(const CameraPtr& camera, const Vector2I& pointerPos) { }
 
 		/**
 		 * @brief	Triggered when the slider state is changed from active to some other state.
@@ -159,7 +159,7 @@ namespace BansheeEngine
 		 * @param	pointerStart	Starting position of the pointer when movement started, in pixels relative to provided camera.
 		 * @param	pointerEnd		Current position of the pointer, in pixels relative to provided camera.
 		 */
-		float calcDelta(const CameraHandlerPtr& camera, const Vector3& position, const Vector3& direction,
+		float calcDelta(const CameraPtr& camera, const Vector3& position, const Vector3& direction,
 			const Vector2I& pointerStart, const Vector2I& pointerEnd);
 
 		bool mFixedScale;

+ 2 - 2
BansheeEditor/Include/BsHandleSliderDisc.h

@@ -33,7 +33,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	HandleSlider::handleInput
 		 */
-		void handleInput(const CameraHandlerPtr& camera, const Vector2I& inputDelta) override;
+		void handleInput(const CameraPtr& camera, const Vector2I& inputDelta) override;
 
 		/**
 		 * @brief	Enables or disables a cut-off plane that can allow the disc to be intersected
@@ -63,7 +63,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	HandleSlider::activate
 		 */
-		void activate(const CameraHandlerPtr& camera, const Vector2I& pointerPos) override;
+		void activate(const CameraPtr& camera, const Vector2I& pointerPos) override;
 
 		/**
 		 * @copydoc	HandleSlider::reset

+ 2 - 2
BansheeEditor/Include/BsHandleSliderLine.h

@@ -35,7 +35,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	HandleSlider::handleInput
 		 */
-		void handleInput(const CameraHandlerPtr& camera, const Vector2I& inputDelta) override;
+		void handleInput(const CameraPtr& camera, const Vector2I& inputDelta) override;
 
 		/**
 		 * @brief	Returns a delta value that is the result of dragging/sliding the pointer 
@@ -47,7 +47,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	HandleSlider::activate
 		 */
-		void activate(const CameraHandlerPtr& camera, const Vector2I& pointerPos) override { mStartPosition = getPosition(); }
+		void activate(const CameraPtr& camera, const Vector2I& pointerPos) override { mStartPosition = getPosition(); }
 
 		/**
 		 * @copydoc	HandleSlider::reset

+ 3 - 3
BansheeEditor/Include/BsHandleSliderManager.h

@@ -21,7 +21,7 @@ namespace BansheeEngine
 		 * @param	inputPos	Position of the pointer.
 		 * @param	inputDelta	Movement of the pointer since last frame.
 		 */
-		void update(const CameraHandlerPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta);
+		void update(const CameraPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta);
 
 		/**
 		 * @brief	Attempts to select (activate) a slider at the specified position (if there is any).
@@ -29,7 +29,7 @@ namespace BansheeEngine
 		 * @param	camera		Camera through which we're interacting with sliders.
 		 * @param	inputPos	Position of the pointer.
 		 */
-		void trySelect(const CameraHandlerPtr& camera, const Vector2I& inputPos);
+		void trySelect(const CameraPtr& camera, const Vector2I& inputPos);
 
 		/**
 		 * @brief	Clears the 0active slider (deactivates it).
@@ -61,7 +61,7 @@ namespace BansheeEngine
 		 *
 		 * @return	Slider if we're intersecting with one, or null otherwise.
 		 */
-		HandleSlider* findUnderCursor(const CameraHandlerPtr& camera, const Vector2I& inputPos) const;
+		HandleSlider* findUnderCursor(const CameraPtr& camera, const Vector2I& inputPos) const;
 
 		HandleSlider* mActiveSlider;
 		HandleSlider* mHoverSlider;

+ 3 - 3
BansheeEditor/Include/BsHandleSliderPlane.h

@@ -38,7 +38,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	HandleSlider::handleInput
 		 */
-		void handleInput(const CameraHandlerPtr& camera, const Vector2I& inputDelta) override;
+		void handleInput(const CameraPtr& camera, const Vector2I& inputDelta) override;
 
 		/**
 		 * @brief	Returns a delta value that is the result of dragging/sliding the pointer 
@@ -51,7 +51,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	HandleSlider::activate
 		 */
-		void activate(const CameraHandlerPtr& camera, const Vector2I& pointerPos) override;
+		void activate(const CameraPtr& camera, const Vector2I& pointerPos) override;
 
 		/**
 		 * @copydoc	HandleSlider::reset
@@ -64,7 +64,7 @@ namespace BansheeEngine
 		 * @param	camera		Camera we're interacting through.
 		 * @param	pointerPos	Position of the pointer in pixels relative to the provided camera's viewport.
 		 */
-		Vector3 getPositionOnPlane(const CameraHandlerPtr& camera, const Vector2I& pointerPos) const;
+		Vector3 getPositionOnPlane(const CameraPtr& camera, const Vector2I& pointerPos) const;
 
 		Vector3 mDirection1;
 		Vector3 mDirection2;

+ 4 - 4
BansheeEditor/Include/BsSceneGrid.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 	class SceneGrid
 	{
 	public:
-		SceneGrid(const CameraHandlerPtr& camera);
+		SceneGrid(const CameraPtr& camera);
 		~SceneGrid();
 
 		/**
@@ -62,7 +62,7 @@ namespace BansheeEngine
 		 * @param	material	Material used for drawing the grid.
 		 * @param	camera		Camera to render the scene grid to.
 		 */
-		void initializeCore(const SPtr<CameraHandlerCore>& camera, const SPtr<MaterialCore>& material);
+		void initializeCore(const SPtr<CameraCore>& camera, const SPtr<MaterialCore>& material);
 
 		/**
 		 * @brief	Destroys the core thread portion of the draw manager.
@@ -100,7 +100,7 @@ namespace BansheeEngine
 		 * @param	material	Material used for drawing the grid.
 		 * @param	camera		Camera to render the scene grid to.
 		 */
-		void initialize(const SPtr<CameraHandlerCore>& camera, const SPtr<MaterialCore>& material);
+		void initialize(const SPtr<CameraCore>& camera, const SPtr<MaterialCore>& material);
 
 		/**
 		 * @brief	Updates the grid mesh to render.
@@ -115,7 +115,7 @@ namespace BansheeEngine
 		 */
 		void render();
 
-		SPtr<CameraHandlerCore> mCamera;
+		SPtr<CameraCore> mCamera;
 		SPtr<MeshCore> mGridMesh;
 		SPtr<MaterialCore> mGridMaterial;
 		float mSpacing = 1.0f;

+ 2 - 2
BansheeEditor/Include/BsScenePicking.h

@@ -41,7 +41,7 @@ namespace BansheeEngine
 		 *
 		 * @return	Nearest SceneObject under the provided area, or an empty handle if no object is found.
 		 */
-		HSceneObject pickClosestObject(const CameraHandlerPtr& cam, const Vector2I& position, const Vector2I& area);
+		HSceneObject pickClosestObject(const CameraPtr& cam, const Vector2I& position, const Vector2I& area);
 
 
 		/**
@@ -55,7 +55,7 @@ namespace BansheeEngine
 		 *
 		 * @return	A list of SceneObject%s under the provided area.
 		 */
-		Vector<HSceneObject> pickObjects(const CameraHandlerPtr& cam, const Vector2I& position, const Vector2I& area);
+		Vector<HSceneObject> pickObjects(const CameraPtr& cam, const Vector2I& position, const Vector2I& area);
 
 	private:
 		friend class ScenePickingCore;

+ 2 - 2
BansheeEditor/Include/BsSceneViewHandler.h

@@ -14,7 +14,7 @@ namespace BansheeEngine
 	class BS_ED_EXPORT SceneViewHandler
 	{
 	public:
-		SceneViewHandler(EditorWidgetBase* parentWidget, const SPtr<CameraHandler>& camera);
+		SceneViewHandler(EditorWidgetBase* parentWidget, const SPtr<Camera>& camera);
 		virtual ~SceneViewHandler();
 
 		/**
@@ -72,7 +72,7 @@ namespace BansheeEngine
 
 	private:
 		EditorWidgetBase* mParentWidget;
-		SPtr<CameraHandler> mCamera;
+		SPtr<Camera> mCamera;
 		SceneGrid* mSceneGrid;
 		SelectionRenderer* mSelectionRenderer;
 

+ 3 - 3
BansheeEditor/Include/BsSelectionRenderer.h

@@ -32,7 +32,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		void update(const CameraHandlerPtr& camera);
+		void update(const CameraPtr& camera);
 
 	private:
 		friend class SelectionRendererCore;
@@ -88,10 +88,10 @@ namespace BansheeEngine
 		 * @param	camera	Camera to render the selection overlay in.
 		 * @param	objects	A set of objects to render with the selection overlay.
 		 */
-		void updateData(const SPtr<CameraHandlerCore>& camera, const Vector<SelectionRenderer::ObjectData>& objects);
+		void updateData(const SPtr<CameraCore>& camera, const Vector<SelectionRenderer::ObjectData>& objects);
 
 		Vector<SelectionRenderer::ObjectData> mObjects;
-		SPtr<CameraHandlerCore> mCamera;
+		SPtr<CameraCore> mCamera;
 
 		// Immutable
 		SPtr<MaterialCore> mMaterial;

+ 1 - 1
BansheeEditor/Source/BsDockManager.cpp

@@ -15,7 +15,7 @@
 #include "BsGUIManager.h"
 #include "BsBuiltinEditorResources.h"
 #include "BsGUIWidget.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsDragAndDropManager.h"
 #include "BsGUIDockSlider.h"
 #include "BsVertexDataDesc.h"

+ 3 - 3
BansheeEditor/Source/BsEditorApplication.cpp

@@ -34,10 +34,10 @@
 #include "BsMaterial.h"
 #include "BsTechnique.h"
 #include "BsPass.h"
-#include "BsRenderable.h"
+#include "BsCRenderable.h"
 #include "BsVirtualInput.h"
 #include "BsFolderMonitor.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsGUIWidget.h"
 #include "BsGUIButton.h"
 #include "BsGUILayout.h"
@@ -154,7 +154,7 @@ namespace BansheeEngine
 		RenderAPICore* renderAPI = RenderAPICore::instancePtr();
 
 		HSceneObject testModelGO = SceneObject::create("TestMesh");
-		HRenderable testRenderable = testModelGO->addComponent<Renderable>();
+		HRenderable testRenderable = testModelGO->addComponent<CRenderable>();
 
 		Path testShaderLoc = RUNTIME_DATA_PATH + L"Test.bsl";;
 

+ 3 - 3
BansheeEditor/Source/BsEditorUtility.cpp

@@ -1,6 +1,6 @@
 #include "BsEditorUtility.h"
 #include "BsSceneObject.h"
-#include "BsRenderable.h"
+#include "BsCRenderable.h"
 
 namespace BansheeEngine
 {
@@ -41,9 +41,9 @@ namespace BansheeEngine
 
 	bool EditorUtility::calculateMeshBounds(const HSceneObject& object, AABox& bounds)
 	{
-		if (object->hasComponent<Renderable>())
+		if (object->hasComponent<CRenderable>())
 		{
-			HRenderable renderable = object->getComponent<Renderable>();
+			HRenderable renderable = object->getComponent<CRenderable>();
 			bounds = renderable->getBounds().getBox();
 
 			return true;

+ 2 - 2
BansheeEditor/Source/BsEditorWindowBase.cpp

@@ -5,7 +5,7 @@
 #include "BsRenderWindow.h"
 
 #include "BsEditorWindowManager.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsGUIWindowFrameWidget.h"
 #include "BsBuiltinEditorResources.h"
 
@@ -65,7 +65,7 @@ namespace BansheeEngine
 		mRenderWindow = renderWindow;
 		mSceneObject = SceneObject::create("EditorWindow", SOF_Internal | SOF_Persistent | SOF_DontSave);
 
-		mCamera = mSceneObject->addComponent<Camera>(renderWindow, 0.0f, 0.0f, 1.0f, 1.0f);
+		mCamera = mSceneObject->addComponent<CCamera>(renderWindow, 0.0f, 0.0f, 1.0f, 1.0f);
 		mCamera->setNearClipDistance(5);
 		mCamera->setAspectRatio(1.0f);
 		mCamera->setLayers(0);

+ 6 - 6
BansheeEditor/Source/BsGizmoManager.cpp

@@ -5,7 +5,7 @@
 #include "BsVertexDataDesc.h"
 #include "BsShapeMeshes3D.h"
 #include "BsMeshHeap.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsSpriteTexture.h"
 #include "BsCoreThread.h"
 #include "BsBuiltinEditorResources.h"
@@ -228,7 +228,7 @@ namespace BansheeEngine
 		mIdxToSceneObjectMap[iconData.idx] = mActiveSO;
 	}
 
-	void GizmoManager::update(const CameraHandlerPtr& camera)
+	void GizmoManager::update(const CameraPtr& camera)
 	{
 		mDrawHelper->clearMeshes();
 
@@ -269,7 +269,7 @@ namespace BansheeEngine
 			solidMesh, wireMesh, iconMesh, iconRenderData));
 	}
 
-	void GizmoManager::renderForPicking(const CameraHandlerPtr& camera, std::function<Color(UINT32)> idxToColorCallback)
+	void GizmoManager::renderForPicking(const CameraPtr& camera, std::function<Color(UINT32)> idxToColorCallback)
 	{
 		Vector<IconData> iconData;
 		IconRenderDataVecPtr iconRenderData;
@@ -418,7 +418,7 @@ namespace BansheeEngine
 		gCoreAccessor().queueCommand(std::bind(&GizmoManagerCore::updateData, core, nullptr, nullptr, nullptr, nullptr, iconRenderData));
 	}
 
-	TransientMeshPtr GizmoManager::buildIconMesh(const CameraHandlerPtr& camera, const Vector<IconData>& iconData,
+	TransientMeshPtr GizmoManager::buildIconMesh(const CameraPtr& camera, const Vector<IconData>& iconData,
 		bool forPicking, GizmoManager::IconRenderDataVecPtr& iconRenderData)
 	{
 		mSortedIconData.clear();
@@ -600,7 +600,7 @@ namespace BansheeEngine
 		height = Math::roundToInt(height * scale);
 	}
 
-	void GizmoManager::calculateIconColors(const Color& tint, const CameraHandlerPtr& camera,
+	void GizmoManager::calculateIconColors(const Color& tint, const CameraPtr& camera,
 		UINT32 iconHeight, bool fixedScale, Color& normalColor, Color& fadedColor)
 	{
 		normalColor = tint;
@@ -708,7 +708,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GizmoManagerCore::updateData(const SPtr<CameraHandlerCore>& camera, const SPtr<MeshCoreBase>& solidMesh, const SPtr<MeshCoreBase>& wireMesh,
+	void GizmoManagerCore::updateData(const SPtr<CameraCore>& camera, const SPtr<MeshCoreBase>& solidMesh, const SPtr<MeshCoreBase>& wireMesh,
 		const SPtr<MeshCoreBase>& iconMesh, const GizmoManager::IconRenderDataVecPtr& iconRenderData)
 	{
 		if (mCamera != camera)

+ 3 - 3
BansheeEditor/Source/BsHandleDrawManager.cpp

@@ -6,7 +6,7 @@
 #include "BsRendererManager.h"
 #include "BsCoreRenderer.h"
 #include "BsTransientMesh.h"
-#include "BsCameraHandler.h"
+#include "BsCamera.h"
 #include "BsSceneObject.h"
 
 using namespace std::placeholders;
@@ -153,7 +153,7 @@ namespace BansheeEngine
 		mDrawHelper->rectangle(area);
 	}
 
-	void HandleDrawManager::draw(const CameraHandlerPtr& camera)
+	void HandleDrawManager::draw(const CameraPtr& camera)
 	{
 		mDrawHelper->clearMeshes();
 		mDrawHelper->buildMeshes(DrawHelper::SortType::BackToFront, camera->getPosition());
@@ -202,7 +202,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void HandleDrawManagerCore::updateData(const SPtr<CameraHandlerCore>& camera, const Vector<MeshData>& meshes)
+	void HandleDrawManagerCore::updateData(const SPtr<CameraCore>& camera, const Vector<MeshData>& meshes)
 	{
 		if (mCamera != camera)
 		{

+ 4 - 4
BansheeEditor/Source/BsHandleManager.cpp

@@ -1,7 +1,7 @@
 #include "BsHandleManager.h"
 #include "BsHandleDrawManager.h"
 #include "BsHandleSliderManager.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsSceneObject.h"
 #include "BsEditorSettings.h"
 
@@ -25,7 +25,7 @@ namespace BansheeEngine
 		return mSliderManager->isSliderActive();
 	}
 
-	void HandleManager::update(const CameraHandlerPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta)
+	void HandleManager::update(const CameraPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta)
 	{
 		if (mSettings != nullptr && mSettingsHash != mSettings->getHash())
 			updateFromEditorSettings();
@@ -52,7 +52,7 @@ namespace BansheeEngine
 		mSettingsHash = mSettings->getHash();
 	}
 
-	void HandleManager::trySelect(const CameraHandlerPtr& camera, const Vector2I& inputPos)
+	void HandleManager::trySelect(const CameraPtr& camera, const Vector2I& inputPos)
 	{
 		return mSliderManager->trySelect(camera, inputPos);
 	}
@@ -62,7 +62,7 @@ namespace BansheeEngine
 		return mSliderManager->clearSelection();
 	}
 
-	float HandleManager::getHandleSize(const CameraHandlerPtr& camera, const Vector3& handlePos) const
+	float HandleManager::getHandleSize(const CameraPtr& camera, const Vector3& handlePos) const
 	{
 		Vector3 cameraPos = camera->getPosition();
 

+ 4 - 4
BansheeEditor/Source/BsHandleSlider.cpp

@@ -1,5 +1,5 @@
 #include "BsHandleSlider.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsHandleManager.h"
 #include "BsDebug.h"
 
@@ -12,7 +12,7 @@ namespace BansheeEngine
 
 	}
 
-	void HandleSlider::update(const CameraHandlerPtr& camera)
+	void HandleSlider::update(const CameraPtr& camera)
 	{
 		if (mFixedScale)
 		{
@@ -77,7 +77,7 @@ namespace BansheeEngine
 		reset(); 
 	}
 
-	void HandleSlider::setActive(const CameraHandlerPtr& camera, const Vector2I& pointerPos)
+	void HandleSlider::setActive(const CameraPtr& camera, const Vector2I& pointerPos)
 	{ 
 		mState = State::Active; 
 		mStartPointerPos = pointerPos; 
@@ -91,7 +91,7 @@ namespace BansheeEngine
 		reset(); 
 	}
 
-	float HandleSlider::calcDelta(const CameraHandlerPtr& camera, const Vector3& position, const Vector3& direction,
+	float HandleSlider::calcDelta(const CameraPtr& camera, const Vector3& position, const Vector3& direction,
 		const Vector2I& pointerStart, const Vector2I& pointerEnd)
 	{
 		// position + direction can sometimes project behind the camera (if the camera is looking at position

+ 3 - 3
BansheeEditor/Source/BsHandleSliderDisc.cpp

@@ -4,7 +4,7 @@
 #include "BsRay.h"
 #include "BsVector3.h"
 #include "BsQuaternion.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 
 // DEBUG ONLY
 #include "BsDebug.h"
@@ -156,7 +156,7 @@ namespace BansheeEngine
 		return Radian(Math::atan2(-point.z, -point.x) + Math::PI);
 	}
 
-	void HandleSliderDisc::activate(const CameraHandlerPtr& camera, const Vector2I& pointerPos)
+	void HandleSliderDisc::activate(const CameraPtr& camera, const Vector2I& pointerPos)
 	{
 		Ray localRay = camera->screenPointToRay(pointerPos);
 		localRay.transformAffine(getTransformInv());
@@ -173,7 +173,7 @@ namespace BansheeEngine
 		mDirection.normalize();
 	}
 
-	void HandleSliderDisc::handleInput(const CameraHandlerPtr& camera, const Vector2I& inputDelta)
+	void HandleSliderDisc::handleInput(const CameraPtr& camera, const Vector2I& inputDelta)
 	{
 		assert(getState() == State::Active);
 

+ 1 - 1
BansheeEditor/Source/BsHandleSliderLine.cpp

@@ -72,7 +72,7 @@ namespace BansheeEngine
 		return gotIntersect;
 	}
 
-	void HandleSliderLine::handleInput(const CameraHandlerPtr& camera, const Vector2I& inputDelta)
+	void HandleSliderLine::handleInput(const CameraPtr& camera, const Vector2I& inputDelta)
 	{
 		assert(getState() == State::Active);
 

+ 4 - 4
BansheeEditor/Source/BsHandleSliderManager.cpp

@@ -6,7 +6,7 @@
 #include "BsRendererManager.h"
 #include "BsCoreRenderer.h"
 #include "BsTransientMesh.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsHandleSlider.h"
 
 using namespace std::placeholders;
@@ -24,7 +24,7 @@ namespace BansheeEngine
 
 	}
 
-	void HandleSliderManager::update(const CameraHandlerPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta)
+	void HandleSliderManager::update(const CameraPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta)
 	{
 		for (auto& slider : mSliders)
 			slider->update(camera);
@@ -54,7 +54,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void HandleSliderManager::trySelect(const CameraHandlerPtr& camera, const Vector2I& inputPos)
+	void HandleSliderManager::trySelect(const CameraPtr& camera, const Vector2I& inputPos)
 	{
 		HandleSlider* newActiveSlider = findUnderCursor(camera, inputPos);
 
@@ -89,7 +89,7 @@ namespace BansheeEngine
 		}
 	}
 
-	HandleSlider* HandleSliderManager::findUnderCursor(const CameraHandlerPtr& camera, const Vector2I& inputPos) const
+	HandleSlider* HandleSliderManager::findUnderCursor(const CameraPtr& camera, const Vector2I& inputPos) const
 	{
 		Ray inputRay = camera->screenPointToRay(inputPos);
 

+ 4 - 4
BansheeEditor/Source/BsHandleSliderPlane.cpp

@@ -4,7 +4,7 @@
 #include "BsVector3.h"
 #include "BsRay.h"
 #include "BsPlane.h"
-#include "BsCameraHandler.h"
+#include "BsCamera.h"
 
 namespace BansheeEngine
 {
@@ -48,13 +48,13 @@ namespace BansheeEngine
 		return false;
 	}
 
-	void HandleSliderPlane::activate(const CameraHandlerPtr& camera, const Vector2I& pointerPos)
+	void HandleSliderPlane::activate(const CameraPtr& camera, const Vector2I& pointerPos)
 	{
 		mStartPlanePosition = getPosition();
 		mStartClickPosition = getPositionOnPlane(camera, pointerPos);
 	}
 
-	void HandleSliderPlane::handleInput(const CameraHandlerPtr& camera, const Vector2I& inputDelta)
+	void HandleSliderPlane::handleInput(const CameraPtr& camera, const Vector2I& inputDelta)
 	{
 		assert(getState() == State::Active);
 
@@ -70,7 +70,7 @@ namespace BansheeEngine
 		mDelta.y = positionDelta.dot(worldDir2);
 	}
 
-	Vector3 HandleSliderPlane::getPositionOnPlane(const CameraHandlerPtr& camera, const Vector2I& pointerPos) const
+	Vector3 HandleSliderPlane::getPositionOnPlane(const CameraPtr& camera, const Vector2I& pointerPos) const
 	{
 		Vector3 worldDir1 = getRotation().rotate(mDirection1);
 		Vector3 worldDir2 = getRotation().rotate(mDirection2);

+ 4 - 4
BansheeEditor/Source/BsSceneGrid.cpp

@@ -6,7 +6,7 @@
 #include "BsMesh.h"
 #include "BsDrawList.h"
 #include "BsBuiltinEditorResources.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsRect3.h"
 #include "BsCoreThread.h"
 #include "BsEditorSettings.h"
@@ -21,7 +21,7 @@ namespace BansheeEngine
 	const float SceneGridCore::FADE_OUT_START = 5.0f;
 	const float SceneGridCore::FADE_OUT_END = 40.0f;
 
-	SceneGrid::SceneGrid(const CameraHandlerPtr& camera)
+	SceneGrid::SceneGrid(const CameraPtr& camera)
 		:mCoreDirty(true), mCore(nullptr)
 	{
 		mVertexDesc = bs_shared_ptr_new<VertexDataDesc>();
@@ -42,7 +42,7 @@ namespace BansheeEngine
 		gCoreAccessor().queueCommand(std::bind(&SceneGrid::destroyCore, this, mCore.load(std::memory_order_relaxed)));
 	}
 
-	void SceneGrid::initializeCore(const SPtr<CameraHandlerCore>& camera, const SPtr<MaterialCore>& material)
+	void SceneGrid::initializeCore(const SPtr<CameraCore>& camera, const SPtr<MaterialCore>& material)
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
@@ -135,7 +135,7 @@ namespace BansheeEngine
 		activeRenderer->_unregisterRenderCallback(mCamera.get(), -20);
 	}
 
-	void SceneGridCore::initialize(const SPtr<CameraHandlerCore>& camera, const SPtr<MaterialCore>& material)
+	void SceneGridCore::initialize(const SPtr<CameraCore>& camera, const SPtr<MaterialCore>& material)
 	{
 		mCamera = camera;
 		mGridMaterial = material;

+ 6 - 6
BansheeEditor/Source/BsScenePicking.cpp

@@ -4,11 +4,11 @@
 #include "BsMatrix4.h"
 #include "BsDebug.h"
 #include "BsMath.h"
-#include "BsRenderable.h"
+#include "BsCRenderable.h"
 #include "BsSceneObject.h"
 #include "BsMesh.h"
 #include "BsConvexVolume.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsCoreThread.h"
 #include "BsRenderAPI.h"
 #include "BsMaterial.h"
@@ -51,7 +51,7 @@ namespace BansheeEngine
 		gCoreAccessor().queueCommand(std::bind(&ScenePickingCore::destroy, mCore));
 	}
 
-	HSceneObject ScenePicking::pickClosestObject(const CameraHandlerPtr& cam, const Vector2I& position, const Vector2I& area)
+	HSceneObject ScenePicking::pickClosestObject(const CameraPtr& cam, const Vector2I& position, const Vector2I& area)
 	{
 		Vector<HSceneObject> selectedObjects = pickObjects(cam, position, area);
 		if (selectedObjects.size() == 0)
@@ -60,7 +60,7 @@ namespace BansheeEngine
 		return selectedObjects[0];
 	}
 
-	Vector<HSceneObject> ScenePicking::pickObjects(const CameraHandlerPtr& cam, const Vector2I& position, const Vector2I& area)
+	Vector<HSceneObject> ScenePicking::pickObjects(const CameraPtr& cam, const Vector2I& position, const Vector2I& area)
 	{
 		auto comparePickElement = [&] (const ScenePicking::RenderablePickData& a, const ScenePicking::RenderablePickData& b)
 		{
@@ -78,13 +78,13 @@ namespace BansheeEngine
 
 		Matrix4 viewProjMatrix = cam->getProjectionMatrixRS() * cam->getViewMatrix();
 
-		const Map<RenderableHandler*, SceneRenderableData>& renderables = SceneManager::instance().getAllRenderables();
+		const Map<Renderable*, SceneRenderableData>& renderables = SceneManager::instance().getAllRenderables();
 		RenderableSet pickData(comparePickElement);
 		Map<UINT32, HSceneObject> idxToRenderable;
 
 		for (auto& renderableData : renderables)
 		{
-			RenderableHandlerPtr renderable = renderableData.second.renderable;
+			RenderablePtr renderable = renderableData.second.renderable;
 			HSceneObject so = renderableData.second.sceneObject;
 
 			if (!so->getActive())

+ 2 - 2
BansheeEditor/Source/BsSceneViewHandler.cpp

@@ -6,7 +6,7 @@
 #include "BsSceneGrid.h"
 #include "BsSelection.h"
 #include "BsScenePicking.h"
-#include "BsCameraHandler.h"
+#include "BsCamera.h"
 #include "BsEditorApplication.h"
 #include "BsEditorWidget.h"
 #include "BsEditorWindowBase.h"
@@ -20,7 +20,7 @@ using namespace std::placeholders;
 
 namespace BansheeEngine
 {
-	SceneViewHandler::SceneViewHandler(EditorWidgetBase* parentWidget, const SPtr<CameraHandler>& camera)
+	SceneViewHandler::SceneViewHandler(EditorWidgetBase* parentWidget, const SPtr<Camera>& camera)
 		:mCamera(camera), mSceneGrid(nullptr), mParentWidget(parentWidget)
 	{
 		mSelectionRenderer = bs_new<SelectionRenderer>();

+ 5 - 5
BansheeEditor/Source/BsSelectionRenderer.cpp

@@ -1,7 +1,7 @@
 #include "BsSelectionRenderer.h"
 #include "BsMesh.h"
 #include "BsVertexDataDesc.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsCoreThread.h"
 #include "BsBuiltinEditorResources.h"
 #include "BsMaterial.h"
@@ -11,7 +11,7 @@
 #include "BsRendererManager.h"
 #include "BsSelection.h"
 #include "BsSceneObject.h"
-#include "BsRenderable.h"
+#include "BsCRenderable.h"
 
 using namespace std::placeholders;
 
@@ -42,14 +42,14 @@ namespace BansheeEngine
 		bs_delete(core);
 	}
 
-	void SelectionRenderer::update(const CameraHandlerPtr& camera)
+	void SelectionRenderer::update(const CameraPtr& camera)
 	{
 		Vector<ObjectData> objects;
 
 		const Vector<HSceneObject>& sceneObjects = Selection::instance().getSceneObjects();
 		for (auto& so : sceneObjects)
 		{
-			HRenderable renderable = so->getComponent<Renderable>();
+			HRenderable renderable = so->getComponent<CRenderable>();
 			if (renderable != nullptr && renderable->getMesh() != nullptr)
 			{
 				objects.push_back(ObjectData());
@@ -83,7 +83,7 @@ namespace BansheeEngine
 		fragParams->getParam("selColor", mColor);
 	}
 
-	void SelectionRendererCore::updateData(const SPtr<CameraHandlerCore>& camera, const Vector<SelectionRenderer::ObjectData>& objects)
+	void SelectionRendererCore::updateData(const SPtr<CameraCore>& camera, const Vector<SelectionRenderer::ObjectData>& objects)
 	{
 		if (mCamera != camera)
 		{

+ 18 - 20
BansheeEngine/BansheeEngine.vcxproj

@@ -232,7 +232,7 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="Source\BsCameraHandler.cpp" />
+    <ClCompile Include="Source\BsCamera.cpp" />
     <ClCompile Include="Source\BsCursor.cpp" />
     <ClCompile Include="Source\BsDrawHelper.cpp" />
     <ClCompile Include="Source\BsDropDownAreaPlacement.cpp" />
@@ -246,11 +246,11 @@
     <ClCompile Include="Source\BsGUISpace.cpp" />
     <ClCompile Include="Source\BsHEString.cpp" />
     <ClCompile Include="Source\BsInputConfiguration.cpp" />
-    <ClCompile Include="Source\BsLight.cpp" />
+    <ClCompile Include="Source\BsCLight.cpp" />
     <ClCompile Include="Source\BsPlainText.cpp" />
     <ClCompile Include="Source\BsPlainTextImporter.cpp" />
     <ClCompile Include="Source\BsRenderableController.cpp" />
-    <ClCompile Include="Source\BsRenderableHandler.cpp" />
+    <ClCompile Include="Source\BsRenderable.cpp" />
     <ClCompile Include="Source\BsRenderer.cpp" />
     <ClCompile Include="Source\BsRenderQueue.cpp" />
     <ClCompile Include="Source\BsScriptCode.cpp" />
@@ -259,10 +259,10 @@
     <ClCompile Include="Source\BsShortcutKey.cpp" />
     <ClCompile Include="Source\BsShortcutManager.cpp" />
     <ClCompile Include="Source\BsVirtualInput.cpp" />
-    <ClCompile Include="Source\BsLightInternal.cpp" />
+    <ClCompile Include="Source\BsLight.cpp" />
     <ClInclude Include="Include\BsApplication.h" />
-    <ClInclude Include="Include\BsCameraHandler.h" />
-    <ClInclude Include="Include\BsCameraHandlerRTTI.h" />
+    <ClInclude Include="Include\BsCamera.h" />
+    <ClInclude Include="Include\BsCameraRTTI.h" />
     <ClInclude Include="Include\BsCursor.h" />
     <ClInclude Include="Include\BsDrawHelper.h" />
     <ClInclude Include="Include\BsDropDownAreaPlacement.h" />
@@ -275,16 +275,16 @@
     <ClInclude Include="Include\BsGUISlider.h" />
     <ClInclude Include="Include\BsGUIWidgetRTTI.h" />
     <ClInclude Include="Include\BsHEString.h" />
+    <ClInclude Include="Include\BsCLight.h" />
     <ClInclude Include="Include\BsLight.h" />
-    <ClInclude Include="Include\BsLightInternal.h" />
-    <ClInclude Include="Include\BsLightInternalRTTI.h" />
     <ClInclude Include="Include\BsLightRTTI.h" />
+    <ClInclude Include="Include\BsCLightRTTI.h" />
     <ClInclude Include="Include\BsPlainText.h" />
     <ClInclude Include="Include\BsPlainTextImporter.h" />
     <ClInclude Include="Include\BsPlainTextRTTI.h" />
     <ClInclude Include="Include\BsRenderableElement.h" />
-    <ClInclude Include="Include\BsRenderableHandler.h" />
-    <ClInclude Include="Include\BsRenderableHandlerRTTI.h" />
+    <ClInclude Include="Include\BsRenderable.h" />
+    <ClInclude Include="Include\BsRenderableRTTI.h" />
     <ClInclude Include="Include\BsRenderer.h" />
     <ClInclude Include="Include\BsScriptCode.h" />
     <ClInclude Include="Include\BsScriptCodeImporter.h" />
@@ -356,13 +356,12 @@
     <ClInclude Include="Include\BsSprite.h" />
     <ClInclude Include="Include\BsSpriteTexture.h" />
     <ClInclude Include="Include\BsTextSprite.h" />
-    <ClInclude Include="Include\BsCamera.h" />
-    <ClInclude Include="Include\BsCameraRTTI.h" />
-    <ClInclude Include="Include\BsOverlay.h" />
+    <ClInclude Include="Include\BsCCamera.h" />
+    <ClInclude Include="Include\BsCCameraRTTI.h" />
+    <ClInclude Include="Include\BsCOverlay.h" />
     <ClInclude Include="Include\BsOverlayManager.h" />
-    <ClInclude Include="Include\BsRenderable.h" />
-    <ClInclude Include="Include\BsRenderableRTTI.h" />
-    <ClInclude Include="Include\BsUpdateCallback.h" />
+    <ClInclude Include="Include\BsCRenderable.h" />
+    <ClInclude Include="Include\BsCRenderableRTTI.h" />
     <ClCompile Include="Source\BsGUIButtonBase.cpp" />
     <ClCompile Include="Source\BsGUIContextMenu.cpp" />
     <ClInclude Include="Include\BsVirtualInput.h" />
@@ -415,11 +414,10 @@
     <ClCompile Include="Source\BsSprite.cpp" />
     <ClCompile Include="Source\BsSpriteTexture.cpp" />
     <ClCompile Include="Source\BsTextSprite.cpp" />
-    <ClCompile Include="Source\BsCamera.cpp" />
-    <ClCompile Include="Source\BsOverlay.cpp" />
+    <ClCompile Include="Source\BsCCamera.cpp" />
+    <ClCompile Include="Source\BsCOverlay.cpp" />
     <ClCompile Include="Source\BsOverlayManager.cpp" />
-    <ClCompile Include="Source\BsRenderable.cpp" />
-    <ClCompile Include="Source\BsUpdateCallback.cpp" />
+    <ClCompile Include="Source\BsCRenderable.cpp" />
     <ClCompile Include="Source\BsGUILayoutX.cpp" />
     <ClCompile Include="Source\BsGUIViewport.cpp" />
     <ClCompile Include="Source\BsGUIMenu.cpp" />

+ 52 - 58
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -83,24 +83,9 @@
     <ClInclude Include="Include\BsSceneManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsOverlay.h">
-      <Filter>Header Files\Components</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderable.h">
-      <Filter>Header Files\Components</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsCameraRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderableRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsOverlayManager.h">
       <Filter>Header Files\2D</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsUpdateCallback.h">
-      <Filter>Header Files\Components</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsGUILayout.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
@@ -248,24 +233,9 @@
     <ClInclude Include="Include\BsDrawHelper.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsCamera.h">
-      <Filter>Header Files\Components</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsCameraHandler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsCameraHandlerRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsRenderableController.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsRenderableHandler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderableHandlerRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsRenderableElement.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -335,27 +305,54 @@
     <ClInclude Include="Include\BsDropDownAreaPlacement.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsLightInternal.h">
+    <ClInclude Include="Include\BsGUIWidgetRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsProfilerOverlayRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsHEString.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsLightInternalRTTI.h">
+    <ClInclude Include="Include\BsCCamera.h">
+      <Filter>Header Files\Components</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCCameraRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsLight.h">
+    <ClInclude Include="Include\BsCRenderableRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCRenderable.h">
       <Filter>Header Files\Components</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsLightRTTI.h">
+    <ClInclude Include="Include\BsCLightRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsGUIWidgetRTTI.h">
+    <ClInclude Include="Include\BsCLight.h">
+      <Filter>Header Files\Components</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCOverlay.h">
+      <Filter>Header Files\Components</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCamera.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCameraRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsProfilerOverlayRTTI.h">
+    <ClInclude Include="Include\BsRenderableRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsHEString.h">
+    <ClInclude Include="Include\BsRenderable.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsLight.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsLightRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
@@ -397,18 +394,6 @@
     <ClCompile Include="Source\BsOverlayManager.cpp">
       <Filter>Source Files\2D</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsCamera.cpp">
-      <Filter>Source Files\Components</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsOverlay.cpp">
-      <Filter>Source Files\Components</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsRenderable.cpp">
-      <Filter>Source Files\Components</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsUpdateCallback.cpp">
-      <Filter>Source Files\Components</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsGUILayout.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
@@ -535,15 +520,9 @@
     <ClCompile Include="Source\BsDrawHelper.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsCameraHandler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsRenderableController.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsRenderableHandler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsRenderer.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -601,13 +580,28 @@
     <ClCompile Include="Source\BsDropDownAreaPlacement.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsLightInternal.cpp">
+    <ClCompile Include="Source\BsHEString.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsLight.cpp">
+    <ClCompile Include="Source\BsCCamera.cpp">
       <Filter>Source Files\Components</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsHEString.cpp">
+    <ClCompile Include="Source\BsCRenderable.cpp">
+      <Filter>Source Files\Components</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsCLight.cpp">
+      <Filter>Source Files\Components</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsCOverlay.cpp">
+      <Filter>Source Files\Components</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsCamera.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsRenderable.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsLight.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>

+ 330 - 0
BansheeEngine/Include/BsCCamera.h

@@ -0,0 +1,330 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsCamera.h"
+#include "BsComponent.h"
+#include "BsViewport.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @copydoc	Camera
+	 * 			
+	 * Wraps a Camera as a Component.
+	 */
+    class BS_EXPORT CCamera : public Component
+    {
+    public:
+		CCamera(const HSceneObject& parent, RenderTargetPtr target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
+
+        virtual ~CCamera();
+
+		/**
+		 * @copydoc	Camera::getViewport
+		 */
+		ViewportPtr getViewport() const { return mInternal->getViewport(); }
+
+		/**
+		 * @copydoc	Camera::setHorzFOV
+		 */
+		virtual void setHorzFOV(const Radian& fovy) { mInternal->setHorzFOV(fovy); }
+
+		/**
+		 * @copydoc	Camera::getHorzFOV
+		 */
+		virtual const Radian& getHorzFOV() const { return mInternal->getHorzFOV(); }
+
+		/**
+		 * @copydoc	Camera::setNearClipDistance
+		 */
+		virtual void setNearClipDistance(float nearDist) { mInternal->setNearClipDistance(nearDist); }
+
+		/**
+		 * @copydoc	Camera::getNearClipDistance
+		 */
+		virtual float getNearClipDistance() const { return mInternal->getNearClipDistance(); }
+
+		/**
+		 * @copydoc	Camera::setFarClipDistance
+		 */
+		virtual void setFarClipDistance(float farDist) { mInternal->setFarClipDistance(farDist); }
+
+		/**
+		 * @copydoc	Camera::getFarClipDistance
+		 */
+		virtual float getFarClipDistance() const { return mInternal->getFarClipDistance(); }
+
+		/**
+		 * @copydoc	Camera::setAspectRatio
+		 */
+		virtual void setAspectRatio(float ratio) { mInternal->setAspectRatio(ratio); }
+
+		/**
+		 * @copydoc	Camera::getAspectRatio
+		 */
+		virtual float getAspectRatio() const { return mInternal->getAspectRatio(); }
+
+		/**
+		 * @copydoc	Camera::setFrustumExtents
+		 */
+		virtual void setFrustumExtents(float left, float right, float top, float bottom)
+		{
+			mInternal->setFrustumExtents(left, right, top, bottom);
+		}
+
+		/**
+		 * @copydoc	Camera::resetFrustumExtents
+		 */
+		virtual void resetFrustumExtents() { mInternal->resetFrustumExtents(); }
+
+		/**
+		 * @copydoc	Camera::getFrustumExtents
+		 */
+		virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const
+		{
+			mInternal->getFrustumExtents(outleft, outright, outtop, outbottom);
+		}
+
+		/**
+		 * @copydoc	Camera::getProjectionMatrixRS
+		 */
+		virtual const Matrix4& getProjectionMatrixRS() const { return mInternal->getProjectionMatrixRS(); }
+
+		/**
+		 * @copydoc	Camera::getProjectionMatrix
+		 */
+		virtual const Matrix4& getProjectionMatrix() const { return mInternal->getProjectionMatrix(); }
+
+		/**
+		 * @copydoc	Camera::getViewMatrix
+		 */
+		virtual const Matrix4& getViewMatrix() const { updateView(); return mInternal->getViewMatrix(); }
+
+		/**
+		 * @copydoc	Camera::setCustomViewMatrix
+		 */
+		virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY)
+		{
+			mInternal->setCustomViewMatrix(enable, viewMatrix);
+		}
+
+		/**
+		 * @copydoc	Camera::isCustomViewMatrixEnabled
+		 */
+		virtual bool isCustomViewMatrixEnabled() const { return mInternal->isCustomViewMatrixEnabled(); }
+		
+		/**
+		 * @copydoc	Camera::setCustomProjectionMatrix
+		 */
+		virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY)
+		{
+			mInternal->setCustomProjectionMatrix(enable, projectionMatrix);
+		}
+
+		/**
+		 * @copydoc	Camera::isCustomProjectionMatrixEnabled
+		 */
+		virtual bool isCustomProjectionMatrixEnabled() const { return mInternal->isCustomProjectionMatrixEnabled(); }
+
+		/**
+		 * @copydoc	Camera::getFrustum
+		 */
+		virtual const ConvexVolume& getFrustum() const { return mInternal->getFrustum(); }
+
+		/**
+		 * @copydoc	Camera::getWorldFrustum
+		 */
+        virtual ConvexVolume getWorldFrustum() const;
+
+		/**
+		 * @copydoc	Camera::getBoundingBox
+		 */
+		const AABox& getBoundingBox() const { return mInternal->getBoundingBox(); }
+
+		/**
+		 * @copydoc	Camera::setProjectionType
+		 */
+		virtual void setProjectionType(ProjectionType pt) { mInternal->setProjectionType(pt); }
+
+		/**
+		 * @copydoc	Camera::getProjectionType
+		 */
+		virtual ProjectionType getProjectionType() const { return mInternal->getProjectionType(); }
+
+		/**
+		 * @copydoc	Camera::setOrthoWindow
+		 */
+		virtual void setOrthoWindow(float w, float h) { mInternal->setOrthoWindow(w, h); }
+
+		/**
+		 * @copydoc	Camera::setOrthoWindowHeight
+		 */
+		virtual void setOrthoWindowHeight(float h) { mInternal->setOrthoWindowHeight(h); }
+
+		/**
+		 * @copydoc	Camera::setOrthoWindowWidth
+		 */
+		virtual void setOrthoWindowWidth(float w) { mInternal->setOrthoWindowWidth(w); }
+
+		/**
+		 * @copydoc	Camera::getOrthoWindowHeight
+		 */
+		virtual float getOrthoWindowHeight() const { return mInternal->getOrthoWindowHeight(); }
+
+		/**
+		 * @copydoc	Camera::getOrthoWindowWidth
+		 */
+		virtual float getOrthoWindowWidth() const { return mInternal->getOrthoWindowWidth(); }
+
+		/**
+		 * @copydoc	Camera::getPriority
+		 */
+		INT32 getPriority() const { return mInternal->getPriority(); }
+
+		/**
+		 * @copydoc	Camera::setPriority
+		 */
+		void setPriority(INT32 priority) { mInternal->setPriority(priority); }
+
+		/**
+		 * @copydoc	Camera::getLayers
+		 */
+		UINT64 getLayers() const { return mInternal->getLayers(); }
+
+		/**
+		 * @copydoc	Camera::setLayers
+		 */
+		void setLayers(UINT64 layers) { mInternal->setLayers(layers); }
+
+		/**
+		 * @copydoc	Camera::worldToScreenPoint
+		 */
+		Vector2I worldToScreenPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToScreenPoint(worldPoint); }
+
+		/**
+		 * @copydoc	Camera::worldToClipPoint
+		 */
+		Vector2 worldToClipPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToClipPoint(worldPoint); }
+
+		/**
+		 * @copydoc	Camera::worldToViewPoint
+		 */
+		Vector3 worldToViewPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToViewPoint(worldPoint); }
+
+		/**
+		 * @copydoc	Camera::screenToWorldPoint
+		 */
+		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const { updateView(); return mInternal->screenToWorldPoint(screenPoint, depth); }
+
+		/**
+		 * @copydoc	Camera::screenToViewPoint
+		 */
+		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const { return mInternal->screenToViewPoint(screenPoint, depth); }
+
+		/**
+		 * @copydoc	Camera::screenToClipPoint
+		 */
+		Vector2 screenToClipPoint(const Vector2I& screenPoint) const { return mInternal->screenToClipPoint(screenPoint); }
+
+		/**
+		 * @copydoc	Camera::viewToWorldPoint
+		 */
+		Vector3 viewToWorldPoint(const Vector3& viewPoint) const { updateView(); return mInternal->viewToWorldPoint(viewPoint); }
+
+		/**
+		 * @copydoc	Camera::viewToScreenPoint
+		 */
+		Vector2I viewToScreenPoint(const Vector3& viewPoint) const { return mInternal->viewToScreenPoint(viewPoint); }
+
+		/**
+		 * @copydoc	Camera::viewToClipPoint
+		 */
+		Vector2 viewToClipPoint(const Vector3& viewPoint) const { return mInternal->viewToClipPoint(viewPoint); }
+
+		/**
+		 * @copydoc	Camera::clipToWorldPoint
+		 */
+		Vector3 clipToWorldPoint(const Vector2& clipPoint, float depth = 0.5f) const { updateView(); return mInternal->clipToWorldPoint(clipPoint, depth); }
+
+		/**
+		 * @copydoc	Camera::clipToViewPoint
+		 */
+		Vector3 clipToViewPoint(const Vector2& clipPoint, float depth = 0.5f) const { return mInternal->clipToViewPoint(clipPoint, depth); }
+
+		/**
+		 * @copydoc	Camera::clipToScreenPoint
+		 */
+		Vector2I clipToScreenPoint(const Vector2& clipPoint) const { return mInternal->clipToScreenPoint(clipPoint); }
+
+		/**
+		 * @copydoc	Camera::screenPointToRay
+		 */
+		Ray screenPointToRay(const Vector2I& screenPoint) const { updateView(); return mInternal->screenPointToRay(screenPoint); }
+
+		/**
+		 * @copydoc	Camera::projectPoint
+		 */
+		Vector3 projectPoint(const Vector3& point) const { return mInternal->projectPoint(point); }
+
+		/**
+		 * @copydoc	Camera::unprojectPoint
+		 */
+		Vector3 unprojectPoint(const Vector3& point) const { return mInternal->unprojectPoint(point); }
+
+		/**
+		 * @brief	Returns the internal camera handler that is used for
+		 *			majority of operations by this component.
+		 */
+		CameraPtr _getHandler() const { updateView(); return mInternal; }
+
+    protected:
+		/**
+		 * @brief	Checks if the world transform of the camera changed, and if needed updates
+		 *			the view matrix.
+		 */
+		void updateView() const;
+
+		mutable CameraPtr mInternal;
+
+		// Only valid during construction
+		RenderTargetPtr mTarget;
+		float mLeft;
+		float mTop;
+		float mWidth;
+		float mHeight;
+
+		/************************************************************************/
+		/* 						COMPONENT OVERRIDES                      		*/
+		/************************************************************************/
+	protected:
+		friend class SceneObject;
+
+		/**
+		 * @copydoc	Component::onInitialized
+		 */
+		void onInitialized() override;
+
+		/**
+		 * @copydoc	Component::onDestroyed
+		 */
+		void onDestroyed() override;
+
+	public:
+		/**
+		 * @copydoc	Component::update
+		 */
+		virtual void update() override;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class CCameraRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+
+	protected:
+		CCamera() {} // Serialization only
+     };
+}

+ 38 - 0
BansheeEngine/Include/BsCCameraRTTI.h

@@ -0,0 +1,38 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsCCamera.h"
+#include "BsGameObjectRTTI.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT CCameraRTTI : public RTTIType<CCamera, Component, CCameraRTTI>
+	{
+	private:
+		CameraPtr getInternal(CCamera* obj) { return obj->mInternal; }
+		void setInternal(CCamera* obj, CameraPtr val) { obj->mInternal = val; }
+
+	public:
+		CCameraRTTI()
+		{
+			addReflectablePtrField("mInternal", 0, &CCameraRTTI::getInternal, &CCameraRTTI::setInternal);
+		}
+
+		virtual const String& getRTTIName() override
+		{
+			static String name = "CCamera";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() override
+		{
+			return TID_CCamera;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
+		{
+			return GameObjectRTTI::createGameObject<CCamera>();
+		}
+	};
+}

+ 157 - 0
BansheeEngine/Include/BsCLight.h

@@ -0,0 +1,157 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsLight.h"
+#include "BsComponent.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @copydoc	LightInternal
+	 *
+	 * Wraps Light as a Component
+	 */
+    class BS_EXPORT CLight : public Component
+    {
+    public:
+		CLight(const HSceneObject& parent, LightType type = LightType::Point, Color color = Color::White, 
+			float intensity = 100.0f, float range = 1.0f, bool castsShadows = false, Degree spotAngle = Degree(45), 
+			Degree spotFalloffAngle = Degree(40));
+
+		virtual ~CLight();
+
+	    /**
+		 * @copydoc	LightInternal::getPosition
+	     */
+		Vector3 getPosition() const { return mInternal->getPosition(); }
+
+	    /**
+		 * @copydoc	LightInternal::setPosition
+	     */
+		void setPosition(const Vector3& position) { mInternal->setPosition(position); }
+
+	    /**
+		 * @copydoc	LightInternal::getRotation
+	     */
+		Quaternion getRotation() const { return mInternal->getRotation(); }
+
+	    /**
+		 * @copydoc	LightInternal::setRotation
+	     */
+		void setRotation(const Quaternion& rotation) { mInternal->setRotation(rotation); }
+
+	    /**
+		 * @copydoc	LightInternal::getType
+	     */
+		LightType getType() const { return mInternal->getType(); }
+
+	    /**
+		 * @copydoc	LightInternal::setType
+	     */
+		void setType(LightType type) { mInternal->setType(type); }
+
+	    /**
+		 * @copydoc	LightInternal::getCastsShadow
+	     */
+		bool getCastsShadow() const { return mInternal->getCastsShadow(); }
+
+	    /**
+		 * @copydoc	LightInternal::setCastsShadow
+	     */
+		void setCastsShadow(bool castsShadow) { mInternal->setCastsShadow(castsShadow); }
+
+	    /**
+		 * @copydoc	LightInternal::getColor
+	     */
+		Color getColor() const { return mInternal->getColor(); }
+
+	    /**
+		 * @copydoc	LightInternal::setColor
+	     */
+		void setColor(const Color& color) { mInternal->setColor(color); }
+
+	    /**
+		 * @copydoc	LightInternal::getRange
+	     */
+		float getRange() const { return mInternal->getRange(); }
+
+	    /**
+		 * @copydoc	LightInternal::setRange
+	     */
+		void setRange(float range) { mInternal->setRange(range);; }
+
+	    /**
+		 * @copydoc	LightInternal::getIntensity
+	     */
+		float getIntensity() const { return mInternal->getIntensity(); }
+
+	    /**
+		 * @copydoc	LightInternal::setIntensity
+	     */
+		void setIntensity(float intensity) { mInternal->setIntensity(intensity); }
+
+	    /**
+		 * @copydoc	LightInternal::getSpotAngle
+	     */
+		Degree getSpotAngle() const { return mInternal->getSpotAngle(); }
+
+	    /**
+		 * @copydoc	LightInternal::setSpotAngle
+	     */
+		void setSpotAngle(const Degree& spotAngle) { mInternal->setSpotAngle(spotAngle); }
+
+	    /**
+		 * @copydoc	LightInternal::getBounds
+	     */
+		Sphere getBounds() const;
+
+	    /**
+		 * @brief	Returns the light internals that this component wraps.
+	     */
+		SPtr<Light> _getInternal() const { return mInternal; }
+
+    protected:
+		mutable SPtr<Light> mInternal;
+
+		// Only valid during construction
+		LightType mType;
+		Color mColor;
+		float mIntensity; 
+		float mRange; 
+		bool mCastsShadows; 
+		Degree mSpotAngle; 
+		Degree mSpotFalloffAngle;
+
+		/************************************************************************/
+		/* 						COMPONENT OVERRIDES                      		*/
+		/************************************************************************/
+	protected:
+		friend class SceneObject;
+
+	    /**
+		 * @copydoc	Component::onInitialized
+	     */
+		void onInitialized() override;
+
+	    /**
+		 * @copydoc	Component::onDestroyed
+	     */
+		void onDestroyed() override;
+
+		/**
+		 * @copydoc	Component::update
+		 */
+		virtual void update() override { }
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class CLightRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+
+	protected:
+		CLight() {} // Serialization only
+     };
+}

+ 38 - 0
BansheeEngine/Include/BsCLightRTTI.h

@@ -0,0 +1,38 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsCLight.h"
+#include "BsGameObjectRTTI.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT CLightRTTI : public RTTIType <CLight, Component, CLightRTTI>
+	{
+	private:
+		SPtr<Light> getInternal(CLight* obj) { return obj->mInternal; }
+		void setInternal(CLight* obj, SPtr<Light> val) { obj->mInternal = val; }
+
+	public:
+		CLightRTTI()
+		{
+			addReflectablePtrField("mInternal", 0, &CLightRTTI::getInternal, &CLightRTTI::setInternal);
+		}
+
+		virtual const String& getRTTIName() override
+		{
+			static String name = "CLight";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() override
+		{
+			return TID_CLight;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
+		{
+			return GameObjectRTTI::createGameObject<CLight>();
+		}
+	};
+}

+ 55 - 55
BansheeEngine/Include/BsOverlay.h → BansheeEngine/Include/BsCOverlay.h

@@ -1,56 +1,56 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsCoreThreadAccessor.h"
-#include "BsComponent.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Overlay components are a special type of components that can be attached directly
-	 * 			to a Viewport and used for rendering 2D graphics. Any overlay components will be 
-	 *			rendered after any other scene objects, so these components are usually used for 
-	 *			GUI elements and full screen effects.
-	 */
-	class BS_EXPORT Overlay : public Component
-	{
-	public:
-		virtual ~Overlay();
-
-		/**
-		 * @brief	Called by the renderer when rendering is in progress. Allows the overlay
-		 *			to queue itself for rendering.
-		 */
-		virtual void render(DrawList& drawList) const = 0;
-
-		/**
-		 * @copydoc	Component::update
-		 */
-		virtual void update() {}
-
-		/**
-		 * @brief	Returns the viewport onto which this overlay will be overlaid on.
-		 */
-		Viewport* getTarget() const { return mRenderTarget; }
-
-		/**
-		 * @brief	Depth determines in which order the overlays render in case they overlap.
-		 * 			Smaller depth means the overlay is in front of anything with larger depth.
-		 */
-		INT32 getDepth() const { return mDepth; }
-
-		/**
-		 * @brief	Depth determines in which order the overlays render in case they overlap.
-		 * 			Smaller depth means the overlay is in front of anything with larger depth.
-		 */
-		void setDepth(INT32 depth) { mDepth = depth; }
-
-	protected:
-		friend class SceneObject;
-
-		Viewport* mRenderTarget;
-		INT32 mDepth;
-
-		Overlay(const HSceneObject& parent, Viewport* target);
-	};
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsCoreThreadAccessor.h"
+#include "BsComponent.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Overlay components are a special type of components that can be attached directly
+	 * 			to a Viewport and used for rendering 2D graphics. Any overlay components will be 
+	 *			rendered after any other scene objects, so these components are usually used for 
+	 *			GUI elements and full screen effects.
+	 */
+	class BS_EXPORT COverlay : public Component
+	{
+	public:
+		virtual ~COverlay();
+
+		/**
+		 * @brief	Called by the renderer when rendering is in progress. Allows the overlay
+		 *			to queue itself for rendering.
+		 */
+		virtual void render(DrawList& drawList) const = 0;
+
+		/**
+		 * @copydoc	Component::update
+		 */
+		virtual void update() override {}
+
+		/**
+		 * @brief	Returns the viewport onto which this overlay will be overlaid on.
+		 */
+		Viewport* getTarget() const { return mRenderTarget; }
+
+		/**
+		 * @brief	Depth determines in which order the overlays render in case they overlap.
+		 * 			Smaller depth means the overlay is in front of anything with larger depth.
+		 */
+		INT32 getDepth() const { return mDepth; }
+
+		/**
+		 * @brief	Depth determines in which order the overlays render in case they overlap.
+		 * 			Smaller depth means the overlay is in front of anything with larger depth.
+		 */
+		void setDepth(INT32 depth) { mDepth = depth; }
+
+	protected:
+		friend class SceneObject;
+
+		Viewport* mRenderTarget;
+		INT32 mDepth;
+
+		COverlay(const HSceneObject& parent, Viewport* target);
+	};
 }

+ 108 - 0
BansheeEngine/Include/BsCRenderable.h

@@ -0,0 +1,108 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsRenderable.h"
+#include "BsBounds.h"
+#include "BsComponent.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @copydoc	Renderable
+	 * 			
+	 * Wraps a Renderable as a Component.
+	 */
+	class BS_EXPORT CRenderable : public Component
+	{
+	public:
+		/**
+		 * @copydoc	Renderable::setMesh
+		 */
+		void setMesh(HMesh mesh) { mInternal->setMesh(mesh); }
+
+		/**
+		 * @copydoc	Renderable::setMaterial
+		 */
+		void setMaterial(UINT32 idx, HMaterial material) { mInternal->setMaterial(idx, material); }
+
+		/**
+		 * @copydoc	Renderable::setMaterial
+		 */
+		void setMaterial(HMaterial material) { mInternal->setMaterial(material); }
+
+		/**
+		 * @copydoc	Renderable::setLayer
+		 */
+		void setLayer(UINT64 layer) { mInternal->setLayer(layer); }
+
+		/**
+		 * @copydoc	Renderable::getLayer
+		 */
+		UINT64 getLayer() const { return mInternal->getLayer(); }
+
+		/**
+		 * @copydoc	Renderable::getMesh
+		 */
+		HMesh getMesh() const { return mInternal->getMesh(); }
+
+		/**
+		 * @copydoc	Renderable::getMaterial
+		 */
+		HMaterial getMaterial(UINT32 idx) const { return mInternal->getMaterial(idx); }
+
+		/**
+		 * @brief	Gets world bounds of the mesh rendered by this object.
+		 */
+		Bounds getBounds() const;
+
+		/**
+		 * @brief	Returns the internal renderable handler that is used for
+		 *			majority of operations by this component.
+		 */
+		RenderablePtr _getHandler() const { return mInternal; }
+
+	private:
+		/**
+		 * @brief	Updates the world transform if the SceneObject transform changed.
+		 */
+		void updateTransform() const;
+
+		mutable RenderablePtr mInternal;
+
+		/************************************************************************/
+		/* 							COMPONENT OVERRIDES                    		*/
+		/************************************************************************/
+
+	protected:
+		friend class SceneObject;
+
+		CRenderable(const HSceneObject& parent);
+
+		/**
+		 * @copydoc	Component::onInitialized
+		 */
+		void onInitialized() override;
+
+		/**
+		 * @copydoc	Component::onDestroyed
+		 */
+		void onDestroyed() override;
+
+	public:
+		/**
+		 * @copydoc	Component::update
+		 */
+		virtual void update() override;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class CRenderableRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+
+	protected:
+		CRenderable() {} // Serialization only
+	};
+}

+ 38 - 0
BansheeEngine/Include/BsCRenderableRTTI.h

@@ -0,0 +1,38 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsCRenderable.h"
+#include "BsGameObjectRTTI.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT CRenderableRTTI : public RTTIType<CRenderable, Component, CRenderableRTTI>
+	{
+	private:
+		RenderablePtr getInternal(CRenderable* obj) { return obj->mInternal; }
+		void setInternal(CRenderable* obj, RenderablePtr val) { obj->mInternal = val; }
+
+	public:
+		CRenderableRTTI()
+		{
+			addReflectablePtrField("mInternal", 0, &CRenderableRTTI::getInternal, &CRenderableRTTI::setInternal);
+		}
+
+		virtual const String& getRTTIName() override
+		{
+			static String name = "CRenderable";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() override
+		{
+			return TID_CRenderable;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
+		{
+			return GameObjectRTTI::createGameObject<CRenderable>();
+		}
+	};
+}

+ 443 - 145
BansheeEngine/Include/BsCamera.h

@@ -1,318 +1,619 @@
 #pragma once
 
 #include "BsPrerequisites.h"
-#include "BsCameraHandler.h"
-#include "BsComponent.h"
-#include "BsViewport.h"
+#include "BsIReflectable.h"
+#include "BsMatrix4.h"
+#include "BsVector3.h"
+#include "BsVector2.h"
+#include "BsVector2I.h"
+#include "BsAABox.h"
+#include "BsQuaternion.h"
+#include "BsRay.h"
+#include "BsCoreObject.h"
+#include "BsConvexVolume.h"
 
 namespace BansheeEngine 
 {
 	/**
-	 * @copydoc	CameraHandler
+	 * @brief	Specified projection type to use by the camera.
 	 */
-    class BS_EXPORT Camera : public Component
+    enum ProjectionType
+    {
+        PT_ORTHOGRAPHIC,
+        PT_PERSPECTIVE
+    };
+
+	/**
+	 * @brief	Clip planes that form the camera frustum (visible area).
+	 */
+    enum FrustumPlane
+    {
+        FRUSTUM_PLANE_NEAR = 0,
+        FRUSTUM_PLANE_FAR = 1,
+        FRUSTUM_PLANE_LEFT = 2,
+        FRUSTUM_PLANE_RIGHT = 3,
+        FRUSTUM_PLANE_TOP = 4,
+        FRUSTUM_PLANE_BOTTOM = 5
+    };
+
+	/**
+	 * @brief	Camera determines how is world geometry projected onto a 2D surface. You may
+	 *			position and orient it in space, set options like aspect ratio and field or view
+	 *			and it outputs view and projection matrices required for rendering.
+	 */
+	class BS_EXPORT CameraBase
     {
     public:
-		Camera(const HSceneObject& parent, RenderTargetPtr target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
+		virtual ~CameraBase() { }
 
-        virtual ~Camera();
+		/**
+		 * @brief	Sets the camera horizontal field of view. This determines how wide the camera
+		 *			viewing angle is along the horizontal axis. Vertical FOV is calculated from the
+		 *			horizontal FOV and the aspect.
+		 */
+        virtual void setHorzFOV(const Radian& fovy);
 
 		/**
-		 * @copydoc	CameraHandler::getViewport
+		 * @brief	Retrieves the camera horizontal field of view.
 		 */
-		ViewportPtr getViewport() const { return mInternal->getViewport(); }
+        virtual const Radian& getHorzFOV() const;
 
 		/**
-		 * @copydoc	CameraHandler::setHorzFOV
+		 * @brief	Sets the distance from the frustum to the near clipping plane. Anything
+		 *			closer than the near clipping plane will not be rendered. Decreasing this value
+		 *			decreases depth buffer precision.
 		 */
-		virtual void setHorzFOV(const Radian& fovy) { mInternal->setHorzFOV(fovy); }
+        virtual void setNearClipDistance(float nearDist);
 
 		/**
-		 * @copydoc	CameraHandler::getHorzFOV
+		 * @brief	Retrieves the distance from the frustum to the near clipping plane. Anything
+		 *			closer than the near clipping plane will not be rendered. Decreasing this value
+		 *			decreases depth buffer precision.
 		 */
-		virtual const Radian& getHorzFOV() const { return mInternal->getHorzFOV(); }
+        virtual float getNearClipDistance() const;
 
 		/**
-		 * @copydoc	CameraHandler::setNearClipDistance
+		 * @brief	Sets the distance from the frustum to the far clipping plane. Anything
+		 *			farther than the far clipping plane will not be rendered. Increasing this value
+		 *			decreases depth buffer precision.
 		 */
-		virtual void setNearClipDistance(float nearDist) { mInternal->setNearClipDistance(nearDist); }
+        virtual void setFarClipDistance(float farDist);
 
 		/**
-		 * @copydoc	CameraHandler::getNearClipDistance
+		 * @brief	Retrieves the distance from the frustum to the far clipping plane. Anything
+		 *			farther than the far clipping plane will not be rendered. Increasing this value
+		 *			decreases depth buffer precision.
 		 */
-		virtual float getNearClipDistance() const { return mInternal->getNearClipDistance(); }
+        virtual float getFarClipDistance() const;
 
 		/**
-		 * @copydoc	CameraHandler::setFarClipDistance
+		 * @brief	Sets the current viewport aspect ratio (width / height).
 		 */
-		virtual void setFarClipDistance(float farDist) { mInternal->setFarClipDistance(farDist); }
+        virtual void setAspectRatio(float ratio);
 
 		/**
-		 * @copydoc	CameraHandler::getFarClipDistance
+		 * @brief	Returns current viewport aspect ratio (width / height).
 		 */
-		virtual float getFarClipDistance() const { return mInternal->getFarClipDistance(); }
+        virtual float getAspectRatio() const;
 
 		/**
-		 * @copydoc	CameraHandler::setAspectRatio
+		 * @brief	Sets camera world space position.
 		 */
-		virtual void setAspectRatio(float ratio) { mInternal->setAspectRatio(ratio); }
+		virtual void setPosition(const Vector3& position);
 
 		/**
-		 * @copydoc	CameraHandler::getAspectRatio
+		 * @brief	Retrieves camera world space position.
 		 */
-		virtual float getAspectRatio() const { return mInternal->getAspectRatio(); }
+		virtual Vector3 getPosition() const { return mPosition; }
 
 		/**
-		 * @copydoc	CameraHandler::setFrustumExtents
+		 * @brief	Gets the Z (forward) axis of the object, in world space.
+		 *
+		 * @return	Forward axis of the object.
 		 */
-		virtual void setFrustumExtents(float left, float right, float top, float bottom)
-		{
-			mInternal->setFrustumExtents(left, right, top, bottom);
-		}
+		Vector3 getForward() const { return getRotation().rotate(-Vector3::UNIT_Z); }
 
 		/**
-		 * @copydoc	CameraHandler::resetFrustumExtents
+		 * @brief	Sets camera world space rotation.
 		 */
-		virtual void resetFrustumExtents() { mInternal->resetFrustumExtents(); }
+		virtual void setRotation(const Quaternion& rotation);
 
 		/**
-		 * @copydoc	CameraHandler::getFrustumExtents
+		 * @brief	Retrieves camera world space rotation.
 		 */
-		virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const
-		{
-			mInternal->getFrustumExtents(outleft, outright, outtop, outbottom);
-		}
+		virtual Quaternion getRotation() const { return mRotation; }
+
+		/** @brief	Manually set the extents of the frustum that will be used when calculating the
+		 *			projection matrix. This will prevents extents for being automatically calculated
+		 *			from aspect and near plane so it is up to the caller to keep these values
+		 *			accurate.
+		 *
+		 *	@param left		The position where the left clip plane intersect the near clip plane, in view space.
+		 *  @param right	The position where the right clip plane intersect the near clip plane, in view space.
+		 *  @param top		The position where the top clip plane intersect the near clip plane, in view space.
+		 *  @param bottom	The position where the bottom clip plane intersect the near clip plane, in view space.
+		*/
+		virtual void setFrustumExtents(float left, float right, float top, float bottom);
+
+		/** 
+		 * @brief	Resets frustum extents so they are automatically derived from other values.
+		 *			This is only relevant if you have previously set custom extents.
+		 */
+		virtual void resetFrustumExtents(); 
+
+		/** 
+		 * @brief	Returns the extents of the frustum in view space at the near plane.
+		 */
+		virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const;
+
+		/** 
+		 * @brief	Returns the standard projection matrix that determines how are 3D points
+		 *			projected to two dimensions. The layout of this matrix depends on currently
+		 *			used render system.
+		 *
+		 * @note	You should use this matrix when sending the matrix to the render system to remain
+		 *			everything works consistently when other render systems are used.
+		 */
+        virtual const Matrix4& getProjectionMatrixRS() const;
+
+		/** 
+		 * @brief	Returns the inverse of the render-system specific projection matrix.
+		 *
+		 * @see		getProjectionMatrixRS
+		 */
+        virtual const Matrix4& getProjectionMatrixRSInv() const;
+
+		/** 
+		 * @brief	Returns the standard projection matrix that determines how are 3D points
+		 *			projected to two dimensions. Returned matrix is standard following right-hand
+		 *			rules and depth range of [-1, 1]. 
+		 *
+		 * @note	Different render systems will expect different projection matrix layouts, in which
+		 *			case use getProjectionMatrixRS.
+         */
+        virtual const Matrix4& getProjectionMatrix() const;
+
+		/** 
+		 * @brief	Returns the inverse of the projection matrix.
+		 *
+		 * @see		getProjectionMatrix
+		 */
+        virtual const Matrix4& getProjectionMatrixInv() const;
+
+		/** 
+		 * @brief	Gets the camera view matrix. Used for positioning/orienting the camera.
+         */
+        virtual const Matrix4& getViewMatrix() const;
+
+		/** 
+		 * @brief	Returns the inverse of the view matrix.
+		 *
+		 * @see		getViewMatrix
+		 */
+		virtual const Matrix4& getViewMatrixInv() const;
+
+		/** 
+		 * @brief	Sets whether the camera should use the custom view matrix.
+		 *			When this is enabled camera will no longer calculate its view matrix
+		 *			based on position/orientation and caller will be resonsible to keep 
+		 *			the view matrix up to date.
+         */
+		virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY);
+
+		/** 
+		 * @brief	Returns true if a custom view matrix is used.
+         */
+		virtual bool isCustomViewMatrixEnabled() const { return mCustomViewMatrix; }
+		
+		/** 
+		 * @brief	Sets whether the camera should use the custom projection matrix.
+		 *			When this is enabled camera will no longer calculate its projection matrix
+		 *			based on field of view, aspect and other parameters and caller will be
+		 *			resonsible to keep the projection matrix up to date.
+         */
+		virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY);
+
+		/** 
+		 * @brief	Returns true if a custom projection matrix is used.
+         */
+		virtual bool isCustomProjectionMatrixEnabled() const { return mCustomProjMatrix; }
+
+		/** 
+		 * @brief	Returns a convex volume representing the visible area of the camera,
+		 *			in local space.
+         */
+        virtual const ConvexVolume& getFrustum() const;
+
+		/** 
+		 * @brief	Returns a convex volume representing the visible area of the camera,
+		 *			in world space.
+         */
+        virtual ConvexVolume getWorldFrustum() const;
 
 		/**
-		 * @copydoc	CameraHandler::getProjectionMatrixRS
+		 * @brief	Returns the bounding of the frustum.
 		 */
-		virtual const Matrix4& getProjectionMatrixRS() const { return mInternal->getProjectionMatrixRS(); }
+        const AABox& getBoundingBox() const;
 
 		/**
-		 * @copydoc	CameraHandler::getProjectionMatrix
+		 * @brief	Sets the type of projection used by the camera.
 		 */
-		virtual const Matrix4& getProjectionMatrix() const { return mInternal->getProjectionMatrix(); }
+        virtual void setProjectionType(ProjectionType pt);
 
 		/**
-		 * @copydoc	CameraHandler::getViewMatrix
+		 * @brief	Returns the type of projection used by the camera.
 		 */
-		virtual const Matrix4& getViewMatrix() const { updateView(); return mInternal->getViewMatrix(); }
+        virtual ProjectionType getProjectionType() const;
 
 		/**
-		 * @copydoc	CameraHandler::setCustomViewMatrix
+		 * @brief	Sets the orthographic window height, for use with orthographic rendering only. 
+		 *
+		 * @param	w	Width of the window in world units.
+		 * @param	h	Height of the window in world units.
+		 *
+		 * @note	Calling this method will recalculate the aspect ratio, use setOrthoWindowHeight or 
+		 *			setOrthoWindowWidth alone if you wish to preserve the aspect ratio but just fit one 
+		 *			or other dimension to a particular size.
 		 */
-		virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY)
-		{
-			mInternal->setCustomViewMatrix(enable, viewMatrix);
-		}
+		virtual void setOrthoWindow(float w, float h);
 
 		/**
-		 * @copydoc	CameraHandler::isCustomViewMatrixEnabled
+		 * @brief	Sets the orthographic window height, for use with orthographic rendering only. 
+		 *
+		 * @param	h	Height of the window in world units.
+		 *
+		 * @note	The width of the window will be calculated from the aspect ratio. 
 		 */
-		virtual bool isCustomViewMatrixEnabled() const { return mInternal->isCustomViewMatrixEnabled(); }
-		
+		virtual void setOrthoWindowHeight(float h);
+
 		/**
-		 * @copydoc	CameraHandler::setCustomProjectionMatrix
+		 * @brief	Sets the orthographic window width, for use with orthographic rendering only. 
+		 *
+		 * @param	w	Width of the window in world units.
+		 *
+		 * @note	The height of the window will be calculated from the aspect ratio. 
 		 */
-		virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY)
-		{
-			mInternal->setCustomProjectionMatrix(enable, projectionMatrix);
-		}
+		virtual void setOrthoWindowWidth(float w);
 
 		/**
-		 * @copydoc	CameraHandler::isCustomProjectionMatrixEnabled
+		 * @brief	Gets the orthographic window width in world units, for use with orthographic rendering only. 
 		 */
-		virtual bool isCustomProjectionMatrixEnabled() const { return mInternal->isCustomProjectionMatrixEnabled(); }
+		virtual float getOrthoWindowHeight() const;
 
 		/**
-		 * @copydoc	CameraHandler::getFrustum
+		 * @brief	Gets the orthographic window width in world units, for use with orthographic rendering only. 
+		 *
+		 * @note	This is calculated from the orthographic height and the aspect ratio.
 		 */
-		virtual const ConvexVolume& getFrustum() const { return mInternal->getFrustum(); }
+		virtual float getOrthoWindowWidth() const;
 
 		/**
-		 * @copydoc	CameraHandler::getWorldFrustum
+		 * @brief	Gets a priority that determines in which orders the cameras are rendered.
+		 *			This only applies to cameras rendering to the same render target. 
 		 */
-        virtual ConvexVolume getWorldFrustum() const;
+		INT32 getPriority() const { return mPriority; }
 
 		/**
-		 * @copydoc	CameraHandler::getBoundingBox
+		 * @brief	Sets a priority that determines in which orders the cameras are rendered.
+		 * 			This only applies to cameras rendering to the same render target. 
+		 *
+		 * @param	priority	The priority. Higher value means the camera will be rendered sooner.
 		 */
-		const AABox& getBoundingBox() const { return mInternal->getBoundingBox(); }
+		void setPriority(INT32 priority) { mPriority = priority; _markCoreDirty(); }
 
 		/**
-		 * @copydoc	CameraHandler::setProjectionType
+		 * @brief	Retrieves layer bitfield that is used when determining which object should the camera render.
 		 */
-		virtual void setProjectionType(ProjectionType pt) { mInternal->setProjectionType(pt); }
+		UINT64 getLayers() const { return mLayers; }
 
 		/**
-		 * @copydoc	CameraHandler::getProjectionType
+		 * @brief	Sets layer bitfield that is used when determining which object should the camera render.
 		 */
-		virtual ProjectionType getProjectionType() const { return mInternal->getProjectionType(); }
+		void setLayers(UINT64 layers) { mLayers = layers; _markCoreDirty(); }
 
 		/**
-		 * @copydoc	CameraHandler::setOrthoWindow
+		 * @brief	Converts a point in world space to screen coordinates (in pixels
+		 *			corresponding to the render target attached to the camera).
 		 */
-		virtual void setOrthoWindow(float w, float h) { mInternal->setOrthoWindow(w, h); }
+		Vector2I worldToScreenPoint(const Vector3& worldPoint) const;
 
 		/**
-		 * @copydoc	CameraHandler::setOrthoWindowHeight
+		 * @brief	Converts a point in world space to normalized clip coordinates 
+		 *			(in [0, 1] range).
 		 */
-		virtual void setOrthoWindowHeight(float h) { mInternal->setOrthoWindowHeight(h); }
+		Vector2 worldToClipPoint(const Vector3& worldPoint) const;
 
 		/**
-		 * @copydoc	CameraHandler::setOrthoWindowWidth
+		 * @brief	Converts a point in world space to point relative to camera's
+		 *			coordinate system (view space).
 		 */
-		virtual void setOrthoWindowWidth(float w) { mInternal->setOrthoWindowWidth(w); }
+		Vector3 worldToViewPoint(const Vector3& worldPoint) const;
 
 		/**
-		 * @copydoc	CameraHandler::getOrthoWindowHeight
+		 * @brief	Converts a point in screen space (pixels corresponding to
+		 *			render target attached to the camera) to a point in world space.
+		 *
+		 * @param	screenPoint	Point to transform.
+		 * @param	depth		Depth to place the world point at. The depth is applied
+		 *						to the vector going from camera origin to the point on
+		 *						the near plane.
 		 */
-		virtual float getOrthoWindowHeight() const { return mInternal->getOrthoWindowHeight(); }
+		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
 
 		/**
-		 * @copydoc	CameraHandler::getOrthoWindowWidth
+		 * @brief	Converts a point in screen space (pixels corresponding to
+		 *			render target attached to the camera) to a point relative to
+		 *			camera's coordinate system (view space).
+		 *
+		 * @param	screenPoint	Point to transform.
+		 * @param	depth		Depth to place the world point at. The depth is applied
+		 *						to the vector going from camera origin to the point on
+		 *						the near plane.
 		 */
-		virtual float getOrthoWindowWidth() const { return mInternal->getOrthoWindowWidth(); }
+		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
 
 		/**
-		 * @copydoc	CameraHandler::getPriority
+		 * @brief	Converts a point in screen space (pixels corresponding to
+		 *			render target attached to the camera) to normalized clip 
+		 *			coordinates (in [0, 1] range).
 		 */
-		INT32 getPriority() const { return mInternal->getPriority(); }
+		Vector2 screenToClipPoint(const Vector2I& screenPoint) const;
 
 		/**
-		 * @copydoc	CameraHandler::setPriority
+		 * @brief	Converts a point relative to camera's coordinate system (view space)
+		 *			into a point in world space.
 		 */
-		void setPriority(INT32 priority) { mInternal->setPriority(priority); }
+		Vector3 viewToWorldPoint(const Vector3& viewPoint) const;
 
 		/**
-		 * @copydoc	CameraHandler::getLayers
+		 * @brief	Converts a point relative to camera's coordinate system (view space)
+		 *			into a point in screen space (pixels corresponding to render target 
+		 *			attached to the camera.
 		 */
-		UINT64 getLayers() const { return mInternal->getLayers(); }
+		Vector2I viewToScreenPoint(const Vector3& viewPoint) const;
 
 		/**
-		 * @copydoc	CameraHandler::setLayers
+		 * @brief	Converts a point relative to camera's coordinate system (view space)
+		 *			into normalized clip coordinates (in [0, 1] range).
 		 */
-		void setLayers(UINT64 layers) { mInternal->setLayers(layers); }
+		Vector2 viewToClipPoint(const Vector3& viewPoint) const;
 
 		/**
-		 * @copydoc	CameraHandler::worldToScreenPoint
+		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
+		 *			a point in world space.
+		 *
+		 * @param	clipPoint	Point to transform.
+		 * @param	depth		Depth to place the world point at. The depth is applied
+		 *						to the vector going from camera origin to the point on
+		 *						the near plane.
 		 */
-		Vector2I worldToScreenPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToScreenPoint(worldPoint); }
+		Vector3 clipToWorldPoint(const Vector2& clipPoint, float depth = 0.5f) const;
 
 		/**
-		 * @copydoc	CameraHandler::worldToClipPoint
+		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
+		 *			a point relative to camera's coordinate system (view space).
+		 *
+		 * @param	clipPoint	Point to transform.
+		 * @param	depth		Depth to place the world point at. The depth is applied
+		 *						to the vector going from camera origin to the point on
+		 *						the near plane.
 		 */
-		Vector2 worldToClipPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToClipPoint(worldPoint); }
+		Vector3 clipToViewPoint(const Vector2& clipPoint, float depth = 0.5f) const;
 
 		/**
-		 * @copydoc	CameraHandler::worldToViewPoint
+		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
+		 *			a point in screen space (pixels corresponding to render target attached 
+		 *			to the camera)
 		 */
-		Vector3 worldToViewPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToViewPoint(worldPoint); }
+		Vector2I clipToScreenPoint(const Vector2& clipPoint) const;
 
 		/**
-		 * @copydoc	CameraHandler::screenToWorldPoint
+		 * @brief	Converts a point in screen space (pixels corresponding to
+		 *			render target attached to the camera) to a ray in world space
+		 *			originating at the selected point on the camera near plane.
 		 */
-		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const { updateView(); return mInternal->screenToWorldPoint(screenPoint, depth); }
+		Ray screenPointToRay(const Vector2I& screenPoint) const;
+
+		/**
+		 * @brief	Projects a point from view to clip space.
+		 */
+		Vector3 projectPoint(const Vector3& point) const;
+
+		/**
+		 * @brief	Un-projects a point in clip space to view space.
+		 */
+		Vector3 unprojectPoint(const Vector3& point) const;
+
+        static const float INFINITE_FAR_PLANE_ADJUST; /**< Small constant used to reduce far plane projection to avoid inaccuracies. */
+
+	protected:
+		CameraBase(RenderTargetPtr target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
 
 		/**
-		 * @copydoc	CameraHandler::screenToViewPoint
+		 * @brief	Calculate projection parameters that are used when constructing the projection matrix.
 		 */
-		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const { return mInternal->screenToViewPoint(screenPoint, depth); }
+		virtual void calcProjectionParameters(float& left, float& right, float& bottom, float& top) const;
 
 		/**
-		 * @copydoc	CameraHandler::screenToClipPoint
+		 * @brief	Recalculate frustum if dirty.
 		 */
-		Vector2 screenToClipPoint(const Vector2I& screenPoint) const { return mInternal->screenToClipPoint(screenPoint); }
+		virtual void updateFrustum() const;
 
 		/**
-		 * @copydoc	CameraHandler::viewToWorldPoint
+		 * @brief	Recalculate frustum planes if dirty.
 		 */
-		Vector3 viewToWorldPoint(const Vector3& viewPoint) const { updateView(); return mInternal->viewToWorldPoint(viewPoint); }
+		virtual void updateFrustumPlanes() const;
 
 		/**
-		 * @copydoc	CameraHandler::viewToScreenPoint
+		 * @brief	Update view matrix from parent position/orientation.
+		 *
+		 * @note	Does nothing when custom view matrix is set.
 		 */
-		Vector2I viewToScreenPoint(const Vector3& viewPoint) const { return mInternal->viewToScreenPoint(viewPoint); }
+		virtual void updateView() const;
 
 		/**
-		 * @copydoc	CameraHandler::viewToClipPoint
+		 * @brief	Checks if the frustum requires updating.
 		 */
-		Vector2 viewToClipPoint(const Vector3& viewPoint) const { return mInternal->viewToClipPoint(viewPoint); }
+		virtual bool isFrustumOutOfDate() const;
 
 		/**
-		 * @copydoc	CameraHandler::clipToWorldPoint
+		 * @brief	Notify camera that the frustum requires to be updated.
 		 */
-		Vector3 clipToWorldPoint(const Vector2& clipPoint, float depth = 0.5f) const { updateView(); return mInternal->clipToWorldPoint(clipPoint, depth); }
+		virtual void invalidateFrustum() const;
 
 		/**
-		 * @copydoc	CameraHandler::clipToViewPoint
+		 * @brief	Returns a rectangle that defines the viewport position and size, in pixels.
 		 */
-		Vector3 clipToViewPoint(const Vector2& clipPoint, float depth = 0.5f) const { return mInternal->clipToViewPoint(clipPoint, depth); }
+		virtual Rect2I getViewportRect() const = 0;
 
 		/**
-		 * @copydoc	CameraHandler::clipToScreenPoint
+		 * @copydoc	CoreObject::markCoreDirty
 		 */
-		Vector2I clipToScreenPoint(const Vector2& clipPoint) const { return mInternal->clipToScreenPoint(clipPoint); }
+		virtual void _markCoreDirty() { }
+
+    protected:
+		UINT64 mLayers; /**< Bitfield that can be used for filtering what objects the camera sees. */
+
+		Vector3 mPosition; /**< World space position. */
+		Quaternion mRotation; /**< World space rotation. */
+
+		ProjectionType mProjType; /**< Type of camera projection. */
+		Radian mHorzFOV; /**< Horizontal field of view represents how wide is the camera angle. */
+		float mFarDist; /**< Clip any objects further than this. Larger value decreases depth precision at smaller depths. */
+		float mNearDist; /**< Clip any objects close than this. Smaller value decreases depth precision at larger depths. */
+		float mAspect; /**< Width/height viewport ratio. */
+		float mOrthoHeight; /**< Height in world units used for orthographic cameras. */
+		INT32 mPriority; /**< Determines in what order will the camera be rendered. Higher priority means the camera will be rendered sooner. */
+
+		bool mCustomViewMatrix; /**< Is custom view matrix set. */
+		bool mCustomProjMatrix; /**< Is custom projection matrix set. */
+
+		bool mFrustumExtentsManuallySet; /**< Are frustum extents manually set. */
+
+		mutable Matrix4 mProjMatrixRS; /**< Cached render-system specific projection matrix. */
+		mutable Matrix4 mProjMatrix; /**< Cached projection matrix that determines how are 3D points projected to a 2D viewport. */
+		mutable Matrix4 mViewMatrix; /**< Cached view matrix that determines camera position/orientation. */
+		mutable Matrix4 mProjMatrixRSInv;
+		mutable Matrix4 mProjMatrixInv;
+		mutable Matrix4 mViewMatrixInv;
+
+		mutable ConvexVolume mFrustum; /**< Main clipping planes describing cameras visible area. */
+		mutable bool mRecalcFrustum; /**< Should frustum be recalculated. */
+		mutable bool mRecalcFrustumPlanes; /**< Should frustum planes be recalculated. */
+		mutable bool mRecalcView; /**< Should view matrix be recalculated. */
+		mutable float mLeft, mRight, mTop, mBottom; /**< Frustum extents. */
+		mutable AABox mBoundingBox; /**< Frustum bounding box. */
+     };
+
+	/**
+	 * @copydoc	CameraBase
+	 */
+	class BS_EXPORT CameraCore : public CoreObjectCore, public CameraBase
+	{
+	public:
+		~CameraCore();
+
+		/**
+		 * @brief	Returns the viewport used by the camera.
+		 */	
+		SPtr<ViewportCore> getViewport() const { return mViewport; }
+
+	protected:
+		friend class Camera;
+
+		CameraCore(SPtr<RenderTargetCore> target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
+
+		CameraCore(const SPtr<ViewportCore>& viewport);
 
 		/**
-		 * @copydoc	CameraHandler::screenPointToRay
+		 * @copydoc	CoreObjectCore::initialize
 		 */
-		Ray screenPointToRay(const Vector2I& screenPoint) const { updateView(); return mInternal->screenPointToRay(screenPoint); }
+		void initialize() override;
 
 		/**
-		 * @copydoc	CameraHandler::projectPoint
+		 * @copydoc	CameraBase
 		 */
-		Vector3 projectPoint(const Vector3& point) const { return mInternal->projectPoint(point); }
+		virtual Rect2I getViewportRect() const override;
 
 		/**
-		 * @copydoc	CameraHandler::unprojectPoint
+		 * @copydoc	CoreObject::syncToCore
 		 */
-		Vector3 unprojectPoint(const Vector3& point) const { return mInternal->unprojectPoint(point); }
+		void syncToCore(const CoreSyncData& data) override;
 
+		SPtr<ViewportCore> mViewport;
+	};
+
+	/**
+	 * @copydoc	CameraBase
+	 */
+	class BS_EXPORT Camera : public IReflectable, public CoreObject, public CameraBase
+    {
+    public:
 		/**
-		 * @brief	Returns the internal camera handler that is used for
-		 *			majority of operations by this component.
+		 * @brief	Returns the viewport used by the camera.
+		 */	
+		ViewportPtr getViewport() const { return mViewport; }
+
+		/**
+		 * @brief	Retrieves an implementation of a camera handler usable only from the
+		 *			core thread.
 		 */
-		CameraHandlerPtr _getHandler() const { updateView(); return mInternal; }
+		SPtr<CameraCore> getCore() const;
 
-    protected:
 		/**
-		 * @brief	Checks if the world transform of the camera changed, and if needed updates
-		 *			the view matrix.
+	     * @brief	Returns the hash value that can be used to identify if the internal data needs an update.
 		 */
-		void updateView() const;
+		UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
 
-		mutable CameraHandlerPtr mInternal;
+		/**
+	     * @brief	Sets the hash value that can be used to identify if the internal data needs an update.
+		 */
+		void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
 
-		// Only valid during construction
-		RenderTargetPtr mTarget;
-		float mLeft;
-		float mTop;
-		float mWidth;
-		float mHeight;
+		/**
+		 * @brief	Creates a new camera that renders to the specified portion of the provided render target.
+		 */
+		static CameraPtr create(RenderTargetPtr target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
 
-		/************************************************************************/
-		/* 						COMPONENT OVERRIDES                      		*/
-		/************************************************************************/
 	protected:
-		friend class SceneObject;
+		Camera(RenderTargetPtr target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
 
 		/**
-		 * @copydoc	Component::onInitialized
+		 * @copydoc	CameraBase
 		 */
-		void onInitialized() override;
+		virtual Rect2I getViewportRect() const override;
 
 		/**
-		 * @copydoc	Component::onDestroyed
+		 * @copydoc	CoreObject::createCore
 		 */
-		void onDestroyed() override;
+		SPtr<CoreObjectCore> createCore() const override;
 
-	public:
 		/**
-		 * @copydoc	Component::update
+		 * @copydoc	CoreObject::markCoreDirty
 		 */
-		virtual void update() override;
+		void _markCoreDirty() override;
+
+		/**
+		 * @copydoc	CoreObject::syncToCore
+		 */
+		CoreSyncData syncToCore(FrameAlloc* allocator) override;
+
+		/**
+		 * @copydoc	CoreObject::getCoreDependencies
+		 */
+		void getCoreDependencies(Vector<SPtr<CoreObject>>& dependencies) override;
+
+		/**
+		 * @brief	Creates a new camera without initializing it.
+		 */
+		static CameraPtr createEmpty();
+
+		ViewportPtr mViewport; /**< Viewport that describes 2D rendering surface. */
+		UINT32 mLastUpdateHash;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -321,8 +622,5 @@ namespace BansheeEngine
 		friend class CameraRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		virtual RTTITypeBase* getRTTI() const override;
-
-	protected:
-		Camera() {} // Serialization only
      };
 }

+ 0 - 626
BansheeEngine/Include/BsCameraHandler.h

@@ -1,626 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsIReflectable.h"
-#include "BsMatrix4.h"
-#include "BsVector3.h"
-#include "BsVector2.h"
-#include "BsVector2I.h"
-#include "BsAABox.h"
-#include "BsQuaternion.h"
-#include "BsRay.h"
-#include "BsCoreObject.h"
-#include "BsConvexVolume.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Specified projection type to use by the camera.
-	 */
-    enum ProjectionType
-    {
-        PT_ORTHOGRAPHIC,
-        PT_PERSPECTIVE
-    };
-
-	/**
-	 * @brief	Clip planes that form the camera frustum (visible area).
-	 */
-    enum FrustumPlane
-    {
-        FRUSTUM_PLANE_NEAR = 0,
-        FRUSTUM_PLANE_FAR = 1,
-        FRUSTUM_PLANE_LEFT = 2,
-        FRUSTUM_PLANE_RIGHT = 3,
-        FRUSTUM_PLANE_TOP = 4,
-        FRUSTUM_PLANE_BOTTOM = 5
-    };
-
-	/**
-	 * @brief	Camera determines how is world geometry projected onto a 2D surface. You may
-	 *			position and orient it in space, set options like aspect ratio and field or view
-	 *			and it outputs view and projection matrices required for rendering.
-	 */
-	class BS_EXPORT CameraHandlerBase
-    {
-    public:
-		virtual ~CameraHandlerBase() { }
-
-		/**
-		 * @brief	Sets the camera horizontal field of view. This determines how wide the camera
-		 *			viewing angle is along the horizontal axis. Vertical FOV is calculated from the
-		 *			horizontal FOV and the aspect.
-		 */
-        virtual void setHorzFOV(const Radian& fovy);
-
-		/**
-		 * @brief	Retrieves the camera horizontal field of view.
-		 */
-        virtual const Radian& getHorzFOV() const;
-
-		/**
-		 * @brief	Sets the distance from the frustum to the near clipping plane. Anything
-		 *			closer than the near clipping plane will not be rendered. Decreasing this value
-		 *			decreases depth buffer precision.
-		 */
-        virtual void setNearClipDistance(float nearDist);
-
-		/**
-		 * @brief	Retrieves the distance from the frustum to the near clipping plane. Anything
-		 *			closer than the near clipping plane will not be rendered. Decreasing this value
-		 *			decreases depth buffer precision.
-		 */
-        virtual float getNearClipDistance() const;
-
-		/**
-		 * @brief	Sets the distance from the frustum to the far clipping plane. Anything
-		 *			farther than the far clipping plane will not be rendered. Increasing this value
-		 *			decreases depth buffer precision.
-		 */
-        virtual void setFarClipDistance(float farDist);
-
-		/**
-		 * @brief	Retrieves the distance from the frustum to the far clipping plane. Anything
-		 *			farther than the far clipping plane will not be rendered. Increasing this value
-		 *			decreases depth buffer precision.
-		 */
-        virtual float getFarClipDistance() const;
-
-		/**
-		 * @brief	Sets the current viewport aspect ratio (width / height).
-		 */
-        virtual void setAspectRatio(float ratio);
-
-		/**
-		 * @brief	Returns current viewport aspect ratio (width / height).
-		 */
-        virtual float getAspectRatio() const;
-
-		/**
-		 * @brief	Sets camera world space position.
-		 */
-		virtual void setPosition(const Vector3& position);
-
-		/**
-		 * @brief	Retrieves camera world space position.
-		 */
-		virtual Vector3 getPosition() const { return mPosition; }
-
-		/**
-		 * @brief	Gets the Z (forward) axis of the object, in world space.
-		 *
-		 * @return	Forward axis of the object.
-		 */
-		Vector3 getForward() const { return getRotation().rotate(-Vector3::UNIT_Z); }
-
-		/**
-		 * @brief	Sets camera world space rotation.
-		 */
-		virtual void setRotation(const Quaternion& rotation);
-
-		/**
-		 * @brief	Retrieves camera world space rotation.
-		 */
-		virtual Quaternion getRotation() const { return mRotation; }
-
-		/** @brief	Manually set the extents of the frustum that will be used when calculating the
-		 *			projection matrix. This will prevents extents for being automatically calculated
-		 *			from aspect and near plane so it is up to the caller to keep these values
-		 *			accurate.
-		 *
-		 *	@param left		The position where the left clip plane intersect the near clip plane, in view space.
-		 *  @param right	The position where the right clip plane intersect the near clip plane, in view space.
-		 *  @param top		The position where the top clip plane intersect the near clip plane, in view space.
-		 *  @param bottom	The position where the bottom clip plane intersect the near clip plane, in view space.
-		*/
-		virtual void setFrustumExtents(float left, float right, float top, float bottom);
-
-		/** 
-		 * @brief	Resets frustum extents so they are automatically derived from other values.
-		 *			This is only relevant if you have previously set custom extents.
-		 */
-		virtual void resetFrustumExtents(); 
-
-		/** 
-		 * @brief	Returns the extents of the frustum in view space at the near plane.
-		 */
-		virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const;
-
-		/** 
-		 * @brief	Returns the standard projection matrix that determines how are 3D points
-		 *			projected to two dimensions. The layout of this matrix depends on currently
-		 *			used render system.
-		 *
-		 * @note	You should use this matrix when sending the matrix to the render system to remain
-		 *			everything works consistently when other render systems are used.
-		 */
-        virtual const Matrix4& getProjectionMatrixRS() const;
-
-		/** 
-		 * @brief	Returns the inverse of the render-system specific projection matrix.
-		 *
-		 * @see		getProjectionMatrixRS
-		 */
-        virtual const Matrix4& getProjectionMatrixRSInv() const;
-
-		/** 
-		 * @brief	Returns the standard projection matrix that determines how are 3D points
-		 *			projected to two dimensions. Returned matrix is standard following right-hand
-		 *			rules and depth range of [-1, 1]. 
-		 *
-		 * @note	Different render systems will expect different projection matrix layouts, in which
-		 *			case use getProjectionMatrixRS.
-         */
-        virtual const Matrix4& getProjectionMatrix() const;
-
-		/** 
-		 * @brief	Returns the inverse of the projection matrix.
-		 *
-		 * @see		getProjectionMatrix
-		 */
-        virtual const Matrix4& getProjectionMatrixInv() const;
-
-		/** 
-		 * @brief	Gets the camera view matrix. Used for positioning/orienting the camera.
-         */
-        virtual const Matrix4& getViewMatrix() const;
-
-		/** 
-		 * @brief	Returns the inverse of the view matrix.
-		 *
-		 * @see		getViewMatrix
-		 */
-		virtual const Matrix4& getViewMatrixInv() const;
-
-		/** 
-		 * @brief	Sets whether the camera should use the custom view matrix.
-		 *			When this is enabled camera will no longer calculate its view matrix
-		 *			based on position/orientation and caller will be resonsible to keep 
-		 *			the view matrix up to date.
-         */
-		virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY);
-
-		/** 
-		 * @brief	Returns true if a custom view matrix is used.
-         */
-		virtual bool isCustomViewMatrixEnabled() const { return mCustomViewMatrix; }
-		
-		/** 
-		 * @brief	Sets whether the camera should use the custom projection matrix.
-		 *			When this is enabled camera will no longer calculate its projection matrix
-		 *			based on field of view, aspect and other parameters and caller will be
-		 *			resonsible to keep the projection matrix up to date.
-         */
-		virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY);
-
-		/** 
-		 * @brief	Returns true if a custom projection matrix is used.
-         */
-		virtual bool isCustomProjectionMatrixEnabled() const { return mCustomProjMatrix; }
-
-		/** 
-		 * @brief	Returns a convex volume representing the visible area of the camera,
-		 *			in local space.
-         */
-        virtual const ConvexVolume& getFrustum() const;
-
-		/** 
-		 * @brief	Returns a convex volume representing the visible area of the camera,
-		 *			in world space.
-         */
-        virtual ConvexVolume getWorldFrustum() const;
-
-		/**
-		 * @brief	Returns the bounding of the frustum.
-		 */
-        const AABox& getBoundingBox() const;
-
-		/**
-		 * @brief	Sets the type of projection used by the camera.
-		 */
-        virtual void setProjectionType(ProjectionType pt);
-
-		/**
-		 * @brief	Returns the type of projection used by the camera.
-		 */
-        virtual ProjectionType getProjectionType() const;
-
-		/**
-		 * @brief	Sets the orthographic window height, for use with orthographic rendering only. 
-		 *
-		 * @param	w	Width of the window in world units.
-		 * @param	h	Height of the window in world units.
-		 *
-		 * @note	Calling this method will recalculate the aspect ratio, use setOrthoWindowHeight or 
-		 *			setOrthoWindowWidth alone if you wish to preserve the aspect ratio but just fit one 
-		 *			or other dimension to a particular size.
-		 */
-		virtual void setOrthoWindow(float w, float h);
-
-		/**
-		 * @brief	Sets the orthographic window height, for use with orthographic rendering only. 
-		 *
-		 * @param	h	Height of the window in world units.
-		 *
-		 * @note	The width of the window will be calculated from the aspect ratio. 
-		 */
-		virtual void setOrthoWindowHeight(float h);
-
-		/**
-		 * @brief	Sets the orthographic window width, for use with orthographic rendering only. 
-		 *
-		 * @param	w	Width of the window in world units.
-		 *
-		 * @note	The height of the window will be calculated from the aspect ratio. 
-		 */
-		virtual void setOrthoWindowWidth(float w);
-
-		/**
-		 * @brief	Gets the orthographic window width in world units, for use with orthographic rendering only. 
-		 */
-		virtual float getOrthoWindowHeight() const;
-
-		/**
-		 * @brief	Gets the orthographic window width in world units, for use with orthographic rendering only. 
-		 *
-		 * @note	This is calculated from the orthographic height and the aspect ratio.
-		 */
-		virtual float getOrthoWindowWidth() const;
-
-		/**
-		 * @brief	Gets a priority that determines in which orders the cameras are rendered.
-		 *			This only applies to cameras rendering to the same render target. 
-		 */
-		INT32 getPriority() const { return mPriority; }
-
-		/**
-		 * @brief	Sets a priority that determines in which orders the cameras are rendered.
-		 * 			This only applies to cameras rendering to the same render target. 
-		 *
-		 * @param	priority	The priority. Higher value means the camera will be rendered sooner.
-		 */
-		void setPriority(INT32 priority) { mPriority = priority; _markCoreDirty(); }
-
-		/**
-		 * @brief	Retrieves layer bitfield that is used when determining which object should the camera render.
-		 */
-		UINT64 getLayers() const { return mLayers; }
-
-		/**
-		 * @brief	Sets layer bitfield that is used when determining which object should the camera render.
-		 */
-		void setLayers(UINT64 layers) { mLayers = layers; _markCoreDirty(); }
-
-		/**
-		 * @brief	Converts a point in world space to screen coordinates (in pixels
-		 *			corresponding to the render target attached to the camera).
-		 */
-		Vector2I worldToScreenPoint(const Vector3& worldPoint) const;
-
-		/**
-		 * @brief	Converts a point in world space to normalized clip coordinates 
-		 *			(in [0, 1] range).
-		 */
-		Vector2 worldToClipPoint(const Vector3& worldPoint) const;
-
-		/**
-		 * @brief	Converts a point in world space to point relative to camera's
-		 *			coordinate system (view space).
-		 */
-		Vector3 worldToViewPoint(const Vector3& worldPoint) const;
-
-		/**
-		 * @brief	Converts a point in screen space (pixels corresponding to
-		 *			render target attached to the camera) to a point in world space.
-		 *
-		 * @param	screenPoint	Point to transform.
-		 * @param	depth		Depth to place the world point at. The depth is applied
-		 *						to the vector going from camera origin to the point on
-		 *						the near plane.
-		 */
-		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
-
-		/**
-		 * @brief	Converts a point in screen space (pixels corresponding to
-		 *			render target attached to the camera) to a point relative to
-		 *			camera's coordinate system (view space).
-		 *
-		 * @param	screenPoint	Point to transform.
-		 * @param	depth		Depth to place the world point at. The depth is applied
-		 *						to the vector going from camera origin to the point on
-		 *						the near plane.
-		 */
-		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
-
-		/**
-		 * @brief	Converts a point in screen space (pixels corresponding to
-		 *			render target attached to the camera) to normalized clip 
-		 *			coordinates (in [0, 1] range).
-		 */
-		Vector2 screenToClipPoint(const Vector2I& screenPoint) const;
-
-		/**
-		 * @brief	Converts a point relative to camera's coordinate system (view space)
-		 *			into a point in world space.
-		 */
-		Vector3 viewToWorldPoint(const Vector3& viewPoint) const;
-
-		/**
-		 * @brief	Converts a point relative to camera's coordinate system (view space)
-		 *			into a point in screen space (pixels corresponding to render target 
-		 *			attached to the camera.
-		 */
-		Vector2I viewToScreenPoint(const Vector3& viewPoint) const;
-
-		/**
-		 * @brief	Converts a point relative to camera's coordinate system (view space)
-		 *			into normalized clip coordinates (in [0, 1] range).
-		 */
-		Vector2 viewToClipPoint(const Vector3& viewPoint) const;
-
-		/**
-		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
-		 *			a point in world space.
-		 *
-		 * @param	clipPoint	Point to transform.
-		 * @param	depth		Depth to place the world point at. The depth is applied
-		 *						to the vector going from camera origin to the point on
-		 *						the near plane.
-		 */
-		Vector3 clipToWorldPoint(const Vector2& clipPoint, float depth = 0.5f) const;
-
-		/**
-		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
-		 *			a point relative to camera's coordinate system (view space).
-		 *
-		 * @param	clipPoint	Point to transform.
-		 * @param	depth		Depth to place the world point at. The depth is applied
-		 *						to the vector going from camera origin to the point on
-		 *						the near plane.
-		 */
-		Vector3 clipToViewPoint(const Vector2& clipPoint, float depth = 0.5f) const;
-
-		/**
-		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
-		 *			a point in screen space (pixels corresponding to render target attached 
-		 *			to the camera)
-		 */
-		Vector2I clipToScreenPoint(const Vector2& clipPoint) const;
-
-		/**
-		 * @brief	Converts a point in screen space (pixels corresponding to
-		 *			render target attached to the camera) to a ray in world space
-		 *			originating at the selected point on the camera near plane.
-		 */
-		Ray screenPointToRay(const Vector2I& screenPoint) const;
-
-		/**
-		 * @brief	Projects a point from view to clip space.
-		 */
-		Vector3 projectPoint(const Vector3& point) const;
-
-		/**
-		 * @brief	Un-projects a point in clip space to view space.
-		 */
-		Vector3 unprojectPoint(const Vector3& point) const;
-
-        static const float INFINITE_FAR_PLANE_ADJUST; /**< Small constant used to reduce far plane projection to avoid inaccuracies. */
-
-	protected:
-		CameraHandlerBase(RenderTargetPtr target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-		/**
-		 * @brief	Calculate projection parameters that are used when constructing the projection matrix.
-		 */
-		virtual void calcProjectionParameters(float& left, float& right, float& bottom, float& top) const;
-
-		/**
-		 * @brief	Recalculate frustum if dirty.
-		 */
-		virtual void updateFrustum() const;
-
-		/**
-		 * @brief	Recalculate frustum planes if dirty.
-		 */
-		virtual void updateFrustumPlanes() const;
-
-		/**
-		 * @brief	Update view matrix from parent position/orientation.
-		 *
-		 * @note	Does nothing when custom view matrix is set.
-		 */
-		virtual void updateView() const;
-
-		/**
-		 * @brief	Checks if the frustum requires updating.
-		 */
-		virtual bool isFrustumOutOfDate() const;
-
-		/**
-		 * @brief	Notify camera that the frustum requires to be updated.
-		 */
-		virtual void invalidateFrustum() const;
-
-		/**
-		 * @brief	Returns a rectangle that defines the viewport position and size, in pixels.
-		 */
-		virtual Rect2I getViewportRect() const = 0;
-
-		/**
-		 * @copydoc	CoreObject::markCoreDirty
-		 */
-		virtual void _markCoreDirty() { }
-
-    protected:
-		UINT64 mLayers; /**< Bitfield that can be used for filtering what objects the camera sees. */
-
-		Vector3 mPosition; /**< World space position. */
-		Quaternion mRotation; /**< World space rotation. */
-
-		ProjectionType mProjType; /**< Type of camera projection. */
-		Radian mHorzFOV; /**< Horizontal field of view represents how wide is the camera angle. */
-		float mFarDist; /**< Clip any objects further than this. Larger value decreases depth precision at smaller depths. */
-		float mNearDist; /**< Clip any objects close than this. Smaller value decreases depth precision at larger depths. */
-		float mAspect; /**< Width/height viewport ratio. */
-		float mOrthoHeight; /**< Height in world units used for orthographic cameras. */
-		INT32 mPriority; /**< Determines in what order will the camera be rendered. Higher priority means the camera will be rendered sooner. */
-
-		bool mCustomViewMatrix; /**< Is custom view matrix set. */
-		bool mCustomProjMatrix; /**< Is custom projection matrix set. */
-
-		bool mFrustumExtentsManuallySet; /**< Are frustum extents manually set. */
-
-		mutable Matrix4 mProjMatrixRS; /**< Cached render-system specific projection matrix. */
-		mutable Matrix4 mProjMatrix; /**< Cached projection matrix that determines how are 3D points projected to a 2D viewport. */
-		mutable Matrix4 mViewMatrix; /**< Cached view matrix that determines camera position/orientation. */
-		mutable Matrix4 mProjMatrixRSInv;
-		mutable Matrix4 mProjMatrixInv;
-		mutable Matrix4 mViewMatrixInv;
-
-		mutable ConvexVolume mFrustum; /**< Main clipping planes describing cameras visible area. */
-		mutable bool mRecalcFrustum; /**< Should frustum be recalculated. */
-		mutable bool mRecalcFrustumPlanes; /**< Should frustum planes be recalculated. */
-		mutable bool mRecalcView; /**< Should view matrix be recalculated. */
-		mutable float mLeft, mRight, mTop, mBottom; /**< Frustum extents. */
-		mutable AABox mBoundingBox; /**< Frustum bounding box. */
-     };
-
-	/**
-	 * @copydoc	CameraHandlerBase
-	 */
-	class BS_EXPORT CameraHandlerCore : public CoreObjectCore, public CameraHandlerBase
-	{
-	public:
-		~CameraHandlerCore();
-
-		/**
-		 * @brief	Returns the viewport used by the camera.
-		 */	
-		SPtr<ViewportCore> getViewport() const { return mViewport; }
-
-	protected:
-		friend class CameraHandler;
-
-		CameraHandlerCore(SPtr<RenderTargetCore> target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-		CameraHandlerCore(const SPtr<ViewportCore>& viewport);
-
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
-		void initialize() override;
-
-		/**
-		 * @copydoc	CameraHandlerBase
-		 */
-		virtual Rect2I getViewportRect() const override;
-
-		/**
-		 * @copydoc	CoreObject::syncToCore
-		 */
-		void syncToCore(const CoreSyncData& data) override;
-
-		SPtr<ViewportCore> mViewport;
-	};
-
-	/**
-	 * @copydoc	CameraHandlerBase
-	 */
-	class BS_EXPORT CameraHandler : public IReflectable, public CoreObject, public CameraHandlerBase
-    {
-    public:
-		/**
-		 * @brief	Returns the viewport used by the camera.
-		 */	
-		ViewportPtr getViewport() const { return mViewport; }
-
-		/**
-		 * @brief	Retrieves an implementation of a camera handler usable only from the
-		 *			core thread.
-		 */
-		SPtr<CameraHandlerCore> getCore() const;
-
-		/**
-	     * @brief	Returns the hash value that can be used to identify if the internal data needs an update.
-		 */
-		UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
-
-		/**
-	     * @brief	Sets the hash value that can be used to identify if the internal data needs an update.
-		 */
-		void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
-
-		/**
-		 * @brief	Creates a new camera that renders to the specified portion of the provided render target.
-		 */
-		static CameraHandlerPtr create(RenderTargetPtr target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-	protected:
-		CameraHandler(RenderTargetPtr target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-		/**
-		 * @copydoc	CameraHandlerBase
-		 */
-		virtual Rect2I getViewportRect() const override;
-
-		/**
-		 * @copydoc	CoreObject::createCore
-		 */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/**
-		 * @copydoc	CoreObject::markCoreDirty
-		 */
-		void _markCoreDirty() override;
-
-		/**
-		 * @copydoc	CoreObject::syncToCore
-		 */
-		CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		/**
-		 * @copydoc	CoreObject::getCoreDependencies
-		 */
-		void getCoreDependencies(Vector<SPtr<CoreObject>>& dependencies) override;
-
-		/**
-		 * @brief	Creates a new camera without initializing it.
-		 */
-		static CameraHandlerPtr createEmpty();
-
-		ViewportPtr mViewport; /**< Viewport that describes 2D rendering surface. */
-		UINT32 mLastUpdateHash;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class CameraHandlerRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-     };
-}

+ 0 - 125
BansheeEngine/Include/BsCameraHandlerRTTI.h

@@ -1,125 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsRTTIType.h"
-#include "BsCameraHandler.h"
-
-namespace BansheeEngine
-{
-	class BS_EXPORT CameraHandlerRTTI : public RTTIType <CameraHandler, IReflectable, CameraHandlerRTTI>
-	{
-	private:
-		ViewportPtr getViewport(CameraHandler* obj) { return obj->mViewport; }
-		void setViewport(CameraHandler* obj, ViewportPtr val) { obj->mViewport = val; }
-
-		UINT64& getLayers(CameraHandler* obj) { return obj->mLayers; }
-		void setLayers(CameraHandler* obj, UINT64& val) { obj->mLayers = val; }
-
-		Vector3& getPosition(CameraHandler* obj) { return obj->mPosition; }
-		void setPosition(CameraHandler* obj, Vector3& val) { obj->mPosition = val; }
-
-		Quaternion& getRotation(CameraHandler* obj) { return obj->mRotation; }
-		void setRotation(CameraHandler* obj, Quaternion& val) { obj->mRotation = val; }
-
-		ProjectionType& getProjType(CameraHandler* obj) { return obj->mProjType; }
-		void setProjType(CameraHandler* obj, ProjectionType& val) { obj->mProjType = val; }
-
-		Radian& getHorzFOV(CameraHandler* obj) { return obj->mHorzFOV; }
-		void setHorzFOV(CameraHandler* obj, Radian& val) { obj->mHorzFOV = val; }
-
-		float& getFarDist(CameraHandler* obj) { return obj->mFarDist; }
-		void setFarDist(CameraHandler* obj, float& val) { obj->mFarDist = val; }
-
-		float& getNearDist(CameraHandler* obj) { return obj->mNearDist; }
-		void setNearDist(CameraHandler* obj, float& val) { obj->mNearDist = val; }
-
-		float& getAspect(CameraHandler* obj) { return obj->mAspect; }
-		void setAspect(CameraHandler* obj, float& val) { obj->mAspect = val; }
-
-		float& getOrthoHeight(CameraHandler* obj) { return obj->mOrthoHeight; }
-		void setOrthoHeight(CameraHandler* obj, float& val) { obj->mOrthoHeight = val; }
-
-		INT32& getPriority(CameraHandler* obj) { return obj->mPriority; }
-		void setPriority(CameraHandler* obj, INT32& val) { obj->mPriority = val; }
-
-		bool& getCustomViewMatrix(CameraHandler* obj) { return obj->mCustomViewMatrix; }
-		void setCustomViewMatrix(CameraHandler* obj, bool& val) { obj->mCustomViewMatrix = val; }
-
-		bool& getCustomProjMatrix(CameraHandler* obj) { return obj->mCustomProjMatrix; }
-		void setCustomProjMatrix(CameraHandler* obj, bool& val) { obj->mCustomProjMatrix = val; }
-
-		bool& getFrustumManual(CameraHandler* obj) { return obj->mFrustumExtentsManuallySet; }
-		void setFrustumManual(CameraHandler* obj, bool& val) { obj->mFrustumExtentsManuallySet = val; }
-
-		Matrix4& getProjMatrix(CameraHandler* obj) { return obj->mProjMatrix; }
-		void setProjMatrix(CameraHandler* obj, Matrix4& val) { obj->mProjMatrix = val; }
-
-		Matrix4& getProjMatrixRS(CameraHandler* obj) { return obj->mProjMatrixRS; }
-		void setProjMatrixRS(CameraHandler* obj, Matrix4& val) { obj->mProjMatrixRS = val; }
-
-		Matrix4& getViewMatrix(CameraHandler* obj) { return obj->mViewMatrix; }
-		void setViewMatrix(CameraHandler* obj, Matrix4& val) { obj->mViewMatrix = val; }
-
-		float& getLeft(CameraHandler* obj) { return obj->mLeft; }
-		void setLeft(CameraHandler* obj, float& val) { obj->mLeft = val; }
-
-		float& getRight(CameraHandler* obj) { return obj->mRight; }
-		void setRight(CameraHandler* obj, float& val) { obj->mRight = val; }
-
-		float& getTop(CameraHandler* obj) { return obj->mTop; }
-		void setTop(CameraHandler* obj, float& val) { obj->mTop = val; }
-
-		float& getBottom(CameraHandler* obj) { return obj->mBottom; }
-		void setBottom(CameraHandler* obj, float& val) { obj->mBottom = val; }
-
-	public:
-		CameraHandlerRTTI()
-		{
-			addReflectablePtrField("mViewport", 0, &CameraHandlerRTTI::getViewport, &CameraHandlerRTTI::setViewport);
-			addPlainField("mLayers", 1, &CameraHandlerRTTI::getLayers, &CameraHandlerRTTI::setLayers);
-			addPlainField("mPosition", 2, &CameraHandlerRTTI::getPosition, &CameraHandlerRTTI::setPosition);
-			addPlainField("mRotation", 3, &CameraHandlerRTTI::getRotation, &CameraHandlerRTTI::setRotation);
-			addPlainField("mProjType", 4, &CameraHandlerRTTI::getProjType, &CameraHandlerRTTI::setProjType);
-			addPlainField("mHorzFOV", 5, &CameraHandlerRTTI::getHorzFOV, &CameraHandlerRTTI::setHorzFOV);
-			addPlainField("mFarDist", 6, &CameraHandlerRTTI::getFarDist, &CameraHandlerRTTI::setFarDist);
-			addPlainField("mNearDist", 7, &CameraHandlerRTTI::getNearDist, &CameraHandlerRTTI::setNearDist);
-			addPlainField("mAspect", 8, &CameraHandlerRTTI::getAspect, &CameraHandlerRTTI::setAspect);
-			addPlainField("mOrthoHeight", 9, &CameraHandlerRTTI::getOrthoHeight, &CameraHandlerRTTI::setOrthoHeight);
-			addPlainField("mPriority", 10, &CameraHandlerRTTI::getPriority, &CameraHandlerRTTI::setPriority);
-			addPlainField("mCustomViewMatrix", 11, &CameraHandlerRTTI::getCustomViewMatrix, &CameraHandlerRTTI::setCustomViewMatrix);
-			addPlainField("mCustomProjMatrix", 12, &CameraHandlerRTTI::getCustomProjMatrix, &CameraHandlerRTTI::setCustomProjMatrix);
-			addPlainField("mFrustumExtentsManuallySet", 13, &CameraHandlerRTTI::getFrustumManual, &CameraHandlerRTTI::setFrustumManual);
-			addPlainField("mProjMatrixRS", 15, &CameraHandlerRTTI::getProjMatrixRS, &CameraHandlerRTTI::setProjMatrixRS);
-			addPlainField("mProjMatrix", 16, &CameraHandlerRTTI::getProjMatrix, &CameraHandlerRTTI::setProjMatrix);
-			addPlainField("mViewMatrix", 17, &CameraHandlerRTTI::getViewMatrix, &CameraHandlerRTTI::setViewMatrix);
-			addPlainField("mLeft", 18, &CameraHandlerRTTI::getLeft, &CameraHandlerRTTI::setLeft);
-			addPlainField("mRight", 19, &CameraHandlerRTTI::getRight, &CameraHandlerRTTI::setRight);
-			addPlainField("mTop", 20, &CameraHandlerRTTI::getTop, &CameraHandlerRTTI::setTop);
-			addPlainField("mBottom", 21, &CameraHandlerRTTI::getBottom, &CameraHandlerRTTI::setBottom);
-		}
-
-		virtual void onDeserializationEnded(IReflectable* obj) override
-		{
-			// Note: Since this is a CoreObject I should call initialize() right after deserialization,
-			// but since this specific type is used in Components we delay initialization until Component
-			// itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component 
-			// purposes (you'll need to call initialize manually).
-		}
-
-		virtual const String& getRTTIName() override
-		{
-			static String name = "CameraHandler";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() override
-		{
-			return TID_CameraHandler;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject() override
-		{
-			return CameraHandler::createEmpty();
-		}
-	};
-}

+ 96 - 9
BansheeEngine/Include/BsCameraRTTI.h

@@ -3,36 +3,123 @@
 #include "BsPrerequisites.h"
 #include "BsRTTIType.h"
 #include "BsCamera.h"
-#include "BsGameObjectRTTI.h"
 
 namespace BansheeEngine
 {
-	class BS_EXPORT CameraRTTI : public RTTIType<Camera, Component, CameraRTTI>
+	class BS_EXPORT CameraRTTI : public RTTIType <Camera, IReflectable, CameraRTTI>
 	{
 	private:
-		CameraHandlerPtr getInternal(Camera* obj) { return obj->mInternal; }
-		void setInternal(Camera* obj, CameraHandlerPtr val) { obj->mInternal = val; }
+		ViewportPtr getViewport(Camera* obj) { return obj->mViewport; }
+		void setViewport(Camera* obj, ViewportPtr val) { obj->mViewport = val; }
+
+		UINT64& getLayers(Camera* obj) { return obj->mLayers; }
+		void setLayers(Camera* obj, UINT64& val) { obj->mLayers = val; }
+
+		Vector3& getPosition(Camera* obj) { return obj->mPosition; }
+		void setPosition(Camera* obj, Vector3& val) { obj->mPosition = val; }
+
+		Quaternion& getRotation(Camera* obj) { return obj->mRotation; }
+		void setRotation(Camera* obj, Quaternion& val) { obj->mRotation = val; }
+
+		ProjectionType& getProjType(Camera* obj) { return obj->mProjType; }
+		void setProjType(Camera* obj, ProjectionType& val) { obj->mProjType = val; }
+
+		Radian& getHorzFOV(Camera* obj) { return obj->mHorzFOV; }
+		void setHorzFOV(Camera* obj, Radian& val) { obj->mHorzFOV = val; }
+
+		float& getFarDist(Camera* obj) { return obj->mFarDist; }
+		void setFarDist(Camera* obj, float& val) { obj->mFarDist = val; }
+
+		float& getNearDist(Camera* obj) { return obj->mNearDist; }
+		void setNearDist(Camera* obj, float& val) { obj->mNearDist = val; }
+
+		float& getAspect(Camera* obj) { return obj->mAspect; }
+		void setAspect(Camera* obj, float& val) { obj->mAspect = val; }
+
+		float& getOrthoHeight(Camera* obj) { return obj->mOrthoHeight; }
+		void setOrthoHeight(Camera* obj, float& val) { obj->mOrthoHeight = val; }
+
+		INT32& getPriority(Camera* obj) { return obj->mPriority; }
+		void setPriority(Camera* obj, INT32& val) { obj->mPriority = val; }
+
+		bool& getCustomViewMatrix(Camera* obj) { return obj->mCustomViewMatrix; }
+		void setCustomViewMatrix(Camera* obj, bool& val) { obj->mCustomViewMatrix = val; }
+
+		bool& getCustomProjMatrix(Camera* obj) { return obj->mCustomProjMatrix; }
+		void setCustomProjMatrix(Camera* obj, bool& val) { obj->mCustomProjMatrix = val; }
+
+		bool& getFrustumManual(Camera* obj) { return obj->mFrustumExtentsManuallySet; }
+		void setFrustumManual(Camera* obj, bool& val) { obj->mFrustumExtentsManuallySet = val; }
+
+		Matrix4& getProjMatrix(Camera* obj) { return obj->mProjMatrix; }
+		void setProjMatrix(Camera* obj, Matrix4& val) { obj->mProjMatrix = val; }
+
+		Matrix4& getProjMatrixRS(Camera* obj) { return obj->mProjMatrixRS; }
+		void setProjMatrixRS(Camera* obj, Matrix4& val) { obj->mProjMatrixRS = val; }
+
+		Matrix4& getViewMatrix(Camera* obj) { return obj->mViewMatrix; }
+		void setViewMatrix(Camera* obj, Matrix4& val) { obj->mViewMatrix = val; }
+
+		float& getLeft(Camera* obj) { return obj->mLeft; }
+		void setLeft(Camera* obj, float& val) { obj->mLeft = val; }
+
+		float& getRight(Camera* obj) { return obj->mRight; }
+		void setRight(Camera* obj, float& val) { obj->mRight = val; }
+
+		float& getTop(Camera* obj) { return obj->mTop; }
+		void setTop(Camera* obj, float& val) { obj->mTop = val; }
+
+		float& getBottom(Camera* obj) { return obj->mBottom; }
+		void setBottom(Camera* obj, float& val) { obj->mBottom = val; }
 
 	public:
 		CameraRTTI()
 		{
-			addReflectablePtrField("mInternal", 0, &CameraRTTI::getInternal, &CameraRTTI::setInternal);
+			addReflectablePtrField("mViewport", 0, &CameraRTTI::getViewport, &CameraRTTI::setViewport);
+			addPlainField("mLayers", 1, &CameraRTTI::getLayers, &CameraRTTI::setLayers);
+			addPlainField("mPosition", 2, &CameraRTTI::getPosition, &CameraRTTI::setPosition);
+			addPlainField("mRotation", 3, &CameraRTTI::getRotation, &CameraRTTI::setRotation);
+			addPlainField("mProjType", 4, &CameraRTTI::getProjType, &CameraRTTI::setProjType);
+			addPlainField("mHorzFOV", 5, &CameraRTTI::getHorzFOV, &CameraRTTI::setHorzFOV);
+			addPlainField("mFarDist", 6, &CameraRTTI::getFarDist, &CameraRTTI::setFarDist);
+			addPlainField("mNearDist", 7, &CameraRTTI::getNearDist, &CameraRTTI::setNearDist);
+			addPlainField("mAspect", 8, &CameraRTTI::getAspect, &CameraRTTI::setAspect);
+			addPlainField("mOrthoHeight", 9, &CameraRTTI::getOrthoHeight, &CameraRTTI::setOrthoHeight);
+			addPlainField("mPriority", 10, &CameraRTTI::getPriority, &CameraRTTI::setPriority);
+			addPlainField("mCustomViewMatrix", 11, &CameraRTTI::getCustomViewMatrix, &CameraRTTI::setCustomViewMatrix);
+			addPlainField("mCustomProjMatrix", 12, &CameraRTTI::getCustomProjMatrix, &CameraRTTI::setCustomProjMatrix);
+			addPlainField("mFrustumExtentsManuallySet", 13, &CameraRTTI::getFrustumManual, &CameraRTTI::setFrustumManual);
+			addPlainField("mProjMatrixRS", 15, &CameraRTTI::getProjMatrixRS, &CameraRTTI::setProjMatrixRS);
+			addPlainField("mProjMatrix", 16, &CameraRTTI::getProjMatrix, &CameraRTTI::setProjMatrix);
+			addPlainField("mViewMatrix", 17, &CameraRTTI::getViewMatrix, &CameraRTTI::setViewMatrix);
+			addPlainField("mLeft", 18, &CameraRTTI::getLeft, &CameraRTTI::setLeft);
+			addPlainField("mRight", 19, &CameraRTTI::getRight, &CameraRTTI::setRight);
+			addPlainField("mTop", 20, &CameraRTTI::getTop, &CameraRTTI::setTop);
+			addPlainField("mBottom", 21, &CameraRTTI::getBottom, &CameraRTTI::setBottom);
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj) override
+		{
+			// Note: Since this is a CoreObject I should call initialize() right after deserialization,
+			// but since this specific type is used in Components we delay initialization until Component
+			// itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component 
+			// purposes (you'll need to call initialize manually).
 		}
 
-		virtual const String& getRTTIName()
+		virtual const String& getRTTIName() override
 		{
 			static String name = "Camera";
 			return name;
 		}
 
-		virtual UINT32 getRTTIId()
+		virtual UINT32 getRTTIId() override
 		{
 			return TID_Camera;
 		}
 
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
-			return GameObjectRTTI::createGameObject<Camera>();
+			return Camera::createEmpty();
 		}
 	};
 }

+ 290 - 131
BansheeEngine/Include/BsLight.h

@@ -1,147 +1,306 @@
 #pragma once
 
 #include "BsPrerequisites.h"
-#include "BsLightInternal.h"
-#include "BsComponent.h"
+#include "BsIReflectable.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
+#include "BsColor.h"
+#include "BsSphere.h"
+#include "BsCoreObject.h"
 
-namespace BansheeEngine 
+namespace BansheeEngine
 {
 	/**
-	 * @copydoc	Component wrapper for LightInternal
+	 * @brief	Light types that determine how is light information parsed
+	 *			by the renderer and other systems.
+	 */
+	enum class LightType
+	{
+		Directional, 
+		Point, 
+		Spot
+	};
+
+	/**
+	 * @brief	Signals which portion of a LightInternal is dirty.
+	 */
+	enum class LightDirtyFlag
+	{
+		Transform = 0x01,
+		Everything = 0x02
+	};
+
+	/**
+	 * @brief	Base class for both sim and core thread Light implementations.
+	 */
+	class BS_EXPORT LightBase
+	{
+	public:
+		LightBase();
+		LightBase(LightType type, Color color, float intensity, float range, 
+			bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
+
+		virtual ~LightBase() { }
+
+		/**
+		 * @brief	Returns the position of the light, in world space.
+		 */
+		Vector3 getPosition() const { return mPosition; }
+
+		/**
+		 * @brief	Sets the position of the light, in world space.
+		 */
+		void setPosition(const Vector3& position) { mPosition = position; _markCoreDirty(); updateBounds(); }
+
+		/**
+		 * @brief	Returns the rotation of the light, in world space.
+		 */
+		Quaternion getRotation() const { return mRotation; }
+
+		/**
+		 * @brief	Sets the rotation of the light, in world space.
+		 */
+		void setRotation(const Quaternion& rotation) { mRotation = rotation; _markCoreDirty(); updateBounds(); }
+
+		/**
+		 * @brief	Returns the type of the light.
+		 */
+		LightType getType() const { return mType; }
+
+		/**
+		 * @brief	Changes the type of the light.
+		 */
+		void setType(LightType type) { mType = type; _markCoreDirty(); updateBounds(); }
+
+		/**
+		 * @brief	Checks does this light cast shadows when rendered.
+		 */
+		bool getCastsShadow() const { return mCastsShadows; }
+
+		/**
+		 * @brief	Sets whether this light will cast shadows when rendered.
+		 */
+		void setCastsShadow(bool castsShadow) { mCastsShadows = castsShadow; _markCoreDirty(); }
+
+		/**
+		 * @brief	Returns the color emitted from the light.
+		 */
+		Color getColor() const { return mColor; }
+
+		/**
+		 * @brief	Sets the color emitted from the light.
+		 */
+		void setColor(const Color& color) { mColor = color; _markCoreDirty(); }
+
+		/**
+		 * @brief	Returns the maximum range of the light. Light will not affect any geometry past that point.
+		 */
+		float getRange() const { return mRange; }
+
+		/**
+		 * @brief	Returns the maximum range of the light. Light will not affect any geometry past that point.
+		 *
+		 * @note	Normally you want to set this at a point where light intensity is too low due to attenuation.
+		 */
+		void setRange(float range) { mRange = range; _markCoreDirty(); updateBounds(); }
+
+		/**
+		 * @brief	Gets the power of the light source. This will be luminous flux for point & spot lights, 
+		 *			and radiance for directional lights.
+		 */
+		float getIntensity() const { return mIntensity; }
+
+		/**
+		 * @brief	Sets the power of the light source. This will be luminous flux for point & spot lights, 
+		 *			and radiance for directional lights.
+		 */
+		void setIntensity(float intensity) { mIntensity = intensity; _markCoreDirty(); }
+
+		/**
+		 * @brief	Gets the total angle covered by a spot light.
+		 */
+		Degree getSpotAngle() const { return mSpotAngle; }
+
+		/**
+		 * @brief	Sets the total angle covered by a spot light.
+		 */
+		void setSpotAngle(const Degree& spotAngle) { mSpotAngle = spotAngle; _markCoreDirty(); updateBounds(); }
+
+		/**
+		 * @brief	Gets the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity
+		 *			starts linearly falling off as the angle approaches the total spot angle.
+		 */
+		Degree getSpotFalloffAngle() const { return mSpotFalloffAngle; }
+
+		/**
+		 * @brief	Sets the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity
+		 *			starts linearly falling off as the angle approaches the total spot angle.
+		 */
+		void setSpotFalloffAngle(const Degree& spotFallofAngle) { mSpotFalloffAngle = spotFallofAngle; _markCoreDirty(); updateBounds(); }
+
+		/**
+		 * @brief	Returns world space bounds that completely encompass the lights area of influence.
+		 */
+		Sphere getBounds() const { return mBounds; }
+
+		/**
+		 * @brief	Returns the radiance of the light source. This is the value that should be used in lighting equations.
+		 *
+		 * @note	Ignores the light direction, therefore caller must ensure to properly handle non-uniform emitters like spot lights
+		 */
+		float getRadiance() const;
+
+		/**
+		 * @brief	Checks whether the light should be rendered or not.
+		 */
+		bool getIsActive() const { return mIsActive; }
+
+		/**
+		 * @brief	Sets whether the light should be rendered or not.
+		 */
+		void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
+
+		/**
+		 * @copydoc	CoreObject::markCoreDirty
+		 */
+		virtual void _markCoreDirty(LightDirtyFlag flag = LightDirtyFlag::Everything) { }
+
+	protected:
+		/**
+		 * @brief	Updates the internal bounds for the light. Call this whenever a property affecting
+		 *			the bounds changes.
+		 */
+		void updateBounds();
+
+		Vector3 mPosition; /**< World space position. */
+		Quaternion mRotation; /**< World space rotation. */
+
+		LightType mType; /**< Type of light that determines how are the rest of the parameters interpreted. */
+		bool mCastsShadows; /**< Determines whether the light casts shadows. */
+		Color mColor; /**< Color of the light. */
+		float mRange; /**< Cut off range for the light when rendering. */
+		float mIntensity; /**< Power of the light source. This will be luminous flux for point & spot lights, and radiance for directional lights. */
+		Degree mSpotAngle; /**< Total angle covered by a spot light. */
+		Degree mSpotFalloffAngle; /**< Spot light angle at which falloff starts. Must be smaller than total angle. */
+		bool mIsActive; /**< Whether the light should be rendered or not. */
+		Sphere mBounds; /**< Sphere that bounds the light area of influence. */
+	};
+
+	/**
+	 * @brief	Core thread usable version of a light.
 	 *
-	 * @see	LightInternal
+	 * @see		LightBase
 	 */
-    class BS_EXPORT Light : public Component
-    {
-    public:
-		Light(const HSceneObject& parent, LightType type = LightType::Point, Color color = Color::White, 
-			float intensity = 100.0f, float range = 1.0f, bool castsShadows = false, Degree spotAngle = Degree(45), 
-			Degree spotFalloffAngle = Degree(40));
-
-		virtual ~Light();
-
-	    /**
-		 * @copydoc	LightInternal::getPosition
-	     */
-		Vector3 getPosition() const { return mInternal->getPosition(); }
-
-	    /**
-		 * @copydoc	LightInternal::setPosition
-	     */
-		void setPosition(const Vector3& position) { mInternal->setPosition(position); }
-
-	    /**
-		 * @copydoc	LightInternal::getRotation
-	     */
-		Quaternion getRotation() const { return mInternal->getRotation(); }
-
-	    /**
-		 * @copydoc	LightInternal::setRotation
-	     */
-		void setRotation(const Quaternion& rotation) { mInternal->setRotation(rotation); }
-
-	    /**
-		 * @copydoc	LightInternal::getType
-	     */
-		LightType getType() const { return mInternal->getType(); }
-
-	    /**
-		 * @copydoc	LightInternal::setType
-	     */
-		void setType(LightType type) { mInternal->setType(type); }
-
-	    /**
-		 * @copydoc	LightInternal::getCastsShadow
-	     */
-		bool getCastsShadow() const { return mInternal->getCastsShadow(); }
-
-	    /**
-		 * @copydoc	LightInternal::setCastsShadow
-	     */
-		void setCastsShadow(bool castsShadow) { mInternal->setCastsShadow(castsShadow); }
-
-	    /**
-		 * @copydoc	LightInternal::getColor
-	     */
-		Color getColor() const { return mInternal->getColor(); }
-
-	    /**
-		 * @copydoc	LightInternal::setColor
-	     */
-		void setColor(const Color& color) { mInternal->setColor(color); }
-
-	    /**
-		 * @copydoc	LightInternal::getRange
-	     */
-		float getRange() const { return mInternal->getRange(); }
-
-	    /**
-		 * @copydoc	LightInternal::setRange
-	     */
-		void setRange(float range) { mInternal->setRange(range);; }
-
-	    /**
-		 * @copydoc	LightInternal::getIntensity
-	     */
-		float getIntensity() const { return mInternal->getIntensity(); }
-
-	    /**
-		 * @copydoc	LightInternal::setIntensity
-	     */
-		void setIntensity(float intensity) { mInternal->setIntensity(intensity); }
-
-	    /**
-		 * @copydoc	LightInternal::getSpotAngle
-	     */
-		Degree getSpotAngle() const { return mInternal->getSpotAngle(); }
-
-	    /**
-		 * @copydoc	LightInternal::setSpotAngle
-	     */
-		void setSpotAngle(const Degree& spotAngle) { mInternal->setSpotAngle(spotAngle); }
-
-	    /**
-		 * @copydoc	LightInternal::getBounds
-	     */
-		Sphere getBounds() const;
-
-	    /**
-		 * @brief	Returns the light internals that this component wraps.
-	     */
-		SPtr<LightInternal> _getInternal() const { return mInternal; }
-
-    protected:
-		mutable SPtr<LightInternal> mInternal;
-
-		// Only valid during construction
-		LightType mType;
-		Color mColor;
-		float mIntensity; 
-		float mRange; 
-		bool mCastsShadows; 
-		Degree mSpotAngle; 
-		Degree mSpotFalloffAngle;
+	class BS_EXPORT LightCore : public CoreObjectCore, public LightBase
+	{
+	public:
+		~LightCore();
+
+		/**
+		 * @brief	Sets an ID that can be used for uniquely identifying this object by the renderer.
+		 */
+		void setRendererId(UINT32 id) { mRendererId = id; }
+
+		/**
+		 * @brief	Retrieves an ID that can be used for uniquely identifying this object by the renderer.
+		 */
+		UINT32 getRendererId() const { return mRendererId; }
+
+	protected:
+		friend class Light;
+
+		LightCore(LightType type, Color color, float intensity, 
+			float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
+
+		/**
+		 * @copydoc	CoreObjectCore::initialize
+		 */
+		void initialize() override;
+
+		/**
+		 * @copydoc	CoreObject::syncToCore
+		 */
+		void syncToCore(const CoreSyncData& data) override;
+
+		UINT32 mRendererId;
+	};
+
+	/**
+	 * @brief	Sim thread usable version of a light.
+	 *
+	 * @see		LightBase
+	 */
+	class BS_EXPORT Light : public IReflectable, public CoreObject, public LightBase
+	{
+	public:
+		/**
+		 * @brief	Retrieves an implementation of a light usable only from the core thread.
+		 */
+		SPtr<LightCore> getCore() const;
+
+		/**
+	     * @brief	Returns the hash value that can be used to identify if the internal data needs an update.
+		 *
+		 * @note	Internal method.
+		 */
+		UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
+
+		/**
+	     * @brief	Sets the hash value that can be used to identify if the internal data needs an update.
+		 *
+		 * @note	Internal method.
+		 */
+		void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
+
+		/**
+		 * @brief	Updates internal transform values from the specified scene object, in case that scene
+		 *			object's transform changed since the last call.
+		 *
+		 * @note	Assumes the same scene object will be provided every time.
+		 */
+		void _updateTransform(const HSceneObject& parent);
+
+		/**
+		 * @brief	Creates a new light with provided settings.
+		 *
+		 * @param	type				Type of light that determines how are the rest of the parameters interpreted.
+		 * @param	color				Color of the light.
+		 * @param	intensity			Power of the light source. This will be luminous flux for point & spot lights, 
+		 *								and radiance for directional lights.
+		 * @param	range				Cut off range for the light when rendering.
+		 * @param	castsShadows		Determines whether the light casts shadows.
+		 * @param	spotAngle			Total angle covered by a spot light.
+		 * @param	spotFalloffAngle	Spot light angle at which falloff starts. Must be smaller than total angle.
+		 */
+		static SPtr<Light> create(LightType type = LightType::Point, Color color = Color::White,
+			float intensity = 100.0f, float range = 10.0f, bool castsShadows = false,
+			Degree spotAngle = Degree(45), Degree spotFalloffAngle = Degree(40));
 
-		/************************************************************************/
-		/* 						COMPONENT OVERRIDES                      		*/
-		/************************************************************************/
 	protected:
-		friend class SceneObject;
+		Light(LightType type, Color color, float intensity, float range, 
+			bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
 
-	    /**
-		 * @copydoc	Component::onInitialized
-	     */
-		void onInitialized() override;
+		/**
+		 * @copydoc	CoreObject::createCore
+		 */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		/**
+		 * @copydoc	CoreObject::markCoreDirty
+		 */
+		void _markCoreDirty(LightDirtyFlag flag = LightDirtyFlag::Everything) override;
 
-	    /**
-		 * @copydoc	Component::onDestroyed
-	     */
-		void onDestroyed() override;
+		/**
+		 * @copydoc	CoreObject::syncToCore
+		 */
+		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 
 		/**
-		 * @copydoc	Component::update
+		 * @brief	Creates a light with without initializing it. Used for serialization.
 		 */
-		virtual void update() override { }
+		static SPtr<Light> createEmpty();
+
+		UINT32 mLastUpdateHash;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -152,6 +311,6 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const override;
 
 	protected:
-		Light() {} // Serialization only
-     };
+		Light(); // Serialization only
+	};
 }

+ 0 - 313
BansheeEngine/Include/BsLightInternal.h

@@ -1,313 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsIReflectable.h"
-#include "BsVector3.h"
-#include "BsQuaternion.h"
-#include "BsColor.h"
-#include "BsSphere.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Light types that determine how is light information parsed
-	 *			by the renderer and other systems.
-	 */
-	enum class LightType
-	{
-		Directional, 
-		Point, 
-		Spot
-	};
-
-	/**
-	 * @brief	Signals which portion of a LightInternal is dirty.
-	 */
-	enum class LightDirtyFlag
-	{
-		Transform = 0x01,
-		Everything = 0x02
-	};
-
-	class BS_EXPORT LightInternalBase
-	{
-	public:
-		LightInternalBase();
-		LightInternalBase(LightType type, Color color, float intensity, float range, 
-			bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
-
-		virtual ~LightInternalBase() { }
-
-		/**
-		 * @brief	Returns the position of the light, in world space.
-		 */
-		Vector3 getPosition() const { return mPosition; }
-
-		/**
-		 * @brief	Sets the position of the light, in world space.
-		 */
-		void setPosition(const Vector3& position) { mPosition = position; _markCoreDirty(); updateBounds(); }
-
-		/**
-		 * @brief	Returns the rotation of the light, in world space.
-		 */
-		Quaternion getRotation() const { return mRotation; }
-
-		/**
-		 * @brief	Sets the rotation of the light, in world space.
-		 */
-		void setRotation(const Quaternion& rotation) { mRotation = rotation; _markCoreDirty(); updateBounds(); }
-
-		/**
-		 * @brief	Returns the type of the light.
-		 */
-		LightType getType() const { return mType; }
-
-		/**
-		 * @brief	Changes the type of the light.
-		 */
-		void setType(LightType type) { mType = type; _markCoreDirty(); updateBounds(); }
-
-		/**
-		 * @brief	Checks does this light cast shadows when rendered.
-		 */
-		bool getCastsShadow() const { return mCastsShadows; }
-
-		/**
-		 * @brief	Sets whether this light will cast shadows when rendered.
-		 */
-		void setCastsShadow(bool castsShadow) { mCastsShadows = castsShadow; _markCoreDirty(); }
-
-		/**
-		 * @brief	Returns the color emitted from the light.
-		 */
-		Color getColor() const { return mColor; }
-
-		/**
-		 * @brief	Sets the color emitted from the light.
-		 */
-		void setColor(const Color& color) { mColor = color; _markCoreDirty(); }
-
-		/**
-		 * @brief	Returns the maximum range of the light. Light will not affect any geometry past that point.
-		 */
-		float getRange() const { return mRange; }
-
-		/**
-		 * @brief	Returns the maximum range of the light. Light will not affect any geometry past that point.
-		 *
-		 * @note	Normally you want to set this at a point where light intensity is too low due to attenuation.
-		 */
-		void setRange(float range) { mRange = range; _markCoreDirty(); updateBounds(); }
-
-		/**
-		 * @brief	Gets the power of the light source. This will be luminous flux for point & spot lights, 
-		 *			and radiance for directional lights.
-		 */
-		float getIntensity() const { return mIntensity; }
-
-		/**
-		 * @brief	Sets the power of the light source. This will be luminous flux for point & spot lights, 
-		 *			and radiance for directional lights.
-		 */
-		void setIntensity(float intensity) { mIntensity = intensity; _markCoreDirty(); }
-
-		/**
-		 * @brief	Gets the total angle covered by a spot light.
-		 */
-		Degree getSpotAngle() const { return mSpotAngle; }
-
-		/**
-		 * @brief	Sets the total angle covered by a spot light.
-		 */
-		void setSpotAngle(const Degree& spotAngle) { mSpotAngle = spotAngle; _markCoreDirty(); updateBounds(); }
-
-		/**
-		 * @brief	Gets the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity
-		 *			starts linearly falling off as the angle approaches the total spot angle.
-		 */
-		Degree getSpotFalloffAngle() const { return mSpotFalloffAngle; }
-
-		/**
-		 * @brief	Sets the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity
-		 *			starts linearly falling off as the angle approaches the total spot angle.
-		 */
-		void setSpotFalloffAngle(const Degree& spotFallofAngle) { mSpotFalloffAngle = spotFallofAngle; _markCoreDirty(); updateBounds(); }
-
-		/**
-		 * @brief	Returns world space bounds that completely encompass the lights area of influence.
-		 */
-		Sphere getBounds() const { return mBounds; }
-
-		/**
-		 * @brief	Returns the radiance of the light source. This is the value that should be used in lighting equations.
-		 *
-		 * @note	Ignores the light direction, therefore caller must ensure to properly handle non-uniform emitters like spot lights
-		 */
-		float getRadiance() const;
-
-		/**
-		 * @brief	Checks whether the light should be rendered or not.
-		 */
-		bool getIsActive() const { return mIsActive; }
-
-		/**
-		 * @brief	Sets whether the light should be rendered or not.
-		 */
-		void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
-
-		/**
-		 * @copydoc	CoreObject::markCoreDirty
-		 */
-		virtual void _markCoreDirty(LightDirtyFlag flag = LightDirtyFlag::Everything) { }
-
-	protected:
-		/**
-		 * @brief	Updates the internal bounds for the light. Call this whenever a property affecting
-		 *			the bounds changes.
-		 */
-		void updateBounds();
-
-		Vector3 mPosition; /**< World space position. */
-		Quaternion mRotation; /**< World space rotation. */
-
-		LightType mType; /**< Type of light that determines how are the rest of the parameters interpreted. */
-		bool mCastsShadows; /**< Determines whether the light casts shadows. */
-		Color mColor; /**< Color of the light. */
-		float mRange; /**< Cut off range for the light when rendering. */
-		float mIntensity; /**< Power of the light source. This will be luminous flux for point & spot lights, and radiance for directional lights. */
-		Degree mSpotAngle; /**< Total angle covered by a spot light. */
-		Degree mSpotFalloffAngle; /**< Spot light angle at which falloff starts. Must be smaller than total angle. */
-		bool mIsActive; /**< Whether the light should be rendered or not. */
-		Sphere mBounds; /**< Sphere that bounds the light area of influence. */
-	};
-
-	/**
-	 * @brief	Core thread usable version of a light.
-	 *
-	 * @see		LightInternalBase
-	 */
-	class BS_EXPORT LightInternalCore : public CoreObjectCore, public LightInternalBase
-	{
-	public:
-		~LightInternalCore();
-
-		/**
-		 * @brief	Sets an ID that can be used for uniquely identifying this object by the renderer.
-		 */
-		void setRendererId(UINT32 id) { mRendererId = id; }
-
-		/**
-		 * @brief	Retrieves an ID that can be used for uniquely identifying this object by the renderer.
-		 */
-		UINT32 getRendererId() const { return mRendererId; }
-
-	protected:
-		friend class LightInternal;
-
-		LightInternalCore(LightType type, Color color, float intensity, 
-			float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
-
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
-		void initialize() override;
-
-		/**
-		 * @copydoc	CoreObject::syncToCore
-		 */
-		void syncToCore(const CoreSyncData& data) override;
-
-		UINT32 mRendererId;
-	};
-
-	/**
-	 * @brief	Sim thread usable version of a light.
-	 *
-	 * @see		LightInternalBase
-	 */
-	class BS_EXPORT LightInternal : public IReflectable, public CoreObject, public LightInternalBase
-	{
-	public:
-		/**
-		 * @brief	Retrieves an implementation of a light usable only from the core thread.
-		 */
-		SPtr<LightInternalCore> getCore() const;
-
-		/**
-	     * @brief	Returns the hash value that can be used to identify if the internal data needs an update.
-		 *
-		 * @note	Internal method.
-		 */
-		UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
-
-		/**
-	     * @brief	Sets the hash value that can be used to identify if the internal data needs an update.
-		 *
-		 * @note	Internal method.
-		 */
-		void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
-
-		/**
-		 * @brief	Updates internal transform values from the specified scene object, in case that scene
-		 *			object's transform changed since the last call.
-		 *
-		 * @note	Assumes the same scene object will be provided every time.
-		 */
-		void _updateTransform(const HSceneObject& parent);
-
-		/**
-		 * @brief	Creates a new light with provided settings.
-		 *
-		 * @param	type				Type of light that determines how are the rest of the parameters interpreted.
-		 * @param	color				Color of the light.
-		 * @param	intensity			Power of the light source. This will be luminous flux for point & spot lights, 
-		 *								and radiance for directional lights.
-		 * @param	range				Cut off range for the light when rendering.
-		 * @param	castsShadows		Determines whether the light casts shadows.
-		 * @param	spotAngle			Total angle covered by a spot light.
-		 * @param	spotFalloffAngle	Spot light angle at which falloff starts. Must be smaller than total angle.
-		 */
-		static SPtr<LightInternal> create(LightType type = LightType::Point, Color color = Color::White,
-			float intensity = 100.0f, float range = 10.0f, bool castsShadows = false,
-			Degree spotAngle = Degree(45), Degree spotFalloffAngle = Degree(40));
-
-	protected:
-		LightInternal(LightType type, Color color, float intensity, float range, 
-			bool castsShadows, Degree spotAngle, Degree spotFalloffAngle);
-
-		/**
-		 * @copydoc	CoreObject::createCore
-		 */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/**
-		 * @copydoc	CoreObject::markCoreDirty
-		 */
-		void _markCoreDirty(LightDirtyFlag flag = LightDirtyFlag::Everything) override;
-
-		/**
-		 * @copydoc	CoreObject::syncToCore
-		 */
-		CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		/**
-		 * @brief	Creates a light with without initializing it. Used for serialization.
-		 */
-		static SPtr<LightInternal> createEmpty();
-
-		UINT32 mLastUpdateHash;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class LightInternalRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-
-	protected:
-		LightInternal(); // Serialization only
-	};
-}

+ 0 - 76
BansheeEngine/Include/BsLightInternalRTTI.h

@@ -1,76 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsRTTIType.h"
-#include "BsLightInternal.h"
-
-namespace BansheeEngine
-{
-	class BS_EXPORT LightInternalRTTI : public RTTIType <LightInternal, IReflectable, LightInternalRTTI>
-	{
-	private:
-		Vector3& getPosition(LightInternal* obj) { return obj->mPosition; }
-		void setPosition(LightInternal* obj, Vector3& position) { obj->mPosition = position; }
-
-		Quaternion& getRotation(LightInternal* obj) { return obj->mRotation; }
-		void setRotation(LightInternal* obj, Quaternion& rotation) { obj->mRotation = rotation; }
-
-		LightType& getType(LightInternal* obj) { return obj->mType; }
-		void setType(LightInternal* obj, LightType& type) { obj->mType = type; }
-
-		bool& getCastsShadow(LightInternal* obj) { return obj->mCastsShadows; }
-		void setCastsShadow(LightInternal* obj, bool& castsShadow) { obj->mCastsShadows = castsShadow; }
-
-		Color& getColor(LightInternal* obj) { return obj->mColor; }
-		void setColor(LightInternal* obj, Color& color) { obj->mColor = color; }
-
-		float& getRange(LightInternal* obj) { return obj->mRange; }
-		void setRange(LightInternal* obj, float& range) { obj->mRange = range; }
-
-		float& getIntensity(LightInternal* obj) { return obj->mIntensity; }
-		void setIntensity(LightInternal* obj, float& intensity) { obj->mIntensity = intensity; }
-
-		Degree& getSpotAngle(LightInternal* obj) { return obj->mSpotAngle; }
-		void setSpotAngle(LightInternal* obj, Degree& spotAngle) { obj->mSpotAngle = spotAngle; }
-
-		Degree& getSpotFalloffAngle(LightInternal* obj) { return obj->mSpotFalloffAngle; }
-		void setSpotFalloffAngle(LightInternal* obj, Degree& spotAngle) { obj->mSpotFalloffAngle = spotAngle; }
-	public:
-		LightInternalRTTI()
-		{
-			addPlainField("mPosition", 0, &LightInternalRTTI::getPosition, &LightInternalRTTI::setPosition);
-			addPlainField("mRotation", 1, &LightInternalRTTI::getRotation, &LightInternalRTTI::setRotation);
-			addPlainField("mType", 2, &LightInternalRTTI::getType, &LightInternalRTTI::setType);
-			addPlainField("mCastsShadow", 3, &LightInternalRTTI::getCastsShadow, &LightInternalRTTI::setCastsShadow);
-			addPlainField("mColor", 4, &LightInternalRTTI::getColor, &LightInternalRTTI::setColor);
-			addPlainField("mRange", 5, &LightInternalRTTI::getRange, &LightInternalRTTI::setRange);
-			addPlainField("mIntensity", 6, &LightInternalRTTI::getIntensity, &LightInternalRTTI::setIntensity);
-			addPlainField("mSpotAngle", 7, &LightInternalRTTI::getSpotAngle, &LightInternalRTTI::setSpotAngle);
-			addPlainField("mSpotFalloffAngle", 8, &LightInternalRTTI::getSpotFalloffAngle, &LightInternalRTTI::setSpotFalloffAngle);
-		}
-
-		virtual void onDeserializationEnded(IReflectable* obj) override
-		{
-			// Note: Since this is a CoreObject I should call initialize() right after deserialization,
-			// but since this specific type is used in Components we delay initialization until Component
-			// itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component 
-			// purposes (you'll need to call initialize manually).
-		}
-
-		virtual const String& getRTTIName() override
-		{
-			static String name = "LightInternal";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() override
-		{
-			return TID_LightInternal;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject() override
-		{
-			return LightInternal::createEmpty();
-		}
-	};
-}

+ 44 - 6
BansheeEngine/Include/BsLightRTTI.h

@@ -3,20 +3,58 @@
 #include "BsPrerequisites.h"
 #include "BsRTTIType.h"
 #include "BsLight.h"
-#include "BsGameObjectRTTI.h"
 
 namespace BansheeEngine
 {
-	class BS_EXPORT LightRTTI : public RTTIType <Light, Component, LightRTTI>
+	class BS_EXPORT LightRTTI : public RTTIType <Light, IReflectable, LightRTTI>
 	{
 	private:
-		SPtr<LightInternal> getInternal(Light* obj) { return obj->mInternal; }
-		void setInternal(Light* obj, SPtr<LightInternal> val) { obj->mInternal = val; }
+		Vector3& getPosition(Light* obj) { return obj->mPosition; }
+		void setPosition(Light* obj, Vector3& position) { obj->mPosition = position; }
 
+		Quaternion& getRotation(Light* obj) { return obj->mRotation; }
+		void setRotation(Light* obj, Quaternion& rotation) { obj->mRotation = rotation; }
+
+		LightType& getType(Light* obj) { return obj->mType; }
+		void setType(Light* obj, LightType& type) { obj->mType = type; }
+
+		bool& getCastsShadow(Light* obj) { return obj->mCastsShadows; }
+		void setCastsShadow(Light* obj, bool& castsShadow) { obj->mCastsShadows = castsShadow; }
+
+		Color& getColor(Light* obj) { return obj->mColor; }
+		void setColor(Light* obj, Color& color) { obj->mColor = color; }
+
+		float& getRange(Light* obj) { return obj->mRange; }
+		void setRange(Light* obj, float& range) { obj->mRange = range; }
+
+		float& getIntensity(Light* obj) { return obj->mIntensity; }
+		void setIntensity(Light* obj, float& intensity) { obj->mIntensity = intensity; }
+
+		Degree& getSpotAngle(Light* obj) { return obj->mSpotAngle; }
+		void setSpotAngle(Light* obj, Degree& spotAngle) { obj->mSpotAngle = spotAngle; }
+
+		Degree& getSpotFalloffAngle(Light* obj) { return obj->mSpotFalloffAngle; }
+		void setSpotFalloffAngle(Light* obj, Degree& spotAngle) { obj->mSpotFalloffAngle = spotAngle; }
 	public:
 		LightRTTI()
 		{
-			addReflectablePtrField("mInternal", 0, &LightRTTI::getInternal, &LightRTTI::setInternal);
+			addPlainField("mPosition", 0, &LightRTTI::getPosition, &LightRTTI::setPosition);
+			addPlainField("mRotation", 1, &LightRTTI::getRotation, &LightRTTI::setRotation);
+			addPlainField("mType", 2, &LightRTTI::getType, &LightRTTI::setType);
+			addPlainField("mCastsShadow", 3, &LightRTTI::getCastsShadow, &LightRTTI::setCastsShadow);
+			addPlainField("mColor", 4, &LightRTTI::getColor, &LightRTTI::setColor);
+			addPlainField("mRange", 5, &LightRTTI::getRange, &LightRTTI::setRange);
+			addPlainField("mIntensity", 6, &LightRTTI::getIntensity, &LightRTTI::setIntensity);
+			addPlainField("mSpotAngle", 7, &LightRTTI::getSpotAngle, &LightRTTI::setSpotAngle);
+			addPlainField("mSpotFalloffAngle", 8, &LightRTTI::getSpotFalloffAngle, &LightRTTI::setSpotFalloffAngle);
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj) override
+		{
+			// Note: Since this is a CoreObject I should call initialize() right after deserialization,
+			// but since this specific type is used in Components we delay initialization until Component
+			// itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component 
+			// purposes (you'll need to call initialize manually).
 		}
 
 		virtual const String& getRTTIName() override
@@ -32,7 +70,7 @@ namespace BansheeEngine
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
-			return GameObjectRTTI::createGameObject<Light>();
+			return Light::createEmpty();
 		}
 	};
 }

+ 6 - 6
BansheeEngine/Include/BsOverlayManager.h

@@ -22,7 +22,7 @@ namespace BansheeEngine
 		 */
 		struct OverlayComparer
 		{
-			bool operator() (const Overlay* const& a, const Overlay* const& b);
+			bool operator() (const COverlay* const& a, const COverlay* const& b);
 		};
 
 	public:
@@ -33,23 +33,23 @@ namespace BansheeEngine
 		void render(ViewportPtr& target, DrawList& drawList) const;
 
 	private:
-		friend class Overlay;
+		friend class COverlay;
 
 		/**
 		 * @brief	Attaches the specified overlay to the viewport.
 		 */
-		void attachOverlay(const Viewport* target, const Overlay* overlay);
+		void attachOverlay(const Viewport* target, const COverlay* overlay);
 
 		/**
 		 * @brief	Detaches the specified overlay from the viewport.
 		 */
-		void detachOverlay(const Viewport* target, const Overlay* overlay);
+		void detachOverlay(const Viewport* target, const COverlay* overlay);
 
 		/**
 		 * @brief	Detaches the specified overlay from all viewports.
 		 */
-		void detachOverlayFromAll(const Overlay* overlay);
+		void detachOverlayFromAll(const COverlay* overlay);
 
-		UnorderedMap<const Viewport*, Set<const Overlay*, OverlayComparer>> mOverlaysPerTarget;
+		UnorderedMap<const Viewport*, Set<const COverlay*, OverlayComparer>> mOverlaysPerTarget;
 	};
 }

+ 20 - 20
BansheeEngine/Include/BsPrerequisites.h

@@ -87,10 +87,10 @@ namespace BansheeEngine
 	class ProfilerOverlay;
 	class ProfilerOverlayInternal;
 	class DrawHelper;
-	class CameraHandler;
-	class RenderableHandler;
-	class CameraHandlerCore;
-	class RenderableHandlerCore;
+	class Camera;
+	class Renderable;
+	class CameraCore;
+	class RenderableCore;
 	class PlainText;
 	class ScriptCode;
 	class ScriptCodeImportOptions;
@@ -103,19 +103,19 @@ namespace BansheeEngine
 	class OverlayManager;
 
 	// Components
-	class Overlay;
-	class Renderable;
-	class Camera;
-	class Light;
+	class COverlay;
+	class CRenderable;
+	class CCamera;
+	class CLight;
 
 	typedef std::shared_ptr<TextSprite> TextSpritePtr;
 	typedef std::shared_ptr<SpriteTexture> SpriteTexturePtr;
-	typedef std::shared_ptr<Overlay> OverlayPtr;
+	typedef std::shared_ptr<COverlay> COverlayPtr;
+	typedef std::shared_ptr<CCamera> CCameraPtr;
+	typedef std::shared_ptr<CRenderable> CRenderablePtr;
+	typedef std::shared_ptr<GUIToggleGroup> GUIToggleGroupPtr;
 	typedef std::shared_ptr<Camera> CameraPtr;
 	typedef std::shared_ptr<Renderable> RenderablePtr;
-	typedef std::shared_ptr<GUIToggleGroup> GUIToggleGroupPtr;
-	typedef std::shared_ptr<CameraHandler> CameraHandlerPtr;
-	typedef std::shared_ptr<RenderableHandler> RenderableHandlerPtr;
 	typedef std::shared_ptr<InputConfiguration> InputConfigurationPtr;
 	typedef std::shared_ptr<PlainText> PlainTextPtr;
 	typedef std::shared_ptr<ScriptCode> ScriptCodePtr;
@@ -123,8 +123,8 @@ namespace BansheeEngine
 	typedef std::shared_ptr<GUIContextMenu> GUIContextMenuPtr;
 
 	typedef GameObjectHandle<GUIWidget> HGUIWidget;
-	typedef GameObjectHandle<Camera> HCamera;
-	typedef GameObjectHandle<Renderable> HRenderable;
+	typedef GameObjectHandle<CCamera> HCamera;
+	typedef GameObjectHandle<CRenderable> HRenderable;
 	typedef GameObjectHandle<ProfilerOverlay> HProfilerOverlay;
 
 	typedef ResourceHandle<SpriteTexture> HSpriteTexture;
@@ -143,18 +143,18 @@ namespace BansheeEngine
 	 */
 	enum TypeID_Banshee
 	{
-		TID_Camera = 30000,
-		TID_Renderable = 30001,
+		TID_CCamera = 30000,
+		TID_CRenderable = 30001,
 		TID_SpriteTexture = 30002,
-		TID_CameraHandler = 30003,
-		TID_RenderableHandler = 30004,
+		TID_Camera = 30003,
+		TID_Renderable = 30004,
 		TID_PlainText = 30005,
 		TID_ScriptCode = 30006,
 		TID_ScriptCodeImportOptions = 30007,
 		TID_GUIElementStyle = 30008,
 		TID_GUISkin = 30009,
 		TID_GUISkinEntry = 30010,
-		TID_LightInternal = 30011,
-		TID_Light = 30012
+		TID_Light = 30011,
+		TID_CLight = 30012
 	};
 }

+ 215 - 40
BansheeEngine/Include/BsRenderable.h

@@ -1,52 +1,149 @@
 #pragma once
 
 #include "BsPrerequisites.h"
-#include "BsRenderableHandler.h"
+#include "BsIReflectable.h"
+#include "BsCoreObject.h"
+#include "BsIResourceListener.h"
 #include "BsBounds.h"
-#include "BsComponent.h"
+#include "BsAABox.h"
 
 namespace BansheeEngine
 {
 	/**
-	 * @copydoc	RenderableHandler
+	 * @brief	Signals which portion of a Renderable is dirty.
 	 */
-	class BS_EXPORT Renderable : public Component
+	enum class RenderableDirtyFlag
 	{
+		Transform = 0x01,
+		Everything = 0x02
+	};
+
+	/**
+	 * @brief	Renderable represents any visible object in the scene. It has a mesh,
+	 *			bounds and a set of materials. Renderer will render any Renderable objects
+	 *			visible by the camera.
+	 */
+	template<bool Core>
+	class BS_EXPORT TRenderable
+	{
+		template<bool Core> struct TMeshType {};
+		template<> struct TMeshType < false > { typedef HMesh Type; };
+		template<> struct TMeshType < true > { typedef SPtr<MeshCore> Type; };
+
+		template<bool Core> struct TMaterialType {};
+		template<> struct TMaterialType < false > { typedef HMaterial Type; };
+		template<> struct TMaterialType < true > { typedef SPtr<MaterialCore> Type; };
+
+		typedef typename TMeshType<Core>::Type MeshType;
+		typedef typename TMaterialType<Core>::Type MaterialType;
+
 	public:
+		TRenderable();
+		virtual ~TRenderable();
+
+		/**
+		 * @brief	Sets the mesh to render. All sub-meshes of the mesh will be rendered,
+		 *			and you may set individual materials for each sub-mesh.
+		 */
+		void setMesh(const MeshType& mesh);
+
+		/**
+		 * @brief	Sets a material that will be used for rendering a sub-mesh with
+		 *			the specified index. If a sub-mesh doesn't have a specific material set
+		 *			then the primary material will be used.
+		 */
+		void setMaterial(UINT32 idx, const MaterialType& material);
+
+		/**
+		 * @brief	Sets the primary material to use for rendering. Any sub-mesh that
+		 *			doesn't have an explicit material set will use this material.
+		 *
+		 * @note	This is equivalent to calling setMaterial(0, material).
+		 */
+		void setMaterial(const MaterialType& material);
+
+		/**
+		 * @brief	Sets the layer bitfield. Renderable layer must match camera layer
+		 *			in order for the camera to render the component.
+		 */
+		void setLayer(UINT64 layer);
+
+		/**
+		 * @brief	Sets the transform matrix that is applied to the object
+		 *			when its being rendered.
+		 */
+		void setTransform(const Matrix4& transform);
+
+		/**
+		 * @brief	Sets the world position of the renderable.
+		 */
+		void setPosition(const Vector3& position);
+
 		/**
-		 * @copydoc	RenderableHandler::setMesh
+		 * @brief	Sets whether the object should be rendered or not.
 		 */
-		void setMesh(HMesh mesh) { mInternal->setMesh(mesh); }
+		void setIsActive(bool active);
 
 		/**
-		 * @copydoc	RenderableHandler::setMaterial
+		 * @brief	Gets the layer bitfield. Renderable layer must match camera layer
+		 *			in order for the camera to render the component.
 		 */
-		void setMaterial(UINT32 idx, HMaterial material) { mInternal->setMaterial(idx, material); }
+		UINT64 getLayer() const { return mLayer; }
 
 		/**
-		 * @copydoc	RenderableHandler::setMaterial
+		 * @brief	Returns the mesh used for rendering.
 		 */
-		void setMaterial(HMaterial material) { mInternal->setMaterial(material); }
+		MeshType getMesh() const { return mMesh; }
 
 		/**
-		 * @copydoc	RenderableHandler::setLayer
+		 * @brief	Returns the material used for rendering a sub-mesh with
+		 *			the specified index.
 		 */
-		void setLayer(UINT64 layer) { mInternal->setLayer(layer); }
+		MaterialType getMaterial(UINT32 idx) const { return mMaterials[idx]; }
 
 		/**
-		 * @copydoc	RenderableHandler::getLayer
+		 * @brief	Returns the transform matrix that is applied to the object
+		 *			when its being rendered.
 		 */
-		UINT64 getLayer() const { return mInternal->getLayer(); }
+		Matrix4 getTransform() const { return mTransform; }
 
 		/**
-		 * @copydoc	RenderableHandler::getMesh
+		 * @brief	Gets whether the object should be rendered or not.
 		 */
-		HMesh getMesh() const { return mInternal->getMesh(); }
+		bool getIsActive() const { return mIsActive; }
 
 		/**
-		 * @copydoc	RenderableHandler::getMaterial
+		 * @brief	Retrieves the world position of the renderable.
 		 */
-		HMaterial getMaterial(UINT32 idx) const { return mInternal->getMaterial(idx); }
+		Vector3 getPosition() const { return mPosition; }
+
+	protected:
+		/**
+		 * @copydoc	CoreObject::markCoreDirty
+		 */
+		virtual void _markCoreDirty(RenderableDirtyFlag flag = RenderableDirtyFlag::Everything) { }
+
+		/**
+		 * @copydoc	IResourceListener::markResourcesDirty
+		 */
+		virtual void _markResourcesDirty() { }
+
+		MeshType mMesh;
+		Vector<MaterialType> mMaterials;
+		UINT64 mLayer;
+		Vector<AABox> mWorldBounds;
+		Vector3 mPosition;
+		Matrix4 mTransform;
+		bool mIsActive;
+	};
+
+	/**
+	 * @copydoc	TRenderable
+	 */
+	class BS_EXPORT RenderableCore : public CoreObjectCore, public TRenderable<true>
+	{
+	public:
+		~RenderableCore();
 
 		/**
 		 * @brief	Gets world bounds of the mesh rendered by this object.
@@ -54,43 +151,124 @@ namespace BansheeEngine
 		Bounds getBounds() const;
 
 		/**
-		 * @brief	Returns the internal renderable handler that is used for
-		 *			majority of operations by this component.
+		 * @brief	Returns the type that controls how is this object rendered.
 		 */
-		RenderableHandlerPtr _getHandler() const { return mInternal; }
+		RenderableType getRenderableType() const { return RenType_LitTextured; }
 
-	private:
 		/**
-		 * @brief	Updates the world transform if the SceneObject transform changed.
+		 * @brief	Sets an ID that can be used for uniquely identifying this handler by the renderer.
 		 */
-		void updateTransform() const;
+		void setRendererId(UINT32 id) { mRendererId = id; }
 
-		mutable RenderableHandlerPtr mInternal;
-
-		/************************************************************************/
-		/* 							COMPONENT OVERRIDES                    		*/
-		/************************************************************************/
+		/**
+		 * @brief	Retrieves an ID that can be used for uniquely identifying this handler by the renderer.
+		 */
+		UINT32 getRendererId() const { return mRendererId; }
 
 	protected:
-		friend class SceneObject;
+		friend class Renderable;
 
-		Renderable(const HSceneObject& parent);
+		RenderableCore();
 
 		/**
-		 * @copydoc	Component::onInitialized
+		 * @copydoc	CoreObject::initialize
 		 */
-		void onInitialized() override;
+		void initialize() override;
 
 		/**
-		 * @copydoc	Component::onDestroyed
+		 * @copydoc	CoreObject::syncToCore
 		 */
-		void onDestroyed() override;
+		void syncToCore(const CoreSyncData& data) override;
+
+		UINT32 mRendererId;
+	};
 
+	/**
+	 * @copydoc	TRenderable
+	 */
+	class BS_EXPORT Renderable : public IReflectable, public CoreObject, public TRenderable<false>, public IResourceListener
+	{
 	public:
 		/**
-		 * @copydoc	Component::update
+		 * @brief	Gets world bounds of the mesh rendered by this object.
+		 */
+		Bounds getBounds() const;
+
+		/**
+		 * @brief	Retrieves an implementation of a renderable handler usable only from the
+		 *			core thread.
+		 */
+		SPtr<RenderableCore> getCore() const;
+
+		/**
+	     * @brief	Returns the hash value that can be used to identify if the internal data needs an update.
+		 */
+		UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
+
+		/**
+	     * @brief	Sets the hash value that can be used to identify if the internal data needs an update.
+		 */
+		void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
+
+		/**
+		 * @brief	Creates a new renderable handler instance.
+		 */
+		static RenderablePtr create();
+
+	protected:
+		Renderable();
+
+		/**
+		 * @copydoc	CoreObject::createCore
+		 */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		/**
+		 * @copydoc	CoreObject::markCoreDirty
+		 */
+		void _markCoreDirty(RenderableDirtyFlag flag = RenderableDirtyFlag::Everything) override;
+
+		/**
+		 * @copydoc	IResourceListener::markResourcesDirty
+		 */
+		void _markResourcesDirty() override;
+
+		/**
+		 * @copydoc	CoreObject::syncToCore
+		 */
+		CoreSyncData syncToCore(FrameAlloc* allocator) override;
+
+		/**
+		 * @copydoc	CoreObject::getCoreDependencies
+		 */
+		void getCoreDependencies(Vector<SPtr<CoreObject>>& dependencies) override;
+
+		/**
+		 * @copydoc	IResourceListener::getListenerResources
+		 */
+		void getListenerResources(Vector<HResource>& resources) override;
+
+		/**
+		 * @copydoc IResourceListener::notifyResourceLoaded
 		 */
-		virtual void update() override;
+		void notifyResourceLoaded(const HResource& resource) override { markCoreDirty(); }
+
+		/**
+		 * @copydoc IResourceListener::notifyResourceDestroyed
+		 */
+		void notifyResourceDestroyed(const HResource& resource) override { markCoreDirty(); }
+
+		/**
+		 * @copydoc IResourceListener::notifyResourceChanged
+		 */
+		void notifyResourceChanged(const HResource& resource) override { markCoreDirty(); }
+
+		/**
+		 * @brief	Creates a new renderable handler instance without initializing it.
+		 */
+		static RenderablePtr createEmpty();
+
+		UINT32 mLastUpdateHash;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -99,8 +277,5 @@ namespace BansheeEngine
 		friend class RenderableRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		virtual RTTITypeBase* getRTTI() const override;
-
-	protected:
-		Renderable() {} // Serialization only
 	};
 }

+ 0 - 281
BansheeEngine/Include/BsRenderableHandler.h

@@ -1,281 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsIReflectable.h"
-#include "BsCoreObject.h"
-#include "BsIResourceListener.h"
-#include "BsBounds.h"
-#include "BsAABox.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Signals which portion of a RenderableHandler is dirty.
-	 */
-	enum class RenderableDirtyFlag
-	{
-		Transform = 0x01,
-		Everything = 0x02
-	};
-
-	/**
-	 * @brief	Renderable represents any visible object in the scene. It has a mesh,
-	 *			bounds and a set of materials. Renderer will render any Renderable objects
-	 *			visible by the camera.
-	 */
-	template<bool Core>
-	class BS_EXPORT TRenderableHandler
-	{
-		template<bool Core> struct TMeshType {};
-		template<> struct TMeshType < false > { typedef HMesh Type; };
-		template<> struct TMeshType < true > { typedef SPtr<MeshCore> Type; };
-
-		template<bool Core> struct TMaterialType {};
-		template<> struct TMaterialType < false > { typedef HMaterial Type; };
-		template<> struct TMaterialType < true > { typedef SPtr<MaterialCore> Type; };
-
-		typedef typename TMeshType<Core>::Type MeshType;
-		typedef typename TMaterialType<Core>::Type MaterialType;
-
-	public:
-		TRenderableHandler();
-		virtual ~TRenderableHandler();
-
-		/**
-		 * @brief	Sets the mesh to render. All sub-meshes of the mesh will be rendered,
-		 *			and you may set individual materials for each sub-mesh.
-		 */
-		void setMesh(const MeshType& mesh);
-
-		/**
-		 * @brief	Sets a material that will be used for rendering a sub-mesh with
-		 *			the specified index. If a sub-mesh doesn't have a specific material set
-		 *			then the primary material will be used.
-		 */
-		void setMaterial(UINT32 idx, const MaterialType& material);
-
-		/**
-		 * @brief	Sets the primary material to use for rendering. Any sub-mesh that
-		 *			doesn't have an explicit material set will use this material.
-		 *
-		 * @note	This is equivalent to calling setMaterial(0, material).
-		 */
-		void setMaterial(const MaterialType& material);
-
-		/**
-		 * @brief	Sets the layer bitfield. Renderable layer must match camera layer
-		 *			in order for the camera to render the component.
-		 */
-		void setLayer(UINT64 layer);
-
-		/**
-		 * @brief	Sets the transform matrix that is applied to the object
-		 *			when its being rendered.
-		 */
-		void setTransform(const Matrix4& transform);
-
-		/**
-		 * @brief	Sets the world position of the renderable.
-		 */
-		void setPosition(const Vector3& position);
-
-		/**
-		 * @brief	Sets whether the object should be rendered or not.
-		 */
-		void setIsActive(bool active);
-
-		/**
-		 * @brief	Gets the layer bitfield. Renderable layer must match camera layer
-		 *			in order for the camera to render the component.
-		 */
-		UINT64 getLayer() const { return mLayer; }
-
-		/**
-		 * @brief	Returns the mesh used for rendering.
-		 */
-		MeshType getMesh() const { return mMesh; }
-
-		/**
-		 * @brief	Returns the material used for rendering a sub-mesh with
-		 *			the specified index.
-		 */
-		MaterialType getMaterial(UINT32 idx) const { return mMaterials[idx]; }
-
-		/**
-		 * @brief	Returns the transform matrix that is applied to the object
-		 *			when its being rendered.
-		 */
-		Matrix4 getTransform() const { return mTransform; }
-
-		/**
-		 * @brief	Gets whether the object should be rendered or not.
-		 */
-		bool getIsActive() const { return mIsActive; }
-
-		/**
-		 * @brief	Retrieves the world position of the renderable.
-		 */
-		Vector3 getPosition() const { return mPosition; }
-
-	protected:
-		/**
-		 * @copydoc	CoreObject::markCoreDirty
-		 */
-		virtual void _markCoreDirty(RenderableDirtyFlag flag = RenderableDirtyFlag::Everything) { }
-
-		/**
-		 * @copydoc	IResourceListener::markResourcesDirty
-		 */
-		virtual void _markResourcesDirty() { }
-
-		MeshType mMesh;
-		Vector<MaterialType> mMaterials;
-		UINT64 mLayer;
-		Vector<AABox> mWorldBounds;
-		Vector3 mPosition;
-		Matrix4 mTransform;
-		bool mIsActive;
-	};
-
-	/**
-	 * @copydoc	TRenderableHandler
-	 */
-	class BS_EXPORT RenderableHandlerCore : public CoreObjectCore, public TRenderableHandler<true>
-	{
-	public:
-		~RenderableHandlerCore();
-
-		/**
-		 * @brief	Gets world bounds of the mesh rendered by this object.
-		 */
-		Bounds getBounds() const;
-
-		/**
-		 * @brief	Returns the type that controls how is this object rendered.
-		 */
-		RenderableType getRenderableType() const { return RenType_LitTextured; }
-
-		/**
-		 * @brief	Sets an ID that can be used for uniquely identifying this handler by the renderer.
-		 */
-		void setRendererId(UINT32 id) { mRendererId = id; }
-
-		/**
-		 * @brief	Retrieves an ID that can be used for uniquely identifying this handler by the renderer.
-		 */
-		UINT32 getRendererId() const { return mRendererId; }
-
-	protected:
-		friend class RenderableHandler;
-
-		RenderableHandlerCore();
-
-		/**
-		 * @copydoc	RenderableHandlerCore::initialize
-		 */
-		void initialize() override;
-
-		/**
-		 * @copydoc	CoreObject::syncToCore
-		 */
-		void syncToCore(const CoreSyncData& data) override;
-
-		UINT32 mRendererId;
-	};
-
-	/**
-	 * @copydoc	TRenderableHandler
-	 */
-	class BS_EXPORT RenderableHandler : public IReflectable, public CoreObject, public TRenderableHandler<false>, public IResourceListener
-	{
-	public:
-		/**
-		 * @brief	Gets world bounds of the mesh rendered by this object.
-		 */
-		Bounds getBounds() const;
-
-		/**
-		 * @brief	Retrieves an implementation of a renderable handler usable only from the
-		 *			core thread.
-		 */
-		SPtr<RenderableHandlerCore> getCore() const;
-
-		/**
-	     * @brief	Returns the hash value that can be used to identify if the internal data needs an update.
-		 */
-		UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
-
-		/**
-	     * @brief	Sets the hash value that can be used to identify if the internal data needs an update.
-		 */
-		void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
-
-		/**
-		 * @brief	Creates a new renderable handler instance.
-		 */
-		static RenderableHandlerPtr create();
-
-	protected:
-		RenderableHandler();
-
-		/**
-		 * @copydoc	CoreObject::createCore
-		 */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/**
-		 * @copydoc	CoreObject::markCoreDirty
-		 */
-		void _markCoreDirty(RenderableDirtyFlag flag = RenderableDirtyFlag::Everything) override;
-
-		/**
-		 * @copydoc	IResourceListener::markResourcesDirty
-		 */
-		void _markResourcesDirty() override;
-
-		/**
-		 * @copydoc	CoreObject::syncToCore
-		 */
-		CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		/**
-		 * @copydoc	CoreObject::getCoreDependencies
-		 */
-		void getCoreDependencies(Vector<SPtr<CoreObject>>& dependencies) override;
-
-		/**
-		 * @copydoc	IResourceListener::getListenerResources
-		 */
-		void getListenerResources(Vector<HResource>& resources) override;
-
-		/**
-		 * @copydoc IResourceListener::notifyResourceLoaded
-		 */
-		void notifyResourceLoaded(const HResource& resource) override { markCoreDirty(); }
-
-		/**
-		 * @copydoc IResourceListener::notifyResourceDestroyed
-		 */
-		void notifyResourceDestroyed(const HResource& resource) override { markCoreDirty(); }
-
-		/**
-		 * @copydoc IResourceListener::notifyResourceChanged
-		 */
-		void notifyResourceChanged(const HResource& resource) override { markCoreDirty(); }
-
-		/**
-		 * @brief	Creates a new renderable handler instance without initializing it.
-		 */
-		static RenderableHandlerPtr createEmpty();
-
-		UINT32 mLastUpdateHash;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class RenderableHandlerRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
-}

+ 0 - 56
BansheeEngine/Include/BsRenderableHandlerRTTI.h

@@ -1,56 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsRTTIType.h"
-#include "BsRenderableHandler.h"
-
-namespace BansheeEngine
-{
-	class BS_EXPORT RenderableHandlerRTTI : public RTTIType<RenderableHandler, IReflectable, RenderableHandlerRTTI>
-	{
-	private:
-		HMesh& getMesh(RenderableHandler* obj) { return obj->mMesh; }
-		void setMesh(RenderableHandler* obj, HMesh& val) { obj->mMesh = val; }
-
-		UINT64& getLayer(RenderableHandler* obj) { return obj->mLayer; }
-		void setLayer(RenderableHandler* obj, UINT64& val) { obj->mLayer = val; }
-
-		HMaterial& getMaterial(RenderableHandler* obj, UINT32 idx) { return obj->mMaterials[idx]; }
-		void setMaterial(RenderableHandler* obj, UINT32 idx, HMaterial& val) { obj->setMaterial(idx, val); }
-		UINT32 getNumMaterials(RenderableHandler* obj) { return (UINT32)obj->mMaterials.size(); }
-		void setNumMaterials(RenderableHandler* obj, UINT32 num) { obj->mMaterials.resize(num); }
-
-	public:
-		RenderableHandlerRTTI()
-		{
-			addReflectableField("mMesh", 0, &RenderableHandlerRTTI::getMesh, &RenderableHandlerRTTI::setMesh);
-			addPlainField("mLayer", 1, &RenderableHandlerRTTI::getLayer, &RenderableHandlerRTTI::setLayer);
-			addReflectableArrayField("mMaterials", 2, &RenderableHandlerRTTI::getMaterial, 
-				&RenderableHandlerRTTI::getNumMaterials, &RenderableHandlerRTTI::setMaterial, &RenderableHandlerRTTI::setNumMaterials);
-		}
-
-		virtual void onDeserializationEnded(IReflectable* obj) override
-		{
-			// Note: Since this is a CoreObject I should call initialize() right after deserialization,
-			// but since this specific type is used in Components we delay initialization until Component
-			// itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component 
-			// purposes (you'll need to call initialize manually).
-		}
-
-		virtual const String& getRTTIName() override
-		{
-			static String name = "RenderableHandler";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() override
-		{
-			return TID_RenderableHandler;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject() override
-		{
-			return RenderableHandler::createEmpty();
-		}
-	};
-}

+ 27 - 9
BansheeEngine/Include/BsRenderableRTTI.h

@@ -3,36 +3,54 @@
 #include "BsPrerequisites.h"
 #include "BsRTTIType.h"
 #include "BsRenderable.h"
-#include "BsGameObjectRTTI.h"
 
 namespace BansheeEngine
 {
-	class BS_EXPORT RenderableRTTI : public RTTIType<Renderable, Component, RenderableRTTI>
+	class BS_EXPORT RenderableRTTI : public RTTIType<Renderable, IReflectable, RenderableRTTI>
 	{
 	private:
-		RenderableHandlerPtr getInternal(Renderable* obj) { return obj->mInternal; }
-		void setInternal(Renderable* obj, RenderableHandlerPtr val) { obj->mInternal = val; }
+		HMesh& getMesh(Renderable* obj) { return obj->mMesh; }
+		void setMesh(Renderable* obj, HMesh& val) { obj->mMesh = val; }
+
+		UINT64& getLayer(Renderable* obj) { return obj->mLayer; }
+		void setLayer(Renderable* obj, UINT64& val) { obj->mLayer = val; }
+
+		HMaterial& getMaterial(Renderable* obj, UINT32 idx) { return obj->mMaterials[idx]; }
+		void setMaterial(Renderable* obj, UINT32 idx, HMaterial& val) { obj->setMaterial(idx, val); }
+		UINT32 getNumMaterials(Renderable* obj) { return (UINT32)obj->mMaterials.size(); }
+		void setNumMaterials(Renderable* obj, UINT32 num) { obj->mMaterials.resize(num); }
 
 	public:
 		RenderableRTTI()
 		{
-			addReflectablePtrField("mInternal", 0, &RenderableRTTI::getInternal, &RenderableRTTI::setInternal);
+			addReflectableField("mMesh", 0, &RenderableRTTI::getMesh, &RenderableRTTI::setMesh);
+			addPlainField("mLayer", 1, &RenderableRTTI::getLayer, &RenderableRTTI::setLayer);
+			addReflectableArrayField("mMaterials", 2, &RenderableRTTI::getMaterial, 
+				&RenderableRTTI::getNumMaterials, &RenderableRTTI::setMaterial, &RenderableRTTI::setNumMaterials);
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj) override
+		{
+			// Note: Since this is a CoreObject I should call initialize() right after deserialization,
+			// but since this specific type is used in Components we delay initialization until Component
+			// itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component 
+			// purposes (you'll need to call initialize manually).
 		}
 
-		virtual const String& getRTTIName()
+		virtual const String& getRTTIName() override
 		{
 			static String name = "Renderable";
 			return name;
 		}
 
-		virtual UINT32 getRTTIId()
+		virtual UINT32 getRTTIId() override
 		{
 			return TID_Renderable;
 		}
 
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
-			return GameObjectRTTI::createGameObject<Renderable>();
+			return Renderable::createEmpty();
 		}
 	};
 }

+ 6 - 6
BansheeEngine/Include/BsRenderer.h

@@ -19,7 +19,7 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		virtual void _notifyRenderableAdded(RenderableHandlerCore* renderable) { }
+		virtual void _notifyRenderableAdded(RenderableCore* renderable) { }
 
 		/**
 		 * @brief	Called whenever a renderable is updated.
@@ -27,7 +27,7 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		virtual void _notifyRenderableUpdated(RenderableHandlerCore* renderable) { }
+		virtual void _notifyRenderableUpdated(RenderableCore* renderable) { }
 
 		/**
 		 * @brief	Called whenever a renderable is destroyed.
@@ -35,7 +35,7 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		virtual void _notifyRenderableRemoved(RenderableHandlerCore* renderable) { }
+		virtual void _notifyRenderableRemoved(RenderableCore* renderable) { }
 
 		/**
 		 * @brief	Called whenever a new light is created.
@@ -43,7 +43,7 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		virtual void _notifyLightAdded(LightInternalCore* light) { }
+		virtual void _notifyLightAdded(LightCore* light) { }
 
 		/**
 		 * @brief	Called whenever a light is updated.
@@ -51,7 +51,7 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		virtual void _notifyLightUpdated(LightInternalCore* light) { }
+		virtual void _notifyLightUpdated(LightCore* light) { }
 
 		/**
 		 * @brief	Called whenever a light is destroyed.
@@ -59,7 +59,7 @@ namespace BansheeEngine
 		 * @note	Core thread.
 		 *			Internal method.
 		 */
-		virtual void _notifyLightRemoved(LightInternalCore* light) { }
+		virtual void _notifyLightRemoved(LightCore* light) { }
 	};
 
 	/**

+ 17 - 17
BansheeEngine/Include/BsSceneManager.h

@@ -12,11 +12,11 @@ namespace BansheeEngine
 	{
 		SceneCameraData() { }
 
-		SceneCameraData(const CameraHandlerPtr& camera, const HSceneObject& sceneObject)
+		SceneCameraData(const CameraPtr& camera, const HSceneObject& sceneObject)
 			:camera(camera), sceneObject(sceneObject)
 		{ }
 
-		CameraHandlerPtr camera;
+		CameraPtr camera;
 		HSceneObject sceneObject;
 	};
 
@@ -27,11 +27,11 @@ namespace BansheeEngine
 	{
 		SceneRenderableData() { }
 
-		SceneRenderableData(const RenderableHandlerPtr& renderable, const HSceneObject& sceneObject)
+		SceneRenderableData(const RenderablePtr& renderable, const HSceneObject& sceneObject)
 			:renderable(renderable), sceneObject(sceneObject)
 		{ }
 
-		RenderableHandlerPtr renderable;
+		RenderablePtr renderable;
 		HSceneObject sceneObject;
 	};
 
@@ -42,11 +42,11 @@ namespace BansheeEngine
 	{
 		SceneLightData() { }
 
-		SceneLightData(const SPtr<LightInternal>& light, const HSceneObject& sceneObject)
+		SceneLightData(const SPtr<Light>& light, const HSceneObject& sceneObject)
 			:light(light), sceneObject(sceneObject)
 		{ }
 
-		SPtr<LightInternal> light;
+		SPtr<Light> light;
 		HSceneObject sceneObject;
 	};
 
@@ -79,56 +79,56 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		const Map<CameraHandler*, SceneCameraData>& getAllCameras() const { return mCameras; }
+		const Map<Camera*, SceneCameraData>& getAllCameras() const { return mCameras; }
 
 		/**
 		 * @brief	Returns all renderables in the scene.
 		 *
 		 * @note	Internal method.
 		 */
-		const Map<RenderableHandler*, SceneRenderableData>& getAllRenderables() const { return mRenderables; }
+		const Map<Renderable*, SceneRenderableData>& getAllRenderables() const { return mRenderables; }
 
 		/**
 		 * @brief	Notifies the scene manager that a new renderable was created.
 		 * 
 		 * @note	Internal method.
 		 */
-		void _registerRenderable(const SPtr<RenderableHandler>& renderable, const HSceneObject& so);
+		void _registerRenderable(const SPtr<Renderable>& renderable, const HSceneObject& so);
 
 		/**
 		 * @brief	Notifies the scene manager that a renderable was removed.
 		 *
 		 * @note	Internal method.
 		 */
-		void _unregisterRenderable(const SPtr<RenderableHandler>& renderable);
+		void _unregisterRenderable(const SPtr<Renderable>& renderable);
 
 		/**
 		 * @brief	Notifies the scene manager that a new camera was created.
 		 *
 		 * @note	Internal method.
 		 */
-		void _registerCamera(const SPtr<CameraHandler>& camera, const HSceneObject& so);
+		void _registerCamera(const SPtr<Camera>& camera, const HSceneObject& so);
 
 		/**
 		 * @brief	Notifies the scene manager that a camera was removed.
 		 *
 		 * @note	Internal method.
 		 */
-		void _unregisterCamera(const SPtr<CameraHandler>& camera);
+		void _unregisterCamera(const SPtr<Camera>& camera);
 
 		/**
 		 * @brief	Notifies the scene manager that a new light was created.
 		 *
 		 * @note	Internal method.
 		 */
-		void _registerLight(const SPtr<LightInternal>& light, const HSceneObject& so);
+		void _registerLight(const SPtr<Light>& light, const HSceneObject& so);
 
 		/**
 		 * @brief	Notifies the scene manager that a light was removed.
 		 *
 		 * @note	Internal method.
 		 */
-		void _unregisterLight(const SPtr<LightInternal>& light);
+		void _unregisterLight(const SPtr<Light>& light);
 
 		/**
 		 * @copydoc	CoreSceneManager::_updateCoreObjectTransforms
@@ -146,9 +146,9 @@ namespace BansheeEngine
 		static SceneManager* instancePtr();
 
 	private:
-		Map<CameraHandler*, SceneCameraData> mCameras;
-		Map<RenderableHandler*, SceneRenderableData> mRenderables;
-		Map<LightInternal*, SceneLightData> mLights;
+		Map<Camera*, SceneCameraData> mCameras;
+		Map<Renderable*, SceneRenderableData> mRenderables;
+		Map<Light*, SceneLightData> mLights;
 
 		volatile static InitOnStart DoInitOnStart;
 	};

+ 0 - 31
BansheeEngine/Include/BsUpdateCallback.h

@@ -1,31 +0,0 @@
-#include "BsPrerequisites.h"
-#include "BsComponent.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Component that allows external objects to subscribe to
-	 *			the standard Component update method.
-	 */
-	class BS_EXPORT UpdateCallback : public Component
-	{
-	public:
-		~UpdateCallback();
-
-		/**
-		 * @copydoc	Component::update
-		 */
-		virtual void update();
-
-		/**
-		 * @brief	Called whenever update() is called.
-		 */
-		Event<void()> onUpdate;
-
-	protected:
-		friend class SceneObject;
-
-		UpdateCallback(const HSceneObject& parent);
-	};
-}

+ 92 - 0
BansheeEngine/Source/BsCCamera.cpp

@@ -0,0 +1,92 @@
+#include "BsCCamera.h"
+#include "BsCCameraRTTI.h"
+#include "BsMath.h"
+#include "BsMatrix3.h"
+#include "BsVector2.h"
+#include "BsAABox.h"
+#include "BsSphere.h"
+#include "BsHardwareBufferManager.h"
+#include "BsVertexBuffer.h"
+#include "BsIndexBuffer.h"
+#include "BsException.h"
+#include "BsRenderAPI.h"
+#include "BsSceneObject.h"
+#include "BsDebug.h"
+#include "BsSceneManager.h"
+
+namespace BansheeEngine 
+{
+	CCamera::CCamera(const HSceneObject& parent, RenderTargetPtr target, float left, float top, float width, float height)
+		: Component(parent), mTarget(target), mLeft(left), mTop(top), mWidth(width), mHeight(height)
+    {
+		setName("Camera");
+    }
+
+    CCamera::~CCamera()
+    {
+		mInternal->destroy();
+    }
+
+	ConvexVolume CCamera::getWorldFrustum() const
+	{
+		const Vector<Plane>& frustumPlanes = getFrustum().getPlanes();
+		Matrix4 worldMatrix = SO()->getWorldTfrm();
+
+		Vector<Plane> worldPlanes(frustumPlanes.size());
+		UINT32 i = 0;
+		for (auto& plane : frustumPlanes)
+		{
+			worldPlanes[i] = worldMatrix.multiplyAffine(plane);
+			i++;
+		}
+
+		return ConvexVolume(worldPlanes);
+	}
+
+	void CCamera::updateView() const
+	{
+		UINT32 curHash = SO()->getTransformHash();
+		if (curHash != mInternal->_getLastModifiedHash())
+		{
+			mInternal->setPosition(SO()->getWorldPosition());
+			mInternal->setRotation(SO()->getWorldRotation());
+
+			mInternal->_setLastModifiedHash(curHash);
+		}
+	}
+
+	void CCamera::update() 
+	{
+
+	}
+
+	void CCamera::onInitialized()
+	{
+		// If mInternal already exists this means this object was deserialized,
+		// so all we need to do is initialize it.
+		if (mInternal != nullptr)
+			mInternal->initialize();
+		else
+		{
+			mInternal = Camera::create(mTarget, mLeft, mTop, mWidth, mHeight);
+			mTarget = nullptr;
+		}
+
+		gSceneManager()._registerCamera(mInternal, SO());
+	}
+
+	void CCamera::onDestroyed()
+	{
+		gSceneManager()._unregisterCamera(mInternal);
+	}
+
+	RTTITypeBase* CCamera::getRTTIStatic()
+	{
+		return CCameraRTTI::instance();
+	}
+
+	RTTITypeBase* CCamera::getRTTI() const
+	{
+		return CCamera::getRTTIStatic();
+	}
+} 

+ 56 - 0
BansheeEngine/Source/BsCLight.cpp

@@ -0,0 +1,56 @@
+#include "BsCLight.h"
+#include "BsCLightRTTI.h"
+#include "BsSceneManager.h"
+
+namespace BansheeEngine
+{
+	CLight::CLight(const HSceneObject& parent, LightType type, Color color,
+		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
+		: Component(parent), mType(type), mColor(color), mIntensity(intensity), mRange(range),
+		mCastsShadows(castsShadows), mSpotAngle(spotAngle), mSpotFalloffAngle(spotFalloffAngle)
+	{
+		setName("Light");
+	}
+
+	CLight::~CLight()
+	{
+		mInternal->destroy();
+	}
+
+	Sphere CLight::getBounds() const
+	{
+		mInternal->_updateTransform(SO());
+
+		return mInternal->getBounds();
+	}
+
+	void CLight::onInitialized()
+	{
+		// If mInternal already exists this means this object was deserialized,
+		// so all we need to do is initialize it.
+		if (mInternal != nullptr)
+			mInternal->initialize();
+		else
+		{
+			mInternal = Light::create(mType, mColor, mIntensity,
+				mRange, mCastsShadows, mSpotAngle, mSpotFalloffAngle);
+		}
+
+		gSceneManager()._registerLight(mInternal, sceneObject());
+	}
+
+	void CLight::onDestroyed()
+	{
+		gSceneManager()._unregisterLight(mInternal);
+	}
+	
+	RTTITypeBase* CLight::getRTTIStatic()
+	{
+		return CLightRTTI::instance();
+	}
+
+	RTTITypeBase* CLight::getRTTI() const
+	{
+		return CLight::getRTTIStatic();
+	}
+}

+ 22 - 22
BansheeEngine/Source/BsOverlay.cpp → BansheeEngine/Source/BsCOverlay.cpp

@@ -1,23 +1,23 @@
-#include "BsOverlay.h"
-#include "BsOverlayManager.h"
-
-namespace BansheeEngine
-{
-	Overlay::Overlay(const HSceneObject& parent, Viewport* target)
-		:Component(parent), mRenderTarget(nullptr), mDepth(0)
-	{
-		setName("Overlay");
-
-		if(mRenderTarget != nullptr)
-			OverlayManager::instance().detachOverlay(mRenderTarget, this);
-
-		mRenderTarget = target;
-
-		OverlayManager::instance().attachOverlay(mRenderTarget, this);	
-	}
-
-	Overlay::~Overlay()
-	{
-		OverlayManager::instance().detachOverlayFromAll(this);
-	}
+#include "BsCOverlay.h"
+#include "BsOverlayManager.h"
+
+namespace BansheeEngine
+{
+	COverlay::COverlay(const HSceneObject& parent, Viewport* target)
+		:Component(parent), mRenderTarget(nullptr), mDepth(0)
+	{
+		setName("Overlay");
+
+		if(mRenderTarget != nullptr)
+			OverlayManager::instance().detachOverlay(mRenderTarget, this);
+
+		mRenderTarget = target;
+
+		OverlayManager::instance().attachOverlay(mRenderTarget, this);	
+	}
+
+	COverlay::~COverlay()
+	{
+		OverlayManager::instance().detachOverlayFromAll(this);
+	}
 }

+ 67 - 0
BansheeEngine/Source/BsCRenderable.cpp

@@ -0,0 +1,67 @@
+#include "BsCRenderable.h"
+#include "BsCRenderableRTTI.h"
+#include "BsSceneObject.h"
+#include "BsBuiltinResources.h"
+#include "BsMesh.h"
+#include "BsMaterial.h"
+#include "BsRenderQueue.h"
+#include "BsBounds.h"
+#include "BsSceneManager.h"
+
+namespace BansheeEngine
+{
+	CRenderable::CRenderable(const HSceneObject& parent)
+		:Component(parent)
+	{
+		setName("Renderable");
+	}
+
+	void CRenderable::onInitialized()
+	{
+		// If mInternal already exists this means this object was deserialized,
+		// so all we need to do is initialize it.
+		if (mInternal != nullptr)
+			mInternal->initialize();
+		else
+			mInternal = Renderable::create();
+
+		gSceneManager()._registerRenderable(mInternal, sceneObject());
+	}
+
+	Bounds CRenderable::getBounds() const
+	{
+		updateTransform();
+
+		return mInternal->getBounds();
+	}
+
+	void CRenderable::updateTransform() const
+	{
+		UINT32 curHash = SO()->getTransformHash();
+		if (curHash != mInternal->_getLastModifiedHash())
+		{
+			mInternal->setTransform(SO()->getWorldTfrm());
+			mInternal->_setLastModifiedHash(curHash);
+		}
+	}
+
+	void CRenderable::update()
+	{
+
+	}
+
+	void CRenderable::onDestroyed()
+	{
+		gSceneManager()._unregisterRenderable(mInternal);
+	}
+
+	RTTITypeBase* CRenderable::getRTTIStatic()
+	{
+		return CRenderableRTTI::instance();
+	}
+
+	RTTITypeBase* CRenderable::getRTTI() const
+	{
+		return CRenderable::getRTTIStatic();
+	}
+}

+ 778 - 34
BansheeEngine/Source/BsCamera.cpp

@@ -5,32 +5,129 @@
 #include "BsVector2.h"
 #include "BsAABox.h"
 #include "BsSphere.h"
-#include "BsHardwareBufferManager.h"
-#include "BsVertexBuffer.h"
-#include "BsIndexBuffer.h"
 #include "BsException.h"
 #include "BsRenderAPI.h"
 #include "BsSceneObject.h"
 #include "BsDebug.h"
-#include "BsSceneManager.h"
+#include "BsRendererManager.h"
+#include "BsCoreRenderer.h"
+#include "BsFrameAlloc.h"
 
-namespace BansheeEngine 
+namespace BansheeEngine
 {
-	Camera::Camera(const HSceneObject& parent, RenderTargetPtr target, float left, float top, float width, float height)
-		: Component(parent), mTarget(target), mLeft(left), mTop(top), mWidth(width), mHeight(height)
-    {
-		setName("Camera");
-    }
+	const float CameraBase::INFINITE_FAR_PLANE_ADJUST = 0.00001f;
 
-    Camera::~Camera()
-    {
-		mInternal->destroy();
-    }
+	CameraBase::CameraBase(RenderTargetPtr target, float left, float top, float width, float height)
+		:mProjType(PT_PERSPECTIVE), mHorzFOV(Radian(Math::PI / 4.0f)), mFarDist(1000.0f),
+		mNearDist(0.05f), mAspect(1.33333333333333f), mOrthoHeight(1000), mRecalcFrustum(true), mRecalcFrustumPlanes(true),
+		mCustomViewMatrix(false), mCustomProjMatrix(false), mFrustumExtentsManuallySet(false), mPriority(0), 
+		mLayers(0xFFFFFFFFFFFFFFFF), mRecalcView(true)
+	{
+		mViewMatrix = Matrix4::ZERO;
+		mProjMatrixRS = Matrix4::ZERO;
+		mViewMatrixInv = Matrix4::ZERO;
+		mProjMatrixRSInv = Matrix4::ZERO;
+		mProjMatrixInv = Matrix4::ZERO;
+
+		invalidateFrustum();
+	}
+
+	void CameraBase::setHorzFOV(const Radian& fov)
+	{
+		mHorzFOV = fov;
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	const Radian& CameraBase::getHorzFOV() const
+	{
+		return mHorzFOV;
+	}
+
+	void CameraBase::setFarClipDistance(float farPlane)
+	{
+		mFarDist = farPlane;
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	float CameraBase::getFarClipDistance() const
+	{
+		return mFarDist;
+	}
+
+	void CameraBase::setNearClipDistance(float nearPlane)
+	{
+		if (nearPlane <= 0)
+		{
+			BS_EXCEPT(InvalidParametersException, "Near clip distance must be greater than zero.");
+		}
+
+		mNearDist = nearPlane;
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	float CameraBase::getNearClipDistance() const
+	{
+		return mNearDist;
+	}
+
+	const Matrix4& CameraBase::getProjectionMatrix() const
+	{
+		updateFrustum();
+
+		return mProjMatrix;
+	}
+
+	const Matrix4& CameraBase::getProjectionMatrixInv() const
+	{
+		updateFrustum();
+
+		return mProjMatrixInv;
+	}
+
+	const Matrix4& CameraBase::getProjectionMatrixRS() const
+	{
+		updateFrustum();
+
+		return mProjMatrixRS;
+	}
 
-	ConvexVolume Camera::getWorldFrustum() const
+	const Matrix4& CameraBase::getProjectionMatrixRSInv() const
+	{
+		updateFrustum();
+
+		return mProjMatrixRSInv;
+	}
+
+	const Matrix4& CameraBase::getViewMatrix() const
+	{
+		updateView();
+
+		return mViewMatrix;
+	}
+
+	const Matrix4& CameraBase::getViewMatrixInv() const
+	{
+		updateView();
+
+		return mViewMatrixInv;
+	}
+
+	const ConvexVolume& CameraBase::getFrustum() const
+	{
+		// Make any pending updates to the calculated frustum planes
+		updateFrustumPlanes();
+
+		return mFrustum;
+	}
+
+	ConvexVolume CameraBase::getWorldFrustum() const
 	{
 		const Vector<Plane>& frustumPlanes = getFrustum().getPlanes();
-		Matrix4 worldMatrix = SO()->getWorldTfrm();
+		Matrix4 worldMatrix;
+		worldMatrix.setTRS(mPosition, mRotation, Vector3::ONE);
 
 		Vector<Plane> worldPlanes(frustumPlanes.size());
 		UINT32 i = 0;
@@ -43,41 +140,688 @@ namespace BansheeEngine
 		return ConvexVolume(worldPlanes);
 	}
 
-	void Camera::updateView() const
+	void CameraBase::calcProjectionParameters(float& left, float& right, float& bottom, float& top) const
+	{
+		if (mCustomProjMatrix)
+		{
+			// Convert clipspace corners to camera space
+			Matrix4 invProj = mProjMatrix.inverse();
+			Vector3 topLeft(-0.5f, 0.5f, 0.0f);
+			Vector3 bottomRight(0.5f, -0.5f, 0.0f);
+
+			topLeft = invProj.multiply(topLeft);
+			bottomRight = invProj.multiply(bottomRight);
+
+			left = topLeft.x;
+			top = topLeft.y;
+			right = bottomRight.x;
+			bottom = bottomRight.y;
+		}
+		else
+		{
+			if (mFrustumExtentsManuallySet)
+			{
+				left = mLeft;
+				right = mRight;
+				top = mTop;
+				bottom = mBottom;
+			}
+			else if (mProjType == PT_PERSPECTIVE)
+			{
+				Radian thetaY(mHorzFOV * 0.5f);
+				float tanThetaY = Math::tan(thetaY);
+				float tanThetaX = tanThetaY * mAspect;
+
+				float half_w = tanThetaX * mNearDist;
+				float half_h = tanThetaY * mNearDist;
+
+				left = -half_w;
+				right = half_w;
+				bottom = -half_h;
+				top = half_h;
+
+				mLeft = left;
+				mRight = right;
+				mTop = top;
+				mBottom = bottom;
+			}
+			else
+			{
+				float half_w = getOrthoWindowWidth() * 0.5f;
+				float half_h = getOrthoWindowHeight() * 0.5f;
+
+				left = -half_w;
+				right = half_w;
+				bottom = -half_h;
+				top = half_h;
+
+				mLeft = left;
+				mRight = right;
+				mTop = top;
+				mBottom = bottom;
+			}
+		}
+	}
+
+	void CameraBase::updateFrustum() const
+	{
+		if (isFrustumOutOfDate())
+		{
+			float left, right, bottom, top;
+
+			calcProjectionParameters(left, right, bottom, top);
+
+			if (!mCustomProjMatrix)
+			{
+				float inv_w = 1 / (right - left);
+				float inv_h = 1 / (top - bottom);
+				float inv_d = 1 / (mFarDist - mNearDist);
+
+				if (mProjType == PT_PERSPECTIVE)
+				{
+					float A = 2 * mNearDist * inv_w;
+					float B = 2 * mNearDist * inv_h;
+					float C = (right + left) * inv_w;
+					float D = (top + bottom) * inv_h;
+					float q, qn;
+
+					if (mFarDist == 0)
+					{
+						// Infinite far plane
+						q = CameraBase::INFINITE_FAR_PLANE_ADJUST - 1;
+						qn = mNearDist * (CameraBase::INFINITE_FAR_PLANE_ADJUST - 2);
+					}
+					else
+					{
+						q = -(mFarDist + mNearDist) * inv_d;
+						qn = -2 * (mFarDist * mNearDist) * inv_d;
+					}
+
+					mProjMatrix = Matrix4::ZERO;
+					mProjMatrix[0][0] = A;
+					mProjMatrix[0][2] = C;
+					mProjMatrix[1][1] = B;
+					mProjMatrix[1][2] = D;
+					mProjMatrix[2][2] = q;
+					mProjMatrix[2][3] = qn;
+					mProjMatrix[3][2] = -1;
+				}
+				else if (mProjType == PT_ORTHOGRAPHIC)
+				{
+					float A = 2 * inv_w;
+					float B = 2 * inv_h;
+					float C = -(right + left) * inv_w;
+					float D = -(top + bottom) * inv_h;
+					float q, qn;
+
+					if (mFarDist == 0)
+					{
+						// Can not do infinite far plane here, avoid divided zero only
+						q = -CameraBase::INFINITE_FAR_PLANE_ADJUST / mNearDist;
+						qn = -CameraBase::INFINITE_FAR_PLANE_ADJUST - 1;
+					}
+					else
+					{
+						q = -2 * inv_d;
+						qn = -(mFarDist + mNearDist)  * inv_d;
+					}
+
+					mProjMatrix = Matrix4::ZERO;
+					mProjMatrix[0][0] = A;
+					mProjMatrix[0][3] = C;
+					mProjMatrix[1][1] = B;
+					mProjMatrix[1][3] = D;
+					mProjMatrix[2][2] = q;
+					mProjMatrix[2][3] = qn;
+					mProjMatrix[3][3] = 1;
+				}
+			}
+
+			RenderAPICore* renderAPI = BansheeEngine::RenderAPICore::instancePtr();
+			renderAPI->convertProjectionMatrix(mProjMatrix, mProjMatrixRS);
+			mProjMatrixInv = mProjMatrix.inverse();
+			mProjMatrixRSInv = mProjMatrixRS.inverse();
+
+			// Calculate bounding box (local)
+			// Box is from 0, down -Z, max dimensions as determined from far plane
+			// If infinite view frustum just pick a far value
+			float farDist = (mFarDist == 0) ? 100000 : mFarDist;
+
+			// Near plane bounds
+			Vector3 min(left, bottom, -farDist);
+			Vector3 max(right, top, 0);
+
+			if (mCustomProjMatrix)
+			{
+				// Some custom projection matrices can have unusual inverted settings
+				// So make sure the AABB is the right way around to start with
+				Vector3 tmp = min;
+				min.floor(max);
+				max.ceil(tmp);
+			}
+
+			if (mProjType == PT_PERSPECTIVE)
+			{
+				// Merge with far plane bounds
+				float radio = farDist / mNearDist;
+				min.floor(Vector3(left * radio, bottom * radio, -farDist));
+				max.ceil(Vector3(right * radio, top * radio, 0));
+			}
+
+			mBoundingBox.setExtents(min, max);
+
+			mRecalcFrustum = false;
+			mRecalcFrustumPlanes = true;
+		}
+	}
+
+	bool CameraBase::isFrustumOutOfDate() const
+	{
+		return mRecalcFrustum;
+	}
+
+	void CameraBase::updateView() const
 	{
-		UINT32 curHash = SO()->getTransformHash();
-		if (curHash != mInternal->_getLastModifiedHash())
+		if (!mCustomViewMatrix && mRecalcView)
 		{
-			mInternal->setPosition(SO()->getWorldPosition());
-			mInternal->setRotation(SO()->getWorldRotation());
+			mViewMatrix.makeView(mPosition, mRotation);
+			mViewMatrixInv = mViewMatrix.inverseAffine();
+			mRecalcView = false;
+		}
+	}
+
+	void CameraBase::updateFrustumPlanes() const
+	{
+		updateFrustum();
+
+		if (mRecalcFrustumPlanes)
+		{
+			Vector<Plane> frustumPlanes(6);
+			Matrix4 combo = mProjMatrix;
+
+			frustumPlanes[FRUSTUM_PLANE_LEFT].normal.x = combo[3][0] + combo[0][0];
+			frustumPlanes[FRUSTUM_PLANE_LEFT].normal.y = combo[3][1] + combo[0][1];
+			frustumPlanes[FRUSTUM_PLANE_LEFT].normal.z = combo[3][2] + combo[0][2];
+			frustumPlanes[FRUSTUM_PLANE_LEFT].d = combo[3][3] + combo[0][3];
+
+			frustumPlanes[FRUSTUM_PLANE_RIGHT].normal.x = combo[3][0] - combo[0][0];
+			frustumPlanes[FRUSTUM_PLANE_RIGHT].normal.y = combo[3][1] - combo[0][1];
+			frustumPlanes[FRUSTUM_PLANE_RIGHT].normal.z = combo[3][2] - combo[0][2];
+			frustumPlanes[FRUSTUM_PLANE_RIGHT].d = combo[3][3] - combo[0][3];
+
+			frustumPlanes[FRUSTUM_PLANE_TOP].normal.x = combo[3][0] - combo[1][0];
+			frustumPlanes[FRUSTUM_PLANE_TOP].normal.y = combo[3][1] - combo[1][1];
+			frustumPlanes[FRUSTUM_PLANE_TOP].normal.z = combo[3][2] - combo[1][2];
+			frustumPlanes[FRUSTUM_PLANE_TOP].d = combo[3][3] - combo[1][3];
 
-			mInternal->_setLastModifiedHash(curHash);
+			frustumPlanes[FRUSTUM_PLANE_BOTTOM].normal.x = combo[3][0] + combo[1][0];
+			frustumPlanes[FRUSTUM_PLANE_BOTTOM].normal.y = combo[3][1] + combo[1][1];
+			frustumPlanes[FRUSTUM_PLANE_BOTTOM].normal.z = combo[3][2] + combo[1][2];
+			frustumPlanes[FRUSTUM_PLANE_BOTTOM].d = combo[3][3] + combo[1][3];
+
+			frustumPlanes[FRUSTUM_PLANE_NEAR].normal.x = combo[3][0] + combo[2][0];
+			frustumPlanes[FRUSTUM_PLANE_NEAR].normal.y = combo[3][1] + combo[2][1];
+			frustumPlanes[FRUSTUM_PLANE_NEAR].normal.z = combo[3][2] + combo[2][2];
+			frustumPlanes[FRUSTUM_PLANE_NEAR].d = combo[3][3] + combo[2][3];
+
+			frustumPlanes[FRUSTUM_PLANE_FAR].normal.x = combo[3][0] - combo[2][0];
+			frustumPlanes[FRUSTUM_PLANE_FAR].normal.y = combo[3][1] - combo[2][1];
+			frustumPlanes[FRUSTUM_PLANE_FAR].normal.z = combo[3][2] - combo[2][2];
+			frustumPlanes[FRUSTUM_PLANE_FAR].d = combo[3][3] - combo[2][3];
+
+			for (UINT32 i = 0; i < 6; i++)
+			{
+				float length = frustumPlanes[i].normal.normalize();
+				frustumPlanes[i].d /= -length;
+			}
+
+			mFrustum = ConvexVolume(frustumPlanes);
+			mRecalcFrustumPlanes = false;
 		}
 	}
 
-	void Camera::update() 
+	float CameraBase::getAspectRatio(void) const
+	{
+		return mAspect;
+	}
+
+	void CameraBase::setAspectRatio(float r)
+	{
+		mAspect = r;
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	const AABox& CameraBase::getBoundingBox() const
+	{
+		updateFrustum();
+
+		return mBoundingBox;
+	}
+
+	void CameraBase::setProjectionType(ProjectionType pt)
+	{
+		mProjType = pt;
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	ProjectionType CameraBase::getProjectionType() const
+	{
+		return mProjType;
+	}
+
+	void CameraBase::setCustomViewMatrix(bool enable, const Matrix4& viewMatrix)
+	{
+		mCustomViewMatrix = enable;
+		if (enable)
+		{
+			assert(viewMatrix.isAffine());
+			mViewMatrix = viewMatrix;
+			mViewMatrixInv = mViewMatrix.inverseAffine();
+		}
+
+		_markCoreDirty();
+	}
+
+	void CameraBase::setCustomProjectionMatrix(bool enable, const Matrix4& projMatrix)
+	{
+		mCustomProjMatrix = enable;
+
+		if (enable)
+			mProjMatrix = projMatrix;
+
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	void CameraBase::setOrthoWindow(float w, float h)
+	{
+		mOrthoHeight = h;
+		mAspect = w / h;
+
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	void CameraBase::setOrthoWindowHeight(float h)
+	{
+		mOrthoHeight = h;
+
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	void CameraBase::setOrthoWindowWidth(float w)
+	{
+		mOrthoHeight = w / mAspect;
+
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	float CameraBase::getOrthoWindowHeight() const
+	{
+		return mOrthoHeight;
+	}
+
+	float CameraBase::getOrthoWindowWidth() const
+	{
+		return mOrthoHeight * mAspect;
+	}
+
+	void CameraBase::setFrustumExtents(float left, float right, float top, float bottom)
+	{
+		mFrustumExtentsManuallySet = true;
+		mLeft = left;
+		mRight = right;
+		mTop = top;
+		mBottom = bottom;
+
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	void CameraBase::resetFrustumExtents()
+	{
+		mFrustumExtentsManuallySet = false;
+
+		invalidateFrustum();
+		_markCoreDirty();
+	}
+
+	void CameraBase::getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const
+	{
+		updateFrustum();
+
+		outleft = mLeft;
+		outright = mRight;
+		outtop = mTop;
+		outbottom = mBottom;
+	}
+
+	void CameraBase::setPosition(const Vector3& position)
+	{
+		mPosition = position;
+
+		mRecalcView = true;
+		_markCoreDirty();
+	}
+
+	void CameraBase::setRotation(const Quaternion& rotation)
+	{
+		mRotation = rotation;
+
+		mRecalcView = true;
+		_markCoreDirty();
+	}
+
+	void CameraBase::invalidateFrustum() const
+	{
+		mRecalcFrustum = true;
+		mRecalcFrustumPlanes = true;
+	}
+
+	Vector2I CameraBase::worldToScreenPoint(const Vector3& worldPoint) const
+	{
+		Vector2 clipPoint = worldToClipPoint(worldPoint);
+		return clipToScreenPoint(clipPoint);
+	}
+
+	Vector2 CameraBase::worldToClipPoint(const Vector3& worldPoint) const
+	{
+		Vector3 viewPoint = worldToViewPoint(worldPoint);
+		return viewToClipPoint(viewPoint);
+	}
+
+	Vector3 CameraBase::worldToViewPoint(const Vector3& worldPoint) const
+	{
+		return getViewMatrix().multiplyAffine(worldPoint);
+	}
+
+	Vector3 CameraBase::screenToWorldPoint(const Vector2I& screenPoint, float depth) const
+	{
+		Vector2 clipPoint = screenToClipPoint(screenPoint);
+		return clipToWorldPoint(clipPoint, depth);
+	}
+
+	Vector3 CameraBase::screenToViewPoint(const Vector2I& screenPoint, float depth) const
+	{
+		Vector2 clipPoint = screenToClipPoint(screenPoint);
+		return clipToViewPoint(clipPoint, depth);
+	}
+
+	Vector2 CameraBase::screenToClipPoint(const Vector2I& screenPoint) const
+	{
+		Rect2I viewport = getViewportRect();
+
+		Vector2 clipPoint;
+		clipPoint.x = (float)(((screenPoint.x - viewport.x) / (float)viewport.width) * 2.0f - 1.0f);
+		clipPoint.y = (float)((1.0f - ((screenPoint.y - viewport.y) / (float)viewport.height)) * 2.0f - 1.0f);
+
+		return clipPoint;
+	}
+
+	Vector3 CameraBase::viewToWorldPoint(const Vector3& viewPoint) const
+	{
+		return getViewMatrix().inverseAffine().multiplyAffine(viewPoint);
+	}
+
+	Vector2I CameraBase::viewToScreenPoint(const Vector3& viewPoint) const
+	{
+		Vector2 clipPoint = viewToClipPoint(viewPoint);
+		return clipToScreenPoint(clipPoint);
+	}
+
+	Vector2 CameraBase::viewToClipPoint(const Vector3& viewPoint) const
+	{
+		Vector3 projPoint = projectPoint(viewPoint);
+
+		return Vector2(projPoint.x, projPoint.y);
+	}
+
+	Vector3 CameraBase::clipToWorldPoint(const Vector2& clipPoint, float depth) const
+	{
+		Vector3 viewPoint = clipToViewPoint(clipPoint, depth);
+		return viewToWorldPoint(viewPoint);
+	}
+
+	Vector3 CameraBase::clipToViewPoint(const Vector2& clipPoint, float depth) const
+	{
+		return unprojectPoint(Vector3(clipPoint.x, clipPoint.y, depth));
+	}
+
+	Vector2I CameraBase::clipToScreenPoint(const Vector2& clipPoint) const
+	{
+		Rect2I viewport = getViewportRect();
+
+		Vector2I screenPoint;
+		screenPoint.x = Math::roundToInt(viewport.x + ((clipPoint.x + 1.0f) * 0.5f) * viewport.width);
+		screenPoint.y = Math::roundToInt(viewport.y + (1.0f - (clipPoint.y + 1.0f) * 0.5f) * viewport.height);
+
+		return screenPoint;
+	}
+
+	Ray CameraBase::screenPointToRay(const Vector2I& screenPoint) const
+	{
+		Vector2 clipPoint = screenToClipPoint(screenPoint);
+
+		Vector3 near = unprojectPoint(Vector3(clipPoint.x, clipPoint.y, mNearDist));
+		Vector3 far = unprojectPoint(Vector3(clipPoint.x, clipPoint.y, mNearDist + 1.0f));
+
+		Ray ray(near, Vector3::normalize(far - near));
+		ray.transformAffine(getViewMatrix().inverseAffine());
+
+		return ray;
+	}
+
+	Vector3 CameraBase::projectPoint(const Vector3& point) const
 	{
+		Vector4 projPoint4(point.x, point.y, point.z, 1.0f);
+		projPoint4 = getProjectionMatrixRS().multiply(projPoint4);
+
+		if (Math::abs(projPoint4.w) > 1e-7f)
+		{
+			float invW = 1.0f / projPoint4.w;
+			projPoint4.x *= invW;
+			projPoint4.y *= invW;
+			projPoint4.z *= invW;
+		}
+		else
+		{
+			projPoint4.x = 0.0f;
+			projPoint4.y = 0.0f;
+			projPoint4.z = 0.0f;
+		}
 
+		return Vector3(projPoint4.x, projPoint4.y, projPoint4.z);
 	}
 
-	void Camera::onInitialized()
+	Vector3 CameraBase::unprojectPoint(const Vector3& point) const
 	{
-		// If mInternal already exists this means this object was deserialized,
-		// so all we need to do is initialize it.
-		if (mInternal != nullptr)
-			mInternal->initialize();
+		Vector4 dir4(point.x, point.y, 0.95f, 1.0f); // 0.95f arbitrary
+		dir4 = getProjectionMatrixRS().inverse().multiply(dir4);
+
+		Vector3 dir;
+		dir.x = dir4.x;
+		dir.y = dir4.y;
+		dir.z = dir4.z;
+
+		if (Math::abs(dir4.w) > 1e-7f)
+		{
+			float invW = 1.0f / dir4.w;
+			dir.x *= invW;
+			dir.y *= invW;
+			dir.z *= invW;
+
+			// Find a point along a ray from camera origin to point on near plane we just found, 
+			// at point.z distance from the origin
+
+			float distToPlane = dir.dot(-Vector3::UNIT_Z);
+			if (distToPlane >= 0.0f)
+			{
+				if (mProjType == PT_PERSPECTIVE)
+					dir *= point.z / distToPlane;
+				else
+					dir += Vector3::UNIT_Z * (distToPlane - point.z);
+			}
+		}
 		else
 		{
-			mInternal = CameraHandler::create(mTarget, mLeft, mTop, mWidth, mHeight);
-			mTarget = nullptr;
+			dir.x = 0.0f;
+			dir.y = 0.0f;
+			dir.z = 0.0f;
 		}
 
-		gSceneManager()._registerCamera(mInternal, SO());
+		return Vector3(dir.x, dir.y, dir.z);
+	}
+
+	CameraCore::~CameraCore()
+	{
+		RendererManager::instance().getActive()->_notifyCameraRemoved(this);
+	}
+
+	CameraCore::CameraCore(SPtr<RenderTargetCore> target, float left, float top, float width, float height)
+	{
+		mViewport = ViewportCore::create(target, left, top, width, height);
+	}
+
+	CameraCore::CameraCore(const SPtr<ViewportCore>& viewport)
+	{
+		mViewport = viewport;
+	}
+
+	void CameraCore::initialize()
+	{
+		RendererManager::instance().getActive()->_notifyCameraAdded(this);
+
+		CoreObjectCore::initialize();
+	}
+
+	Rect2I CameraCore::getViewportRect() const
+	{
+		return mViewport->getArea();
+	}
+
+	void CameraCore::syncToCore(const CoreSyncData& data)
+	{
+		char* dataPtr = (char*)data.getBuffer();
+
+		dataPtr = rttiReadElem(mLayers, dataPtr);
+		dataPtr = rttiReadElem(mPosition, dataPtr);
+		dataPtr = rttiReadElem(mRotation, dataPtr);
+		dataPtr = rttiReadElem(mProjType, dataPtr);
+		dataPtr = rttiReadElem(mHorzFOV, dataPtr);
+		dataPtr = rttiReadElem(mFarDist, dataPtr);
+		dataPtr = rttiReadElem(mNearDist, dataPtr);
+		dataPtr = rttiReadElem(mAspect, dataPtr);
+		dataPtr = rttiReadElem(mOrthoHeight, dataPtr);
+		dataPtr = rttiReadElem(mPriority, dataPtr);
+		dataPtr = rttiReadElem(mCustomViewMatrix, dataPtr);
+		dataPtr = rttiReadElem(mCustomProjMatrix, dataPtr);
+		dataPtr = rttiReadElem(mFrustumExtentsManuallySet, dataPtr);
+
+		mRecalcFrustum = true;
+		mRecalcFrustumPlanes = true;
+		mRecalcView = true;
+	}
+
+	Camera::Camera(RenderTargetPtr target, float left, float top, float width, float height)
+		:mLastUpdateHash(0)
+	{
+		if (target != nullptr)
+			target->blockUntilCoreInitialized();
+
+		mViewport = Viewport::create(target, left, top, width, height);
+	}
+
+	SPtr<CameraCore> Camera::getCore() const
+	{
+		return std::static_pointer_cast<CameraCore>(mCoreSpecific);
+	}
+
+	CameraPtr Camera::create(RenderTargetPtr target, float left, float top, float width, float height)
+	{
+		Camera* handler = new (bs_alloc<Camera>()) Camera(target, left, top, width, height);
+		CameraPtr handlerPtr = bs_core_ptr<Camera>(handler);
+		handlerPtr->_setThisPtr(handlerPtr);
+		handlerPtr->initialize();
+
+		return handlerPtr;
+	}
+
+	CameraPtr Camera::createEmpty()
+	{
+		Camera* handler = new (bs_alloc<Camera>()) Camera();
+		CameraPtr handlerPtr = bs_core_ptr<Camera>(handler);
+		handlerPtr->_setThisPtr(handlerPtr);
+
+		return handlerPtr;
+	}
+
+	SPtr<CoreObjectCore> Camera::createCore() const
+	{
+		Rect2 normArea = mViewport->getNormArea();
+
+		CameraCore* handler = new (bs_alloc<CameraCore>()) CameraCore(mViewport->getCore());
+		SPtr<CameraCore> handlerPtr = bs_shared_ptr<CameraCore>(handler);
+		handlerPtr->_setThisPtr(handlerPtr);
+
+		return handlerPtr;
+	}
+
+	Rect2I Camera::getViewportRect() const
+	{
+		return mViewport->getArea();
+	}
+
+	CoreSyncData Camera::syncToCore(FrameAlloc* allocator)
+	{
+		UINT32 size = 0;
+		size += rttiGetElemSize(mLayers);
+		size += rttiGetElemSize(mPosition);
+		size += rttiGetElemSize(mRotation);
+		size += rttiGetElemSize(mProjType);
+		size += rttiGetElemSize(mHorzFOV);
+		size += rttiGetElemSize(mFarDist);
+		size += rttiGetElemSize(mNearDist);
+		size += rttiGetElemSize(mAspect);
+		size += rttiGetElemSize(mOrthoHeight);
+		size += rttiGetElemSize(mPriority);
+
+		size += rttiGetElemSize(mCustomViewMatrix);
+		size += rttiGetElemSize(mCustomProjMatrix);
+
+		size += rttiGetElemSize(mFrustumExtentsManuallySet);
+
+		UINT8* buffer = allocator->alloc(size);
+
+		char* dataPtr = (char*)buffer;
+		dataPtr = rttiWriteElem(mLayers, dataPtr);
+		dataPtr = rttiWriteElem(mPosition, dataPtr);
+		dataPtr = rttiWriteElem(mRotation, dataPtr);
+		dataPtr = rttiWriteElem(mProjType, dataPtr);
+		dataPtr = rttiWriteElem(mHorzFOV, dataPtr);
+		dataPtr = rttiWriteElem(mFarDist, dataPtr);
+		dataPtr = rttiWriteElem(mNearDist, dataPtr);
+		dataPtr = rttiWriteElem(mAspect, dataPtr);
+		dataPtr = rttiWriteElem(mOrthoHeight, dataPtr);
+		dataPtr = rttiWriteElem(mPriority, dataPtr);
+		dataPtr = rttiWriteElem(mCustomViewMatrix, dataPtr);
+		dataPtr = rttiWriteElem(mCustomProjMatrix, dataPtr);
+		dataPtr = rttiWriteElem(mFrustumExtentsManuallySet, dataPtr);
+
+		return CoreSyncData(buffer, size);
+	}
+
+	void Camera::getCoreDependencies(Vector<SPtr<CoreObject>>& dependencies)
+	{
+		dependencies.push_back(mViewport);
 	}
 
-	void Camera::onDestroyed()
+	void Camera::_markCoreDirty()
 	{
-		gSceneManager()._unregisterCamera(mInternal);
+		markCoreDirty();
 	}
 
 	RTTITypeBase* Camera::getRTTIStatic()
@@ -89,4 +833,4 @@ namespace BansheeEngine
 	{
 		return Camera::getRTTIStatic();
 	}
-} 
+}

+ 0 - 836
BansheeEngine/Source/BsCameraHandler.cpp

@@ -1,836 +0,0 @@
-#include "BsCameraHandler.h"
-#include "BsCameraHandlerRTTI.h"
-#include "BsMath.h"
-#include "BsMatrix3.h"
-#include "BsVector2.h"
-#include "BsAABox.h"
-#include "BsSphere.h"
-#include "BsException.h"
-#include "BsRenderAPI.h"
-#include "BsSceneObject.h"
-#include "BsDebug.h"
-#include "BsRendererManager.h"
-#include "BsCoreRenderer.h"
-#include "BsFrameAlloc.h"
-
-namespace BansheeEngine
-{
-	const float CameraHandlerBase::INFINITE_FAR_PLANE_ADJUST = 0.00001f;
-
-	CameraHandlerBase::CameraHandlerBase(RenderTargetPtr target, float left, float top, float width, float height)
-		:mProjType(PT_PERSPECTIVE), mHorzFOV(Radian(Math::PI / 4.0f)), mFarDist(1000.0f),
-		mNearDist(0.05f), mAspect(1.33333333333333f), mOrthoHeight(1000), mRecalcFrustum(true), mRecalcFrustumPlanes(true),
-		mCustomViewMatrix(false), mCustomProjMatrix(false), mFrustumExtentsManuallySet(false), mPriority(0), 
-		mLayers(0xFFFFFFFFFFFFFFFF), mRecalcView(true)
-	{
-		mViewMatrix = Matrix4::ZERO;
-		mProjMatrixRS = Matrix4::ZERO;
-		mViewMatrixInv = Matrix4::ZERO;
-		mProjMatrixRSInv = Matrix4::ZERO;
-		mProjMatrixInv = Matrix4::ZERO;
-
-		invalidateFrustum();
-	}
-
-	void CameraHandlerBase::setHorzFOV(const Radian& fov)
-	{
-		mHorzFOV = fov;
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	const Radian& CameraHandlerBase::getHorzFOV() const
-	{
-		return mHorzFOV;
-	}
-
-	void CameraHandlerBase::setFarClipDistance(float farPlane)
-	{
-		mFarDist = farPlane;
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	float CameraHandlerBase::getFarClipDistance() const
-	{
-		return mFarDist;
-	}
-
-	void CameraHandlerBase::setNearClipDistance(float nearPlane)
-	{
-		if (nearPlane <= 0)
-		{
-			BS_EXCEPT(InvalidParametersException, "Near clip distance must be greater than zero.");
-		}
-
-		mNearDist = nearPlane;
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	float CameraHandlerBase::getNearClipDistance() const
-	{
-		return mNearDist;
-	}
-
-	const Matrix4& CameraHandlerBase::getProjectionMatrix() const
-	{
-		updateFrustum();
-
-		return mProjMatrix;
-	}
-
-	const Matrix4& CameraHandlerBase::getProjectionMatrixInv() const
-	{
-		updateFrustum();
-
-		return mProjMatrixInv;
-	}
-
-	const Matrix4& CameraHandlerBase::getProjectionMatrixRS() const
-	{
-		updateFrustum();
-
-		return mProjMatrixRS;
-	}
-
-	const Matrix4& CameraHandlerBase::getProjectionMatrixRSInv() const
-	{
-		updateFrustum();
-
-		return mProjMatrixRSInv;
-	}
-
-	const Matrix4& CameraHandlerBase::getViewMatrix() const
-	{
-		updateView();
-
-		return mViewMatrix;
-	}
-
-	const Matrix4& CameraHandlerBase::getViewMatrixInv() const
-	{
-		updateView();
-
-		return mViewMatrixInv;
-	}
-
-	const ConvexVolume& CameraHandlerBase::getFrustum() const
-	{
-		// Make any pending updates to the calculated frustum planes
-		updateFrustumPlanes();
-
-		return mFrustum;
-	}
-
-	ConvexVolume CameraHandlerBase::getWorldFrustum() const
-	{
-		const Vector<Plane>& frustumPlanes = getFrustum().getPlanes();
-		Matrix4 worldMatrix;
-		worldMatrix.setTRS(mPosition, mRotation, Vector3::ONE);
-
-		Vector<Plane> worldPlanes(frustumPlanes.size());
-		UINT32 i = 0;
-		for (auto& plane : frustumPlanes)
-		{
-			worldPlanes[i] = worldMatrix.multiplyAffine(plane);
-			i++;
-		}
-
-		return ConvexVolume(worldPlanes);
-	}
-
-	void CameraHandlerBase::calcProjectionParameters(float& left, float& right, float& bottom, float& top) const
-	{
-		if (mCustomProjMatrix)
-		{
-			// Convert clipspace corners to camera space
-			Matrix4 invProj = mProjMatrix.inverse();
-			Vector3 topLeft(-0.5f, 0.5f, 0.0f);
-			Vector3 bottomRight(0.5f, -0.5f, 0.0f);
-
-			topLeft = invProj.multiply(topLeft);
-			bottomRight = invProj.multiply(bottomRight);
-
-			left = topLeft.x;
-			top = topLeft.y;
-			right = bottomRight.x;
-			bottom = bottomRight.y;
-		}
-		else
-		{
-			if (mFrustumExtentsManuallySet)
-			{
-				left = mLeft;
-				right = mRight;
-				top = mTop;
-				bottom = mBottom;
-			}
-			else if (mProjType == PT_PERSPECTIVE)
-			{
-				Radian thetaY(mHorzFOV * 0.5f);
-				float tanThetaY = Math::tan(thetaY);
-				float tanThetaX = tanThetaY * mAspect;
-
-				float half_w = tanThetaX * mNearDist;
-				float half_h = tanThetaY * mNearDist;
-
-				left = -half_w;
-				right = half_w;
-				bottom = -half_h;
-				top = half_h;
-
-				mLeft = left;
-				mRight = right;
-				mTop = top;
-				mBottom = bottom;
-			}
-			else
-			{
-				float half_w = getOrthoWindowWidth() * 0.5f;
-				float half_h = getOrthoWindowHeight() * 0.5f;
-
-				left = -half_w;
-				right = half_w;
-				bottom = -half_h;
-				top = half_h;
-
-				mLeft = left;
-				mRight = right;
-				mTop = top;
-				mBottom = bottom;
-			}
-		}
-	}
-
-	void CameraHandlerBase::updateFrustum() const
-	{
-		if (isFrustumOutOfDate())
-		{
-			float left, right, bottom, top;
-
-			calcProjectionParameters(left, right, bottom, top);
-
-			if (!mCustomProjMatrix)
-			{
-				float inv_w = 1 / (right - left);
-				float inv_h = 1 / (top - bottom);
-				float inv_d = 1 / (mFarDist - mNearDist);
-
-				if (mProjType == PT_PERSPECTIVE)
-				{
-					float A = 2 * mNearDist * inv_w;
-					float B = 2 * mNearDist * inv_h;
-					float C = (right + left) * inv_w;
-					float D = (top + bottom) * inv_h;
-					float q, qn;
-
-					if (mFarDist == 0)
-					{
-						// Infinite far plane
-						q = CameraHandlerBase::INFINITE_FAR_PLANE_ADJUST - 1;
-						qn = mNearDist * (CameraHandlerBase::INFINITE_FAR_PLANE_ADJUST - 2);
-					}
-					else
-					{
-						q = -(mFarDist + mNearDist) * inv_d;
-						qn = -2 * (mFarDist * mNearDist) * inv_d;
-					}
-
-					mProjMatrix = Matrix4::ZERO;
-					mProjMatrix[0][0] = A;
-					mProjMatrix[0][2] = C;
-					mProjMatrix[1][1] = B;
-					mProjMatrix[1][2] = D;
-					mProjMatrix[2][2] = q;
-					mProjMatrix[2][3] = qn;
-					mProjMatrix[3][2] = -1;
-				}
-				else if (mProjType == PT_ORTHOGRAPHIC)
-				{
-					float A = 2 * inv_w;
-					float B = 2 * inv_h;
-					float C = -(right + left) * inv_w;
-					float D = -(top + bottom) * inv_h;
-					float q, qn;
-
-					if (mFarDist == 0)
-					{
-						// Can not do infinite far plane here, avoid divided zero only
-						q = -CameraHandlerBase::INFINITE_FAR_PLANE_ADJUST / mNearDist;
-						qn = -CameraHandlerBase::INFINITE_FAR_PLANE_ADJUST - 1;
-					}
-					else
-					{
-						q = -2 * inv_d;
-						qn = -(mFarDist + mNearDist)  * inv_d;
-					}
-
-					mProjMatrix = Matrix4::ZERO;
-					mProjMatrix[0][0] = A;
-					mProjMatrix[0][3] = C;
-					mProjMatrix[1][1] = B;
-					mProjMatrix[1][3] = D;
-					mProjMatrix[2][2] = q;
-					mProjMatrix[2][3] = qn;
-					mProjMatrix[3][3] = 1;
-				}
-			}
-
-			RenderAPICore* renderAPI = BansheeEngine::RenderAPICore::instancePtr();
-			renderAPI->convertProjectionMatrix(mProjMatrix, mProjMatrixRS);
-			mProjMatrixInv = mProjMatrix.inverse();
-			mProjMatrixRSInv = mProjMatrixRS.inverse();
-
-			// Calculate bounding box (local)
-			// Box is from 0, down -Z, max dimensions as determined from far plane
-			// If infinite view frustum just pick a far value
-			float farDist = (mFarDist == 0) ? 100000 : mFarDist;
-
-			// Near plane bounds
-			Vector3 min(left, bottom, -farDist);
-			Vector3 max(right, top, 0);
-
-			if (mCustomProjMatrix)
-			{
-				// Some custom projection matrices can have unusual inverted settings
-				// So make sure the AABB is the right way around to start with
-				Vector3 tmp = min;
-				min.floor(max);
-				max.ceil(tmp);
-			}
-
-			if (mProjType == PT_PERSPECTIVE)
-			{
-				// Merge with far plane bounds
-				float radio = farDist / mNearDist;
-				min.floor(Vector3(left * radio, bottom * radio, -farDist));
-				max.ceil(Vector3(right * radio, top * radio, 0));
-			}
-
-			mBoundingBox.setExtents(min, max);
-
-			mRecalcFrustum = false;
-			mRecalcFrustumPlanes = true;
-		}
-	}
-
-	bool CameraHandlerBase::isFrustumOutOfDate() const
-	{
-		return mRecalcFrustum;
-	}
-
-	void CameraHandlerBase::updateView() const
-	{
-		if (!mCustomViewMatrix && mRecalcView)
-		{
-			mViewMatrix.makeView(mPosition, mRotation);
-			mViewMatrixInv = mViewMatrix.inverseAffine();
-			mRecalcView = false;
-		}
-	}
-
-	void CameraHandlerBase::updateFrustumPlanes() const
-	{
-		updateFrustum();
-
-		if (mRecalcFrustumPlanes)
-		{
-			Vector<Plane> frustumPlanes(6);
-			Matrix4 combo = mProjMatrix;
-
-			frustumPlanes[FRUSTUM_PLANE_LEFT].normal.x = combo[3][0] + combo[0][0];
-			frustumPlanes[FRUSTUM_PLANE_LEFT].normal.y = combo[3][1] + combo[0][1];
-			frustumPlanes[FRUSTUM_PLANE_LEFT].normal.z = combo[3][2] + combo[0][2];
-			frustumPlanes[FRUSTUM_PLANE_LEFT].d = combo[3][3] + combo[0][3];
-
-			frustumPlanes[FRUSTUM_PLANE_RIGHT].normal.x = combo[3][0] - combo[0][0];
-			frustumPlanes[FRUSTUM_PLANE_RIGHT].normal.y = combo[3][1] - combo[0][1];
-			frustumPlanes[FRUSTUM_PLANE_RIGHT].normal.z = combo[3][2] - combo[0][2];
-			frustumPlanes[FRUSTUM_PLANE_RIGHT].d = combo[3][3] - combo[0][3];
-
-			frustumPlanes[FRUSTUM_PLANE_TOP].normal.x = combo[3][0] - combo[1][0];
-			frustumPlanes[FRUSTUM_PLANE_TOP].normal.y = combo[3][1] - combo[1][1];
-			frustumPlanes[FRUSTUM_PLANE_TOP].normal.z = combo[3][2] - combo[1][2];
-			frustumPlanes[FRUSTUM_PLANE_TOP].d = combo[3][3] - combo[1][3];
-
-			frustumPlanes[FRUSTUM_PLANE_BOTTOM].normal.x = combo[3][0] + combo[1][0];
-			frustumPlanes[FRUSTUM_PLANE_BOTTOM].normal.y = combo[3][1] + combo[1][1];
-			frustumPlanes[FRUSTUM_PLANE_BOTTOM].normal.z = combo[3][2] + combo[1][2];
-			frustumPlanes[FRUSTUM_PLANE_BOTTOM].d = combo[3][3] + combo[1][3];
-
-			frustumPlanes[FRUSTUM_PLANE_NEAR].normal.x = combo[3][0] + combo[2][0];
-			frustumPlanes[FRUSTUM_PLANE_NEAR].normal.y = combo[3][1] + combo[2][1];
-			frustumPlanes[FRUSTUM_PLANE_NEAR].normal.z = combo[3][2] + combo[2][2];
-			frustumPlanes[FRUSTUM_PLANE_NEAR].d = combo[3][3] + combo[2][3];
-
-			frustumPlanes[FRUSTUM_PLANE_FAR].normal.x = combo[3][0] - combo[2][0];
-			frustumPlanes[FRUSTUM_PLANE_FAR].normal.y = combo[3][1] - combo[2][1];
-			frustumPlanes[FRUSTUM_PLANE_FAR].normal.z = combo[3][2] - combo[2][2];
-			frustumPlanes[FRUSTUM_PLANE_FAR].d = combo[3][3] - combo[2][3];
-
-			for (UINT32 i = 0; i < 6; i++)
-			{
-				float length = frustumPlanes[i].normal.normalize();
-				frustumPlanes[i].d /= -length;
-			}
-
-			mFrustum = ConvexVolume(frustumPlanes);
-			mRecalcFrustumPlanes = false;
-		}
-	}
-
-	float CameraHandlerBase::getAspectRatio(void) const
-	{
-		return mAspect;
-	}
-
-	void CameraHandlerBase::setAspectRatio(float r)
-	{
-		mAspect = r;
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	const AABox& CameraHandlerBase::getBoundingBox() const
-	{
-		updateFrustum();
-
-		return mBoundingBox;
-	}
-
-	void CameraHandlerBase::setProjectionType(ProjectionType pt)
-	{
-		mProjType = pt;
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	ProjectionType CameraHandlerBase::getProjectionType() const
-	{
-		return mProjType;
-	}
-
-	void CameraHandlerBase::setCustomViewMatrix(bool enable, const Matrix4& viewMatrix)
-	{
-		mCustomViewMatrix = enable;
-		if (enable)
-		{
-			assert(viewMatrix.isAffine());
-			mViewMatrix = viewMatrix;
-			mViewMatrixInv = mViewMatrix.inverseAffine();
-		}
-
-		_markCoreDirty();
-	}
-
-	void CameraHandlerBase::setCustomProjectionMatrix(bool enable, const Matrix4& projMatrix)
-	{
-		mCustomProjMatrix = enable;
-
-		if (enable)
-			mProjMatrix = projMatrix;
-
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	void CameraHandlerBase::setOrthoWindow(float w, float h)
-	{
-		mOrthoHeight = h;
-		mAspect = w / h;
-
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	void CameraHandlerBase::setOrthoWindowHeight(float h)
-	{
-		mOrthoHeight = h;
-
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	void CameraHandlerBase::setOrthoWindowWidth(float w)
-	{
-		mOrthoHeight = w / mAspect;
-
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	float CameraHandlerBase::getOrthoWindowHeight() const
-	{
-		return mOrthoHeight;
-	}
-
-	float CameraHandlerBase::getOrthoWindowWidth() const
-	{
-		return mOrthoHeight * mAspect;
-	}
-
-	void CameraHandlerBase::setFrustumExtents(float left, float right, float top, float bottom)
-	{
-		mFrustumExtentsManuallySet = true;
-		mLeft = left;
-		mRight = right;
-		mTop = top;
-		mBottom = bottom;
-
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	void CameraHandlerBase::resetFrustumExtents()
-	{
-		mFrustumExtentsManuallySet = false;
-
-		invalidateFrustum();
-		_markCoreDirty();
-	}
-
-	void CameraHandlerBase::getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const
-	{
-		updateFrustum();
-
-		outleft = mLeft;
-		outright = mRight;
-		outtop = mTop;
-		outbottom = mBottom;
-	}
-
-	void CameraHandlerBase::setPosition(const Vector3& position)
-	{
-		mPosition = position;
-
-		mRecalcView = true;
-		_markCoreDirty();
-	}
-
-	void CameraHandlerBase::setRotation(const Quaternion& rotation)
-	{
-		mRotation = rotation;
-
-		mRecalcView = true;
-		_markCoreDirty();
-	}
-
-	void CameraHandlerBase::invalidateFrustum() const
-	{
-		mRecalcFrustum = true;
-		mRecalcFrustumPlanes = true;
-	}
-
-	Vector2I CameraHandlerBase::worldToScreenPoint(const Vector3& worldPoint) const
-	{
-		Vector2 clipPoint = worldToClipPoint(worldPoint);
-		return clipToScreenPoint(clipPoint);
-	}
-
-	Vector2 CameraHandlerBase::worldToClipPoint(const Vector3& worldPoint) const
-	{
-		Vector3 viewPoint = worldToViewPoint(worldPoint);
-		return viewToClipPoint(viewPoint);
-	}
-
-	Vector3 CameraHandlerBase::worldToViewPoint(const Vector3& worldPoint) const
-	{
-		return getViewMatrix().multiplyAffine(worldPoint);
-	}
-
-	Vector3 CameraHandlerBase::screenToWorldPoint(const Vector2I& screenPoint, float depth) const
-	{
-		Vector2 clipPoint = screenToClipPoint(screenPoint);
-		return clipToWorldPoint(clipPoint, depth);
-	}
-
-	Vector3 CameraHandlerBase::screenToViewPoint(const Vector2I& screenPoint, float depth) const
-	{
-		Vector2 clipPoint = screenToClipPoint(screenPoint);
-		return clipToViewPoint(clipPoint, depth);
-	}
-
-	Vector2 CameraHandlerBase::screenToClipPoint(const Vector2I& screenPoint) const
-	{
-		Rect2I viewport = getViewportRect();
-
-		Vector2 clipPoint;
-		clipPoint.x = (float)(((screenPoint.x - viewport.x) / (float)viewport.width) * 2.0f - 1.0f);
-		clipPoint.y = (float)((1.0f - ((screenPoint.y - viewport.y) / (float)viewport.height)) * 2.0f - 1.0f);
-
-		return clipPoint;
-	}
-
-	Vector3 CameraHandlerBase::viewToWorldPoint(const Vector3& viewPoint) const
-	{
-		return getViewMatrix().inverseAffine().multiplyAffine(viewPoint);
-	}
-
-	Vector2I CameraHandlerBase::viewToScreenPoint(const Vector3& viewPoint) const
-	{
-		Vector2 clipPoint = viewToClipPoint(viewPoint);
-		return clipToScreenPoint(clipPoint);
-	}
-
-	Vector2 CameraHandlerBase::viewToClipPoint(const Vector3& viewPoint) const
-	{
-		Vector3 projPoint = projectPoint(viewPoint);
-
-		return Vector2(projPoint.x, projPoint.y);
-	}
-
-	Vector3 CameraHandlerBase::clipToWorldPoint(const Vector2& clipPoint, float depth) const
-	{
-		Vector3 viewPoint = clipToViewPoint(clipPoint, depth);
-		return viewToWorldPoint(viewPoint);
-	}
-
-	Vector3 CameraHandlerBase::clipToViewPoint(const Vector2& clipPoint, float depth) const
-	{
-		return unprojectPoint(Vector3(clipPoint.x, clipPoint.y, depth));
-	}
-
-	Vector2I CameraHandlerBase::clipToScreenPoint(const Vector2& clipPoint) const
-	{
-		Rect2I viewport = getViewportRect();
-
-		Vector2I screenPoint;
-		screenPoint.x = Math::roundToInt(viewport.x + ((clipPoint.x + 1.0f) * 0.5f) * viewport.width);
-		screenPoint.y = Math::roundToInt(viewport.y + (1.0f - (clipPoint.y + 1.0f) * 0.5f) * viewport.height);
-
-		return screenPoint;
-	}
-
-	Ray CameraHandlerBase::screenPointToRay(const Vector2I& screenPoint) const
-	{
-		Vector2 clipPoint = screenToClipPoint(screenPoint);
-
-		Vector3 near = unprojectPoint(Vector3(clipPoint.x, clipPoint.y, mNearDist));
-		Vector3 far = unprojectPoint(Vector3(clipPoint.x, clipPoint.y, mNearDist + 1.0f));
-
-		Ray ray(near, Vector3::normalize(far - near));
-		ray.transformAffine(getViewMatrix().inverseAffine());
-
-		return ray;
-	}
-
-	Vector3 CameraHandlerBase::projectPoint(const Vector3& point) const
-	{
-		Vector4 projPoint4(point.x, point.y, point.z, 1.0f);
-		projPoint4 = getProjectionMatrixRS().multiply(projPoint4);
-
-		if (Math::abs(projPoint4.w) > 1e-7f)
-		{
-			float invW = 1.0f / projPoint4.w;
-			projPoint4.x *= invW;
-			projPoint4.y *= invW;
-			projPoint4.z *= invW;
-		}
-		else
-		{
-			projPoint4.x = 0.0f;
-			projPoint4.y = 0.0f;
-			projPoint4.z = 0.0f;
-		}
-
-		return Vector3(projPoint4.x, projPoint4.y, projPoint4.z);
-	}
-
-	Vector3 CameraHandlerBase::unprojectPoint(const Vector3& point) const
-	{
-		Vector4 dir4(point.x, point.y, 0.95f, 1.0f); // 0.95f arbitrary
-		dir4 = getProjectionMatrixRS().inverse().multiply(dir4);
-
-		Vector3 dir;
-		dir.x = dir4.x;
-		dir.y = dir4.y;
-		dir.z = dir4.z;
-
-		if (Math::abs(dir4.w) > 1e-7f)
-		{
-			float invW = 1.0f / dir4.w;
-			dir.x *= invW;
-			dir.y *= invW;
-			dir.z *= invW;
-
-			// Find a point along a ray from camera origin to point on near plane we just found, 
-			// at point.z distance from the origin
-
-			float distToPlane = dir.dot(-Vector3::UNIT_Z);
-			if (distToPlane >= 0.0f)
-			{
-				if (mProjType == PT_PERSPECTIVE)
-					dir *= point.z / distToPlane;
-				else
-					dir += Vector3::UNIT_Z * (distToPlane - point.z);
-			}
-		}
-		else
-		{
-			dir.x = 0.0f;
-			dir.y = 0.0f;
-			dir.z = 0.0f;
-		}
-
-		return Vector3(dir.x, dir.y, dir.z);
-	}
-
-	CameraHandlerCore::~CameraHandlerCore()
-	{
-		RendererManager::instance().getActive()->_notifyCameraRemoved(this);
-	}
-
-	CameraHandlerCore::CameraHandlerCore(SPtr<RenderTargetCore> target, float left, float top, float width, float height)
-	{
-		mViewport = ViewportCore::create(target, left, top, width, height);
-	}
-
-	CameraHandlerCore::CameraHandlerCore(const SPtr<ViewportCore>& viewport)
-	{
-		mViewport = viewport;
-	}
-
-	void CameraHandlerCore::initialize()
-	{
-		RendererManager::instance().getActive()->_notifyCameraAdded(this);
-
-		CoreObjectCore::initialize();
-	}
-
-	Rect2I CameraHandlerCore::getViewportRect() const
-	{
-		return mViewport->getArea();
-	}
-
-	void CameraHandlerCore::syncToCore(const CoreSyncData& data)
-	{
-		char* dataPtr = (char*)data.getBuffer();
-
-		dataPtr = rttiReadElem(mLayers, dataPtr);
-		dataPtr = rttiReadElem(mPosition, dataPtr);
-		dataPtr = rttiReadElem(mRotation, dataPtr);
-		dataPtr = rttiReadElem(mProjType, dataPtr);
-		dataPtr = rttiReadElem(mHorzFOV, dataPtr);
-		dataPtr = rttiReadElem(mFarDist, dataPtr);
-		dataPtr = rttiReadElem(mNearDist, dataPtr);
-		dataPtr = rttiReadElem(mAspect, dataPtr);
-		dataPtr = rttiReadElem(mOrthoHeight, dataPtr);
-		dataPtr = rttiReadElem(mPriority, dataPtr);
-		dataPtr = rttiReadElem(mCustomViewMatrix, dataPtr);
-		dataPtr = rttiReadElem(mCustomProjMatrix, dataPtr);
-		dataPtr = rttiReadElem(mFrustumExtentsManuallySet, dataPtr);
-
-		mRecalcFrustum = true;
-		mRecalcFrustumPlanes = true;
-		mRecalcView = true;
-	}
-
-	CameraHandler::CameraHandler(RenderTargetPtr target, float left, float top, float width, float height)
-		:mLastUpdateHash(0)
-	{
-		if (target != nullptr)
-			target->blockUntilCoreInitialized();
-
-		mViewport = Viewport::create(target, left, top, width, height);
-	}
-
-	SPtr<CameraHandlerCore> CameraHandler::getCore() const
-	{
-		return std::static_pointer_cast<CameraHandlerCore>(mCoreSpecific);
-	}
-
-	CameraHandlerPtr CameraHandler::create(RenderTargetPtr target, float left, float top, float width, float height)
-	{
-		CameraHandler* handler = new (bs_alloc<CameraHandler>()) CameraHandler(target, left, top, width, height);
-		CameraHandlerPtr handlerPtr = bs_core_ptr<CameraHandler>(handler);
-		handlerPtr->_setThisPtr(handlerPtr);
-		handlerPtr->initialize();
-
-		return handlerPtr;
-	}
-
-	CameraHandlerPtr CameraHandler::createEmpty()
-	{
-		CameraHandler* handler = new (bs_alloc<CameraHandler>()) CameraHandler();
-		CameraHandlerPtr handlerPtr = bs_core_ptr<CameraHandler>(handler);
-		handlerPtr->_setThisPtr(handlerPtr);
-
-		return handlerPtr;
-	}
-
-	SPtr<CoreObjectCore> CameraHandler::createCore() const
-	{
-		Rect2 normArea = mViewport->getNormArea();
-
-		CameraHandlerCore* handler = new (bs_alloc<CameraHandlerCore>()) CameraHandlerCore(mViewport->getCore());
-		SPtr<CameraHandlerCore> handlerPtr = bs_shared_ptr<CameraHandlerCore>(handler);
-		handlerPtr->_setThisPtr(handlerPtr);
-
-		return handlerPtr;
-	}
-
-	Rect2I CameraHandler::getViewportRect() const
-	{
-		return mViewport->getArea();
-	}
-
-	CoreSyncData CameraHandler::syncToCore(FrameAlloc* allocator)
-	{
-		UINT32 size = 0;
-		size += rttiGetElemSize(mLayers);
-		size += rttiGetElemSize(mPosition);
-		size += rttiGetElemSize(mRotation);
-		size += rttiGetElemSize(mProjType);
-		size += rttiGetElemSize(mHorzFOV);
-		size += rttiGetElemSize(mFarDist);
-		size += rttiGetElemSize(mNearDist);
-		size += rttiGetElemSize(mAspect);
-		size += rttiGetElemSize(mOrthoHeight);
-		size += rttiGetElemSize(mPriority);
-
-		size += rttiGetElemSize(mCustomViewMatrix);
-		size += rttiGetElemSize(mCustomProjMatrix);
-
-		size += rttiGetElemSize(mFrustumExtentsManuallySet);
-
-		UINT8* buffer = allocator->alloc(size);
-
-		char* dataPtr = (char*)buffer;
-		dataPtr = rttiWriteElem(mLayers, dataPtr);
-		dataPtr = rttiWriteElem(mPosition, dataPtr);
-		dataPtr = rttiWriteElem(mRotation, dataPtr);
-		dataPtr = rttiWriteElem(mProjType, dataPtr);
-		dataPtr = rttiWriteElem(mHorzFOV, dataPtr);
-		dataPtr = rttiWriteElem(mFarDist, dataPtr);
-		dataPtr = rttiWriteElem(mNearDist, dataPtr);
-		dataPtr = rttiWriteElem(mAspect, dataPtr);
-		dataPtr = rttiWriteElem(mOrthoHeight, dataPtr);
-		dataPtr = rttiWriteElem(mPriority, dataPtr);
-		dataPtr = rttiWriteElem(mCustomViewMatrix, dataPtr);
-		dataPtr = rttiWriteElem(mCustomProjMatrix, dataPtr);
-		dataPtr = rttiWriteElem(mFrustumExtentsManuallySet, dataPtr);
-
-		return CoreSyncData(buffer, size);
-	}
-
-	void CameraHandler::getCoreDependencies(Vector<SPtr<CoreObject>>& dependencies)
-	{
-		dependencies.push_back(mViewport);
-	}
-
-	void CameraHandler::_markCoreDirty()
-	{
-		markCoreDirty();
-	}
-
-	RTTITypeBase* CameraHandler::getRTTIStatic()
-	{
-		return CameraHandlerRTTI::instance();
-	}
-
-	RTTITypeBase* CameraHandler::getRTTI() const
-	{
-		return CameraHandler::getRTTIStatic();
-	}
-}

+ 1 - 1
BansheeEngine/Source/BsGUIViewport.cpp

@@ -3,7 +3,7 @@
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsViewport.h"
 #include "BsRenderTarget.h"
 #include "BsException.h"

+ 1 - 1
BansheeEngine/Source/BsGUIWidget.cpp

@@ -11,7 +11,7 @@
 #include "BsMesh.h"
 #include "BsVector2I.h"
 #include "BsOverlayManager.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsViewport.h"
 #include "BsSceneObject.h"
 #include "BsRenderWindow.h"

+ 212 - 22
BansheeEngine/Source/BsLight.cpp

@@ -1,49 +1,239 @@
 #include "BsLight.h"
 #include "BsLightRTTI.h"
-#include "BsSceneManager.h"
+#include "BsRendererManager.h"
+#include "BsRenderer.h"
+#include "BsFrameAlloc.h"
+#include "BsSceneObject.h"
 
 namespace BansheeEngine
 {
-	Light::Light(const HSceneObject& parent, LightType type, Color color,
+	LightBase::LightBase()
+		:mType(LightType::Point), mCastsShadows(false), mRange(10.0f),
+		mIntensity(100.0f), mSpotAngle(45), mColor(Color::White), mIsActive(true)
+	{
+		mBounds = Sphere(mPosition, mRange);
+	}
+
+	LightBase::LightBase(LightType type, Color color,
 		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
-		: Component(parent), mType(type), mColor(color), mIntensity(intensity), mRange(range),
-		mCastsShadows(castsShadows), mSpotAngle(spotAngle), mSpotFalloffAngle(spotFalloffAngle)
+		:mType(type), mCastsShadows(castsShadows), mRange(range), mSpotFalloffAngle(spotFalloffAngle),
+		mIntensity(intensity), mSpotAngle(spotAngle), mColor(color), mIsActive(true)
 	{
-		setName("Light");
+		mBounds = Sphere(mPosition, mRange);
 	}
 
-	Light::~Light()
+	float LightBase::getRadiance() const
 	{
-		mInternal->destroy();
+		switch (mType)
+		{
+		case LightType::Point:
+			return mIntensity / (4 * Math::PI);
+		case LightType::Spot:
+		{
+			float cosTotalAngle = Math::cos(mSpotAngle);
+			float cosFalloffAngle = Math::cos(mSpotFalloffAngle);
+
+			return mIntensity / (Math::TWO_PI * (1.0f - (cosFalloffAngle + cosTotalAngle) * 0.5f));
+		}
+		}
+
+		return mIntensity;
 	}
 
-	Sphere Light::getBounds() const
+	void LightBase::updateBounds()
 	{
-		mInternal->_updateTransform(SO());
+		switch (mType)
+		{
+		case LightType::Directional:
+			mBounds = Sphere(mPosition, std::numeric_limits<float>::infinity());
+			break;
+		case LightType::Point:
+			mBounds = Sphere(mPosition, mRange);
+			break;
+		case LightType::Spot:
+		{
+			Degree angle = Math::clamp(mSpotAngle, Degree(-90), Degree(90));
+			float coneRadius = Math::tan(angle) * mRange;
 
-		return mInternal->getBounds();
+			float radius;
+			Vector3 offset;
+			if (coneRadius < mRange)
+			{
+				radius = (mRange * mRange + coneRadius * coneRadius) / (0.5f * mRange);
+				offset = Vector3(0, 0, -(mRange - coneRadius));
+			}
+			else
+				radius = coneRadius;
+
+			Vector3 center = mPosition + mRotation.rotate(offset);
+			mBounds = Sphere(center, radius);
+		}
+			break;
+		}
 	}
 
-	void Light::onInitialized()
+	LightCore::LightCore(LightType type, Color color,
+		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
+		:LightBase(type, color, intensity, range, castsShadows, spotAngle, spotFalloffAngle), mRendererId(0)
 	{
-		// If mInternal already exists this means this object was deserialized,
-		// so all we need to do is initialize it.
-		if (mInternal != nullptr)
-			mInternal->initialize();
+
+	}
+
+	LightCore::~LightCore()
+	{
+		gRenderer()->_notifyLightRemoved(this);
+	}
+
+	void LightCore::initialize()
+	{
+		gRenderer()->_notifyLightAdded(this);
+
+		CoreObjectCore::initialize();
+	}
+
+	void LightCore::syncToCore(const CoreSyncData& data)
+	{
+		char* dataPtr = (char*)data.getBuffer();
+
+		UINT32 dirtyFlags = 0;
+		bool oldIsActive = mIsActive;
+
+		dataPtr = rttiReadElem(mPosition, dataPtr);
+		dataPtr = rttiReadElem(mRotation, dataPtr);
+		dataPtr = rttiReadElem(mType, dataPtr);
+		dataPtr = rttiReadElem(mCastsShadows, dataPtr);
+		dataPtr = rttiReadElem(mColor, dataPtr);
+		dataPtr = rttiReadElem(mRange, dataPtr);
+		dataPtr = rttiReadElem(mIntensity, dataPtr);
+		dataPtr = rttiReadElem(mSpotAngle, dataPtr);
+		dataPtr = rttiReadElem(mSpotFalloffAngle, dataPtr);
+		dataPtr = rttiReadElem(mIsActive, dataPtr);
+		dataPtr = rttiReadElem(dirtyFlags, dataPtr);
+		dataPtr = rttiReadElem(mBounds, dataPtr);
+
+		if (dirtyFlags == (UINT32)LightDirtyFlag::Transform)
+		{
+			if (mIsActive)
+				gRenderer()->_notifyLightUpdated(this);
+		}
 		else
 		{
-			mInternal = LightInternal::create(mType, mColor, mIntensity,
-				mRange, mCastsShadows, mSpotAngle, mSpotFalloffAngle);
+			if (oldIsActive != mIsActive)
+			{
+				if (mIsActive)
+					gRenderer()->_notifyLightAdded(this);
+				else
+					gRenderer()->_notifyLightRemoved(this);
+			}
+			else
+			{
+				gRenderer()->_notifyLightRemoved(this);
+				gRenderer()->_notifyLightAdded(this);
+			}
 		}
+	}
+
+	Light::Light()
+		:mLastUpdateHash(0)
+	{
+		
+	}
+
+	Light::Light(LightType type, Color color,
+		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
+		: LightBase(type, color, intensity, range, castsShadows, spotAngle, spotFalloffAngle),
+		mLastUpdateHash(0)
+	{
 
-		gSceneManager()._registerLight(mInternal, sceneObject());
 	}
 
-	void Light::onDestroyed()
+	SPtr<LightCore> Light::getCore() const
 	{
-		gSceneManager()._unregisterLight(mInternal);
+		return std::static_pointer_cast<LightCore>(mCoreSpecific);
 	}
-	
+
+	SPtr<Light> Light::create(LightType type, Color color,
+		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
+	{
+		Light* handler = new (bs_alloc<Light>()) 
+			Light(type, color, intensity, range, castsShadows, spotAngle, spotFalloffAngle);
+		SPtr<Light> handlerPtr = bs_core_ptr<Light>(handler);
+		handlerPtr->_setThisPtr(handlerPtr);
+		handlerPtr->initialize();
+
+		return handlerPtr;
+	}
+
+	SPtr<Light> Light::createEmpty()
+	{
+		Light* handler = new (bs_alloc<Light>()) Light();
+		SPtr<Light> handlerPtr = bs_core_ptr<Light>(handler);
+		handlerPtr->_setThisPtr(handlerPtr);
+
+		return handlerPtr;
+	}
+
+	SPtr<CoreObjectCore> Light::createCore() const
+	{
+		LightCore* handler = new (bs_alloc<LightCore>()) 
+			LightCore(mType, mColor, mIntensity, mRange, mCastsShadows, mSpotAngle, mSpotFalloffAngle);
+		SPtr<LightCore> handlerPtr = bs_shared_ptr<LightCore>(handler);
+		handlerPtr->_setThisPtr(handlerPtr);
+
+		return handlerPtr;
+	}
+
+	CoreSyncData Light::syncToCore(FrameAlloc* allocator)
+	{
+		UINT32 size = 0;
+		size += rttiGetElemSize(mPosition);
+		size += rttiGetElemSize(mRotation);
+		size += rttiGetElemSize(mType);
+		size += rttiGetElemSize(mCastsShadows);
+		size += rttiGetElemSize(mColor);
+		size += rttiGetElemSize(mRange);
+		size += rttiGetElemSize(mIntensity);
+		size += rttiGetElemSize(mSpotAngle);
+		size += rttiGetElemSize(mIsActive);
+		size += rttiGetElemSize(mSpotFalloffAngle);
+		size += rttiGetElemSize(getCoreDirtyFlags());
+		size += rttiGetElemSize(mBounds);
+
+		UINT8* buffer = allocator->alloc(size);
+
+		char* dataPtr = (char*)buffer;
+		dataPtr = rttiWriteElem(mPosition, dataPtr);
+		dataPtr = rttiWriteElem(mRotation, dataPtr);
+		dataPtr = rttiWriteElem(mType, dataPtr);
+		dataPtr = rttiWriteElem(mCastsShadows, dataPtr);
+		dataPtr = rttiWriteElem(mColor, dataPtr);
+		dataPtr = rttiWriteElem(mRange, dataPtr);
+		dataPtr = rttiWriteElem(mIntensity, dataPtr);
+		dataPtr = rttiWriteElem(mSpotAngle, dataPtr);
+		dataPtr = rttiWriteElem(mSpotFalloffAngle, dataPtr);
+		dataPtr = rttiWriteElem(mIsActive, dataPtr);
+		dataPtr = rttiWriteElem(getCoreDirtyFlags(), dataPtr);
+		dataPtr = rttiWriteElem(mBounds, dataPtr);
+
+		return CoreSyncData(buffer, size);
+	}
+
+	void Light::_updateTransform(const HSceneObject& parent)
+	{
+		UINT32 curHash = parent->getTransformHash();
+		if (curHash != _getLastModifiedHash())
+		{
+			setPosition(parent->getWorldPosition());
+			setRotation(parent->getWorldRotation());
+			_setLastModifiedHash(curHash);
+		}
+	}
+
+	void Light::_markCoreDirty(LightDirtyFlag flag)
+	{
+		markCoreDirty((UINT32)flag);
+	}
+
 	RTTITypeBase* Light::getRTTIStatic()
 	{
 		return LightRTTI::instance();
@@ -53,4 +243,4 @@ namespace BansheeEngine
 	{
 		return Light::getRTTIStatic();
 	}
-}
+}

+ 0 - 246
BansheeEngine/Source/BsLightInternal.cpp

@@ -1,246 +0,0 @@
-#include "BsLightInternal.h"
-#include "BsRendererManager.h"
-#include "BsRenderer.h"
-#include "BsFrameAlloc.h"
-#include "BsSceneObject.h"
-#include "BsLightInternalRTTI.h"
-
-namespace BansheeEngine
-{
-	LightInternalBase::LightInternalBase()
-		:mType(LightType::Point), mCastsShadows(false), mRange(10.0f),
-		mIntensity(100.0f), mSpotAngle(45), mColor(Color::White), mIsActive(true)
-	{
-		mBounds = Sphere(mPosition, mRange);
-	}
-
-	LightInternalBase::LightInternalBase(LightType type, Color color,
-		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
-		:mType(type), mCastsShadows(castsShadows), mRange(range), mSpotFalloffAngle(spotFalloffAngle),
-		mIntensity(intensity), mSpotAngle(spotAngle), mColor(color), mIsActive(true)
-	{
-		mBounds = Sphere(mPosition, mRange);
-	}
-
-	float LightInternalBase::getRadiance() const
-	{
-		switch (mType)
-		{
-		case LightType::Point:
-			return mIntensity / (4 * Math::PI);
-		case LightType::Spot:
-		{
-			float cosTotalAngle = Math::cos(mSpotAngle);
-			float cosFalloffAngle = Math::cos(mSpotFalloffAngle);
-
-			return mIntensity / (Math::TWO_PI * (1.0f - (cosFalloffAngle + cosTotalAngle) * 0.5f));
-		}
-		}
-
-		return mIntensity;
-	}
-
-	void LightInternalBase::updateBounds()
-	{
-		switch (mType)
-		{
-		case LightType::Directional:
-			mBounds = Sphere(mPosition, std::numeric_limits<float>::infinity());
-			break;
-		case LightType::Point:
-			mBounds = Sphere(mPosition, mRange);
-			break;
-		case LightType::Spot:
-		{
-			Degree angle = Math::clamp(mSpotAngle, Degree(-90), Degree(90));
-			float coneRadius = Math::tan(angle) * mRange;
-
-			float radius;
-			Vector3 offset;
-			if (coneRadius < mRange)
-			{
-				radius = (mRange * mRange + coneRadius * coneRadius) / (0.5f * mRange);
-				offset = Vector3(0, 0, -(mRange - coneRadius));
-			}
-			else
-				radius = coneRadius;
-
-			Vector3 center = mPosition + mRotation.rotate(offset);
-			mBounds = Sphere(center, radius);
-		}
-			break;
-		}
-	}
-
-	LightInternalCore::LightInternalCore(LightType type, Color color,
-		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
-		:LightInternalBase(type, color, intensity, range, castsShadows, spotAngle, spotFalloffAngle), mRendererId(0)
-	{
-
-	}
-
-	LightInternalCore::~LightInternalCore()
-	{
-		gRenderer()->_notifyLightRemoved(this);
-	}
-
-	void LightInternalCore::initialize()
-	{
-		gRenderer()->_notifyLightAdded(this);
-
-		CoreObjectCore::initialize();
-	}
-
-	void LightInternalCore::syncToCore(const CoreSyncData& data)
-	{
-		char* dataPtr = (char*)data.getBuffer();
-
-		UINT32 dirtyFlags = 0;
-		bool oldIsActive = mIsActive;
-
-		dataPtr = rttiReadElem(mPosition, dataPtr);
-		dataPtr = rttiReadElem(mRotation, dataPtr);
-		dataPtr = rttiReadElem(mType, dataPtr);
-		dataPtr = rttiReadElem(mCastsShadows, dataPtr);
-		dataPtr = rttiReadElem(mColor, dataPtr);
-		dataPtr = rttiReadElem(mRange, dataPtr);
-		dataPtr = rttiReadElem(mIntensity, dataPtr);
-		dataPtr = rttiReadElem(mSpotAngle, dataPtr);
-		dataPtr = rttiReadElem(mSpotFalloffAngle, dataPtr);
-		dataPtr = rttiReadElem(mIsActive, dataPtr);
-		dataPtr = rttiReadElem(dirtyFlags, dataPtr);
-		dataPtr = rttiReadElem(mBounds, dataPtr);
-
-		if (dirtyFlags == (UINT32)LightDirtyFlag::Transform)
-		{
-			if (mIsActive)
-				gRenderer()->_notifyLightUpdated(this);
-		}
-		else
-		{
-			if (oldIsActive != mIsActive)
-			{
-				if (mIsActive)
-					gRenderer()->_notifyLightAdded(this);
-				else
-					gRenderer()->_notifyLightRemoved(this);
-			}
-			else
-			{
-				gRenderer()->_notifyLightRemoved(this);
-				gRenderer()->_notifyLightAdded(this);
-			}
-		}
-	}
-
-	LightInternal::LightInternal()
-		:mLastUpdateHash(0)
-	{
-		
-	}
-
-	LightInternal::LightInternal(LightType type, Color color,
-		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
-		: LightInternalBase(type, color, intensity, range, castsShadows, spotAngle, spotFalloffAngle),
-		mLastUpdateHash(0)
-	{
-
-	}
-
-	SPtr<LightInternalCore> LightInternal::getCore() const
-	{
-		return std::static_pointer_cast<LightInternalCore>(mCoreSpecific);
-	}
-
-	SPtr<LightInternal> LightInternal::create(LightType type, Color color,
-		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
-	{
-		LightInternal* handler = new (bs_alloc<LightInternal>()) 
-			LightInternal(type, color, intensity, range, castsShadows, spotAngle, spotFalloffAngle);
-		SPtr<LightInternal> handlerPtr = bs_core_ptr<LightInternal>(handler);
-		handlerPtr->_setThisPtr(handlerPtr);
-		handlerPtr->initialize();
-
-		return handlerPtr;
-	}
-
-	SPtr<LightInternal> LightInternal::createEmpty()
-	{
-		LightInternal* handler = new (bs_alloc<LightInternal>()) LightInternal();
-		SPtr<LightInternal> handlerPtr = bs_core_ptr<LightInternal>(handler);
-		handlerPtr->_setThisPtr(handlerPtr);
-
-		return handlerPtr;
-	}
-
-	SPtr<CoreObjectCore> LightInternal::createCore() const
-	{
-		LightInternalCore* handler = new (bs_alloc<LightInternalCore>()) 
-			LightInternalCore(mType, mColor, mIntensity, mRange, mCastsShadows, mSpotAngle, mSpotFalloffAngle);
-		SPtr<LightInternalCore> handlerPtr = bs_shared_ptr<LightInternalCore>(handler);
-		handlerPtr->_setThisPtr(handlerPtr);
-
-		return handlerPtr;
-	}
-
-	CoreSyncData LightInternal::syncToCore(FrameAlloc* allocator)
-	{
-		UINT32 size = 0;
-		size += rttiGetElemSize(mPosition);
-		size += rttiGetElemSize(mRotation);
-		size += rttiGetElemSize(mType);
-		size += rttiGetElemSize(mCastsShadows);
-		size += rttiGetElemSize(mColor);
-		size += rttiGetElemSize(mRange);
-		size += rttiGetElemSize(mIntensity);
-		size += rttiGetElemSize(mSpotAngle);
-		size += rttiGetElemSize(mIsActive);
-		size += rttiGetElemSize(mSpotFalloffAngle);
-		size += rttiGetElemSize(getCoreDirtyFlags());
-		size += rttiGetElemSize(mBounds);
-
-		UINT8* buffer = allocator->alloc(size);
-
-		char* dataPtr = (char*)buffer;
-		dataPtr = rttiWriteElem(mPosition, dataPtr);
-		dataPtr = rttiWriteElem(mRotation, dataPtr);
-		dataPtr = rttiWriteElem(mType, dataPtr);
-		dataPtr = rttiWriteElem(mCastsShadows, dataPtr);
-		dataPtr = rttiWriteElem(mColor, dataPtr);
-		dataPtr = rttiWriteElem(mRange, dataPtr);
-		dataPtr = rttiWriteElem(mIntensity, dataPtr);
-		dataPtr = rttiWriteElem(mSpotAngle, dataPtr);
-		dataPtr = rttiWriteElem(mSpotFalloffAngle, dataPtr);
-		dataPtr = rttiWriteElem(mIsActive, dataPtr);
-		dataPtr = rttiWriteElem(getCoreDirtyFlags(), dataPtr);
-		dataPtr = rttiWriteElem(mBounds, dataPtr);
-
-		return CoreSyncData(buffer, size);
-	}
-
-	void LightInternal::_updateTransform(const HSceneObject& parent)
-	{
-		UINT32 curHash = parent->getTransformHash();
-		if (curHash != _getLastModifiedHash())
-		{
-			setPosition(parent->getWorldPosition());
-			setRotation(parent->getWorldRotation());
-			_setLastModifiedHash(curHash);
-		}
-	}
-
-	void LightInternal::_markCoreDirty(LightDirtyFlag flag)
-	{
-		markCoreDirty((UINT32)flag);
-	}
-
-	RTTITypeBase* LightInternal::getRTTIStatic()
-	{
-		return LightInternalRTTI::instance();
-	}
-
-	RTTITypeBase* LightInternal::getRTTI() const
-	{
-		return LightInternal::getRTTIStatic();
-	}
-}

+ 6 - 6
BansheeEngine/Source/BsOverlayManager.cpp

@@ -1,10 +1,10 @@
 #include "BsOverlayManager.h"
-#include "BsCamera.h"
-#include "BsOverlay.h"
+#include "BsCCamera.h"
+#include "BsCOverlay.h"
 
 namespace BansheeEngine
 {
-	bool OverlayManager::OverlayComparer::operator() (const Overlay* const& a, const Overlay* const& b)
+	bool OverlayManager::OverlayComparer::operator() (const COverlay* const& a, const COverlay* const& b)
 	{
 		return a->getDepth() > b->getDepth();
 	}
@@ -23,17 +23,17 @@ namespace BansheeEngine
 		}
 	}
 
-	void OverlayManager::attachOverlay(const Viewport* target, const Overlay* overlay)
+	void OverlayManager::attachOverlay(const Viewport* target, const COverlay* overlay)
 	{
 		mOverlaysPerTarget[target].insert(overlay);
 	}
 
-	void OverlayManager::detachOverlay(const Viewport* target, const Overlay* overlay)
+	void OverlayManager::detachOverlay(const Viewport* target, const COverlay* overlay)
 	{
 		mOverlaysPerTarget[target].erase(overlay);
 	}
 
-	void OverlayManager::detachOverlayFromAll(const Overlay* overlay)
+	void OverlayManager::detachOverlayFromAll(const COverlay* overlay)
 	{
 		for(auto& overlays : mOverlaysPerTarget)
 		{

+ 288 - 21
BansheeEngine/Source/BsRenderable.cpp

@@ -6,53 +6,320 @@
 #include "BsMaterial.h"
 #include "BsRenderQueue.h"
 #include "BsBounds.h"
-#include "BsSceneManager.h"
+#include "BsRenderer.h"
+#include "BsFrameAlloc.h"
+#include "BsDebug.h"
 
 namespace BansheeEngine
 {
-	Renderable::Renderable(const HSceneObject& parent)
-		:Component(parent)
+	template<bool Core>
+	TRenderable<Core>::TRenderable()
+		:mLayer(1), mTransform(Matrix4::IDENTITY), mIsActive(true)
 	{
-		setName("Renderable");
+		mMaterials.resize(1);
 	}
 
-	void Renderable::onInitialized()
+	template<bool Core>
+	TRenderable<Core>::~TRenderable()
 	{
-		// If mInternal already exists this means this object was deserialized,
-		// so all we need to do is initialize it.
-		if (mInternal != nullptr)
-			mInternal->initialize();
+
+	}
+
+	template<bool Core>
+	void TRenderable<Core>::setMesh(const MeshType& mesh)
+	{
+		mMesh = mesh;
+
+		int numSubMeshes = 0;
+		if (mesh != nullptr)
+			numSubMeshes = mesh->getProperties().getNumSubMeshes();
+
+		mMaterials.resize(numSubMeshes);
+
+		_markResourcesDirty();
+		_markCoreDirty();
+	}
+
+	template<bool Core>
+	void TRenderable<Core>::setMaterial(UINT32 idx, const MaterialType& material)
+	{
+		if (idx >= (UINT32)mMaterials.size())
+			return;
+
+		mMaterials[idx] = material;
+
+		_markResourcesDirty();
+		_markCoreDirty();
+	}
+
+	template<bool Core>
+	void TRenderable<Core>::setMaterial(const MaterialType& material)
+	{
+		setMaterial(0, material);
+	}
+
+	template<bool Core>
+	void TRenderable<Core>::setLayer(UINT64 layer)
+	{
+		bool isPow2 = layer && !((layer - 1) & layer);
+
+		if (!isPow2)
+		{
+			LOGWRN("Invalid layer provided. Only one layer bit may be set. Ignoring.");
+			return;
+		}
+
+		mLayer = layer;
+		_markCoreDirty();
+	}
+
+	template<bool Core>
+	void TRenderable<Core>::setTransform(const Matrix4& transform)
+	{
+		mTransform = transform;
+		_markCoreDirty(RenderableDirtyFlag::Transform);
+	}
+
+	template<bool Core>
+	void TRenderable<Core>::setPosition(const Vector3& position)
+	{
+		mPosition = position;
+		_markCoreDirty(RenderableDirtyFlag::Transform);
+	}
+
+	template<bool Core>
+	void TRenderable<Core>::setIsActive(bool active)
+	{
+		mIsActive = active;
+		_markCoreDirty();
+	}
+
+	template class TRenderable < false >;
+	template class TRenderable < true >;
+
+	RenderableCore::RenderableCore() 
+		:mRendererId(0)
+	{
+	}
+
+	RenderableCore::~RenderableCore()
+	{
+		if (mIsActive)
+			gRenderer()->_notifyRenderableRemoved(this);
+	}
+
+	void RenderableCore::initialize()
+	{
+		gRenderer()->_notifyRenderableAdded(this);
+
+		CoreObjectCore::initialize();
+	}
+
+	Bounds RenderableCore::getBounds() const
+	{
+		SPtr<MeshCore> mesh = getMesh();
+
+		if (mesh == nullptr)
+		{
+			AABox box(mPosition, mPosition);
+			Sphere sphere(mPosition, 0.0f);
+
+			return Bounds(box, sphere);
+		}
+		else
+		{
+			Bounds bounds = mesh->getProperties().getBounds();
+			bounds.transformAffine(mTransform);
+
+			return bounds;
+		}
+	}
+
+	void RenderableCore::syncToCore(const CoreSyncData& data)
+	{
+		char* dataPtr = (char*)data.getBuffer();
+
+		mWorldBounds.clear();
+		mMaterials.clear();
+
+		UINT32 numMaterials = 0;
+		UINT32 dirtyFlags = 0;
+		bool oldIsActive = mIsActive;
+
+		dataPtr = rttiReadElem(mLayer, dataPtr);
+		dataPtr = rttiReadElem(mWorldBounds, dataPtr);
+		dataPtr = rttiReadElem(numMaterials, dataPtr);
+		dataPtr = rttiReadElem(mTransform, dataPtr);
+		dataPtr = rttiReadElem(mPosition, dataPtr);
+		dataPtr = rttiReadElem(mIsActive, dataPtr);
+		dataPtr = rttiReadElem(dirtyFlags, dataPtr);
+
+		SPtr<MeshCore>* mesh = (SPtr<MeshCore>*)dataPtr;
+		mMesh = *mesh;
+		mesh->~SPtr<MeshCore>();
+		dataPtr += sizeof(SPtr<MeshCore>);
+
+		for (UINT32 i = 0; i < numMaterials; i++)
+		{
+			SPtr<MaterialCore>* material = (SPtr<MaterialCore>*)dataPtr;
+			mMaterials.push_back(*material);
+			material->~SPtr<MaterialCore>();
+			dataPtr += sizeof(SPtr<MaterialCore>);
+		}
+
+		if (dirtyFlags == (UINT32)RenderableDirtyFlag::Transform)
+		{
+			if (mIsActive)
+				gRenderer()->_notifyRenderableUpdated(this);
+		}
 		else
-			mInternal = RenderableHandler::create();
+		{
+			if (oldIsActive != mIsActive)
+			{
+				if (mIsActive)
+					gRenderer()->_notifyRenderableAdded(this);
+				else
+					gRenderer()->_notifyRenderableRemoved(this);
+			}
+			else
+			{
+				gRenderer()->_notifyRenderableRemoved(this);
+				gRenderer()->_notifyRenderableAdded(this);
+			}
+		}
+	}
 
-		gSceneManager()._registerRenderable(mInternal, sceneObject());
+	Renderable::Renderable()
+		:mLastUpdateHash(0)
+	{
+		
 	}
 
 	Bounds Renderable::getBounds() const
 	{
-		updateTransform();
+		HMesh mesh = getMesh();
+
+		if (!mesh.isLoaded())
+		{
+			AABox box(mPosition, mPosition);
+			Sphere sphere(mPosition, 0.0f);
+
+			return Bounds(box, sphere);
+		}
+		else
+		{
+			Bounds bounds = mesh->getProperties().getBounds();
+			bounds.transformAffine(mTransform);
 
-		return mInternal->getBounds();
+			return bounds;
+		}
+	}
+
+	SPtr<RenderableCore> Renderable::getCore() const
+	{
+		return std::static_pointer_cast<RenderableCore>(mCoreSpecific);
 	}
 
-	void Renderable::updateTransform() const
+	SPtr<CoreObjectCore> Renderable::createCore() const
 	{
-		UINT32 curHash = SO()->getTransformHash();
-		if (curHash != mInternal->_getLastModifiedHash())
+		RenderableCore* handler = new (bs_alloc<RenderableCore>()) RenderableCore();
+		SPtr<RenderableCore> handlerPtr = bs_shared_ptr<RenderableCore>(handler);
+		handlerPtr->_setThisPtr(handlerPtr);
+
+		return handlerPtr;
+	}
+
+	void Renderable::_markCoreDirty(RenderableDirtyFlag flag)
+	{
+		markCoreDirty((UINT32)flag);
+	}
+
+	void Renderable::_markResourcesDirty()
+	{
+		markListenerResourcesDirty();
+	}
+
+	CoreSyncData Renderable::syncToCore(FrameAlloc* allocator)
+	{
+		UINT32 numMaterials = (UINT32)mMaterials.size();
+
+		UINT32 size = rttiGetElemSize(mLayer) + 
+			rttiGetElemSize(mWorldBounds) + 
+			rttiGetElemSize(numMaterials) + 
+			rttiGetElemSize(mTransform) +
+			rttiGetElemSize(mPosition) +
+			rttiGetElemSize(mIsActive) +
+			rttiGetElemSize(getCoreDirtyFlags()) +
+			sizeof(SPtr<MeshCore>) + 
+			numMaterials * sizeof(SPtr<MaterialCore>);
+
+		UINT8* data = allocator->alloc(size);
+		char* dataPtr = (char*)data;
+		dataPtr = rttiWriteElem(mLayer, dataPtr);
+		dataPtr = rttiWriteElem(mWorldBounds, dataPtr);
+		dataPtr = rttiWriteElem(numMaterials, dataPtr);
+		dataPtr = rttiWriteElem(mTransform, dataPtr);
+		dataPtr = rttiWriteElem(mPosition, dataPtr);
+		dataPtr = rttiWriteElem(mIsActive, dataPtr);
+		dataPtr = rttiWriteElem(getCoreDirtyFlags(), dataPtr);
+
+		SPtr<MeshCore>* mesh = new (dataPtr) SPtr<MeshCore>();
+		if (mMesh.isLoaded())
+			*mesh = mMesh->getCore();
+
+		dataPtr += sizeof(SPtr<MeshCore>);
+
+		for (UINT32 i = 0; i < numMaterials; i++)
 		{
-			mInternal->setTransform(SO()->getWorldTfrm());
-			mInternal->_setLastModifiedHash(curHash);
+			SPtr<MaterialCore>* material = new (dataPtr)SPtr<MaterialCore>();
+			if (mMaterials[i].isLoaded())
+				*material = mMaterials[i]->getCore();
+
+			dataPtr += sizeof(SPtr<MaterialCore>);
 		}
+
+		return CoreSyncData(data, size);
 	}
 
-	void Renderable::update()
+	void Renderable::getCoreDependencies(Vector<SPtr<CoreObject>>& dependencies)
 	{
+		if (mMesh.isLoaded())
+			dependencies.push_back(mMesh.getInternalPtr());
 
+		for (auto& material : mMaterials)
+		{
+			if (material.isLoaded())
+				dependencies.push_back(material.getInternalPtr());
+		}
 	}
 
-	void Renderable::onDestroyed()
+	void Renderable::getListenerResources(Vector<HResource>& resources)
 	{
-		gSceneManager()._unregisterRenderable(mInternal);
+		if (mMesh != nullptr)
+			resources.push_back(mMesh);
+
+		for (auto& material : mMaterials)
+		{
+			if (material != nullptr)
+				resources.push_back(material);
+		}
+	}
+
+	RenderablePtr Renderable::create()
+	{
+		RenderablePtr handlerPtr = createEmpty();
+		handlerPtr->initialize();
+
+		return handlerPtr;
+	}
+
+	RenderablePtr Renderable::createEmpty()
+	{
+		Renderable* handler = new (bs_alloc<Renderable>()) Renderable();
+		RenderablePtr handlerPtr = bs_core_ptr<Renderable>(handler);
+		handlerPtr->_setThisPtr(handlerPtr);
+
+		return handlerPtr;
 	}
 
 	RTTITypeBase* Renderable::getRTTIStatic()

+ 0 - 334
BansheeEngine/Source/BsRenderableHandler.cpp

@@ -1,334 +0,0 @@
-#include "BsRenderableHandler.h"
-#include "BsRenderableHandlerRTTI.h"
-#include "BsSceneObject.h"
-#include "BsBuiltinResources.h"
-#include "BsMesh.h"
-#include "BsMaterial.h"
-#include "BsRenderQueue.h"
-#include "BsBounds.h"
-#include "BsRenderer.h"
-#include "BsFrameAlloc.h"
-#include "BsDebug.h"
-
-namespace BansheeEngine
-{
-	template<bool Core>
-	TRenderableHandler<Core>::TRenderableHandler()
-		:mLayer(1), mTransform(Matrix4::IDENTITY), mIsActive(true)
-	{
-		mMaterials.resize(1);
-	}
-
-	template<bool Core>
-	TRenderableHandler<Core>::~TRenderableHandler()
-	{
-
-	}
-
-	template<bool Core>
-	void TRenderableHandler<Core>::setMesh(const MeshType& mesh)
-	{
-		mMesh = mesh;
-
-		int numSubMeshes = 0;
-		if (mesh != nullptr)
-			numSubMeshes = mesh->getProperties().getNumSubMeshes();
-
-		mMaterials.resize(numSubMeshes);
-
-		_markResourcesDirty();
-		_markCoreDirty();
-	}
-
-	template<bool Core>
-	void TRenderableHandler<Core>::setMaterial(UINT32 idx, const MaterialType& material)
-	{
-		if (idx >= (UINT32)mMaterials.size())
-			return;
-
-		mMaterials[idx] = material;
-
-		_markResourcesDirty();
-		_markCoreDirty();
-	}
-
-	template<bool Core>
-	void TRenderableHandler<Core>::setMaterial(const MaterialType& material)
-	{
-		setMaterial(0, material);
-	}
-
-	template<bool Core>
-	void TRenderableHandler<Core>::setLayer(UINT64 layer)
-	{
-		bool isPow2 = layer && !((layer - 1) & layer);
-
-		if (!isPow2)
-		{
-			LOGWRN("Invalid layer provided. Only one layer bit may be set. Ignoring.");
-			return;
-		}
-
-		mLayer = layer;
-		_markCoreDirty();
-	}
-
-	template<bool Core>
-	void TRenderableHandler<Core>::setTransform(const Matrix4& transform)
-	{
-		mTransform = transform;
-		_markCoreDirty(RenderableDirtyFlag::Transform);
-	}
-
-	template<bool Core>
-	void TRenderableHandler<Core>::setPosition(const Vector3& position)
-	{
-		mPosition = position;
-		_markCoreDirty(RenderableDirtyFlag::Transform);
-	}
-
-	template<bool Core>
-	void TRenderableHandler<Core>::setIsActive(bool active)
-	{
-		mIsActive = active;
-		_markCoreDirty();
-	}
-
-	template class TRenderableHandler < false >;
-	template class TRenderableHandler < true >;
-
-	RenderableHandlerCore::RenderableHandlerCore() 
-		:mRendererId(0)
-	{
-	}
-
-	RenderableHandlerCore::~RenderableHandlerCore()
-	{
-		if (mIsActive)
-			gRenderer()->_notifyRenderableRemoved(this);
-	}
-
-	void RenderableHandlerCore::initialize()
-	{
-		gRenderer()->_notifyRenderableAdded(this);
-
-		CoreObjectCore::initialize();
-	}
-
-	Bounds RenderableHandlerCore::getBounds() const
-	{
-		SPtr<MeshCore> mesh = getMesh();
-
-		if (mesh == nullptr)
-		{
-			AABox box(mPosition, mPosition);
-			Sphere sphere(mPosition, 0.0f);
-
-			return Bounds(box, sphere);
-		}
-		else
-		{
-			Bounds bounds = mesh->getProperties().getBounds();
-			bounds.transformAffine(mTransform);
-
-			return bounds;
-		}
-	}
-
-	void RenderableHandlerCore::syncToCore(const CoreSyncData& data)
-	{
-		char* dataPtr = (char*)data.getBuffer();
-
-		mWorldBounds.clear();
-		mMaterials.clear();
-
-		UINT32 numMaterials = 0;
-		UINT32 dirtyFlags = 0;
-		bool oldIsActive = mIsActive;
-
-		dataPtr = rttiReadElem(mLayer, dataPtr);
-		dataPtr = rttiReadElem(mWorldBounds, dataPtr);
-		dataPtr = rttiReadElem(numMaterials, dataPtr);
-		dataPtr = rttiReadElem(mTransform, dataPtr);
-		dataPtr = rttiReadElem(mPosition, dataPtr);
-		dataPtr = rttiReadElem(mIsActive, dataPtr);
-		dataPtr = rttiReadElem(dirtyFlags, dataPtr);
-
-		SPtr<MeshCore>* mesh = (SPtr<MeshCore>*)dataPtr;
-		mMesh = *mesh;
-		mesh->~SPtr<MeshCore>();
-		dataPtr += sizeof(SPtr<MeshCore>);
-
-		for (UINT32 i = 0; i < numMaterials; i++)
-		{
-			SPtr<MaterialCore>* material = (SPtr<MaterialCore>*)dataPtr;
-			mMaterials.push_back(*material);
-			material->~SPtr<MaterialCore>();
-			dataPtr += sizeof(SPtr<MaterialCore>);
-		}
-
-		if (dirtyFlags == (UINT32)RenderableDirtyFlag::Transform)
-		{
-			if (mIsActive)
-				gRenderer()->_notifyRenderableUpdated(this);
-		}
-		else
-		{
-			if (oldIsActive != mIsActive)
-			{
-				if (mIsActive)
-					gRenderer()->_notifyRenderableAdded(this);
-				else
-					gRenderer()->_notifyRenderableRemoved(this);
-			}
-			else
-			{
-				gRenderer()->_notifyRenderableRemoved(this);
-				gRenderer()->_notifyRenderableAdded(this);
-			}
-		}
-	}
-
-	RenderableHandler::RenderableHandler()
-		:mLastUpdateHash(0)
-	{
-		
-	}
-
-	Bounds RenderableHandler::getBounds() const
-	{
-		HMesh mesh = getMesh();
-
-		if (!mesh.isLoaded())
-		{
-			AABox box(mPosition, mPosition);
-			Sphere sphere(mPosition, 0.0f);
-
-			return Bounds(box, sphere);
-		}
-		else
-		{
-			Bounds bounds = mesh->getProperties().getBounds();
-			bounds.transformAffine(mTransform);
-
-			return bounds;
-		}
-	}
-
-	SPtr<RenderableHandlerCore> RenderableHandler::getCore() const
-	{
-		return std::static_pointer_cast<RenderableHandlerCore>(mCoreSpecific);
-	}
-
-	SPtr<CoreObjectCore> RenderableHandler::createCore() const
-	{
-		RenderableHandlerCore* handler = new (bs_alloc<RenderableHandlerCore>()) RenderableHandlerCore();
-		SPtr<RenderableHandlerCore> handlerPtr = bs_shared_ptr<RenderableHandlerCore>(handler);
-		handlerPtr->_setThisPtr(handlerPtr);
-
-		return handlerPtr;
-	}
-
-	void RenderableHandler::_markCoreDirty(RenderableDirtyFlag flag)
-	{
-		markCoreDirty((UINT32)flag);
-	}
-
-	void RenderableHandler::_markResourcesDirty()
-	{
-		markListenerResourcesDirty();
-	}
-
-	CoreSyncData RenderableHandler::syncToCore(FrameAlloc* allocator)
-	{
-		UINT32 numMaterials = (UINT32)mMaterials.size();
-
-		UINT32 size = rttiGetElemSize(mLayer) + 
-			rttiGetElemSize(mWorldBounds) + 
-			rttiGetElemSize(numMaterials) + 
-			rttiGetElemSize(mTransform) +
-			rttiGetElemSize(mPosition) +
-			rttiGetElemSize(mIsActive) +
-			rttiGetElemSize(getCoreDirtyFlags()) +
-			sizeof(SPtr<MeshCore>) + 
-			numMaterials * sizeof(SPtr<MaterialCore>);
-
-		UINT8* data = allocator->alloc(size);
-		char* dataPtr = (char*)data;
-		dataPtr = rttiWriteElem(mLayer, dataPtr);
-		dataPtr = rttiWriteElem(mWorldBounds, dataPtr);
-		dataPtr = rttiWriteElem(numMaterials, dataPtr);
-		dataPtr = rttiWriteElem(mTransform, dataPtr);
-		dataPtr = rttiWriteElem(mPosition, dataPtr);
-		dataPtr = rttiWriteElem(mIsActive, dataPtr);
-		dataPtr = rttiWriteElem(getCoreDirtyFlags(), dataPtr);
-
-		SPtr<MeshCore>* mesh = new (dataPtr) SPtr<MeshCore>();
-		if (mMesh.isLoaded())
-			*mesh = mMesh->getCore();
-
-		dataPtr += sizeof(SPtr<MeshCore>);
-
-		for (UINT32 i = 0; i < numMaterials; i++)
-		{
-			SPtr<MaterialCore>* material = new (dataPtr)SPtr<MaterialCore>();
-			if (mMaterials[i].isLoaded())
-				*material = mMaterials[i]->getCore();
-
-			dataPtr += sizeof(SPtr<MaterialCore>);
-		}
-
-		return CoreSyncData(data, size);
-	}
-
-	void RenderableHandler::getCoreDependencies(Vector<SPtr<CoreObject>>& dependencies)
-	{
-		if (mMesh.isLoaded())
-			dependencies.push_back(mMesh.getInternalPtr());
-
-		for (auto& material : mMaterials)
-		{
-			if (material.isLoaded())
-				dependencies.push_back(material.getInternalPtr());
-		}
-	}
-
-	void RenderableHandler::getListenerResources(Vector<HResource>& resources)
-	{
-		if (mMesh != nullptr)
-			resources.push_back(mMesh);
-
-		for (auto& material : mMaterials)
-		{
-			if (material != nullptr)
-				resources.push_back(material);
-		}
-	}
-
-	RenderableHandlerPtr RenderableHandler::create()
-	{
-		RenderableHandlerPtr handlerPtr = createEmpty();
-		handlerPtr->initialize();
-
-		return handlerPtr;
-	}
-
-	RenderableHandlerPtr RenderableHandler::createEmpty()
-	{
-		RenderableHandler* handler = new (bs_alloc<RenderableHandler>()) RenderableHandler();
-		RenderableHandlerPtr handlerPtr = bs_core_ptr<RenderableHandler>(handler);
-		handlerPtr->_setThisPtr(handlerPtr);
-
-		return handlerPtr;
-	}
-
-	RTTITypeBase* RenderableHandler::getRTTIStatic()
-	{
-		return RenderableHandlerRTTI::instance();
-	}
-
-	RTTITypeBase* RenderableHandler::getRTTI() const
-	{
-		return RenderableHandler::getRTTIStatic();
-	}
-}

+ 12 - 12
BansheeEngine/Source/BsSceneManager.cpp

@@ -1,40 +1,40 @@
 #include "BsSceneManager.h"
 #include "BsSceneObject.h"
-#include "BsRenderableHandler.h"
-#include "BsCameraHandler.h"
-#include "BsLightInternal.h"
+#include "BsRenderable.h"
+#include "BsCamera.h"
+#include "BsLight.h"
 #include "BsDebug.h"
 
 namespace BansheeEngine
 {
 	volatile SceneManager::InitOnStart SceneManager::DoInitOnStart;
 
-	void SceneManager::_registerRenderable(const SPtr<RenderableHandler>& renderable, const HSceneObject& so)
+	void SceneManager::_registerRenderable(const SPtr<Renderable>& renderable, const HSceneObject& so)
 	{
 		mRenderables[renderable.get()] = SceneRenderableData(renderable, so);
 	}
 
-	void SceneManager::_unregisterRenderable(const SPtr<RenderableHandler>& renderable)
+	void SceneManager::_unregisterRenderable(const SPtr<Renderable>& renderable)
 	{
 		mRenderables.erase(renderable.get());
 	}
 
-	void SceneManager::_registerCamera(const SPtr<CameraHandler>& camera, const HSceneObject& so)
+	void SceneManager::_registerCamera(const SPtr<Camera>& camera, const HSceneObject& so)
 	{
 		mCameras[camera.get()] = SceneCameraData(camera, so);
 	}
 
-	void SceneManager::_unregisterCamera(const SPtr<CameraHandler>& camera)
+	void SceneManager::_unregisterCamera(const SPtr<Camera>& camera)
 	{
 		mCameras.erase(camera.get());
 	}
 
-	void SceneManager::_registerLight(const SPtr<LightInternal>& light, const HSceneObject& so)
+	void SceneManager::_registerLight(const SPtr<Light>& light, const HSceneObject& so)
 	{
 		mLights[light.get()] = SceneLightData(light, so);
 	}
 
-	void SceneManager::_unregisterLight(const SPtr<LightInternal>& light)
+	void SceneManager::_unregisterLight(const SPtr<Light>& light)
 	{
 		mLights.erase(light.get());
 	}
@@ -43,7 +43,7 @@ namespace BansheeEngine
 	{
 		for (auto& renderablePair : mRenderables)
 		{
-			RenderableHandlerPtr handler = renderablePair.second.renderable;
+			RenderablePtr handler = renderablePair.second.renderable;
 			HSceneObject so = renderablePair.second.sceneObject;
 
 			UINT32 curHash = so->getTransformHash();
@@ -61,7 +61,7 @@ namespace BansheeEngine
 
 		for (auto& cameraPair : mCameras)
 		{
-			CameraHandlerPtr handler = cameraPair.second.camera;
+			CameraPtr handler = cameraPair.second.camera;
 			HSceneObject so = cameraPair.second.sceneObject;
 
 			UINT32 curHash = so->getTransformHash();
@@ -76,7 +76,7 @@ namespace BansheeEngine
 
 		for (auto& lightPair : mLights)
 		{
-			SPtr<LightInternal> handler = lightPair.second.light;
+			SPtr<Light> handler = lightPair.second.light;
 			HSceneObject so = lightPair.second.sceneObject;
 
 			UINT32 curHash = so->getTransformHash();

+ 1 - 1
BansheeEngine/Source/BsShapeMeshes2D.cpp

@@ -7,7 +7,7 @@
 #include "BsPass.h"
 #include "BsCoreApplication.h"
 #include "BsRenderQueue.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsCoreThreadAccessor.h"
 #include "BsBuiltinResources.h"
 #include "BsVertexDataDesc.h"

+ 1 - 1
BansheeEngine/Source/BsShapeMeshes3D.cpp

@@ -10,7 +10,7 @@
 #include "BsCoreApplication.h"
 #include "BsRenderQueue.h"
 #include "BsException.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsBuiltinResources.h"
 #include "BsVertexDataDesc.h"
 

+ 0 - 23
BansheeEngine/Source/BsUpdateCallback.cpp

@@ -1,23 +0,0 @@
-#include "BsUpdateCallback.h"
-
-namespace BansheeEngine
-{
-	UpdateCallback::UpdateCallback(const HSceneObject& parent)
-		:Component(parent)
-	{
-		setName("UpdateCallback");
-	}
-
-	UpdateCallback::~UpdateCallback()
-	{
-
-	}
-
-	void UpdateCallback::update()
-	{
-		if(!onUpdate.empty())
-		{
-			onUpdate();
-		}
-	}
-}

+ 2 - 2
ExampleProject/CameraFlyer.cpp

@@ -3,7 +3,7 @@
 #include "BsTime.h"
 #include "BsMath.h"
 #include "BsSceneObject.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsPlatform.h"
 #include "BsCursor.h"
 #include "BsDebug.h"
@@ -32,7 +32,7 @@ namespace BansheeEngine
 	{
 		setName("CameraFlyer");
 
-		mCamera = sceneObject()->getComponent<Camera>();
+		mCamera = sceneObject()->getComponent<CCamera>();
 		mCamera->setNearClipDistance(5);
 
 		mMoveForward = VirtualButton("Forward");

+ 5 - 5
ExampleProject/Main/Main.cpp

@@ -10,8 +10,8 @@
 #include "BsCoreThreadAccessor.h"
 #include "BsApplication.h"
 #include "BsVirtualInput.h"
-#include "BsCamera.h"
-#include "BsRenderable.h"
+#include "BsCCamera.h"
+#include "BsCRenderable.h"
 #include "BsGUIWidget.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
@@ -215,7 +215,7 @@ namespace BansheeEngine
 
 		// Attach the Renderable component and hook up the mesh we imported earlier,
 		// and the material we created in the previous section.
-		HRenderable renderable = dragonSO->addComponent<Renderable>();
+		HRenderable renderable = dragonSO->addComponent<CRenderable>();
 		renderable->setMesh(mesh);
 		renderable->setMaterial(material);
 
@@ -235,7 +235,7 @@ namespace BansheeEngine
 
 		// Add a Camera component that will output whatever it sees into that window 
 		// (You could also use a render texture or another window you created).
-		sceneCamera = sceneCameraSO->addComponent<Camera>(window);
+		sceneCamera = sceneCameraSO->addComponent<CCamera>(window);
 
 		// Set up camera component properties
 
@@ -305,7 +305,7 @@ namespace BansheeEngine
 		RenderWindowPtr window = gApplication().getPrimaryWindow();
 
 		// First we want another camera that is responsible for rendering GUI
-		HCamera guiCamera = guiSO->addComponent<Camera>(window);
+		HCamera guiCamera = guiSO->addComponent<CCamera>(window);
 
 		// Set up GUI camera properties. 
 		// We don't care about aspect ratio for GUI camera.

+ 1 - 1
MBansheeEditor/Scene/SceneViewHandler.cs

@@ -12,7 +12,7 @@ namespace BansheeEditor
     {
         internal SceneViewHandler(EditorWindow parent, Camera sceneCamera)
         {
-            Internal_Create(this, parent.GetCachedPtr(), sceneCamera.Handler.GetCachedPtr());
+            Internal_Create(this, parent.GetCachedPtr(), sceneCamera.Native.GetCachedPtr());
         }
 
         internal void Update()

+ 71 - 71
MBansheeEngine/Camera.cs

@@ -8,154 +8,154 @@ namespace BansheeEngine
 {
     public class Camera : Component
     {
-        private CameraHandler handler;
+        private NativeCamera native;
 
         [SerializeField]
         private SerializableData serializableData = new SerializableData();
 
-        internal CameraHandler Handler
+        internal NativeCamera Native
         {
-            get { return handler; }
+            get { return native; }
         }
 
         public float AspectRatio
         {
-            get { return handler.aspectRatio; }
-            set { handler.aspectRatio = value; serializableData.aspectRatio = value; }
+            get { return native.aspectRatio; }
+            set { native.aspectRatio = value; serializableData.aspectRatio = value; }
         }
 
         public float NearClipPlane
         {
-            get { return handler.nearClipPlane; }
-            set { handler.nearClipPlane = value; serializableData.nearClipPlane = value; }
+            get { return native.nearClipPlane; }
+            set { native.nearClipPlane = value; serializableData.nearClipPlane = value; }
         }
 
         public float FarClipPlane
         {
-            get { return handler.farClipPlane; }
-            set { handler.farClipPlane = value; serializableData.farClipPlane = value; }
+            get { return native.farClipPlane; }
+            set { native.farClipPlane = value; serializableData.farClipPlane = value; }
         }
 
         public Degree FieldOfView
         {
-            get { return handler.fieldOfView; }
-            set { handler.fieldOfView = value; serializableData.fieldOfView = value; }
+            get { return native.fieldOfView; }
+            set { native.fieldOfView = value; serializableData.fieldOfView = value; }
         }
 
         public Rect2 ViewportRect
         {
-            get { return handler.viewportRect; }
-            set { handler.viewportRect = value; serializableData.viewportRect = value; }
+            get { return native.viewportRect; }
+            set { native.viewportRect = value; serializableData.viewportRect = value; }
         }
 
         public ProjectionType ProjectionType
         {
-            get { return handler.projectionType; }
-            set { handler.projectionType = value; serializableData.projectionType = value; }
+            get { return native.projectionType; }
+            set { native.projectionType = value; serializableData.projectionType = value; }
         }
 
         public float OrthoHeight
         {
-            get { return handler.orthoHeight; }
-            set { handler.orthoHeight = value; serializableData.orthoHeight = value; }
+            get { return native.orthoHeight; }
+            set { native.orthoHeight = value; serializableData.orthoHeight = value; }
         }
 
         public float OrthoWidth
         {
-            get { return handler.orthoWidth; }
+            get { return native.orthoWidth; }
         }
 
         public Color ClearColor
         {
-            get { return handler.clearColor; }
-            set { handler.clearColor = value; serializableData.clearColor = value; }
+            get { return native.clearColor; }
+            set { native.clearColor = value; serializableData.clearColor = value; }
         }
 
         public float ClearDepth
         {
-            get { return handler.clearDepth; }
-            set { handler.clearDepth = value; serializableData.clearDepth = value; }
+            get { return native.clearDepth; }
+            set { native.clearDepth = value; serializableData.clearDepth = value; }
         }
 
         public UInt16 ClearStencil
         {
-            get { return handler.clearStencil; }
-            set { handler.clearStencil = value; serializableData.clearStencil = value; }
+            get { return native.clearStencil; }
+            set { native.clearStencil = value; serializableData.clearStencil = value; }
         }
 
         public ClearFlags ClearFlags
         {
-            get { return handler.clearFlags; }
-            set { handler.clearFlags = value; serializableData.clearFlags = value; }
+            get { return native.clearFlags; }
+            set { native.clearFlags = value; serializableData.clearFlags = value; }
         }
 
         public int Priority
         {
-            get { return handler.priority; }
-            set { handler.priority = value; serializableData.priority = value; }
+            get { return native.priority; }
+            set { native.priority = value; serializableData.priority = value; }
         }
 
         public UInt64 Layers
         {
-            get { return handler.layers; }
-            set { handler.layers = value; serializableData.layers = value; }
+            get { return native.layers; }
+            set { native.layers = value; serializableData.layers = value; }
         }
 
         public Matrix4 ProjMatrix
         {
-            get { return handler.projMatrix; }
+            get { return native.projMatrix; }
         }
 
         public Matrix4 ProjMatrixInverse
         {
-            get { return handler.projMatrixInv; }
+            get { return native.projMatrixInv; }
         }
 
         public Matrix4 ViewMatrix
         {
-            get { return handler.viewMatrix; }
+            get { return native.viewMatrix; }
         }
 
         public Matrix4 ViewMatrixInverse
         {
-            get { return handler.viewMatrixInv; }
+            get { return native.viewMatrixInv; }
         }
 
         public int WidthPixels
         {
-            get { return handler.widthPixels; }
+            get { return native.widthPixels; }
         }
 
         public int HeightPixels
         {
-            get { return handler.heightPixels; }
+            get { return native.heightPixels; }
         }
 
         public RenderTarget Target
         {
-            get { return handler.target; }
-            set { handler.target = value; }
+            get { return native.target; }
+            set { native.target = value; }
         }
 
-        public Vector2I WorldToScreen(Vector3 value) { return handler.WorldToScreen(value); }
-        public Vector2 WorldToClip(Vector3 value) { return handler.WorldToClip(value); }
-        public Vector3 WorldToView(Vector3 value) { return handler.WorldToView(value); }
+        public Vector2I WorldToScreen(Vector3 value) { return native.WorldToScreen(value); }
+        public Vector2 WorldToClip(Vector3 value) { return native.WorldToClip(value); }
+        public Vector3 WorldToView(Vector3 value) { return native.WorldToView(value); }
 
-        public Vector3 ScreenToWorld(Vector2I value, float depth = 0.5f) { return handler.ScreenToWorld(value, depth); }
-        public Vector3 ScreenToView(Vector2I value, float depth = 0.5f) { return handler.ScreenToView(value, depth); }
-        public Vector2 ScreenToClip(Vector2I value) { return handler.ScreenToClip(value); }
+        public Vector3 ScreenToWorld(Vector2I value, float depth = 0.5f) { return native.ScreenToWorld(value, depth); }
+        public Vector3 ScreenToView(Vector2I value, float depth = 0.5f) { return native.ScreenToView(value, depth); }
+        public Vector2 ScreenToClip(Vector2I value) { return native.ScreenToClip(value); }
 
-        public Vector3 ViewToWorld(Vector3 value) { return handler.ViewToWorld(value); }
-        public Vector2I ViewToScreen(Vector3 value) { return handler.ViewToScreen(value); }
-        public Vector2 ViewToClip(Vector3 value) { return handler.ViewToClip(value); }
+        public Vector3 ViewToWorld(Vector3 value) { return native.ViewToWorld(value); }
+        public Vector2I ViewToScreen(Vector3 value) { return native.ViewToScreen(value); }
+        public Vector2 ViewToClip(Vector3 value) { return native.ViewToClip(value); }
 
-        public Vector3 ClipToWorld(Vector2 value, float depth = 0.5f) { return handler.ClipToWorld(value, depth); }
-        public Vector3 ClipToView(Vector2 value, float depth = 0.5f) { return handler.ClipToView(value, depth); }
-        public Vector2I ClipToScreen(Vector2 value) { return handler.ClipToScreen(value); }
+        public Vector3 ClipToWorld(Vector2 value, float depth = 0.5f) { return native.ClipToWorld(value, depth); }
+        public Vector3 ClipToView(Vector2 value, float depth = 0.5f) { return native.ClipToView(value, depth); }
+        public Vector2I ClipToScreen(Vector2 value) { return native.ClipToScreen(value); }
 
-        public Ray ScreenToWorldRay(Vector2I value) { return handler.ScreenToWorldRay(value); }
-        public Vector3 ProjectPoint(Vector3 value) { return handler.ProjectPoint(value); }
-        public Vector3 UnprojectPoint(Vector3 value) { return handler.UnprojectPoint(value); }
+        public Ray ScreenToWorldRay(Vector2I value) { return native.ScreenToWorldRay(value); }
+        public Vector3 ProjectPoint(Vector3 value) { return native.ProjectPoint(value); }
+        public Vector3 UnprojectPoint(Vector3 value) { return native.UnprojectPoint(value); }
 
         private void OnInitialize()
         {
@@ -173,37 +173,37 @@ namespace BansheeEngine
 
         private void OnReset()
         {
-            if (handler != null)
-                handler.OnDestroy();
+            if (native != null)
+                native.OnDestroy();
 
-            handler = new CameraHandler(SceneObject);
+            native = new NativeCamera(SceneObject);
 
             // Restore saved values after reset
-            handler.aspectRatio = serializableData.aspectRatio;
-            handler.nearClipPlane = serializableData.nearClipPlane;
-            handler.farClipPlane = serializableData.farClipPlane;
-            handler.fieldOfView = serializableData.fieldOfView;
-            handler.viewportRect = serializableData.viewportRect;
-            handler.projectionType = serializableData.projectionType;
-            handler.orthoHeight = serializableData.orthoHeight;
-            handler.clearColor = serializableData.clearColor;
-            handler.clearDepth = serializableData.clearDepth;
-            handler.clearStencil = serializableData.clearStencil;
-            handler.clearFlags = serializableData.clearFlags;
-            handler.priority = serializableData.priority;
-            handler.layers = serializableData.layers;
+            native.aspectRatio = serializableData.aspectRatio;
+            native.nearClipPlane = serializableData.nearClipPlane;
+            native.farClipPlane = serializableData.farClipPlane;
+            native.fieldOfView = serializableData.fieldOfView;
+            native.viewportRect = serializableData.viewportRect;
+            native.projectionType = serializableData.projectionType;
+            native.orthoHeight = serializableData.orthoHeight;
+            native.clearColor = serializableData.clearColor;
+            native.clearDepth = serializableData.clearDepth;
+            native.clearStencil = serializableData.clearStencil;
+            native.clearFlags = serializableData.clearFlags;
+            native.priority = serializableData.priority;
+            native.layers = serializableData.layers;
 
             // TODO - Make RenderTexture a resource so I can save/restore it?
         }
 
         private void Update()
         {
-            handler.UpdateView(SceneObject);
+            native.UpdateView(SceneObject);
         }
 
         private void OnDestroy()
         {
-            handler.OnDestroy();
+            native.OnDestroy();
         }
 
         [SerializeObject]

+ 35 - 35
MBansheeEngine/Light.cs

@@ -8,73 +8,73 @@ namespace BansheeEngine
 {
     public class Light : Component
     {
-        private LightInternal internalLight;
+        private NativeLight _nativeLight;
 
         [SerializeField]
         private SerializableData serializableData = new SerializableData();
 
-        internal LightInternal Internal
+        internal NativeLight Native
         {
-            get { return internalLight; }
+            get { return _nativeLight; }
         }
 
         public Vector3 Position
         {
-            get { return internalLight.Position; }
-            set { internalLight.Position = value; serializableData.position = value; }
+            get { return _nativeLight.Position; }
+            set { _nativeLight.Position = value; serializableData.position = value; }
         }
 
         public Quaternion Rotation
         {
-            get { return internalLight.Rotation; }
-            set { internalLight.Rotation = value; serializableData.rotation = value; }
+            get { return _nativeLight.Rotation; }
+            set { _nativeLight.Rotation = value; serializableData.rotation = value; }
         }
 
         public LightType Type
         {
-            get { return internalLight.Type; }
-            set { internalLight.Type = value; serializableData.type = value; }
+            get { return _nativeLight.Type; }
+            set { _nativeLight.Type = value; serializableData.type = value; }
         }
 
         public Color Color
         {
-            get { return internalLight.Color; }
-            set { internalLight.Color = value; serializableData.color = value; }
+            get { return _nativeLight.Color; }
+            set { _nativeLight.Color = value; serializableData.color = value; }
         }
 
         public float Range
         {
-            get { return internalLight.Range; }
-            set { internalLight.Range = value; serializableData.range = value; }
+            get { return _nativeLight.Range; }
+            set { _nativeLight.Range = value; serializableData.range = value; }
         }
 
         public float Intensity
         {
-            get { return internalLight.Intensity; }
-            set { internalLight.Intensity = value; serializableData.intensity = value; }
+            get { return _nativeLight.Intensity; }
+            set { _nativeLight.Intensity = value; serializableData.intensity = value; }
         }
 
         public Degree SpotAngle
         {
-            get { return internalLight.SpotAngle; }
-            set { internalLight.SpotAngle = value; serializableData.spotAngle = value; }
+            get { return _nativeLight.SpotAngle; }
+            set { _nativeLight.SpotAngle = value; serializableData.spotAngle = value; }
         }
 
         public Degree SpotFalloffAngle
         {
-            get { return internalLight.SpotFalloffAngle; }
-            set { internalLight.SpotFalloffAngle = value; serializableData.spotFalloffAngle = value; }
+            get { return _nativeLight.SpotFalloffAngle; }
+            set { _nativeLight.SpotFalloffAngle = value; serializableData.spotFalloffAngle = value; }
         }
 
         public bool CastsShadow
         {
-            get { return internalLight.CastsShadow; }
-            set { internalLight.CastsShadow = value; serializableData.castShadows = value; }
+            get { return _nativeLight.CastsShadow; }
+            set { _nativeLight.CastsShadow = value; serializableData.castShadows = value; }
         }
 
         public Sphere Bounds
         {
-            get { Internal.UpdateTransform(SceneObject); return Internal.Bounds; }
+            get { Native.UpdateTransform(SceneObject); return Native.Bounds; }
         }
 
         private void OnInitialize()
@@ -92,21 +92,21 @@ namespace BansheeEngine
 
         private void OnReset()
         {
-            if (internalLight != null)
-                internalLight.OnDestroy();
+            if (_nativeLight != null)
+                _nativeLight.OnDestroy();
 
-            internalLight = new LightInternal(SceneObject);
+            _nativeLight = new NativeLight(SceneObject);
 
             // Restore saved values after reset
-            internalLight.Position = serializableData.position;
-            internalLight.Rotation = serializableData.rotation;
-            internalLight.Color = serializableData.color;
-            internalLight.SpotAngle = serializableData.spotAngle;
-            internalLight.SpotFalloffAngle = serializableData.spotFalloffAngle;
-            internalLight.Range = serializableData.range;
-            internalLight.Intensity = serializableData.intensity;
-            internalLight.Type = serializableData.type;
-            internalLight.CastsShadow = serializableData.castShadows;
+            _nativeLight.Position = serializableData.position;
+            _nativeLight.Rotation = serializableData.rotation;
+            _nativeLight.Color = serializableData.color;
+            _nativeLight.SpotAngle = serializableData.spotAngle;
+            _nativeLight.SpotFalloffAngle = serializableData.spotFalloffAngle;
+            _nativeLight.Range = serializableData.range;
+            _nativeLight.Intensity = serializableData.intensity;
+            _nativeLight.Type = serializableData.type;
+            _nativeLight.CastsShadow = serializableData.castShadows;
         }
 
         private void Update()
@@ -116,7 +116,7 @@ namespace BansheeEngine
 
         private void OnDestroy()
         {
-            internalLight.OnDestroy();
+            _nativeLight.OnDestroy();
         }
 
         [SerializeObject]

+ 3 - 3
MBansheeEngine/MBansheeEngine.csproj

@@ -46,7 +46,7 @@
     <Compile Include="Bounds.cs" />
     <Compile Include="Builtin.cs" />
     <Compile Include="Camera.cs" />
-    <Compile Include="CameraHandler.cs" />
+    <Compile Include="NativeCamera.cs" />
     <Compile Include="ContextMenu.cs" />
     <Compile Include="Cursor.cs" />
     <Compile Include="Debug.cs" />
@@ -84,7 +84,7 @@
     <Compile Include="Input.cs" />
     <Compile Include="InputConfiguration.cs" />
     <Compile Include="Light.cs" />
-    <Compile Include="LightInternal.cs" />
+    <Compile Include="NativeLight.cs" />
     <Compile Include="LocString.cs" />
     <Compile Include="ManagedResource.cs" />
     <Compile Include="Material.cs" />
@@ -113,7 +113,7 @@
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Math\Quaternion.cs" />
     <Compile Include="Renderable.cs" />
-    <Compile Include="RenderableHandler.cs" />
+    <Compile Include="NativeRenderable.cs" />
     <Compile Include="RenderTarget.cs" />
     <Compile Include="RenderTexture.cs" />
     <Compile Include="RenderTexture2D.cs" />

+ 3 - 3
MBansheeEngine/CameraHandler.cs → MBansheeEngine/NativeCamera.cs

@@ -19,7 +19,7 @@ namespace BansheeEngine
         None = 0, Color = 0x01, Depth = 0x02, Stencil = 0x04
     }
 
-    internal class CameraHandler : ScriptObject
+    internal class NativeCamera : ScriptObject
     {
         internal float aspectRatio
         {
@@ -174,7 +174,7 @@ namespace BansheeEngine
 
         private RenderTarget _target;
 
-        public CameraHandler(SceneObject sceneObject)
+        public NativeCamera(SceneObject sceneObject)
         {
             IntPtr sceneObjPtr = IntPtr.Zero;
             if (sceneObject != null)
@@ -194,7 +194,7 @@ namespace BansheeEngine
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Create(CameraHandler instance, IntPtr parentSO);
+        private static extern void Internal_Create(NativeCamera instance, IntPtr parentSO);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern float Internal_GetAspect(IntPtr instance);

+ 3 - 3
MBansheeEngine/LightInternal.cs → MBansheeEngine/NativeLight.cs

@@ -12,7 +12,7 @@ namespace BansheeEngine
         Directional, Point, Spot
     }
 
-    internal class LightInternal : ScriptObject
+    internal class NativeLight : ScriptObject
     {
         internal Vector3 Position
         {
@@ -73,7 +73,7 @@ namespace BansheeEngine
             get { return Internal_GetBounds(mCachedPtr); }
         }
 
-        internal LightInternal(SceneObject sceneObject)
+        internal NativeLight(SceneObject sceneObject)
         {
             IntPtr sceneObjPtr = IntPtr.Zero;
             if (sceneObject != null)
@@ -94,7 +94,7 @@ namespace BansheeEngine
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Create(LightInternal instance, IntPtr parentSO);
+        private static extern void Internal_Create(NativeLight instance, IntPtr parentSO);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern Vector3 Internal_GetPosition(IntPtr instance);

+ 3 - 3
MBansheeEngine/RenderableHandler.cs → MBansheeEngine/NativeRenderable.cs

@@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
 
 namespace BansheeEngine
 {
-    internal class RenderableHandler : ScriptObject
+    internal class NativeRenderable : ScriptObject
     {
         internal Mesh Mesh
         {
@@ -52,7 +52,7 @@ namespace BansheeEngine
         private Material[] materials = new Material[0];
         private Mesh mesh;
         
-        public RenderableHandler(SceneObject sceneObject)
+        public NativeRenderable(SceneObject sceneObject)
         {
             IntPtr sceneObjPtr = IntPtr.Zero;
             if (sceneObject != null)
@@ -88,7 +88,7 @@ namespace BansheeEngine
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Create(RenderableHandler instance, IntPtr parentSO);
+        private static extern void Internal_Create(NativeRenderable instance, IntPtr parentSO);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_UpdateTransform(IntPtr thisPtr, IntPtr parentSO);

+ 2 - 2
MBansheeEngine/ProfilerOverlayInternal.cs

@@ -12,7 +12,7 @@ namespace BansheeEngine
         {
             IntPtr ptr = IntPtr.Zero;
             if (camera != null)
-                ptr = camera.Handler.GetCachedPtr();
+                ptr = camera.Native.GetCachedPtr();
 
             Internal_CreateInstance(this, ptr);
         }
@@ -33,7 +33,7 @@ namespace BansheeEngine
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(ProfilerOverlayInternal instance, IntPtr cameraHandler);
+        private static extern void Internal_CreateInstance(ProfilerOverlayInternal instance, IntPtr camera);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetType(IntPtr instance, ProfilerOverlayType type);

+ 20 - 20
MBansheeEngine/Renderable.cs

@@ -4,22 +4,22 @@ namespace BansheeEngine
 {
     public class Renderable : Component
     {
-        private RenderableHandler handler;
+        private NativeRenderable _native;
 
         [SerializeField]
         private SerializableData serializableData = new SerializableData();
 
-        internal RenderableHandler Handler
+        internal NativeRenderable Native
         {
-            get { return handler; }
+            get { return _native; }
         }
 
         public Mesh Mesh
         {
-            get { return handler.Mesh; }
+            get { return _native.Mesh; }
             set 
             { 
-                handler.Mesh = value; 
+                _native.Mesh = value; 
                 serializableData.mesh = value;
 
                 int subMeshCount = 0;
@@ -35,31 +35,31 @@ namespace BansheeEngine
 
         public Material Material
         {
-            get { return handler.GetMaterial(0); }
+            get { return _native.GetMaterial(0); }
             set 
-            { handler.SetMaterial(value); serializableData.materials[0] = value; }
+            { _native.SetMaterial(value); serializableData.materials[0] = value; }
         }
 
         public Material GetMaterial(int index = 0)
         {
-            return handler.GetMaterial(index);
+            return _native.GetMaterial(index);
         }
 
         public void SetMaterial(Material material, int index = 0)
         {
-            handler.SetMaterial(material, index);
+            _native.SetMaterial(material, index);
             serializableData.materials[index] = material;
         }
 
         public UInt64 Layers
         {
-            get { return handler.Layers; }
-            set { handler.Layers = value; serializableData.layers = value; }
+            get { return _native.Layers; }
+            set { _native.Layers = value; serializableData.layers = value; }
         }
 
         public Bounds Bounds
         {
-            get { return handler.GetBounds(SceneObject); }
+            get { return _native.GetBounds(SceneObject); }
         }
 
         private void OnInitialize()
@@ -70,31 +70,31 @@ namespace BansheeEngine
 
         private void OnReset()
         {
-            if (handler != null)
-                handler.OnDestroy();
+            if (_native != null)
+                _native.OnDestroy();
 
-            handler = new RenderableHandler(SceneObject);
+            _native = new NativeRenderable(SceneObject);
 
             // Restore saved values after reset
-            handler.Mesh = serializableData.mesh;
+            _native.Mesh = serializableData.mesh;
 
             if (serializableData.materials != null)
             {
                 for (int i = 0; i < serializableData.materials.Length; i++)
-                    handler.SetMaterial(serializableData.materials[i], i);
+                    _native.SetMaterial(serializableData.materials[i], i);
             }
 
-            handler.Layers = serializableData.layers;
+            _native.Layers = serializableData.layers;
         }
 
         private void Update()
         {
-            handler.UpdateTransform(SceneObject);
+            _native.UpdateTransform(SceneObject);
         }
 
         private void OnDestroy()
         {
-            handler.OnDestroy();
+            _native.OnDestroy();
         }
 
         [SerializeObject]

+ 2 - 2
RenderBeast/Include/BsLitTexRenderableController.h

@@ -31,12 +31,12 @@ namespace BansheeEngine
 		LitTexRenderableController();
 
 		/**
-		 * @copydoc	RenderableHandler::initializeRenderElem
+		 * @copydoc	RenderableController::initializeRenderElem
 		 */
 		void initializeRenderElem(RenderableElement& element) override;
 
 		/**
-		 * @copydoc	RenderableHandler::bindPerObjectBuffers
+		 * @copydoc	RenderableController::bindPerObjectBuffers
 		 */
 		void bindPerObjectBuffers(const RenderableElement& element) override;
 

+ 14 - 14
RenderBeast/Include/BsRenderBeast.h

@@ -23,7 +23,7 @@ namespace BansheeEngine
 	 */
 	struct RenderableData
 	{
-		RenderableHandlerCore* renderable;
+		RenderableCore* renderable;
 		Vector<BeastRenderableElement> elements;
 		RenderableController* controller;
 	};
@@ -63,7 +63,7 @@ namespace BansheeEngine
 		struct RenderTargetData
 		{
 			SPtr<RenderTargetCore> target;
-			Vector<const CameraHandlerCore*> cameras;
+			Vector<const CameraCore*> cameras;
 		};
 
 		/**
@@ -79,7 +79,7 @@ namespace BansheeEngine
 		 */
 		struct LightData
 		{
-			LightInternalCore* internal;
+			LightCore* internal;
 		};
 
 	public:
@@ -120,42 +120,42 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	Renderer::_notifyCameraAdded
 		 */
-		void _notifyCameraAdded(const CameraHandlerCore* camera) override;
+		void _notifyCameraAdded(const CameraCore* camera) override;
 
 		/**
 		 * @copydoc	Renderer::_notifyCameraRemoved
 		 */
-		void _notifyCameraRemoved(const CameraHandlerCore* camera) override;
+		void _notifyCameraRemoved(const CameraCore* camera) override;
 
 		/**
 		 * @copydoc	Renderer::_notifyLightAdded
 		 */
-		void _notifyLightAdded(LightInternalCore* light) override;
+		void _notifyLightAdded(LightCore* light) override;
 
 		/**
 		 * @copydoc	Renderer::_notifyLightUpdated
 		 */
-		void _notifyLightUpdated(LightInternalCore* light) override;
+		void _notifyLightUpdated(LightCore* light) override;
 
 		/**
 		 * @copydoc	Renderer::_notifyLightRemoved
 		 */
-		void _notifyLightRemoved(LightInternalCore* light) override;
+		void _notifyLightRemoved(LightCore* light) override;
 
 		/**
 		 * @copydoc	Renderer::_notifyRenderableAdded
 		 */
-		void _notifyRenderableAdded(RenderableHandlerCore* renderable) override;
+		void _notifyRenderableAdded(RenderableCore* renderable) override;
 
 		/**
 		 * @copydoc	Renderer::_notifyRenderableUpdated
 		 */
-		void _notifyRenderableUpdated(RenderableHandlerCore* renderable) override;
+		void _notifyRenderableUpdated(RenderableCore* renderable) override;
 
 		/**
 		 * @copydoc	Renderer::_notifyRenderableRemoved
 		 */
-		void _notifyRenderableRemoved(RenderableHandlerCore* renderable) override;
+		void _notifyRenderableRemoved(RenderableCore* renderable) override;
 
 		/**
 		 * @brief	Adds a new set of objects to the cameras render queue.
@@ -165,7 +165,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Core thread only.
 		 */
-		void addToRenderQueue(const SPtr<CameraHandlerCore>& proxy, RenderQueuePtr renderQueue);
+		void addToRenderQueue(const SPtr<CameraCore>& proxy, RenderQueuePtr renderQueue);
 
 		/**
 		 * @brief	Updates the render options on the core thread.
@@ -191,7 +191,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Core thread only.
 		 */
-		virtual void render(const CameraHandlerCore& camera, RenderQueuePtr& renderQueue);
+		virtual void render(const CameraCore& camera, RenderQueuePtr& renderQueue);
 
 		/**
 		 * @brief	Creates data used by the renderer on the core thread.
@@ -229,7 +229,7 @@ namespace BansheeEngine
 		static void setPass(const SPtr<MaterialCore>& material, UINT32 passIdx, PassSamplerOverrides* samplerOverrides);
 
 		Vector<RenderTargetData> mRenderTargets; // Core thread
-		UnorderedMap<const CameraHandlerCore*, CameraData> mCameraData; // Core thread
+		UnorderedMap<const CameraCore*, CameraData> mCameraData; // Core thread
 		UnorderedMap<SPtr<MaterialCore>, MaterialSamplerOverrides*> mSamplerOverrides; // Core thread
 
 		SPtr<MaterialCore> mDummyMaterial; // Core thread

+ 23 - 23
RenderBeast/Source/BsRenderBeast.cpp

@@ -1,8 +1,8 @@
 #include "BsRenderBeast.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 #include "BsSceneObject.h"
 #include "BsSceneManager.h"
-#include "BsRenderable.h"
+#include "BsCRenderable.h"
 #include "BsMaterial.h"
 #include "BsMesh.h"
 #include "BsPass.h"
@@ -32,7 +32,7 @@
 #include "BsCoreObjectManager.h"
 #include "BsRenderBeastOptions.h"
 #include "BsSamplerOverrides.h"
-#include "BsLightInternal.h"
+#include "BsLight.h"
 #include "BsRenderTexturePool.h"
 
 using namespace std::placeholders;
@@ -93,7 +93,7 @@ namespace BansheeEngine
 		mDummyMaterial = nullptr;
 	}
 
-	void RenderBeast::_notifyRenderableAdded(RenderableHandlerCore* renderable)
+	void RenderBeast::_notifyRenderableAdded(RenderableCore* renderable)
 	{
 		UINT32 renderableId = (UINT32)mRenderables.size();
 
@@ -152,10 +152,10 @@ namespace BansheeEngine
 		}
 	}
 
-	void RenderBeast::_notifyRenderableRemoved(RenderableHandlerCore* renderable)
+	void RenderBeast::_notifyRenderableRemoved(RenderableCore* renderable)
 	{
 		UINT32 renderableId = renderable->getRendererId();
-		RenderableHandlerCore* lastRenerable = mRenderables.back().renderable;
+		RenderableCore* lastRenerable = mRenderables.back().renderable;
 		UINT32 lastRenderableId = lastRenerable->getRendererId();
 
 		Vector<BeastRenderableElement>& elements = mRenderables[renderableId].elements;
@@ -195,7 +195,7 @@ namespace BansheeEngine
 		mWorldTransforms.erase(mWorldTransforms.end() - 1);
 	}
 
-	void RenderBeast::_notifyRenderableUpdated(RenderableHandlerCore* renderable)
+	void RenderBeast::_notifyRenderableUpdated(RenderableCore* renderable)
 	{
 		UINT32 renderableId = renderable->getRendererId();
 
@@ -203,7 +203,7 @@ namespace BansheeEngine
 		mWorldBounds[renderableId] = renderable->getBounds();
 	}
 
-	void RenderBeast::_notifyLightAdded(LightInternalCore* light)
+	void RenderBeast::_notifyLightAdded(LightCore* light)
 	{
 		UINT32 lightId = (UINT32)mLights.size();
 
@@ -216,17 +216,17 @@ namespace BansheeEngine
 		lightData.internal = light;
 	}
 
-	void RenderBeast::_notifyLightUpdated(LightInternalCore* light)
+	void RenderBeast::_notifyLightUpdated(LightCore* light)
 	{
 		UINT32 lightId = light->getRendererId();
 
 		mLightWorldBounds[lightId] = light->getBounds();
 	}
 
-	void RenderBeast::_notifyLightRemoved(LightInternalCore* light)
+	void RenderBeast::_notifyLightRemoved(LightCore* light)
 	{
 		UINT32 lightId = light->getRendererId();
-		LightInternalCore* lastLight = mLights.back().internal;
+		LightCore* lastLight = mLights.back().internal;
 		UINT32 lastLightId = lastLight->getRendererId();
 
 		if (lightId != lastLightId)
@@ -243,13 +243,13 @@ namespace BansheeEngine
 		mLightWorldBounds.erase(mLightWorldBounds.end() - 1);
 	}
 
-	void RenderBeast::_notifyCameraAdded(const CameraHandlerCore* camera)
+	void RenderBeast::_notifyCameraAdded(const CameraCore* camera)
 	{
 		CameraData& camData = mCameraData[camera];
 		camData.renderQueue = bs_shared_ptr_new<RenderQueue>();
 	}
 
-	void RenderBeast::_notifyCameraRemoved(const CameraHandlerCore* camera)
+	void RenderBeast::_notifyCameraRemoved(const CameraCore* camera)
 	{
 		mCameraData.erase(camera);
 	}
@@ -268,10 +268,10 @@ namespace BansheeEngine
 	void RenderBeast::renderAll() 
 	{
 		// Populate direct draw lists
-		const Map<CameraHandler*, SceneCameraData>& allCameras = gSceneManager().getAllCameras();
+		const Map<Camera*, SceneCameraData>& allCameras = gSceneManager().getAllCameras();
 		for (auto& cameraData : allCameras)
 		{
-			CameraHandlerPtr camera = cameraData.second.camera;
+			CameraPtr camera = cameraData.second.camera;
 			HSceneObject cameraSO = cameraData.second.sceneObject;
 
 			DrawListPtr drawList = bs_shared_ptr_new<DrawList>();
@@ -315,7 +315,7 @@ namespace BansheeEngine
 		gCoreAccessor().queueCommand(std::bind(&RenderBeast::renderAllCore, this, gTime().getTime()));
 	}
 
-	void RenderBeast::addToRenderQueue(const SPtr<CameraHandlerCore>& camera, RenderQueuePtr renderQueue)
+	void RenderBeast::addToRenderQueue(const SPtr<CameraCore>& camera, RenderQueuePtr renderQueue)
 	{
 		RenderQueuePtr cameraRenderQueue = mCameraData[camera.get()].renderQueue;
 		cameraRenderQueue->add(*renderQueue);
@@ -348,7 +348,7 @@ namespace BansheeEngine
 		// Sort cameras by render target
 		for (auto& cameraData : mCameraData)
 		{
-			const CameraHandlerCore* camera = cameraData.first;
+			const CameraCore* camera = cameraData.first;
 			SPtr<RenderTargetCore> renderTarget = camera->getViewport()->getTarget();
 
 			if (renderTarget == nullptr)
@@ -370,14 +370,14 @@ namespace BansheeEngine
 		}
 
 		// Sort everything based on priority
-		auto cameraComparer = [&](const CameraHandlerCore* a, const CameraHandlerCore* b) { return a->getPriority() > b->getPriority(); };
+		auto cameraComparer = [&](const CameraCore* a, const CameraCore* b) { return a->getPriority() > b->getPriority(); };
 		auto renderTargetInfoComparer = [&](const RenderTargetData& a, const RenderTargetData& b)
 		{ return a.target->getProperties().getPriority() > b.target->getProperties().getPriority(); };
 		std::sort(begin(mRenderTargets), end(mRenderTargets), renderTargetInfoComparer);
 
 		for (auto& camerasPerTarget : mRenderTargets)
 		{
-			Vector<const CameraHandlerCore*>& cameras = camerasPerTarget.cameras;
+			Vector<const CameraCore*>& cameras = camerasPerTarget.cameras;
 
 			std::sort(begin(cameras), end(cameras), cameraComparer);
 		}
@@ -386,7 +386,7 @@ namespace BansheeEngine
 		for (auto& renderTargetData : mRenderTargets)
 		{
 			SPtr<RenderTargetCore> target = renderTargetData.target;
-			Vector<const CameraHandlerCore*>& cameras = renderTargetData.cameras;
+			Vector<const CameraCore*>& cameras = renderTargetData.cameras;
 
 			RenderAPICore::instance().beginFrame();
 			RenderAPICore::instance().setRenderTarget(target);
@@ -419,7 +419,7 @@ namespace BansheeEngine
 		mRenderTargets.clear();
 	}
 
-	void RenderBeast::render(const CameraHandlerCore& camera, RenderQueuePtr& renderQueue)
+	void RenderBeast::render(const CameraCore& camera, RenderQueuePtr& renderQueue)
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
@@ -452,7 +452,7 @@ namespace BansheeEngine
 		// Update per-object param buffers and queue render elements
 		for (auto& renderableData : mRenderables)
 		{
-			RenderableHandlerCore* renderable = renderableData.renderable;
+			RenderableCore* renderable = renderableData.renderable;
 			RenderableController* controller = renderableData.controller;
 			UINT32 renderableType = renderable->getRenderableType();
 			UINT32 rendererId = renderable->getRendererId();
@@ -492,7 +492,7 @@ namespace BansheeEngine
 				UINT32 rendererId = renderElem->renderableId;
 				const RenderableData& renderableData = mRenderables[rendererId];
 
-				RenderableHandlerCore* renderable = renderableData.renderable;
+				RenderableCore* renderable = renderableData.renderable;
 				RenderableController* controller = renderableData.controller;
 				UINT32 renderableType = renderable->getRenderableType();
 				

+ 2 - 2
SBansheeEditor/Include/BsScriptSceneViewHandler.h

@@ -14,7 +14,7 @@ namespace BansheeEngine
 		SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "SceneViewHandler")
 
 	private:
-		ScriptSceneViewHandler(MonoObject* object, EditorWidgetBase* parentWidget, const SPtr<CameraHandler>& camera);
+		ScriptSceneViewHandler(MonoObject* object, EditorWidgetBase* parentWidget, const SPtr<Camera>& camera);
 		~ScriptSceneViewHandler();
 
 		SceneViewHandler* mHandler;
@@ -22,7 +22,7 @@ namespace BansheeEngine
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
-		static void internal_Create(MonoObject* managedInstance, ScriptEditorWindow* parentWindow, ScriptCameraHandler* camera);
+		static void internal_Create(MonoObject* managedInstance, ScriptEditorWindow* parentWindow, ScriptCamera* camera);
 		static void internal_Update(ScriptSceneViewHandler* thisPtr);
 		static void internal_UpdateHandle(ScriptSceneViewHandler* thisPtr, Vector2I inputPos, Vector2I inputDelta);
 		static void internal_UpdateSelection(ScriptSceneViewHandler* thisPtr);

+ 1 - 1
SBansheeEditor/Source/BsScriptEditorApplication.cpp

@@ -15,7 +15,7 @@
 #include "BsProfilerOverlay.h"
 #include "BsGUIWidget.h"
 #include "BsSceneObject.h"
-#include "BsCamera.h"
+#include "BsCCamera.h"
 
 namespace BansheeEngine
 {

+ 3 - 3
SBansheeEditor/Source/BsScriptSceneViewHandler.cpp

@@ -3,14 +3,14 @@
 #include "BsMonoClass.h"
 #include "BsMonoUtil.h"
 #include "BsSceneViewHandler.h"
-#include "BsScriptCameraHandler.h"
+#include "BsScriptCamera.h"
 #include "BsScriptEditorWindow.h"
 #include "BsEditorWidgetContainer.h"
 #include "BsEditorWindowBase.h"
 
 namespace BansheeEngine
 {
-	ScriptSceneViewHandler::ScriptSceneViewHandler(MonoObject* object, EditorWidgetBase* parentWidget, const SPtr<CameraHandler>& camera)
+	ScriptSceneViewHandler::ScriptSceneViewHandler(MonoObject* object, EditorWidgetBase* parentWidget, const SPtr<Camera>& camera)
 		:ScriptObject(object), mHandler(nullptr)
 	{ 
 		mHandler = bs_new<SceneViewHandler>(parentWidget, camera);
@@ -33,7 +33,7 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_PickObject", &ScriptSceneViewHandler::internal_PickObject);
 	}
 
-	void ScriptSceneViewHandler::internal_Create(MonoObject* managedInstance, ScriptEditorWindow* parentWindow, ScriptCameraHandler* camera)
+	void ScriptSceneViewHandler::internal_Create(MonoObject* managedInstance, ScriptEditorWindow* parentWindow, ScriptCamera* camera)
 	{
 		EditorWidgetBase* widget = nullptr;
 		

+ 121 - 0
SBansheeEngine/Include/BsScriptCamera.h

@@ -0,0 +1,121 @@
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptObject.h"
+#include "BsVector2.h"
+#include "BsVector3.h"
+#include "BsVector2I.h"
+#include "BsRay.h"
+#include "BsDegree.h"
+#include "BsMatrix4.h"
+#include "BsRect2.h"
+#include "BsColor.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Interop class between C++ & CLR for Camera.
+	 */
+	class BS_SCR_BE_EXPORT ScriptCamera : public ScriptObject<ScriptCamera>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "NativeCamera")
+
+		/**
+		 * @brief	Returns the wrapped native Camera object.
+		 */
+		SPtr<Camera> getInternal() const { return mCamera; }
+
+	private:
+		ScriptCamera(MonoObject* managedInstance, const HSceneObject& parentSO);
+		~ScriptCamera();
+
+		/**
+		 * @brief	Updates the internal camera handler from the transform of the
+		 *			provided scene object.
+		 */
+		void updateView(const HSceneObject& parent);
+
+		SPtr<Camera> mCamera;
+		UINT32 mLastUpdateHash;
+
+		/************************************************************************/
+		/* 								CLR HOOKS						   		*/
+		/************************************************************************/
+		static void internal_Create(MonoObject* managedInstance, ScriptSceneObject* parentSO);
+
+		static float internal_GetAspect(ScriptCamera* instance);
+		static void internal_SetAspect(ScriptCamera* instance, float value);
+		static float internal_GetNearClip(ScriptCamera* instance);
+		static void internal_SetNearClip(ScriptCamera* instance, float value);
+
+		static float internal_GetFarClip(ScriptCamera* instance);
+		static void internal_SetFarClip(ScriptCamera* instance, float value);
+
+		static Degree internal_GetFieldOfView(ScriptCamera* instance);
+		static void internal_SetFieldOfView(ScriptCamera* instance, Degree value);
+
+		static Rect2 internal_GetViewportRect(ScriptCamera* instance);
+		static void internal_SetViewportRect(ScriptCamera* instance, Rect2 value);
+
+		static UINT32 internal_GetProjectionType(ScriptCamera* instance);
+		static void internal_SetProjectionType(ScriptCamera* instance, UINT32 value);
+
+		static float internal_GetOrthographicHeight(ScriptCamera* instance);
+		static void internal_SetOrthographicHeight(ScriptCamera* instance, float value);
+
+		static float internal_GetOrthographicWidth(ScriptCamera* instance);
+
+		static Color internal_GetClearColor(ScriptCamera* instance);
+		static void internal_SetClearColor(ScriptCamera* instance, Color value);
+
+		static float internal_GetDepthClearValue(ScriptCamera* instance);
+		static void internal_SetDepthClearValue(ScriptCamera* instance, float value);
+
+		static UINT16 internal_GetStencilClearValue(ScriptCamera* instance);
+		static void internal_SetStencilClearValue(ScriptCamera* instance, UINT16 value);
+
+		static UINT32 internal_GetClearFlags(ScriptCamera* instance);
+		static void internal_SetClearFlags(ScriptCamera* instance, UINT32 value);
+
+		static int internal_GetPriority(ScriptCamera* instance);
+		static void internal_SetPriority(ScriptCamera* instance, int value);
+
+		static UINT64 internal_GetLayers(ScriptCamera* instance);
+		static void internal_SetLayers(ScriptCamera* instance, UINT64 value);
+
+		static Matrix4 internal_GetProjMatrix(ScriptCamera* instance);
+		static Matrix4 internal_GetProjMatrixInv(ScriptCamera* instance);
+
+		static Matrix4 internal_GetViewMatrix(ScriptCamera* instance);
+		static Matrix4 internal_GetViewMatrixInv(ScriptCamera* instance);
+
+		static int internal_GetWidthPixels(ScriptCamera* instance);
+		static int internal_GetHeightPixels(ScriptCamera* instance);
+
+		static Vector2I internal_WorldToScreen(ScriptCamera* instance, Vector3 value);
+		static Vector2 internal_WorldToClip(ScriptCamera* instance, Vector3 value);
+		static Vector3 internal_WorldToView(ScriptCamera* instance, Vector3 value);
+
+		static Vector3 internal_ScreenToWorld(ScriptCamera* instance, Vector2I value, float depth);
+		static Vector3 internal_ScreenToView(ScriptCamera* instance, Vector2I value, float depth);
+		static Vector2 internal_ScreenToClip(ScriptCamera* instance, Vector2I value);
+
+		static Vector3 internal_ViewToWorld(ScriptCamera* instance, Vector3 value);
+		static Vector2I internal_ViewToScreen(ScriptCamera* instance, Vector3 value);
+		static Vector2 internal_ViewToClip(ScriptCamera* instance, Vector3 value);
+
+		static Vector3 internal_ClipToWorld(ScriptCamera* instance, Vector2 value, float depth);
+		static Vector3 internal_ClipToView(ScriptCamera* instance, Vector2 value, float depth);
+		static Vector2I internal_ClipToScreen(ScriptCamera* instance, Vector2 value);
+
+		static Ray internal_ScreenToWorldRay(ScriptCamera* instance, Vector2I value);
+		static Vector3 internal_ProjectPoint(ScriptCamera* instance, Vector3 value);
+		static Vector3 internal_UnprojectPoint(ScriptCamera* instance, Vector3 value);
+
+		static void internal_SetRenderTarget(ScriptCamera* instance, ScriptRenderTarget* target);
+
+		static void internal_UpdateView(ScriptCamera* instance, ScriptSceneObject* parent);
+		static void internal_OnDestroy(ScriptCamera* instance);
+	};
+}

+ 0 - 121
SBansheeEngine/Include/BsScriptCameraHandler.h

@@ -1,121 +0,0 @@
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptObject.h"
-#include "BsVector2.h"
-#include "BsVector3.h"
-#include "BsVector2I.h"
-#include "BsRay.h"
-#include "BsDegree.h"
-#include "BsMatrix4.h"
-#include "BsRect2.h"
-#include "BsColor.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Interop class between C++ & CLR for CameraHandler.
-	 */
-	class BS_SCR_BE_EXPORT ScriptCameraHandler : public ScriptObject<ScriptCameraHandler>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "CameraHandler")
-
-		/**
-		 * @brief	Returns the wrapped native CameraHandler object.
-		 */
-		SPtr<CameraHandler> getInternal() const { return mCameraHandler; }
-
-	private:
-		ScriptCameraHandler(MonoObject* managedInstance, const HSceneObject& parentSO);
-		~ScriptCameraHandler();
-
-		/**
-		 * @brief	Updates the internal camera handler from the transform of the
-		 *			provided scene object.
-		 */
-		void updateView(const HSceneObject& parent);
-
-		SPtr<CameraHandler> mCameraHandler;
-		UINT32 mLastUpdateHash;
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_Create(MonoObject* managedInstance, ScriptSceneObject* parentSO);
-
-		static float internal_GetAspect(ScriptCameraHandler* instance);
-		static void internal_SetAspect(ScriptCameraHandler* instance, float value);
-		static float internal_GetNearClip(ScriptCameraHandler* instance);
-		static void internal_SetNearClip(ScriptCameraHandler* instance, float value);
-
-		static float internal_GetFarClip(ScriptCameraHandler* instance);
-		static void internal_SetFarClip(ScriptCameraHandler* instance, float value);
-
-		static Degree internal_GetFieldOfView(ScriptCameraHandler* instance);
-		static void internal_SetFieldOfView(ScriptCameraHandler* instance, Degree value);
-
-		static Rect2 internal_GetViewportRect(ScriptCameraHandler* instance);
-		static void internal_SetViewportRect(ScriptCameraHandler* instance, Rect2 value);
-
-		static UINT32 internal_GetProjectionType(ScriptCameraHandler* instance);
-		static void internal_SetProjectionType(ScriptCameraHandler* instance, UINT32 value);
-
-		static float internal_GetOrthographicHeight(ScriptCameraHandler* instance);
-		static void internal_SetOrthographicHeight(ScriptCameraHandler* instance, float value);
-
-		static float internal_GetOrthographicWidth(ScriptCameraHandler* instance);
-
-		static Color internal_GetClearColor(ScriptCameraHandler* instance);
-		static void internal_SetClearColor(ScriptCameraHandler* instance, Color value);
-
-		static float internal_GetDepthClearValue(ScriptCameraHandler* instance);
-		static void internal_SetDepthClearValue(ScriptCameraHandler* instance, float value);
-
-		static UINT16 internal_GetStencilClearValue(ScriptCameraHandler* instance);
-		static void internal_SetStencilClearValue(ScriptCameraHandler* instance, UINT16 value);
-
-		static UINT32 internal_GetClearFlags(ScriptCameraHandler* instance);
-		static void internal_SetClearFlags(ScriptCameraHandler* instance, UINT32 value);
-
-		static int internal_GetPriority(ScriptCameraHandler* instance);
-		static void internal_SetPriority(ScriptCameraHandler* instance, int value);
-
-		static UINT64 internal_GetLayers(ScriptCameraHandler* instance);
-		static void internal_SetLayers(ScriptCameraHandler* instance, UINT64 value);
-
-		static Matrix4 internal_GetProjMatrix(ScriptCameraHandler* instance);
-		static Matrix4 internal_GetProjMatrixInv(ScriptCameraHandler* instance);
-
-		static Matrix4 internal_GetViewMatrix(ScriptCameraHandler* instance);
-		static Matrix4 internal_GetViewMatrixInv(ScriptCameraHandler* instance);
-
-		static int internal_GetWidthPixels(ScriptCameraHandler* instance);
-		static int internal_GetHeightPixels(ScriptCameraHandler* instance);
-
-		static Vector2I internal_WorldToScreen(ScriptCameraHandler* instance, Vector3 value);
-		static Vector2 internal_WorldToClip(ScriptCameraHandler* instance, Vector3 value);
-		static Vector3 internal_WorldToView(ScriptCameraHandler* instance, Vector3 value);
-
-		static Vector3 internal_ScreenToWorld(ScriptCameraHandler* instance, Vector2I value, float depth);
-		static Vector3 internal_ScreenToView(ScriptCameraHandler* instance, Vector2I value, float depth);
-		static Vector2 internal_ScreenToClip(ScriptCameraHandler* instance, Vector2I value);
-
-		static Vector3 internal_ViewToWorld(ScriptCameraHandler* instance, Vector3 value);
-		static Vector2I internal_ViewToScreen(ScriptCameraHandler* instance, Vector3 value);
-		static Vector2 internal_ViewToClip(ScriptCameraHandler* instance, Vector3 value);
-
-		static Vector3 internal_ClipToWorld(ScriptCameraHandler* instance, Vector2 value, float depth);
-		static Vector3 internal_ClipToView(ScriptCameraHandler* instance, Vector2 value, float depth);
-		static Vector2I internal_ClipToScreen(ScriptCameraHandler* instance, Vector2 value);
-
-		static Ray internal_ScreenToWorldRay(ScriptCameraHandler* instance, Vector2I value);
-		static Vector3 internal_ProjectPoint(ScriptCameraHandler* instance, Vector3 value);
-		static Vector3 internal_UnprojectPoint(ScriptCameraHandler* instance, Vector3 value);
-
-		static void internal_SetRenderTarget(ScriptCameraHandler* instance, ScriptRenderTarget* target);
-
-		static void internal_UpdateView(ScriptCameraHandler* instance, ScriptSceneObject* parent);
-		static void internal_OnDestroy(ScriptCameraHandler* instance);
-	};
-}

+ 1 - 1
SBansheeEngine/Include/BsScriptEnginePrerequisites.h

@@ -45,7 +45,7 @@ namespace BansheeEngine
 	class ScriptManagedResource;
 	class ScriptRenderTarget;
 	class ScriptRenderTexture2D;
-	class ScriptCameraHandler;
+	class ScriptCamera;
 	class ScriptMeshData;
 	class ManagedComponent;
 	class ManagedSerializableFieldData;

+ 0 - 70
SBansheeEngine/Include/BsScriptLightInternal.h

@@ -1,70 +0,0 @@
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptObject.h"
-#include "BsVector3.h"
-#include "BsQuaternion.h"
-#include "BsDegree.h"
-#include "BsColor.h"
-#include "BsLightInternal.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Interop class between C++ & CLR for LightInternal.
-	 */
-	class BS_SCR_BE_EXPORT ScriptLightInternal : public ScriptObject <ScriptLightInternal>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "LightInternal")
-
-		/**
-		 * @brief	Gets the wrapped native LightInternal object.
-		 */
-		SPtr<LightInternal> getInternal() const { return mLightInternal; }
-
-	private:
-		ScriptLightInternal(MonoObject* managedInstance, const HSceneObject& parentSO);
-		~ScriptLightInternal();
-
-		SPtr<LightInternal> mLightInternal;
-		UINT32 mLastUpdateHash;
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_create(MonoObject* managedInstance, ScriptSceneObject* parentSO);
-
-		static Vector3 internal_getPosition(ScriptLightInternal* thisPtr);
-		static void internal_setPosition(ScriptLightInternal* thisPtr, Vector3 position);
-
-		static Quaternion internal_getRotation(ScriptLightInternal* thisPtr);
-		static void internal_setRotation(ScriptLightInternal* thisPtr, Quaternion rotation);
-
-		static LightType internal_getType(ScriptLightInternal* thisPtr);
-		static void internal_setType(ScriptLightInternal* thisPtr, LightType type);
-
-		static bool internal_getCastsShadow(ScriptLightInternal* thisPtr);
-		static void internal_setCastsShadow(ScriptLightInternal* thisPtr, bool castsShadow);
-
-		static Color internal_getColor(ScriptLightInternal* thisPtr);
-		static void internal_setColor(ScriptLightInternal* thisPtr, Color color);
-
-		static float internal_getRange(ScriptLightInternal* thisPtr);
-		static void internal_setRange(ScriptLightInternal* thisPtr, float range);
-
-		static float internal_getIntensity(ScriptLightInternal* thisPtr);
-		static void internal_setIntensity(ScriptLightInternal* thisPtr, float intensity);
-
-		static Degree internal_getSpotAngle(ScriptLightInternal* thisPtr);
-		static void internal_setSpotAngle(ScriptLightInternal* thisPtr, Degree spotAngle);
-
-		static Degree internal_getSpotFalloffAngle(ScriptLightInternal* thisPtr);
-		static void internal_setSpotFalloffAngle(ScriptLightInternal* thisPtr, Degree spotFalloffAngle);
-
-		static Sphere internal_getBounds(ScriptLightInternal* thisPtr);
-
-		static void internal_updateTransform(ScriptLightInternal* thisPtr, ScriptSceneObject* parent);
-		static void internal_onDestroy(ScriptLightInternal* instance);
-	};
-}

+ 2 - 2
SBansheeEngine/Include/BsScriptProfilerOverlayInternal.h

@@ -20,7 +20,7 @@ namespace BansheeEngine
 		ProfilerOverlayInternal* getInternal() const { return mProfilerOverlayInternal; }
 
 	private:
-		ScriptProfilerOverlayInternal(MonoObject* managedInstance, const SPtr<CameraHandler>& camera);
+		ScriptProfilerOverlayInternal(MonoObject* managedInstance, const SPtr<Camera>& camera);
 		~ScriptProfilerOverlayInternal();
 
 		ProfilerOverlayInternal* mProfilerOverlayInternal;
@@ -28,7 +28,7 @@ namespace BansheeEngine
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
-		static void internal_CreateInstance(MonoObject* instance, ScriptCameraHandler* camera);
+		static void internal_CreateInstance(MonoObject* instance, ScriptCamera* camera);
 		static void internal_SetType(ScriptProfilerOverlayInternal* thisPtr, ProfilerOverlayType type);
 		static void internal_Update(ScriptProfilerOverlayInternal* thisPtr);
 		static void internal_DestroyInstance(ScriptProfilerOverlayInternal* thisPtr);

+ 51 - 0
SBansheeEngine/Include/BsScriptRenderable.h

@@ -0,0 +1,51 @@
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptObject.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Interop class between C++ & CLR for Renderable.
+	 */
+	class BS_SCR_BE_EXPORT ScriptRenderable : public ScriptObject < ScriptRenderable >
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "NativeRenderable")
+
+		/**
+		 * @brief	Returns the native wrapped renderable handler.
+		 */
+		SPtr<Renderable> getInternal() const { return mRenderable; }
+
+	private:
+		ScriptRenderable(MonoObject* managedInstance, const HSceneObject& parentSO);
+		~ScriptRenderable();
+
+		/**
+		 * @brief	Updates the internal transform of the renderable handled according to
+		 *			the scene object it is attached to.
+		 */
+		void updateTransform(const HSceneObject& parent);
+
+		/**
+		 * @brief	Destroys the internal renderable handler object.
+		 */
+		void destroy();
+
+		SPtr<Renderable> mRenderable;
+		UINT32 mLastUpdateHash;
+
+		/************************************************************************/
+		/* 								CLR HOOKS						   		*/
+		/************************************************************************/
+		static void internal_Create(MonoObject* instance, ScriptSceneObject* parentSO);
+		static void internal_UpdateTransform(ScriptRenderable* thisPtr, ScriptSceneObject* parentSO);
+		static void internal_SetMesh(ScriptRenderable* thisPtr, ScriptMesh* mesh);
+		static void internal_GetBounds(ScriptRenderable* thisPtr, ScriptSceneObject* parentSO, AABox* box, Sphere* sphere);
+		static UINT64 internal_GetLayers(ScriptRenderable* thisPtr);
+		static void internal_SetLayers(ScriptRenderable* thisPtr, UINT64 layers);
+		static void internal_SetMaterial(ScriptRenderable* thisPtr, ScriptMaterial* material, int index);
+		static void internal_OnDestroy(ScriptRenderable* thisPtr);
+	};
+}

+ 0 - 51
SBansheeEngine/Include/BsScriptRenderableHandler.h

@@ -1,51 +0,0 @@
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Interop class between C++ & CLR for RenderableHandler.
-	 */
-	class BS_SCR_BE_EXPORT ScriptRenderableHandler : public ScriptObject < ScriptRenderableHandler >
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "RenderableHandler")
-
-		/**
-		 * @brief	Returns the native wrapped renderable handler.
-		 */
-		SPtr<RenderableHandler> getInternal() const { return mRenderableHandler; }
-
-	private:
-		ScriptRenderableHandler(MonoObject* managedInstance, const HSceneObject& parentSO);
-		~ScriptRenderableHandler();
-
-		/**
-		 * @brief	Updates the internal transform of the renderable handled according to
-		 *			the scene object it is attached to.
-		 */
-		void updateTransform(const HSceneObject& parent);
-
-		/**
-		 * @brief	Destroys the internal renderable handler object.
-		 */
-		void destroy();
-
-		SPtr<RenderableHandler> mRenderableHandler;
-		UINT32 mLastUpdateHash;
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_Create(MonoObject* instance, ScriptSceneObject* parentSO);
-		static void internal_UpdateTransform(ScriptRenderableHandler* thisPtr, ScriptSceneObject* parentSO);
-		static void internal_SetMesh(ScriptRenderableHandler* thisPtr, ScriptMesh* mesh);
-		static void internal_GetBounds(ScriptRenderableHandler* thisPtr, ScriptSceneObject* parentSO, AABox* box, Sphere* sphere);
-		static UINT64 internal_GetLayers(ScriptRenderableHandler* thisPtr);
-		static void internal_SetLayers(ScriptRenderableHandler* thisPtr, UINT64 layers);
-		static void internal_SetMaterial(ScriptRenderableHandler* thisPtr, ScriptMaterial* material, int index);
-		static void internal_OnDestroy(ScriptRenderableHandler* thisPtr);
-	};
-}

+ 6 - 6
SBansheeEngine/SBansheeEngine.vcxproj

@@ -257,7 +257,7 @@
     <ClInclude Include="Include\BsScriptAsyncOp.h" />
     <ClInclude Include="Include\BsScriptBoneWeight.h" />
     <ClInclude Include="Include\BsScriptBuiltin.h" />
-    <ClInclude Include="Include\BsScriptCameraHandler.h" />
+    <ClInclude Include="Include\BsScriptCamera.h" />
     <ClInclude Include="Include\BsScriptColor.h" />
     <ClInclude Include="Include\BsScriptComponent.h" />
     <ClInclude Include="Include\BsScriptContextMenu.h" />
@@ -289,7 +289,7 @@
     <ClInclude Include="Include\BsScriptHString.h" />
     <ClInclude Include="Include\BsScriptInput.h" />
     <ClInclude Include="Include\BsScriptInputConfiguration.h" />
-    <ClInclude Include="Include\BsScriptLightInternal.h" />
+    <ClInclude Include="Include\BsScriptLight.h" />
     <ClInclude Include="Include\BsScriptManagedResource.h" />
     <ClInclude Include="Include\BsScriptMaterial.h" />
     <ClInclude Include="Include\BsScriptMesh.h" />
@@ -302,7 +302,7 @@
     <ClInclude Include="Include\BsScriptPlainText.h" />
     <ClInclude Include="Include\BsScriptPrefab.h" />
     <ClInclude Include="Include\BsScriptProfilerOverlayInternal.h" />
-    <ClInclude Include="Include\BsScriptRenderableHandler.h" />
+    <ClInclude Include="Include\BsScriptRenderable.h" />
     <ClInclude Include="Include\BsScriptRenderTarget.h" />
     <ClInclude Include="Include\BsScriptRenderTexture.h" />
     <ClInclude Include="Include\BsScriptRenderTexture2D.h" />
@@ -349,7 +349,7 @@
     <ClCompile Include="Source\BsScriptAsyncOp.cpp" />
     <ClCompile Include="Source\BsScriptBoneWeight.cpp" />
     <ClCompile Include="Source\BsScriptBuiltin.cpp" />
-    <ClCompile Include="Source\BsScriptCameraHandler.cpp" />
+    <ClCompile Include="Source\BsScriptCamera.cpp" />
     <ClCompile Include="Source\BsScriptColor.cpp" />
     <ClCompile Include="Source\BsScriptComponent.cpp" />
     <ClCompile Include="Source\BsScriptContextMenu.cpp" />
@@ -381,7 +381,7 @@
     <ClCompile Include="Source\BsScriptGUIInputBox.cpp" />
     <ClCompile Include="Source\BsScriptInput.cpp" />
     <ClCompile Include="Source\BsScriptInputConfiguration.cpp" />
-    <ClCompile Include="Source\BsScriptLightInternal.cpp" />
+    <ClCompile Include="Source\BsScriptLight.cpp" />
     <ClCompile Include="Source\BsScriptManagedResource.cpp" />
     <ClCompile Include="Source\BsScriptMaterial.cpp" />
     <ClCompile Include="Source\BsScriptMesh.cpp" />
@@ -394,7 +394,7 @@
     <ClCompile Include="Source\BsScriptPlainText.cpp" />
     <ClCompile Include="Source\BsScriptPrefab.cpp" />
     <ClCompile Include="Source\BsScriptProfilerOverlayInternal.cpp" />
-    <ClCompile Include="Source\BsScriptRenderableHandler.cpp" />
+    <ClCompile Include="Source\BsScriptRenderable.cpp" />
     <ClCompile Include="Source\BsScriptRenderTarget.cpp" />
     <ClCompile Include="Source\BsScriptRenderTexture.cpp" />
     <ClCompile Include="Source\BsScriptRenderTexture2D.cpp" />

+ 18 - 18
SBansheeEngine/SBansheeEngine.vcxproj.filters

@@ -258,9 +258,6 @@
     <ClInclude Include="Include\BsScriptGUIRenderTexture.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsScriptCameraHandler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsScriptObjectManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -300,9 +297,6 @@
     <ClInclude Include="Include\BsScriptBoneWeight.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsScriptRenderableHandler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsScriptContextMenu.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -321,9 +315,6 @@
     <ClInclude Include="Include\BsScriptScene.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsScriptLightInternal.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsScriptProfilerOverlayInternal.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -342,6 +333,15 @@
     <ClInclude Include="Include\BsEngineScriptLibrary.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsScriptCamera.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsScriptRenderable.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsScriptLight.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
@@ -536,9 +536,6 @@
     <ClCompile Include="Source\BsScriptGUIRenderTexture.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsScriptCameraHandler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsScriptObjectManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -584,9 +581,6 @@
     <ClCompile Include="Source\BsScriptBoneWeight.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsScriptRenderableHandler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsScriptContextMenu.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -602,9 +596,6 @@
     <ClCompile Include="Source\BsScriptScene.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsScriptLightInternal.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsScriptProfilerOverlayInternal.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -623,5 +614,14 @@
     <ClCompile Include="Source\BsEngineScriptLibrary.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsScriptCamera.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsScriptRenderable.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsScriptLight.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

Some files were not shown because too many files changed in this diff