Many ecs, component and editor changes

This commit is contained in:
Simon Lübeß
2022-03-02 01:59:51 +01:00
parent afe36b19df
commit cbee9f59d8
10 changed files with 243 additions and 31 deletions
+19 -1
View File
@@ -3,7 +3,25 @@ using GlitchyEngine.Math;
namespace GlitchyEngine.Renderer
{
public abstract class Camera
struct Camera
{
protected Matrix _projection;
public Matrix Projection => _projection;
protected this()
{
_projection = .Identity;
}
public this(Matrix projection)
{
_projection = projection;
}
}
public abstract class OldCamera
{
protected Matrix _view;
protected Matrix _transform;
@@ -2,7 +2,7 @@ using GlitchyEngine.Math;
namespace GlitchyEngine.Renderer
{
public struct CameraComponent
public struct OldCameraComponent
{
public enum Projection
{
@@ -29,10 +29,11 @@ namespace GlitchyEngine.Renderer
*/
Orthographic
}
float _nearPlane;
float _farPlane;
Projection _projectionType;
float _fovY;
float _aspect;
@@ -2,7 +2,7 @@ using GlitchyEngine.Math;
namespace GlitchyEngine.Renderer
{
public class OrthographicCamera : Camera
public class OrthographicCamera : OldCamera
{
protected float _bottom, _left, _right, _top;
@@ -6,7 +6,7 @@ namespace GlitchyEngine.Renderer
/**
* If FarPlane is float.PositiveInfinity the projection matrix will be an infinite projection (that means no far plane)
*/
public class PerspectiveCamera : Camera
public class PerspectiveCamera : OldCamera
{
public enum ProjectionType
{
+4 -3
View File
@@ -79,7 +79,8 @@ namespace GlitchyEngine.Renderer
LineGeometry.SetVertexLayout(layout..ReleaseRefNoDelete());
}
public static void BeginScene(EcsWorld world, EcsEntity cameraEntity)
// TODO
/*public static void BeginScene(EcsWorld world, EcsEntity cameraEntity)
{
Debug.Profiler.ProfileRendererFunction!();
@@ -91,9 +92,9 @@ namespace GlitchyEngine.Renderer
var proj = camera.Projection;
_sceneConstants.ViewProjection = proj * view;
}
}*/
public static void BeginScene(Camera camera)
public static void BeginScene(OldCamera camera)
{
Debug.Profiler.ProfileRendererFunction!();
+45 -1
View File
@@ -3,6 +3,7 @@ using System.Collections;
using System;
using System.Diagnostics;
using GlitchyEngine.Renderer.Text;
using GlitchyEngine.World;
namespace GlitchyEngine.Renderer
{
@@ -362,7 +363,8 @@ namespace GlitchyEngine.Renderer
#endif
}
public static void BeginScene(Camera camera, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
// TODO: remove?
public static void BeginScene(OldCamera camera, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
{
Debug.Profiler.ProfileRendererFunction!();
#if DEBUG
@@ -397,6 +399,48 @@ namespace GlitchyEngine.Renderer
s_drawOrder = drawOrder;
#if DEBUG
s_sceneRunning = true;
#endif
}
public static void BeginScene(Camera camera, Matrix transform, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
{
Debug.Profiler.ProfileRendererFunction!();
#if DEBUG
Log.EngineLogger.AssertDebug(s_initialized, "Renderer2D was not initialized.");
Log.EngineLogger.AssertDebug(!s_sceneRunning, "You have to call EndScene before you can make another call to BeginScene.");
#endif
//s_textureColorEffect.Bind(Renderer._context);
s_currentEffect?.ReleaseRef();
if(effect != null)
{
s_currentEffect = effect..AddRef();
}
else
{
s_currentEffect = s_batchEffect..AddRef();
}
s_currentCircleEffect?.ReleaseRef();
if(circleEffect != null)
{
s_currentCircleEffect = effect..AddRef();
}
else
{
s_currentCircleEffect = s_circleBatchEffect..AddRef();
}
Matrix viewProjection = camera.Projection * Matrix.Invert(transform);
s_currentEffect.Variables["ViewProjection"].SetData(viewProjection);
s_currentCircleEffect.Variables["ViewProjection"].SetData(viewProjection);
s_drawOrder = drawOrder;
#if DEBUG
s_sceneRunning = true;
#endif