Separated Assets to Resources (Engine assets) and Assets (Project specific)

+ AssetHierarchy: Exposed RootNode
+ ContentBrowserWindow: Fixed Empty Folder not being Leaf-Node
+ TreeNode: Added IsParentOf, IsChildOf and IsInSubtree.
    + Fixed InternalDeleteTreeAndChildren for null trees
This commit is contained in:
Simon Lübeß
2023-07-30 20:30:06 +02:00
parent 20dae92be7
commit c1a87ed946
85 changed files with 413 additions and 240 deletions
+31
View File
@@ -65,6 +65,34 @@ namespace GlitchyEngine.Collections
DepthFirst
}
public bool IsParentOf(TreeNode<T> wantedChild)
{
return wantedChild.IsChildOf(this);
}
public bool IsChildOf(TreeNode<T> wantedParent)
{
TreeNode<T> currentParent = Parent;
while (currentParent != null)
{
if (currentParent == wantedParent)
return true;
currentParent = currentParent.Parent;
}
return false;
}
public bool IsInSubtree(TreeNode<T> subtree)
{
if (this == subtree)
return true;
return IsChildOf(subtree);
}
public void ForEach(ElementFunc func, IterationMode iterationMode = .DepthFirst)
{
if (iterationMode == .BreadthFirst)
@@ -123,6 +151,9 @@ namespace GlitchyEngine.Collections
private static void InternalDeleteTreeAndChildren<T>(TreeNode<T> tree) where T : class, delete
{
if (tree == null)
return;
for (var child in tree.Children)
{
InternalDeleteTreeAndChildren(child);
@@ -3,6 +3,7 @@
using GlitchyEngine.Math;
using GlitchyEngine.Platform.DX11;
using System;
using GlitchyEngine.Content;
using internal GlitchyEngine.Renderer;
using internal GlitchyEngine.Platform.DX11;
@@ -15,7 +16,7 @@ namespace GlitchyEngine.Renderer
{
private GraphicsContext _context ~ _?.ReleaseRef();
private Effect _clearUintFx ~ _?.ReleaseRef();
private AssetHandle<Effect> _clearUintFx;
private BlendState _nonblendingState ~ _?.ReleaseRef();
public GraphicsContext Context
@@ -30,7 +31,7 @@ namespace GlitchyEngine.Renderer
{
Debug.Profiler.ProfileFunction!();
_clearUintFx = new Effect("content/Shaders/ClearUInt.hlsl");
_clearUintFx = Content.LoadAsset("Resources/Shaders/ClearUInt.hlsl", null, true);
BlendStateDescription desc =.Default;
desc.RenderTarget[0].BlendEnable = false;
_nonblendingState = new BlendState(desc);
@@ -57,11 +57,11 @@ namespace GlitchyEngine.Renderer
Path.Combine(pathNextToParent, includer._parentFileDirectory, StringView(fileName));
Stream fileStream = Application.Get().ContentManager.GetStream(pathNextToParent);
Stream fileStream = Application.Instance.ContentManager.GetStream(pathNextToParent);
if (fileStream == null)
{
fileStream = Application.Get().ContentManager.GetStream(StringView(fileName));
fileStream = Application.Instance.ContentManager.GetStream(StringView(fileName));
}
if (fileStream == null)
+2 -2
View File
@@ -176,8 +176,8 @@ namespace GlitchyEngine.Renderer
static void InitDeferredRenderer()
{
TestFullscreenEffect = Content.LoadAsset("Shaders\\simpleLight.hlsl");
s_tonemappingEffect = Content.LoadAsset("Shaders\\SimpleTonemapping.hlsl");
TestFullscreenEffect = Content.LoadAsset("Resources/Shaders/simpleLight.hlsl");
s_tonemappingEffect = Content.LoadAsset("Resources/Shaders/SimpleTonemapping.hlsl");
_gBuffer = new GBuffer();
BlendStateDescription gBufferBlendDesc = .Default;
+38 -71
View File
@@ -4,6 +4,7 @@ using System;
using System.Diagnostics;
using GlitchyEngine.Renderer.Text;
using GlitchyEngine.World;
using GlitchyEngine.Content;
namespace GlitchyEngine.Renderer
{
@@ -130,9 +131,9 @@ namespace GlitchyEngine.Renderer
private static bool s_sceneRunning;
#endif
private static Effect s_quadBatchEffect;
private static Effect s_circleBatchEffect;
private static Effect s_lineBatchEffect;
private static AssetHandle<Effect> s_quadBatchEffect;
private static AssetHandle<Effect> s_circleBatchEffect;
private static AssetHandle<Effect> s_lineBatchEffect;
private static GeometryBinding s_quadGeometry;
@@ -161,9 +162,9 @@ namespace GlitchyEngine.Renderer
private static DrawOrder s_drawOrder;
/// The effect that is currently used to draw the sprites.
private static Effect s_currentQuadEffect;
private static Effect s_currentCircleEffect;
private static Effect s_currentLineEffect;
private static AssetHandle<Effect> s_currentQuadEffect;
private static AssetHandle<Effect> s_currentCircleEffect;
private static AssetHandle<Effect> s_currentLineEffect;
public static uint32 MaxInstancesPerBatch
{
@@ -183,9 +184,9 @@ namespace GlitchyEngine.Renderer
{
Debug.Profiler.ProfileFunction!();
s_quadBatchEffect = new Effect("content\\Shaders\\spritebatch.hlsl");
s_circleBatchEffect = new Effect("content\\Shaders\\circlebatch.hlsl");
s_lineBatchEffect = new Effect("content\\Shaders\\linebatch.hlsl");
s_quadBatchEffect = Content.LoadAsset("Resources/Shaders/spritebatch.hlsl", null, true);
s_circleBatchEffect = Content.LoadAsset("Resources/Shaders/circlebatch.hlsl", null, true);
s_lineBatchEffect = Content.LoadAsset("Resources/Shaders/linebatch.hlsl", null, true);
}
private static void InitGeometry()
@@ -427,10 +428,6 @@ namespace GlitchyEngine.Renderer
FontRenderer.Deinit();
s_quadBatchEffect.ReleaseRef();
s_circleBatchEffect.ReleaseRef();
s_lineBatchEffect.ReleaseRef();
s_quadGeometry.ReleaseRef();
s_whiteTexture.ReleaseRef();
@@ -449,10 +446,6 @@ namespace GlitchyEngine.Renderer
delete s_circleInstanceQueue;
delete s_lineInstanceQueue;
s_currentQuadEffect?.ReleaseRef();
s_currentCircleEffect?.ReleaseRef();
s_currentLineEffect?.ReleaseRef();
s_opaqueBlendState.ReleaseRef();
s_transparentBlendState.ReleaseRef();
@@ -462,7 +455,7 @@ namespace GlitchyEngine.Renderer
}
// TODO: remove?
public static void BeginScene(OldCamera camera, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
public static void BeginScene(OldCamera camera, DrawOrder drawOrder = .SortByTexture, AssetHandle<Effect> effect = .Invalid, AssetHandle<Effect> circleEffect = .Invalid)
{
Debug.Profiler.ProfileRendererFunction!();
#if DEBUG
@@ -470,28 +463,26 @@ namespace GlitchyEngine.Renderer
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_currentQuadEffect?.ReleaseRef();
if(effect != null)
if(effect != .Invalid)
{
s_currentQuadEffect = effect..AddRef();
s_currentQuadEffect = effect;
}
else
{
s_currentQuadEffect = s_quadBatchEffect..AddRef();
s_currentQuadEffect = s_quadBatchEffect;
}
s_currentCircleEffect?.ReleaseRef();
if(circleEffect != null)
if(circleEffect != .Invalid)
{
s_currentCircleEffect = effect..AddRef();
s_currentCircleEffect = circleEffect;
}
else
{
s_currentCircleEffect = s_circleBatchEffect..AddRef();
s_currentCircleEffect = s_circleBatchEffect;
}
s_currentLineEffect = s_lineBatchEffect;
s_currentQuadEffect.Variables["ViewProjection"].SetData(camera.ViewProjection);
s_currentCircleEffect.Variables["ViewProjection"].SetData(camera.ViewProjection);
@@ -502,45 +493,33 @@ namespace GlitchyEngine.Renderer
#endif
}
public static void BeginScene(Camera camera, Matrix transform, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
public static void BeginScene(Camera camera, Matrix transform, DrawOrder drawOrder = .SortByTexture, AssetHandle<Effect> effect = .Invalid, AssetHandle<Effect> circleEffect = .Invalid)
{
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_currentQuadEffect?.ReleaseRef();
if(effect != null)
if(effect != .Invalid)
{
s_currentQuadEffect = effect..AddRef();
s_currentQuadEffect = effect;
}
else
{
s_currentQuadEffect = s_quadBatchEffect..AddRef();
s_currentQuadEffect = s_quadBatchEffect;
}
s_currentCircleEffect?.ReleaseRef();
if(circleEffect != null)
if(circleEffect != .Invalid)
{
s_currentCircleEffect = effect..AddRef();
s_currentCircleEffect = circleEffect;
}
else
{
s_currentCircleEffect = s_circleBatchEffect..AddRef();
s_currentCircleEffect = s_circleBatchEffect;
}
s_currentLineEffect?.ReleaseRef();
/*if(circleEffect != null)
{
s_currentLineEffect = effect..AddRef();
}
else
{*/
s_currentLineEffect = s_lineBatchEffect..AddRef();
//}
s_currentLineEffect = s_lineBatchEffect;
Matrix viewProjection = camera.Projection * Matrix.Invert(transform);
@@ -555,7 +534,7 @@ namespace GlitchyEngine.Renderer
#endif
}
public static void BeginScene(EditorCamera camera, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
public static void BeginScene(EditorCamera camera, DrawOrder drawOrder = .SortByTexture, AssetHandle<Effect> effect = .Invalid, AssetHandle<Effect> circleEffect = .Invalid)
{
Debug.Profiler.ProfileRendererFunction!();
#if DEBUG
@@ -563,37 +542,25 @@ namespace GlitchyEngine.Renderer
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_currentQuadEffect?.ReleaseRef();
if(effect != null)
if(effect != .Invalid)
{
s_currentQuadEffect = effect..AddRef();
s_currentQuadEffect = effect;
}
else
{
s_currentQuadEffect = s_quadBatchEffect..AddRef();
s_currentQuadEffect = s_quadBatchEffect;
}
s_currentCircleEffect?.ReleaseRef();
if(circleEffect != null)
if(circleEffect != .Invalid)
{
s_currentCircleEffect = effect..AddRef();
s_currentCircleEffect = circleEffect;
}
else
{
s_currentCircleEffect = s_circleBatchEffect..AddRef();
s_currentCircleEffect = s_circleBatchEffect;
}
s_currentLineEffect?.ReleaseRef();
/*if(circleEffect != null)
{
s_currentLineEffect = effect..AddRef();
}
else
{*/
s_currentLineEffect = s_lineBatchEffect..AddRef();
//}
s_currentLineEffect = s_lineBatchEffect;
Matrix viewProjection = camera.Projection * camera.View;
@@ -4,6 +4,7 @@ using System.Diagnostics;
using GlitchyEngine.Math;
using System.Collections;
using GlitchyEngine.Core;
using GlitchyEngine.Content;
using static FreeType.HarfBuzz;
using internal GlitchyEngine.Renderer.Text;
@@ -15,7 +16,7 @@ namespace GlitchyEngine.Renderer.Text
{
internal static FT_Library s_Library;
public static Effect _msdfEffect;
public static AssetHandle<Effect> _msdfEffect;
internal static bool s_isInitialized;
@@ -28,7 +29,7 @@ namespace GlitchyEngine.Renderer.Text
InitFreetype();
_msdfEffect = new Effect("content\\Shaders\\msdfShader.hlsl");
_msdfEffect = Content.LoadAsset("Resources/Shaders/msdfShader.hlsl");
s_isInitialized = true;
}
@@ -37,8 +38,6 @@ namespace GlitchyEngine.Renderer.Text
{
Debug.Profiler.ProfileFunction!();
_msdfEffect.ReleaseRef();
DeinitFreetype();
s_isInitialized = false;
@@ -334,7 +333,7 @@ namespace GlitchyEngine.Renderer.Text
// TODO: this is very not good!
var lastEffect = Renderer2D.[Friend]s_currentQuadEffect;
Renderer2D.[Friend]s_currentQuadEffect = _msdfEffect..AddRef();
Renderer2D.[Friend]s_currentQuadEffect = _msdfEffect;
// TODO: oh no....
// Copy viewProjection from current effect
Matrix viewProjection = lastEffect.Variables["ViewProjection"].[Friend]GetData<Matrix>();
@@ -409,7 +408,6 @@ namespace GlitchyEngine.Renderer.Text
// TODO: not good!
// Change back effect
_msdfEffect.ReleaseRef();
Renderer2D.[Friend]s_currentQuadEffect = lastEffect;
// release all atlas textures
@@ -440,7 +438,7 @@ namespace GlitchyEngine.Renderer.Text
// TODO: this is very not good!
var lastEffect = Renderer2D.[Friend]s_currentQuadEffect;
Renderer2D.[Friend]s_currentQuadEffect = _msdfEffect..AddRef();
Renderer2D.[Friend]s_currentQuadEffect = _msdfEffect;
// TODO: oh no....
// Copy viewProjection from current effect
Matrix viewProjection = lastEffect.Variables["ViewProjection"].[Friend]GetData<Matrix>();
@@ -663,7 +661,6 @@ namespace GlitchyEngine.Renderer.Text
// TODO: not good!
// Change back effect
_msdfEffect.ReleaseRef();
Renderer2D.[Friend]s_currentQuadEffect = lastEffect;
// release all atlas textures
+2 -2
View File
@@ -18,7 +18,7 @@ class SceneRenderer
private uint32 _viewportWidth;
private uint32 _viewportHeight;
private AssetHandle _gammaCorrectEffect;
private AssetHandle<Effect> _gammaCorrectEffect;
public RenderTargetGroup CompositeTarget => _compositeTarget;
@@ -41,7 +41,7 @@ class SceneRenderer
DepthTargetDescription = .(.D24_UNorm_S8_UInt)
});
_gammaCorrectEffect = Content.LoadAsset("Shaders/GammaCorrect.hlsl");//Application.Get().EffectLibrary.Load("content/Shaders/GammaCorrect.hlsl");
_gammaCorrectEffect = Content.LoadAsset("Resources/Shaders/GammaCorrect.hlsl");
}
/// Sets the size of the viewport into which the scene will be rendered.