2021-03-07

+ IScriptable can now be disabled instancewise
+ IShowItem can disable rendering.

~ SM.Base.Mesh has now ILineMesh

- IGenericWindow.AspectRatioReverse
This commit is contained in:
Michel Fedde 2021-03-07 12:30:54 +01:00
parent c6bf5c75bc
commit 4efc47d75a
10 changed files with 16 additions and 10 deletions

View file

@ -46,6 +46,7 @@ namespace SM.Base.Drawing
/// This value determents if the object should draw something. /// This value determents if the object should draw something.
/// </summary> /// </summary>
public bool Active { get; set; } = true; public bool Active { get; set; } = true;
public bool RenderActive { get; set; } = true;
/// <inheritdoc /> /// <inheritdoc />
public void Draw(DrawContext context) public void Draw(DrawContext context)

View file

@ -74,6 +74,8 @@ namespace SM.Base.Drawing.Particles
CreateParticles(); CreateParticles();
} }
public bool UpdateActive { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public void Update(UpdateContext context) public void Update(UpdateContext context)
{ {

View file

@ -8,8 +8,11 @@ using SM.OGL.Mesh;
namespace SM.Base.Objects namespace SM.Base.Objects
{ {
/// <inheritdoc /> /// <inheritdoc />
public class Mesh : GenericMesh public class Mesh : GenericMesh, ILineMesh
{ {
public float LineWidth { get; set; } = 1;
/// <summary> /// <summary>
/// While initializing, it will add the <see cref="Color" /> to the data index. /// While initializing, it will add the <see cref="Color" /> to the data index.
/// </summary> /// </summary>
@ -23,5 +26,6 @@ namespace SM.Base.Objects
/// Contains vertex colors /// Contains vertex colors
/// </summary> /// </summary>
public virtual VBO Color { get; protected set; } public virtual VBO Color { get; protected set; }
} }
} }

View file

@ -45,7 +45,7 @@ namespace SM.Base.Scene
for (var i = 0; i < _scriptableObjects.Count; i++) for (var i = 0; i < _scriptableObjects.Count; i++)
{ {
if (!_scriptableObjects[i].Active) continue; if (!_scriptableObjects[i].Active || !_scriptableObjects[i].UpdateActive) continue;
_scriptableObjects[i].Update(context); _scriptableObjects[i].Update(context);
} }
} }
@ -57,7 +57,7 @@ namespace SM.Base.Scene
for (var i = 0; i < Objects.Count; i++) for (var i = 0; i < Objects.Count; i++)
{ {
if (!this[i].Active) continue; if (!this[i].Active || !this[i].RenderActive) continue;
this[i].Draw(context); this[i].Draw(context);
} }
} }

View file

@ -9,6 +9,7 @@ namespace SM.Base.Scene
public interface IScriptable public interface IScriptable
{ {
bool Active { get; set; } bool Active { get; set; }
bool UpdateActive { get; set; }
/// <summary> /// <summary>
/// Updates the object. /// Updates the object.

View file

@ -31,6 +31,7 @@ namespace SM.Base.Scene
ICollection<string> Flags { get; set; } ICollection<string> Flags { get; set; }
bool Active { get; set; } bool Active { get; set; }
bool RenderActive { get; set; }
/// <summary> /// <summary>
/// Tells the object to draw its object. /// Tells the object to draw its object.

View file

@ -13,7 +13,6 @@ namespace SM.Base.Windows
{ {
public bool Loading { get; private set; } = true; public bool Loading { get; private set; } = true;
public float AspectRatio { get; set; } public float AspectRatio { get; set; }
public float AspectRatioReverse { get; set; }
public GenericCamera ViewportCamera { get; set; } public GenericCamera ViewportCamera { get; set; }
public bool ForceViewportCamera { get; set; } public bool ForceViewportCamera { get; set; }

View file

@ -11,7 +11,6 @@ namespace SM.Base.Windows
{ {
bool Loading { get; } bool Loading { get; }
float AspectRatio { get; set; } float AspectRatio { get; set; }
float AspectRatioReverse { get; set; }
GenericCamera ViewportCamera { get; set; } GenericCamera ViewportCamera { get; set; }
bool ForceViewportCamera { get; set; } bool ForceViewportCamera { get; set; }

View file

@ -55,7 +55,6 @@ namespace SM.Base.Windows
{ {
window.WindowSize = new Vector2(window.Width, window.Height); window.WindowSize = new Vector2(window.Width, window.Height);
window.AspectRatio = (float) window.Width / window.Height; window.AspectRatio = (float) window.Width / window.Height;
window.AspectRatioReverse = (float) window.Height / window.Width;
GL.Viewport(window.ClientRectangle); GL.Viewport(window.ClientRectangle);
window.CurrentRenderPipeline?.Resize(); window.CurrentRenderPipeline?.Resize();

View file

@ -61,7 +61,7 @@ namespace SM2D.Scene
{ {
if (RequestedWorldScale.HasValue) if (RequestedWorldScale.HasValue)
{ {
float aspect = window.Width > window.Height ? window.AspectRatio : window.AspectRatioReverse; float aspect = window.AspectRatio;
Vector2 requested = RequestedWorldScale.Value; Vector2 requested = RequestedWorldScale.Value;
if (requested.X > 0 && requested.Y > 0) if (requested.X > 0 && requested.Y > 0)