mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Handle loading error and placeholder shaders
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include "GlitchyEngine.hlsl"
|
||||
|
||||
struct VS_IN
|
||||
{
|
||||
float3 Position : POSITION;
|
||||
};
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
};
|
||||
|
||||
PS_IN VS(VS_IN input)
|
||||
{
|
||||
PS_IN output;
|
||||
|
||||
float4 worldPosition = mul(Transform, float4(input.Position, 1));
|
||||
output.Position = mul(ViewProjection, worldPosition);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PS(PS_IN input) : SV_TARGET
|
||||
{
|
||||
return float4(1, 0, 1, 1);
|
||||
}
|
||||
|
||||
#pragma Effect[VS = VS; PS = PS]
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
AssetLoader = null,
|
||||
Config = null,
|
||||
Importer = "ShaderImporter",
|
||||
ImporterConfig = null,
|
||||
Processor = null,
|
||||
ProcessorConfig = null,
|
||||
Exporter = null,
|
||||
ExporterConfig = null,
|
||||
AssetHandle = 652951988555027469
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "GlitchyEngine.hlsl"
|
||||
|
||||
struct VS_IN
|
||||
{
|
||||
float3 Position : POSITION;
|
||||
};
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
};
|
||||
|
||||
PS_IN VS(VS_IN input)
|
||||
{
|
||||
PS_IN output;
|
||||
|
||||
float4 worldPosition = mul(Transform, float4(input.Position, 1));
|
||||
output.Position = mul(ViewProjection, worldPosition);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PS(PS_IN input) : SV_TARGET
|
||||
{
|
||||
return float4(0, 1, 1, 1);
|
||||
}
|
||||
|
||||
#pragma Effect[VS = VS; PS = PS]
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
AssetLoader = null,
|
||||
Config = null,
|
||||
Importer = "ShaderImporter",
|
||||
ImporterConfig = null,
|
||||
Processor = null,
|
||||
ProcessorConfig = null,
|
||||
Exporter = null,
|
||||
ExporterConfig = null,
|
||||
AssetHandle = 3052446500956620342
|
||||
}
|
||||
@@ -316,8 +316,7 @@ namespace GlitchyEditor.EditWindows
|
||||
{
|
||||
_manager.Update();
|
||||
|
||||
// Show History
|
||||
if (ImGui.Begin("Debug History"))
|
||||
/*if (ImGui.Begin("Debug History"))
|
||||
{
|
||||
ImGui.CollapsingHeader("History");
|
||||
for (String path in _directoryHistory.[Friend]_history)
|
||||
@@ -338,7 +337,7 @@ namespace GlitchyEditor.EditWindows
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
}
|
||||
}*/
|
||||
|
||||
// Make sure we are in an existing directory.
|
||||
if (!_manager.AssetHierarchy.FileExists(CurrentDirectory))
|
||||
@@ -745,57 +744,81 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
private ImGui.RectangleSelectionData _rectangleSelection;
|
||||
|
||||
enum Modifiers
|
||||
{
|
||||
None,
|
||||
Alt,
|
||||
Ctrl,
|
||||
Shift
|
||||
}
|
||||
|
||||
private void HandleShortcuts()
|
||||
{
|
||||
Modifiers modifiers = .None;
|
||||
|
||||
Enum.SetFlagConditionally(ref modifiers, .Alt, Input.IsKeyPressed(.Alt));
|
||||
Enum.SetFlagConditionally(ref modifiers, .Ctrl, Input.IsKeyPressed(.Control));
|
||||
Enum.SetFlagConditionally(ref modifiers, .Shift, Input.IsKeyPressed(.Shift));
|
||||
|
||||
// TODO: Come up with a good hotkey system...
|
||||
if (modifiers == .Alt)
|
||||
{
|
||||
if (Input.IsKeyPressing(.Up))
|
||||
{
|
||||
NavigateUp();
|
||||
}
|
||||
|
||||
if (Input.IsKeyPressing(.Left))
|
||||
{
|
||||
NavigateBack();
|
||||
}
|
||||
|
||||
if (Input .IsKeyPressing(.Right))
|
||||
{
|
||||
NavigateForward();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.IsMouseButtonPressing(.XButton1))
|
||||
{
|
||||
NavigateBack();
|
||||
}
|
||||
|
||||
if (Input.IsMouseButtonPressing(.XButton2))
|
||||
{
|
||||
NavigateForward();
|
||||
}
|
||||
|
||||
if (modifiers == .Ctrl)
|
||||
{
|
||||
if (Input.IsKeyPressing(.C))
|
||||
{
|
||||
CopySelectedFiles(cutFiles: false);
|
||||
}
|
||||
|
||||
if (Input.IsKeyPressing(.X))
|
||||
{
|
||||
CopySelectedFiles(cutFiles: true);
|
||||
}
|
||||
|
||||
if (Input.IsKeyPressing(.V))
|
||||
{
|
||||
PasteFiles(CurrentDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
if (modifiers == .Ctrl | .Shift)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// Renders the contents of _currentDirectory. Returns the node of the current directory, or null if the browser isn't in a directory.
|
||||
private void DrawCurrentDirectory(TreeNode<AssetNode> currentDirectoryNode)
|
||||
{
|
||||
if (ImGui.IsWindowHovered())
|
||||
{
|
||||
// TODO: Come up with a good hotkey system...
|
||||
if (Input.IsKeyPressed(.Alt))
|
||||
{
|
||||
if (Input.IsKeyPressing(.Up))
|
||||
{
|
||||
NavigateUp();
|
||||
}
|
||||
|
||||
if (Input.IsKeyPressing(.Left))
|
||||
{
|
||||
NavigateBack();
|
||||
}
|
||||
|
||||
if (Input .IsKeyPressing(.Right))
|
||||
{
|
||||
NavigateForward();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.IsMouseButtonPressing(.XButton1))
|
||||
{
|
||||
NavigateBack();
|
||||
}
|
||||
|
||||
if (Input.IsMouseButtonPressing(.XButton2))
|
||||
{
|
||||
NavigateForward();
|
||||
}
|
||||
|
||||
if (Input.IsKeyPressed(.Control))
|
||||
{
|
||||
if (Input.IsKeyPressing(.C))
|
||||
{
|
||||
CopySelectedFiles(cutFiles: false);
|
||||
}
|
||||
|
||||
if (Input.IsKeyPressing(.X))
|
||||
{
|
||||
CopySelectedFiles(cutFiles: true);
|
||||
}
|
||||
|
||||
if (Input.IsKeyPressing(.V))
|
||||
{
|
||||
PasteFiles(CurrentDirectory);
|
||||
}
|
||||
}
|
||||
HandleShortcuts();
|
||||
}
|
||||
|
||||
List<TreeNode<AssetNode>> directoryEntries = scope List<TreeNode<AssetNode>>();
|
||||
|
||||
@@ -367,7 +367,16 @@ class EditorContentManager : IContentManager
|
||||
|
||||
if (!_handleToAsset.TryGetValue(handle, out asset))
|
||||
{
|
||||
LoadAsset(handle, blocking);
|
||||
AssetHandle handleAfterLoading = LoadAsset(handle, blocking);
|
||||
|
||||
if (handleAfterLoading == .Invalid)
|
||||
{
|
||||
// TODO: If the asset existed at some point, the cache might still know of it.
|
||||
// Or we store the asset name somewhere else. (For the editor in the asset using it?)
|
||||
asset = new NewPlaceholderAsset(handle, .Error);
|
||||
|
||||
AssignHandleAndManage(asset, handle);
|
||||
}
|
||||
}
|
||||
|
||||
if (var placeholder = asset as PlaceholderAsset)
|
||||
@@ -401,6 +410,8 @@ class EditorContentManager : IContentManager
|
||||
|
||||
private Asset GetPlaceholderAsset(Type assetType, PlaceholderType placeholderType)
|
||||
{
|
||||
// TODO: Probably don't hardcode paths here.
|
||||
// TODO: Probably verify existence at start of application.
|
||||
switch (assetType)
|
||||
{
|
||||
case typeof(Texture2D):
|
||||
@@ -414,6 +425,17 @@ class EditorContentManager : IContentManager
|
||||
AssetHandle handle = LoadAsset("Resources/Textures/ErrorTexture2D.png", true);
|
||||
return GetAsset(null, handle);
|
||||
}
|
||||
case typeof(Effect):
|
||||
if (placeholderType == .Loading)
|
||||
{
|
||||
AssetHandle handle = LoadAsset("Resources/Shaders/PlaceholderLoading.fx", true);
|
||||
return GetAsset(null, handle);
|
||||
}
|
||||
else if (placeholderType == .Error)
|
||||
{
|
||||
AssetHandle handle = LoadAsset("Resources/Shaders/PlaceholderError.fx", true);
|
||||
return GetAsset(null, handle);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -623,6 +645,7 @@ class EditorContentManager : IContentManager
|
||||
using (_finishedEntriesLock.Enter())
|
||||
{
|
||||
loadedAsset.Identifier = assetNode.Identifier;
|
||||
// TODO: AssignHandleAndManage
|
||||
loadedAsset.[Friend]_contentManager = this;
|
||||
loadedAsset.[Friend]_handle = handle;
|
||||
|
||||
@@ -874,14 +897,23 @@ class EditorContentManager : IContentManager
|
||||
// If this happens too often we could use a different random generator
|
||||
}
|
||||
|
||||
//_handles.Add(asset.Identifier, handle);
|
||||
AssignHandleAndManage(asset, handle);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
private void AssignHandleAndManage(Asset asset, AssetHandle handle)
|
||||
{
|
||||
if (_handleToAsset.TryGetValue(handle, let existingAsset))
|
||||
{
|
||||
existingAsset.ReleaseRef();
|
||||
}
|
||||
|
||||
_handleToAsset.Add(handle, asset);
|
||||
|
||||
asset.[Friend]_contentManager = this;
|
||||
asset.[Friend]_handle = handle;
|
||||
asset.AddRef();
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
private void SwapAsset(Asset oldAsset, Asset newAsset)
|
||||
|
||||
@@ -27,7 +27,10 @@ class MaterialLoader : IProcessedAssetLoader
|
||||
String textureName = scope String(textureNameLength);
|
||||
stream.ReadStrSized32(textureNameLength, textureName);
|
||||
|
||||
material.SetTexture(textureName, textureHandle);
|
||||
if (material.SetTexture(textureName, textureHandle) case .Err(let error))
|
||||
{
|
||||
Log.EngineLogger.Error($"Failed to set texture slot {textureName}: {error}");
|
||||
}
|
||||
}
|
||||
|
||||
uint16 bufferCount = Try!(stream.Read<uint16>());
|
||||
|
||||
@@ -532,7 +532,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
s_quadBatchMaterial.SetVariable("ViewProjection", sceneViewProjection);
|
||||
//s_currentQuadEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection);
|
||||
s_currentCircleEffect.Get()?.Variables["ViewProjection"].SetData(sceneViewProjection);
|
||||
//s_currentCircleEffect.Get()?.Variables["ViewProjection"].SetData(sceneViewProjection);
|
||||
s_currentLineEffect.Get()?.Variables["ViewProjection"].SetData(sceneViewProjection);
|
||||
|
||||
s_drawOrder = drawOrder;
|
||||
@@ -574,7 +574,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
//s_currentQuadEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection);
|
||||
s_quadBatchMaterial.SetVariable("ViewProjection", sceneViewProjection);
|
||||
s_currentCircleEffect.Get()?.Variables["ViewProjection"].SetData(sceneViewProjection);
|
||||
//s_currentCircleEffect.Get()?.Variables["ViewProjection"].SetData(sceneViewProjection);
|
||||
s_currentLineEffect.Get()?.Variables["ViewProjection"].SetData(sceneViewProjection);
|
||||
|
||||
s_drawOrder = drawOrder;
|
||||
|
||||
Reference in New Issue
Block a user