From 4efc47d75ad1eb28914ba1ac4abc100f4461934e Mon Sep 17 00:00:00 2001 From: Michel Fedde Date: Sun, 7 Mar 2021 12:30:54 +0100 Subject: [PATCH] 2021-03-07 + IScriptable can now be disabled instancewise + IShowItem can disable rendering. ~ SM.Base.Mesh has now ILineMesh - IGenericWindow.AspectRatioReverse --- SMCode/SM.Base/Drawing/DrawingBasis.cs | 3 ++- SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs | 4 +++- SMCode/SM.Base/Objects/Mesh.cs | 6 +++++- SMCode/SM.Base/Scene/GenericItemCollection.cs | 4 ++-- SMCode/SM.Base/Scene/IScriptable.cs | 1 + SMCode/SM.Base/Scene/IShowItem.cs | 3 ++- SMCode/SM.Base/Window/GLWindow.cs | 1 - SMCode/SM.Base/Window/IGenericWindow.cs | 1 - SMCode/SM.Base/Window/WindowCode.cs | 1 - SMCode/SM2D/Scene/Camera.cs | 2 +- 10 files changed, 16 insertions(+), 10 deletions(-) diff --git a/SMCode/SM.Base/Drawing/DrawingBasis.cs b/SMCode/SM.Base/Drawing/DrawingBasis.cs index 38daa5d..8dd4796 100644 --- a/SMCode/SM.Base/Drawing/DrawingBasis.cs +++ b/SMCode/SM.Base/Drawing/DrawingBasis.cs @@ -46,7 +46,8 @@ namespace SM.Base.Drawing /// This value determents if the object should draw something. /// public bool Active { get; set; } = true; - + public bool RenderActive { get; set; } = true; + /// public void Draw(DrawContext context) { diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs index a89c8b3..31da040 100644 --- a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs +++ b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs @@ -73,7 +73,9 @@ namespace SM.Base.Drawing.Particles CreateParticles(); } - + + public bool UpdateActive { get; set; } + /// public void Update(UpdateContext context) { diff --git a/SMCode/SM.Base/Objects/Mesh.cs b/SMCode/SM.Base/Objects/Mesh.cs index 7d4a53a..ccdf31b 100644 --- a/SMCode/SM.Base/Objects/Mesh.cs +++ b/SMCode/SM.Base/Objects/Mesh.cs @@ -8,8 +8,11 @@ using SM.OGL.Mesh; namespace SM.Base.Objects { /// - public class Mesh : GenericMesh + public class Mesh : GenericMesh, ILineMesh { + + public float LineWidth { get; set; } = 1; + /// /// While initializing, it will add the to the data index. /// @@ -23,5 +26,6 @@ namespace SM.Base.Objects /// Contains vertex colors /// public virtual VBO Color { get; protected set; } + } } \ No newline at end of file diff --git a/SMCode/SM.Base/Scene/GenericItemCollection.cs b/SMCode/SM.Base/Scene/GenericItemCollection.cs index 54e1f29..bc23520 100644 --- a/SMCode/SM.Base/Scene/GenericItemCollection.cs +++ b/SMCode/SM.Base/Scene/GenericItemCollection.cs @@ -45,7 +45,7 @@ namespace SM.Base.Scene 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); } } @@ -57,7 +57,7 @@ namespace SM.Base.Scene 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); } } diff --git a/SMCode/SM.Base/Scene/IScriptable.cs b/SMCode/SM.Base/Scene/IScriptable.cs index 5c6087a..cedc974 100644 --- a/SMCode/SM.Base/Scene/IScriptable.cs +++ b/SMCode/SM.Base/Scene/IScriptable.cs @@ -9,6 +9,7 @@ namespace SM.Base.Scene public interface IScriptable { bool Active { get; set; } + bool UpdateActive { get; set; } /// /// Updates the object. diff --git a/SMCode/SM.Base/Scene/IShowItem.cs b/SMCode/SM.Base/Scene/IShowItem.cs index 6d3bd00..04046ce 100644 --- a/SMCode/SM.Base/Scene/IShowItem.cs +++ b/SMCode/SM.Base/Scene/IShowItem.cs @@ -31,7 +31,8 @@ namespace SM.Base.Scene ICollection Flags { get; set; } bool Active { get; set; } - + bool RenderActive { get; set; } + /// /// Tells the object to draw its object. /// diff --git a/SMCode/SM.Base/Window/GLWindow.cs b/SMCode/SM.Base/Window/GLWindow.cs index b60a14c..d50c183 100644 --- a/SMCode/SM.Base/Window/GLWindow.cs +++ b/SMCode/SM.Base/Window/GLWindow.cs @@ -13,7 +13,6 @@ namespace SM.Base.Windows { public bool Loading { get; private set; } = true; public float AspectRatio { get; set; } - public float AspectRatioReverse { get; set; } public GenericCamera ViewportCamera { get; set; } public bool ForceViewportCamera { get; set; } diff --git a/SMCode/SM.Base/Window/IGenericWindow.cs b/SMCode/SM.Base/Window/IGenericWindow.cs index 4d6d804..7d653ea 100644 --- a/SMCode/SM.Base/Window/IGenericWindow.cs +++ b/SMCode/SM.Base/Window/IGenericWindow.cs @@ -11,7 +11,6 @@ namespace SM.Base.Windows { bool Loading { get; } float AspectRatio { get; set; } - float AspectRatioReverse { get; set; } GenericCamera ViewportCamera { get; set; } bool ForceViewportCamera { get; set; } diff --git a/SMCode/SM.Base/Window/WindowCode.cs b/SMCode/SM.Base/Window/WindowCode.cs index a666aaa..69d87ac 100644 --- a/SMCode/SM.Base/Window/WindowCode.cs +++ b/SMCode/SM.Base/Window/WindowCode.cs @@ -55,7 +55,6 @@ namespace SM.Base.Windows { window.WindowSize = new Vector2(window.Width, window.Height); window.AspectRatio = (float) window.Width / window.Height; - window.AspectRatioReverse = (float) window.Height / window.Width; GL.Viewport(window.ClientRectangle); window.CurrentRenderPipeline?.Resize(); diff --git a/SMCode/SM2D/Scene/Camera.cs b/SMCode/SM2D/Scene/Camera.cs index 0abd1c2..f042af5 100644 --- a/SMCode/SM2D/Scene/Camera.cs +++ b/SMCode/SM2D/Scene/Camera.cs @@ -61,7 +61,7 @@ namespace SM2D.Scene { if (RequestedWorldScale.HasValue) { - float aspect = window.Width > window.Height ? window.AspectRatio : window.AspectRatioReverse; + float aspect = window.AspectRatio; Vector2 requested = RequestedWorldScale.Value; if (requested.X > 0 && requested.Y > 0)