Loads and loads of small improvements I added while developing on my game
This commit is contained in:
parent
41421b1df9
commit
a7c71e7ea1
107 changed files with 2278 additions and 1023 deletions
|
|
@ -1,103 +1,33 @@
|
|||
#region usings
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Scene;
|
||||
using SM.OGL.Mesh;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Contexts
|
||||
namespace SM.Base.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains important information for drawing.
|
||||
/// </summary>
|
||||
public struct DrawContext
|
||||
{
|
||||
/// <summary>
|
||||
/// This says if it was forced to use the viewport camera.
|
||||
/// </summary>
|
||||
public bool ForceViewport;
|
||||
public IGenericWindow Window { get; internal set; }
|
||||
public GenericScene Scene { get; internal set; }
|
||||
public RenderPipeline RenderPipeline { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the currently used render pipeline.
|
||||
/// </summary>
|
||||
public RenderPipeline ActivePipeline;
|
||||
public GenericCamera UseCamera { get; internal set; }
|
||||
public Matrix4 World => UseCamera.World;
|
||||
public Matrix4 View => UseCamera.View;
|
||||
|
||||
public GenericScene ActiveScene;
|
||||
public IGenericWindow Window;
|
||||
public GenericMesh Mesh { get; set; }
|
||||
public Material Material { get; set; }
|
||||
public MaterialShader Shader => Material.CustomShader ?? RenderPipeline.DefaultShader;
|
||||
|
||||
|
||||
public GenericCamera UsedCamera =>
|
||||
ForceViewport || ActiveScene._camera == null ? Window.ViewportCamera : ActiveScene._camera;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The mesh.
|
||||
/// </summary>
|
||||
public GenericMesh Mesh;
|
||||
|
||||
/// <summary>
|
||||
/// The material.
|
||||
/// </summary>
|
||||
public Material Material;
|
||||
|
||||
/// <summary>
|
||||
/// The drawing instances.
|
||||
/// <para>If there is only one, it's index 0</para>
|
||||
/// </summary>
|
||||
public Matrix4 ModelMatrix;
|
||||
public Matrix3 TextureMatrix;
|
||||
public IList<Instance> Instances;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The current world scale.
|
||||
/// </summary>
|
||||
public Vector2 WorldScale;
|
||||
|
||||
/// <summary>
|
||||
/// The last collection the context was passed though.
|
||||
/// </summary>
|
||||
public object LastPassthough;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the appropriate shader.
|
||||
/// <para>
|
||||
/// Returns the material shader, if available, otherwise it will take the default shader from the render
|
||||
/// pipeline.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public MaterialShader Shader => Material.CustomShader ?? ActivePipeline._defaultShader;
|
||||
/// <summary>
|
||||
/// Arguments for shaders
|
||||
/// </summary>
|
||||
public IDictionary<string, object> ShaderArguments;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The current world matrix.
|
||||
/// </summary>
|
||||
public Matrix4 World;
|
||||
|
||||
/// <summary>
|
||||
/// The current view matrix.
|
||||
/// </summary>
|
||||
public Matrix4 View;
|
||||
|
||||
/// <summary>
|
||||
/// The current WorldView matrix.
|
||||
/// </summary>
|
||||
public Matrix4 WorldView;
|
||||
|
||||
/// <summary>
|
||||
/// The master model matrix.
|
||||
/// </summary>
|
||||
public Matrix4 ModelMaster;
|
||||
public void SetCamera(GenericCamera camera)
|
||||
{
|
||||
UseCamera = camera;
|
||||
camera.CalculateViewMatrix(Window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +1,14 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK.Input;
|
||||
using OpenTK.Input;
|
||||
using SM.Base.Scene;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Contexts
|
||||
namespace SM.Base.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// The update context.
|
||||
/// </summary>
|
||||
public struct UpdateContext
|
||||
{
|
||||
/// <summary>
|
||||
/// The delta time.
|
||||
/// </summary>
|
||||
public IGenericWindow Window;
|
||||
|
||||
public float Deltatime => SMRenderer.DefaultDeltatime.DeltaTime;
|
||||
|
||||
/// <summary>
|
||||
/// The current keyboard state.
|
||||
/// </summary>
|
||||
public KeyboardState KeyboardState;
|
||||
|
||||
/// <summary>
|
||||
/// The current mouse state.
|
||||
/// </summary>
|
||||
public MouseState MouseState;
|
||||
|
||||
public GenericScene CurrentScene;
|
||||
public GenericScene Scene;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue