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
@@ -7,4 +7,4 @@ TargetType = "BeefGUIApplication"
|
|||||||
StartupObject = "GlitchyEngine.Program"
|
StartupObject = "GlitchyEngine.Program"
|
||||||
|
|
||||||
[Configs.Debug.Win64]
|
[Configs.Debug.Win64]
|
||||||
DebugCommandArguments = "\"content\\Scenes\\physics2D.scene\""
|
DebugCommandArguments = "\"D:\\Development\\Projects\\Beef\\GlitchyEngine\\GlitchyEditor\\SandboxProject\""
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
B = 0.32878688,
|
B = 0.32878688,
|
||||||
A = 1
|
A = 1
|
||||||
},
|
},
|
||||||
Sprite = "Textures/TestMat/rustediron2_albedo.png",
|
Sprite = "Assets/Textures/TestMat/rustediron2_albedo.png",
|
||||||
UvTransform = {
|
UvTransform = {
|
||||||
X = 0,
|
X = 0,
|
||||||
Y = 0,
|
Y = 0,
|
||||||
@@ -309,10 +309,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
MeshComponent = {
|
MeshComponent = {
|
||||||
Mesh = "Models/sphere.glb"
|
Mesh = "Assets/Models/sphere.glb"
|
||||||
},
|
},
|
||||||
MeshRendererComponent = {
|
MeshRendererComponent = {
|
||||||
Material = "Textures/TestMaterial.mat"
|
Material = "Assets/Textures/TestMaterial.mat"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B |
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
Effect = "Resources/Shaders/myEffect.hlsl",
|
||||||
|
Textures = [
|
||||||
|
"AlbedoTexture": "Assets/Textures/rocket.png",
|
||||||
|
"NormalTexture": "Assets/Textures/TestMat/rustediron2_normal.png",
|
||||||
|
"MetallicTexture": "Assets/Textures/TestMat/rustediron2_metallic.png",
|
||||||
|
"RoughnessTexture": "Assets/Textures/TestMat/rustediron2_roughness.png"
|
||||||
|
],
|
||||||
|
Variables = [
|
||||||
|
"AlbedoColor": .ColorRGBA{
|
||||||
|
Value = {
|
||||||
|
R = 1,
|
||||||
|
G = 1,
|
||||||
|
B = 1,
|
||||||
|
A = 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"NormalScaling": .Float2{
|
||||||
|
Value = {
|
||||||
|
X = 1,
|
||||||
|
Y = 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"MetallicFactor": .Float{
|
||||||
|
Value = 0
|
||||||
|
},
|
||||||
|
"RoughnessFactor": .Float{
|
||||||
|
Value = 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 10 MiB After Width: | Height: | Size: 10 MiB |
|
Before Width: | Height: | Size: 3.3 MiB After Width: | Height: | Size: 3.3 MiB |
|
Before Width: | Height: | Size: 7.4 MiB After Width: | Height: | Size: 7.4 MiB |
|
Before Width: | Height: | Size: 3.0 MiB After Width: | Height: | Size: 3.0 MiB |
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
Effect = "Shaders/myEffect.hlsl",
|
Effect = "Resources/Shaders/myEffect.hlsl",
|
||||||
Textures = [
|
Textures = [
|
||||||
"AlbedoTexture": "Textures/TestMat/rustediron2_albedo.png",
|
"AlbedoTexture": "Assets/Textures/TestMat/rustediron2_albedo.png",
|
||||||
"NormalTexture": "Textures/TestMat/rustediron2_normal.png",
|
"NormalTexture": "Assets/Textures/TestMat/rustediron2_normal.png",
|
||||||
"MetallicTexture": "Textures/TestMat/rustediron2_metallic.png",
|
"MetallicTexture": "Assets/Textures/TestMat/rustediron2_metallic.png",
|
||||||
"RoughnessTexture": "Textures/TestMat/rustediron2_roughness.png",
|
"RoughnessTexture": "Assets/Textures/TestMat/rustediron2_roughness.png",
|
||||||
"EmissiveTexture": "Textures/rocket.png"
|
"EmissiveTexture": "Assets/Textures/rocket.png"
|
||||||
],
|
],
|
||||||
Variables = [
|
Variables = [
|
||||||
"AlbedoColor": .ColorRGBA{
|
"AlbedoColor": .ColorRGBA{
|
||||||
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
Effect = "Shaders/myEffect.hlsl",
|
|
||||||
Textures = [
|
|
||||||
"AlbedoTexture": "Textures/rocket.png",
|
|
||||||
"NormalTexture": "Textures/TestMat/rustediron2_normal.png",
|
|
||||||
"MetallicTexture": "Textures/TestMat/rustediron2_metallic.png",
|
|
||||||
"RoughnessTexture": "Textures/TestMat/rustediron2_roughness.png"
|
|
||||||
],
|
|
||||||
Variables = [
|
|
||||||
"AlbedoColor": .ColorRGBA{
|
|
||||||
Value = {
|
|
||||||
R = 1,
|
|
||||||
G = 1,
|
|
||||||
B = 1,
|
|
||||||
A = 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"NormalScaling": .Float2{
|
|
||||||
Value = {
|
|
||||||
X = 1,
|
|
||||||
Y = 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MetallicFactor": .Float{
|
|
||||||
Value = 0
|
|
||||||
},
|
|
||||||
"RoughnessFactor": .Float{
|
|
||||||
Value = 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -12,6 +12,7 @@ public class AssetNode
|
|||||||
{
|
{
|
||||||
public String Name ~ delete _;
|
public String Name ~ delete _;
|
||||||
public String Path ~ delete _;
|
public String Path ~ delete _;
|
||||||
|
public String Identifier ~ delete _;
|
||||||
|
|
||||||
public bool IsDirectory;
|
public bool IsDirectory;
|
||||||
|
|
||||||
@@ -38,14 +39,43 @@ public static class AssetIdentifier
|
|||||||
{
|
{
|
||||||
public const char8 DirectorySeparatorChar = '/';
|
public const char8 DirectorySeparatorChar = '/';
|
||||||
|
|
||||||
|
// TODO: Asset identifiers and paths have little to do with each other and already caused a bit of pain, we should consider not using String for both.
|
||||||
|
/// Removes or unifies potential platform specific or file-path related stuff in the given asset identifier
|
||||||
public static void Fixup(String assetIdentifier)
|
public static void Fixup(String assetIdentifier)
|
||||||
{
|
{
|
||||||
const String DotSeperator = $".{DirectorySeparatorChar}";
|
int dotIndex = 0;
|
||||||
const String SeperatorDot = $"{DirectorySeparatorChar}.";
|
|
||||||
|
|
||||||
assetIdentifier.Replace('\\', DirectorySeparatorChar);
|
assetIdentifier.Replace('\\', DirectorySeparatorChar);
|
||||||
assetIdentifier.Replace(DotSeperator, "");
|
|
||||||
assetIdentifier.Replace(SeperatorDot, "");
|
// Replace /./ stuff
|
||||||
|
while ((dotIndex = assetIdentifier.IndexOf('.', dotIndex)) != -1)
|
||||||
|
{
|
||||||
|
char8 lastChar = '\0';
|
||||||
|
char8 nextChar = '\0';
|
||||||
|
|
||||||
|
int nextIndex = dotIndex + 1;
|
||||||
|
if (nextIndex < assetIdentifier.Length)
|
||||||
|
nextChar = assetIdentifier[nextIndex];
|
||||||
|
|
||||||
|
int lastIndex = dotIndex - 1;
|
||||||
|
if (lastIndex < assetIdentifier.Length)
|
||||||
|
lastChar = assetIdentifier[nextIndex];
|
||||||
|
|
||||||
|
// We either need to have a slash on both sides, or we have to be at the start or end of the string
|
||||||
|
if ((lastChar == '\0' || lastChar == DirectorySeparatorChar) &&
|
||||||
|
(lastChar == '\0' || lastChar == DirectorySeparatorChar))
|
||||||
|
{
|
||||||
|
if (lastChar != '\0')
|
||||||
|
assetIdentifier.Remove(lastIndex, 2);
|
||||||
|
else
|
||||||
|
assetIdentifier.Remove(dotIndex, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Skip the dot
|
||||||
|
dotIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (assetIdentifier.StartsWith(DirectorySeparatorChar))
|
if (assetIdentifier.StartsWith(DirectorySeparatorChar))
|
||||||
assetIdentifier.Remove(0, 1);
|
assetIdentifier.Remove(0, 1);
|
||||||
@@ -61,32 +91,119 @@ class AssetHierarchy
|
|||||||
|
|
||||||
bool _fileSystemDirty = false;
|
bool _fileSystemDirty = false;
|
||||||
|
|
||||||
internal TreeNode<AssetNode> _assetHierarchy = null ~ DeleteTreeAndChildren!(_);
|
internal TreeNode<AssetNode> _assetRootNode = null ~ DeleteTreeAndChildren!(_);
|
||||||
|
internal TreeNode<AssetNode> _resourcesDirectoryNode = null;
|
||||||
|
internal TreeNode<AssetNode> _assetsDirectoryNode = null;
|
||||||
private append Dictionary<StringView, TreeNode<AssetNode>> _pathToAssetNode = .();
|
private append Dictionary<StringView, TreeNode<AssetNode>> _pathToAssetNode = .();
|
||||||
|
private append Dictionary<StringView, TreeNode<AssetNode>> _identifierToAssetNode = .();
|
||||||
|
|
||||||
private append String _contentDirectory = .();
|
private append String _resourcesDirectory = .();
|
||||||
|
private append String _assetsDirectory = .();
|
||||||
|
|
||||||
private EditorContentManager _contentManager;
|
private EditorContentManager _contentManager;
|
||||||
|
|
||||||
public StringView ContentDirectory
|
public TreeNode<AssetNode> RootNode => _assetRootNode;
|
||||||
|
|
||||||
|
public StringView ResourcesDirectory
|
||||||
{
|
{
|
||||||
get => _contentDirectory;
|
get => _resourcesDirectory;
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
_contentDirectory.Clear();
|
_resourcesDirectory.Set(value);
|
||||||
_contentDirectory.Append(value);
|
Path.Fixup(_resourcesDirectory);
|
||||||
Path.Fixup(_contentDirectory);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringView AssetsDirectory
|
||||||
|
{
|
||||||
|
get => _assetsDirectory;
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
_assetsDirectory.Set(value);
|
||||||
|
Path.Fixup(_assetsDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public this(EditorContentManager contentManager)
|
public this(EditorContentManager contentManager)
|
||||||
{
|
{
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
|
|
||||||
|
// Create a root node that will contain all Asset directory nodes.
|
||||||
|
_assetRootNode = new TreeNode<AssetNode>(new AssetNode());
|
||||||
|
_assetRootNode->Path = new String();
|
||||||
|
_assetRootNode->Name = new String();
|
||||||
|
_assetRootNode->IsDirectory = true;
|
||||||
|
|
||||||
|
Log.EngineLogger.Trace($"Created root node");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetContentDirectory(StringView contentDirectory)
|
public void SetResourcesDirectory(StringView fileName)
|
||||||
{
|
{
|
||||||
ContentDirectory = contentDirectory;
|
ResourcesDirectory = fileName;
|
||||||
|
|
||||||
|
_resourcesDirectoryNode?.ForEach(scope (node) => {
|
||||||
|
_pathToAssetNode.Remove(node->Path);
|
||||||
|
_identifierToAssetNode.Remove(node->Identifier);
|
||||||
|
});
|
||||||
|
DeleteTreeAndChildren!(_resourcesDirectoryNode);
|
||||||
|
|
||||||
|
if (!Directory.Exists(ResourcesDirectory))
|
||||||
|
{
|
||||||
|
Log.EngineLogger.Error($"Resources directory \"{ResourcesDirectory}\" doesn't exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetNode assetNode = new AssetNode();
|
||||||
|
assetNode.Path = new String(ResourcesDirectory);
|
||||||
|
assetNode.Name = new String();
|
||||||
|
assetNode.Identifier = new String("###resources");
|
||||||
|
assetNode.IsDirectory = true;
|
||||||
|
Path.GetFileName(assetNode.Path, assetNode.Name);
|
||||||
|
|
||||||
|
_resourcesDirectoryNode = _assetRootNode.AddChild(assetNode);
|
||||||
|
_pathToAssetNode.Add(assetNode.Path, _resourcesDirectoryNode);
|
||||||
|
_identifierToAssetNode.Add(assetNode.Identifier, _resourcesDirectoryNode);
|
||||||
|
|
||||||
|
Log.EngineLogger.Trace($"Created directory node for: \"{ResourcesDirectory}\"");
|
||||||
|
|
||||||
|
_fileSystemDirty = true;
|
||||||
|
|
||||||
|
// TODO: Watch resources folder?
|
||||||
|
//SetupResourcesFileSystemWatcher();
|
||||||
|
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetAssetsDirectory(StringView fileName)
|
||||||
|
{
|
||||||
|
AssetsDirectory = fileName;
|
||||||
|
|
||||||
|
_assetsDirectoryNode?.ForEach(scope (node) => {
|
||||||
|
_pathToAssetNode.Remove(node->Path);
|
||||||
|
_identifierToAssetNode.Remove(node->Identifier);
|
||||||
|
});
|
||||||
|
DeleteTreeAndChildren!(_assetsDirectoryNode);
|
||||||
|
|
||||||
|
if (!Directory.Exists(AssetsDirectory))
|
||||||
|
{
|
||||||
|
// TODO: This is not an error, if no project is loaded
|
||||||
|
Log.EngineLogger.Warning($"Assets directory \"{AssetsDirectory}\" doesn't exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetNode assetNode = new AssetNode();
|
||||||
|
assetNode.Path = new String(AssetsDirectory);
|
||||||
|
assetNode.Name = new String();
|
||||||
|
assetNode.Identifier = new String("###assets");
|
||||||
|
assetNode.IsDirectory = true;
|
||||||
|
Path.GetFileName(assetNode.Path, assetNode.Name);
|
||||||
|
|
||||||
|
_assetsDirectoryNode = _assetRootNode.AddChild(assetNode);
|
||||||
|
_pathToAssetNode.Add(assetNode.Path, _assetsDirectoryNode);
|
||||||
|
_identifierToAssetNode.Add(assetNode.Identifier, _assetsDirectoryNode);
|
||||||
|
|
||||||
|
Log.EngineLogger.Trace($"Created directory node for: \"{AssetsDirectory}\"");
|
||||||
|
|
||||||
|
|
||||||
_fileSystemDirty = true;
|
_fileSystemDirty = true;
|
||||||
|
|
||||||
@@ -99,7 +216,7 @@ class AssetHierarchy
|
|||||||
private void SetupFileSystemWatcher()
|
private void SetupFileSystemWatcher()
|
||||||
{
|
{
|
||||||
delete fsw;
|
delete fsw;
|
||||||
fsw = new FileSystemWatcher(_contentDirectory);
|
fsw = new FileSystemWatcher(_assetsDirectory);
|
||||||
fsw.IncludeSubdirectories = true;
|
fsw.IncludeSubdirectories = true;
|
||||||
|
|
||||||
fsw.OnChanged.Add(new (filename) => {
|
fsw.OnChanged.Add(new (filename) => {
|
||||||
@@ -153,6 +270,19 @@ class AssetHierarchy
|
|||||||
return .Err;
|
return .Err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets the tree node for the given filePath or .Err, if the file/directory doesn't exist.
|
||||||
|
/// @param filePath the path for which to return the tree node.
|
||||||
|
/// @remarks Do not hold a reference to the TreeNode because it can become invalid when the file hierarchy changes.
|
||||||
|
public Result<TreeNode<AssetNode>> GetNodeFromIdentifier(StringView identifier)
|
||||||
|
{
|
||||||
|
if (_identifierToAssetNode.TryGetValue(identifier, let treeNode))
|
||||||
|
{
|
||||||
|
return treeNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return .Err;
|
||||||
|
}
|
||||||
|
|
||||||
public bool FileExists(StringView filePath)
|
public bool FileExists(StringView filePath)
|
||||||
{
|
{
|
||||||
return _pathToAssetNode.ContainsKey(filePath);
|
return _pathToAssetNode.ContainsKey(filePath);
|
||||||
@@ -173,27 +303,9 @@ class AssetHierarchy
|
|||||||
{
|
{
|
||||||
Log.EngineLogger.Trace($"Updating asset hierarchy");
|
Log.EngineLogger.Trace($"Updating asset hierarchy");
|
||||||
|
|
||||||
if (_assetHierarchy == null)
|
|
||||||
{
|
|
||||||
// TODO: move to init?
|
|
||||||
|
|
||||||
_assetHierarchy = new TreeNode<AssetNode>(new AssetNode());
|
|
||||||
_assetHierarchy->Path = new String(ContentDirectory);
|
|
||||||
_assetHierarchy->Name = new String("Content");
|
|
||||||
_assetHierarchy->IsDirectory = true;
|
|
||||||
|
|
||||||
Log.EngineLogger.Trace($"Created directory node for: \"{_assetHierarchy->Path}\"");
|
|
||||||
|
|
||||||
_pathToAssetNode.Add(ContentDirectory, _assetHierarchy);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleFile(AssetNode node)
|
void HandleFile(AssetNode node)
|
||||||
{
|
{
|
||||||
String identifier = scope .(node.Path.Length);
|
node.AssetFile = new AssetFile(_contentManager, node.Identifier, node.Path, node.IsDirectory);
|
||||||
Path.GetRelativePath(node.Path, _contentDirectory, identifier);
|
|
||||||
AssetIdentifier.Fixup(identifier);
|
|
||||||
|
|
||||||
node.AssetFile = new AssetFile(_contentManager, identifier, node.Path, node.IsDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines the files that belong to the given directory and adds them to the tree.
|
/// Determines the files that belong to the given directory and adds them to the tree.
|
||||||
@@ -230,8 +342,11 @@ class AssetHierarchy
|
|||||||
assetNode.Path = new String(filepathBuffer);
|
assetNode.Path = new String(filepathBuffer);
|
||||||
assetNode.IsDirectory = false;
|
assetNode.IsDirectory = false;
|
||||||
|
|
||||||
|
DetermineIdentifier(assetNode, directory);
|
||||||
|
|
||||||
treeNode = directory.AddChild(assetNode);
|
treeNode = directory.AddChild(assetNode);
|
||||||
_pathToAssetNode.Add(assetNode.Path, treeNode);
|
_pathToAssetNode.Add(assetNode.Path, treeNode);
|
||||||
|
_identifierToAssetNode.Add(assetNode.Identifier, treeNode);
|
||||||
|
|
||||||
//GrabSubAssets(node);
|
//GrabSubAssets(node);
|
||||||
HandleFile(treeNode.Value);
|
HandleFile(treeNode.Value);
|
||||||
@@ -243,17 +358,6 @@ class AssetHierarchy
|
|||||||
|
|
||||||
void RemoveOrphanedEntries(TreeNode<AssetNode> node)
|
void RemoveOrphanedEntries(TreeNode<AssetNode> node)
|
||||||
{
|
{
|
||||||
/// Removes the node and its children from _pathToAssetNode
|
|
||||||
void RemoveSubtree(TreeNode<AssetNode> tree)
|
|
||||||
{
|
|
||||||
_pathToAssetNode.Remove(tree->Path);
|
|
||||||
|
|
||||||
for (var child in tree.Children)
|
|
||||||
{
|
|
||||||
RemoveSubtree(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TreeNode<AssetNode> child in node.Children)
|
for (TreeNode<AssetNode> child in node.Children)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(child->Path) && !File.Exists(child->Path))
|
if (!Directory.Exists(child->Path) && !File.Exists(child->Path))
|
||||||
@@ -262,13 +366,37 @@ class AssetHierarchy
|
|||||||
|
|
||||||
@child.Remove();
|
@child.Remove();
|
||||||
|
|
||||||
RemoveSubtree(child);
|
child.ForEach(scope (node) => {
|
||||||
|
_pathToAssetNode.Remove(node->Path);
|
||||||
|
_identifierToAssetNode.Remove(node->Identifier);
|
||||||
|
});
|
||||||
|
|
||||||
DeleteTreeAndChildren!(child);
|
DeleteTreeAndChildren!(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DetermineIdentifier(AssetNode assetNode, TreeNode<AssetNode> parentNode)
|
||||||
|
{
|
||||||
|
if (assetNode.Identifier == null)
|
||||||
|
assetNode.Identifier = new String();
|
||||||
|
|
||||||
|
assetNode.Identifier.Clear();
|
||||||
|
|
||||||
|
// Get the Identifier which is simply the path relative to the asste root (either Resources- or Assets-Folder)
|
||||||
|
if (parentNode.IsInSubtree(_resourcesDirectoryNode))
|
||||||
|
{
|
||||||
|
Path.GetRelativePath(assetNode.Path, _resourcesDirectoryNode->Path, assetNode.Identifier);
|
||||||
|
assetNode.Identifier.Insert(0, "Resources/");
|
||||||
|
}
|
||||||
|
else if (parentNode.IsInSubtree(_assetsDirectoryNode))
|
||||||
|
{
|
||||||
|
Path.GetRelativePath(assetNode.Path, _assetsDirectoryNode->Path, assetNode.Identifier);
|
||||||
|
assetNode.Identifier.Insert(0, "Assets/");
|
||||||
|
}
|
||||||
|
AssetIdentifier.Fixup(assetNode.Identifier);
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds the given directory to the specified tree.
|
/// Adds the given directory to the specified tree.
|
||||||
/// Recursively adds all Files and Subdirectories.
|
/// Recursively adds all Files and Subdirectories.
|
||||||
void AddDirectoryToTree(String path, TreeNode<AssetNode> parentNode)
|
void AddDirectoryToTree(String path, TreeNode<AssetNode> parentNode)
|
||||||
@@ -284,11 +412,29 @@ class AssetHierarchy
|
|||||||
AssetNode assetNode = new AssetNode();
|
AssetNode assetNode = new AssetNode();
|
||||||
assetNode.Path = new String(path);
|
assetNode.Path = new String(path);
|
||||||
assetNode.Name = new String();
|
assetNode.Name = new String();
|
||||||
|
//assetNode.Identifier = new String();
|
||||||
assetNode.IsDirectory = true;
|
assetNode.IsDirectory = true;
|
||||||
Path.GetFileName(assetNode.Path, assetNode.Name);
|
Path.GetFileName(assetNode.Path, assetNode.Name);
|
||||||
|
|
||||||
|
DetermineIdentifier(assetNode, parentNode);
|
||||||
|
|
||||||
|
/*// Get the Identifier which is simply the path relative to the asste root (either Resources- or Assets-Folder)
|
||||||
|
if (parentNode == _resourcesDirectoryNode || parentNode.IsChildOf(_resourcesDirectoryNode))
|
||||||
|
{
|
||||||
|
Path.GetRelativePath(assetNode.Path, _resourcesDirectoryNode->Path, assetNode.Identifier);
|
||||||
|
assetNode.Identifier.Insert(0, "Resources/");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Path.GetRelativePath(assetNode.Path, _assetsDirectoryNode->Path, assetNode.Identifier);
|
||||||
|
assetNode.Identifier.Insert(0, "Assets/");
|
||||||
|
}
|
||||||
|
AssetIdentifier.Fixup(assetNode.Identifier);*/
|
||||||
|
|
||||||
treeNode = parentNode.AddChild(assetNode);
|
treeNode = parentNode.AddChild(assetNode);
|
||||||
_pathToAssetNode.Add(assetNode.Path, treeNode);
|
_pathToAssetNode.Add(assetNode.Path, treeNode);
|
||||||
|
// No Identifiers for Directories, because we can't use directories as Assets anyways...
|
||||||
|
//_identifierToAssetNode.Add(assetNode.Identifier, treeNode);
|
||||||
|
|
||||||
Log.EngineLogger.Trace($"Created directory node for: \"{assetNode.Path}\"");
|
Log.EngineLogger.Trace($"Created directory node for: \"{assetNode.Path}\"");
|
||||||
}
|
}
|
||||||
@@ -310,8 +456,38 @@ class AssetHierarchy
|
|||||||
RemoveOrphanedEntries(treeNode);
|
RemoveOrphanedEntries(treeNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
String filter = scope $"{ContentDirectory}/*";
|
if (!AssetsDirectory.IsWhiteSpace)
|
||||||
|
{
|
||||||
|
String filter = scope $"{AssetsDirectory}/*";
|
||||||
|
|
||||||
|
String directoryNameBuffer = scope String(256);
|
||||||
|
|
||||||
|
for (var directory in Directory.Enumerate(filter, .Directories))
|
||||||
|
{
|
||||||
|
directory.GetFilePath(directoryNameBuffer..Clear());
|
||||||
|
|
||||||
|
AddDirectoryToTree(directoryNameBuffer, _assetsDirectoryNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ResourcesDirectory.IsWhiteSpace)
|
||||||
|
{
|
||||||
|
String filter = scope $"{ResourcesDirectory}/*";
|
||||||
|
|
||||||
|
String directoryNameBuffer = scope String(256);
|
||||||
|
|
||||||
|
for (var directory in Directory.Enumerate(filter, .Directories))
|
||||||
|
{
|
||||||
|
directory.GetFilePath(directoryNameBuffer..Clear());
|
||||||
|
|
||||||
|
AddDirectoryToTree(directoryNameBuffer, _resourcesDirectoryNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveOrphanedEntries(_assetRootNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//*String filter = scope $"{AssetsDirectory}/*";
|
||||||
|
/*
|
||||||
String directoryNameBuffer = scope String(256);
|
String directoryNameBuffer = scope String(256);
|
||||||
|
|
||||||
for (var directory in Directory.Enumerate(filter, .Directories))
|
for (var directory in Directory.Enumerate(filter, .Directories))
|
||||||
@@ -321,7 +497,7 @@ class AssetHierarchy
|
|||||||
AddDirectoryToTree(directoryNameBuffer, _assetHierarchy);
|
AddDirectoryToTree(directoryNameBuffer, _assetHierarchy);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveOrphanedEntries(_assetHierarchy);
|
RemoveOrphanedEntries(_assetHierarchy);*/
|
||||||
|
|
||||||
_fileSystemDirty = false;
|
_fileSystemDirty = false;
|
||||||
}
|
}
|
||||||
@@ -336,7 +512,7 @@ class AssetHierarchy
|
|||||||
fileName.RemoveFromEnd(AssetFile.ConfigFileExtension.Length);
|
fileName.RemoveFromEnd(AssetFile.ConfigFileExtension.Length);
|
||||||
|
|
||||||
String fileNameWithContentRoot = scope .();
|
String fileNameWithContentRoot = scope .();
|
||||||
Path.InternalCombine(fileNameWithContentRoot, _contentDirectory, fileName);
|
Path.InternalCombine(fileNameWithContentRoot, _assetsDirectory, fileName);
|
||||||
|
|
||||||
var nodeResult = GetNodeFromPath(fileNameWithContentRoot);
|
var nodeResult = GetNodeFromPath(fileNameWithContentRoot);
|
||||||
|
|
||||||
@@ -366,10 +542,10 @@ class AssetHierarchy
|
|||||||
|
|
||||||
|
|
||||||
String oldFileNameWithContentRoot = scope .();
|
String oldFileNameWithContentRoot = scope .();
|
||||||
Path.InternalCombine(oldFileNameWithContentRoot, _contentDirectory, oldFilePath);
|
Path.InternalCombine(oldFileNameWithContentRoot, _assetsDirectory, oldFilePath);
|
||||||
|
|
||||||
String newFileNameWithContentRoot = scope .();
|
String newFileNameWithContentRoot = scope .();
|
||||||
Path.InternalCombine(newFileNameWithContentRoot, _contentDirectory, newFilePath);
|
Path.InternalCombine(newFileNameWithContentRoot, _assetsDirectory, newFilePath);
|
||||||
|
|
||||||
// Rename config file
|
// Rename config file
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -175,8 +175,8 @@ class TexturererViewerer
|
|||||||
|
|
||||||
public this()
|
public this()
|
||||||
{
|
{
|
||||||
_effect = Content.LoadAsset("Shaders\\textureViewerShader.hlsl");
|
_effect = Content.LoadAsset("Resources/Shaders/textureViewerShader.hlsl");
|
||||||
_renderTargetEffect = Content.LoadAsset("Shaders\\RenderTargetGroupViewer.hlsl");
|
_renderTargetEffect = Content.LoadAsset("Resources/Shaders/RenderTargetGroupViewer.hlsl");
|
||||||
}
|
}
|
||||||
|
|
||||||
float2 _position;
|
float2 _position;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using ImGui;
|
using ImGui;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using GlitchyEngine.Collections;
|
using GlitchyEngine.Collections;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using GlitchyEngine.Renderer;
|
using GlitchyEngine.Renderer;
|
||||||
@@ -39,7 +40,7 @@ namespace GlitchyEditor.EditWindows
|
|||||||
// Make sure we are in an existing directory.
|
// Make sure we are in an existing directory.
|
||||||
if (!_manager.AssetHierarchy.FileExists(_currentDirectory))
|
if (!_manager.AssetHierarchy.FileExists(_currentDirectory))
|
||||||
{
|
{
|
||||||
_currentDirectory.Set(_manager.ContentDirectory);
|
_currentDirectory.Set(_manager.AssetDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ImGui.Begin(s_WindowTitle, &_open, .None))
|
if(!ImGui.Begin(s_WindowTitle, &_open, .None))
|
||||||
@@ -125,7 +126,7 @@ namespace GlitchyEditor.EditWindows
|
|||||||
/// Renders a sidebar that shows a tree of all directories in the asset folder.
|
/// Renders a sidebar that shows a tree of all directories in the asset folder.
|
||||||
private void DrawDirectorySideBar()
|
private void DrawDirectorySideBar()
|
||||||
{
|
{
|
||||||
for(var child in _manager.AssetHierarchy.[Friend]_assetHierarchy.Children)
|
for(var child in _manager.AssetHierarchy.RootNode.Children)
|
||||||
{
|
{
|
||||||
ImGuiPrintEntityTree(child);
|
ImGuiPrintEntityTree(child);
|
||||||
}
|
}
|
||||||
@@ -142,17 +143,22 @@ namespace GlitchyEditor.EditWindows
|
|||||||
|
|
||||||
ImGui.TreeNodeFlags flags = .OpenOnArrow | .SpanAvailWidth;
|
ImGui.TreeNodeFlags flags = .OpenOnArrow | .SpanAvailWidth;
|
||||||
|
|
||||||
if(tree.Children.Count == 0)
|
if(tree.Children.Where(scope (node) => node->IsDirectory).Count() == 0)
|
||||||
flags |= .Leaf;
|
flags |= .Leaf;
|
||||||
|
|
||||||
if (tree->Path == _currentDirectory)
|
if (tree->Path == _currentDirectory)
|
||||||
{
|
|
||||||
flags |= .Selected;
|
flags |= .Selected;
|
||||||
}
|
|
||||||
|
// TODO: this kinda works, but the user should be able to close the directory
|
||||||
|
/*if (_manager.AssetHierarchy.GetNodeFromPath(_currentDirectory) case .Ok(let currentTreeNode))
|
||||||
|
{
|
||||||
|
if (currentTreeNode.IsInSubtree(tree))
|
||||||
|
ImGui.SetNextItemOpen(true);
|
||||||
|
}*/
|
||||||
|
|
||||||
bool isOpen = ImGui.TreeNodeEx(name, flags, $"{name}");
|
bool isOpen = ImGui.TreeNodeEx(name, flags, $"{name}");
|
||||||
|
|
||||||
if (ImGui.IsItemClicked(.Left))
|
if (!ImGui.IsItemToggledOpen() && ImGui.IsItemClicked(.Left))
|
||||||
{
|
{
|
||||||
_currentDirectory.Set(tree->Path);
|
_currentDirectory.Set(tree->Path);
|
||||||
}
|
}
|
||||||
@@ -186,7 +192,7 @@ namespace GlitchyEditor.EditWindows
|
|||||||
if (_searchEverywhere && searchFilter.Length > 0)
|
if (_searchEverywhere && searchFilter.Length > 0)
|
||||||
{
|
{
|
||||||
files = scope:: List<TreeNode<AssetNode>>();
|
files = scope:: List<TreeNode<AssetNode>>();
|
||||||
_manager.AssetHierarchy.[Friend]_assetHierarchy.ForEach(scope (node) =>
|
_manager.AssetHierarchy.[Friend]_assetRootNode.ForEach(scope (node) =>
|
||||||
{
|
{
|
||||||
if (node->Name.Contains(searchFilter, true))
|
if (node->Name.Contains(searchFilter, true))
|
||||||
{
|
{
|
||||||
@@ -343,8 +349,8 @@ namespace GlitchyEditor.EditWindows
|
|||||||
String fullpath = scope String(entry->Path);
|
String fullpath = scope String(entry->Path);
|
||||||
|
|
||||||
// TODO: this is dirty
|
// TODO: this is dirty
|
||||||
if (fullpath.StartsWith(_manager.ContentDirectory, .OrdinalIgnoreCase))
|
if (fullpath.StartsWith(_manager.AssetDirectory, .OrdinalIgnoreCase))
|
||||||
fullpath.Remove(0, _manager.ContentDirectory.Length);
|
fullpath.Remove(0, _manager.AssetDirectory.Length);
|
||||||
|
|
||||||
Path.Fixup(fullpath);
|
Path.Fixup(fullpath);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace GlitchyEditor
|
|||||||
_contentManager.SetAsDefaultAssetLoader<EffectAssetLoader>(".hlsl");
|
_contentManager.SetAsDefaultAssetLoader<EffectAssetLoader>(".hlsl");
|
||||||
_contentManager.SetAssetPropertiesEditor<EffectAssetLoader>(=> EffectAssetPropertiesEditor.Factory);
|
_contentManager.SetAssetPropertiesEditor<EffectAssetLoader>(=> EffectAssetPropertiesEditor.Factory);
|
||||||
|
|
||||||
_contentManager.SetContentDirectory("./content");
|
_contentManager.SetResourcesDirectory("./Resources");
|
||||||
|
|
||||||
return _contentManager;
|
return _contentManager;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ namespace GlitchyEditor;
|
|||||||
|
|
||||||
class EditorContentManager : IContentManager
|
class EditorContentManager : IContentManager
|
||||||
{
|
{
|
||||||
private append String _contentDirectory = .();
|
private append String _resourcesDirectory = .();
|
||||||
|
private append String _assetsDirectory = .();
|
||||||
|
|
||||||
public StringView ContentDirectory => _contentDirectory;
|
public StringView ResourcesDirectory => _resourcesDirectory;
|
||||||
|
public StringView AssetDirectory => _assetsDirectory;
|
||||||
//private append List<String> _identifiers = .() ~ _.ClearAndDeleteItems();
|
|
||||||
|
|
||||||
private append Dictionary<StringView, AssetHandle> _identiferToHandle = .(); // TODO: Check if all resources are unloaded
|
private append Dictionary<StringView, AssetHandle> _identiferToHandle = .(); // TODO: Check if all resources are unloaded
|
||||||
|
|
||||||
@@ -64,13 +64,20 @@ class EditorContentManager : IContentManager
|
|||||||
_identiferToHandle.Add(asset.Identifier, asset.Handle);
|
_identiferToHandle.Add(asset.Identifier, asset.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetContentDirectory(StringView contentDirectory)
|
public void SetResourcesDirectory(StringView fileName)
|
||||||
{
|
{
|
||||||
_contentDirectory.Clear();
|
_resourcesDirectory.Set(fileName);
|
||||||
_contentDirectory.Append(contentDirectory);
|
Path.Fixup(_resourcesDirectory);
|
||||||
Path.Fixup(_contentDirectory);
|
|
||||||
|
|
||||||
_assetHierarchy.SetContentDirectory(contentDirectory);
|
_assetHierarchy.SetResourcesDirectory(_resourcesDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetAssetDirectory(StringView fileName)
|
||||||
|
{
|
||||||
|
_assetsDirectory.Set(fileName);
|
||||||
|
Path.Fixup(_assetsDirectory);
|
||||||
|
|
||||||
|
_assetHierarchy.SetAssetsDirectory(_assetsDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
@@ -302,7 +309,7 @@ class EditorContentManager : IContentManager
|
|||||||
|
|
||||||
private void GetResourceFilePath(StringView resourceName, String filePath)
|
private void GetResourceFilePath(StringView resourceName, String filePath)
|
||||||
{
|
{
|
||||||
Path.Combine(filePath, _contentDirectory, resourceName);
|
Path.Combine(filePath, _assetsDirectory, resourceName);
|
||||||
|
|
||||||
Path.Fixup(filePath);
|
Path.Fixup(filePath);
|
||||||
}
|
}
|
||||||
@@ -337,7 +344,10 @@ class EditorContentManager : IContentManager
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// Todo: How strict should we be on paths?
|
// It's valid to request no entity, but no entity is obviously invalid.
|
||||||
|
if (identifier.IsWhiteSpace)
|
||||||
|
return .Invalid;
|
||||||
|
|
||||||
String fixedIdentifier = scope String(identifier);
|
String fixedIdentifier = scope String(identifier);
|
||||||
AssetIdentifier.Fixup(fixedIdentifier);
|
AssetIdentifier.Fixup(fixedIdentifier);
|
||||||
|
|
||||||
@@ -346,17 +356,16 @@ class EditorContentManager : IContentManager
|
|||||||
|
|
||||||
GetResourceAndSubassetName(fixedIdentifier, let resourceName, let subassetName);
|
GetResourceAndSubassetName(fixedIdentifier, let resourceName, let subassetName);
|
||||||
|
|
||||||
String filePath = scope .();
|
Result<TreeNode<AssetNode>> resultNode = AssetHierarchy.GetNodeFromIdentifier(fixedIdentifier);
|
||||||
GetResourceFilePath(resourceName, filePath);
|
|
||||||
|
|
||||||
Result<TreeNode<AssetNode>> resultNode = AssetHierarchy.GetNodeFromPath(filePath);
|
|
||||||
|
|
||||||
if (resultNode case .Err)
|
if (resultNode case .Err)
|
||||||
{
|
{
|
||||||
Log.EngineLogger.Error($"Could not find asset \"{filePath}\".");
|
Log.EngineLogger.Error($"Could not find asset \"{fixedIdentifier}\".");
|
||||||
return .Invalid;
|
return .Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String filePath = scope String(resultNode->Value.Path);
|
||||||
|
|
||||||
AssetFile file = resultNode->Value.AssetFile;
|
AssetFile file = resultNode->Value.AssetFile;
|
||||||
|
|
||||||
IAssetLoader assetLoader = GetAssetLoader(file);
|
IAssetLoader assetLoader = GetAssetLoader(file);
|
||||||
@@ -374,7 +383,7 @@ class EditorContentManager : IContentManager
|
|||||||
// TODO: Support lazy loading for all asset types
|
// TODO: Support lazy loading for all asset types
|
||||||
if (!(assetLoader is EditorTextureAssetLoader) || blocking)
|
if (!(assetLoader is EditorTextureAssetLoader) || blocking)
|
||||||
{
|
{
|
||||||
Stream stream = GetStream(filePath);
|
Stream stream = OpenStream(filePath, true);
|
||||||
|
|
||||||
loadedAsset = assetLoader.LoadAsset(stream, file.AssetConfig.Config, resourceName, subassetName, this);
|
loadedAsset = assetLoader.LoadAsset(stream, file.AssetConfig.Config, resourceName, subassetName, this);
|
||||||
|
|
||||||
@@ -418,7 +427,7 @@ class EditorContentManager : IContentManager
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Stream stream = GetStream(filePath);
|
Stream stream = OpenStream(filePath, true);
|
||||||
|
|
||||||
Asset loadedAsset = assetLoader.LoadAsset(stream, file.AssetConfig.Config, resourceName, subassetName, this);
|
Asset loadedAsset = assetLoader.LoadAsset(stream, file.AssetConfig.Config, resourceName, subassetName, this);
|
||||||
|
|
||||||
@@ -511,23 +520,13 @@ class EditorContentManager : IContentManager
|
|||||||
return .Ok;
|
return .Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream OpenStream(StringView assetIdentifier, bool openOnly)
|
private Stream OpenStream(StringView fileName, bool openOnly)
|
||||||
{
|
{
|
||||||
var assetIdentifier;
|
|
||||||
|
|
||||||
if (!assetIdentifier.StartsWith(_contentDirectory))
|
|
||||||
{
|
|
||||||
String filePath = scope:: String(assetIdentifier.Length + _contentDirectory.Length + 2);
|
|
||||||
Path.Combine(filePath, _contentDirectory, assetIdentifier);
|
|
||||||
|
|
||||||
assetIdentifier = filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileStream fs = new FileStream();
|
FileStream fs = new FileStream();
|
||||||
|
|
||||||
FileMode fileMode = openOnly ? FileMode.Open : FileMode.OpenOrCreate;
|
FileMode fileMode = openOnly ? FileMode.Open : FileMode.OpenOrCreate;
|
||||||
|
|
||||||
var result = fs.Open(assetIdentifier, fileMode, openOnly ? .Read : .ReadWrite, .ReadWrite);
|
var result = fs.Open(fileName, fileMode, openOnly ? .Read : .ReadWrite, .ReadWrite);
|
||||||
|
|
||||||
if (result case .Err)
|
if (result case .Err)
|
||||||
return null;
|
return null;
|
||||||
@@ -535,28 +534,21 @@ class EditorContentManager : IContentManager
|
|||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: probably not needed
|
/// Returns a file stream for the given assetIdentifier
|
||||||
public Stream GetStream(StringView assetIdentifier)
|
public Stream GetStream(StringView assetIdentifier)
|
||||||
{
|
{
|
||||||
return OpenStream(assetIdentifier, true);
|
String fixuppedIdentifier = scope .(assetIdentifier);
|
||||||
|
AssetIdentifier.Fixup(fixuppedIdentifier);
|
||||||
|
|
||||||
/*var assetIdentifier;
|
var node = _assetHierarchy.GetNodeFromIdentifier(fixuppedIdentifier);
|
||||||
|
|
||||||
if (!assetIdentifier.StartsWith(_contentDirectory))
|
if (node case .Err)
|
||||||
{
|
{
|
||||||
String filePath = scope:: String(assetIdentifier.Length + _contentDirectory.Length + 2);
|
Log.EngineLogger.Error($"Could not find asset node \"{assetIdentifier}\".");
|
||||||
Path.Combine(filePath, _contentDirectory, assetIdentifier);
|
return null;
|
||||||
|
|
||||||
assetIdentifier = filePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream fs = new FileStream();
|
return OpenStream(node->Value.Path, true);
|
||||||
var result = fs.Open(assetIdentifier, .Open, .Read, .ReadWrite);
|
|
||||||
|
|
||||||
if (result case .Err)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return fs;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetHandle ManageAsset(Asset asset)
|
public AssetHandle ManageAsset(Asset asset)
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ namespace GlitchyEditor
|
|||||||
.(.R8G8B8A8_UNorm))
|
.(.R8G8B8A8_UNorm))
|
||||||
});
|
});
|
||||||
|
|
||||||
_editorIcons = new EditorIcons("Textures/EditorIcons.dds", .(64, 64));
|
_editorIcons = new EditorIcons("Resources/Textures/EditorIcons.dds", .(64, 64));
|
||||||
_editorIcons.SamplerState = SamplerStateManager.AnisotropicClamp;
|
_editorIcons.SamplerState = SamplerStateManager.AnisotropicClamp;
|
||||||
|
|
||||||
ContentBrowserWindow.s_FolderTexture = _editorIcons.Folder;
|
ContentBrowserWindow.s_FolderTexture = _editorIcons.Folder;
|
||||||
@@ -783,6 +783,8 @@ namespace GlitchyEditor
|
|||||||
_currentProject = Project.Load(workspacePath);
|
_currentProject = Project.Load(workspacePath);
|
||||||
|
|
||||||
String appAssemblyPath = scope String();
|
String appAssemblyPath = scope String();
|
||||||
|
_contentManager.SetAssetDirectory(_currentProject.AssetsFolder);
|
||||||
|
|
||||||
// TODO: obviously change dll name, configurable?
|
// TODO: obviously change dll name, configurable?
|
||||||
Path.Combine(appAssemblyPath, _currentProject.AssetsFolder, "Scripts/bin/Sandbox.dll");
|
Path.Combine(appAssemblyPath, _currentProject.AssetsFolder, "Scripts/bin/Sandbox.dll");
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,34 @@ namespace GlitchyEngine.Collections
|
|||||||
DepthFirst
|
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)
|
public void ForEach(ElementFunc func, IterationMode iterationMode = .DepthFirst)
|
||||||
{
|
{
|
||||||
if (iterationMode == .BreadthFirst)
|
if (iterationMode == .BreadthFirst)
|
||||||
@@ -123,6 +151,9 @@ namespace GlitchyEngine.Collections
|
|||||||
|
|
||||||
private static void InternalDeleteTreeAndChildren<T>(TreeNode<T> tree) where T : class, delete
|
private static void InternalDeleteTreeAndChildren<T>(TreeNode<T> tree) where T : class, delete
|
||||||
{
|
{
|
||||||
|
if (tree == null)
|
||||||
|
return;
|
||||||
|
|
||||||
for (var child in tree.Children)
|
for (var child in tree.Children)
|
||||||
{
|
{
|
||||||
InternalDeleteTreeAndChildren(child);
|
InternalDeleteTreeAndChildren(child);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
using GlitchyEngine.Platform.DX11;
|
using GlitchyEngine.Platform.DX11;
|
||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
|
||||||
using internal GlitchyEngine.Renderer;
|
using internal GlitchyEngine.Renderer;
|
||||||
using internal GlitchyEngine.Platform.DX11;
|
using internal GlitchyEngine.Platform.DX11;
|
||||||
@@ -15,7 +16,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
private GraphicsContext _context ~ _?.ReleaseRef();
|
private GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
private Effect _clearUintFx ~ _?.ReleaseRef();
|
private AssetHandle<Effect> _clearUintFx;
|
||||||
private BlendState _nonblendingState ~ _?.ReleaseRef();
|
private BlendState _nonblendingState ~ _?.ReleaseRef();
|
||||||
|
|
||||||
public GraphicsContext Context
|
public GraphicsContext Context
|
||||||
@@ -30,7 +31,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileFunction!();
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_clearUintFx = new Effect("content/Shaders/ClearUInt.hlsl");
|
_clearUintFx = Content.LoadAsset("Resources/Shaders/ClearUInt.hlsl", null, true);
|
||||||
BlendStateDescription desc =.Default;
|
BlendStateDescription desc =.Default;
|
||||||
desc.RenderTarget[0].BlendEnable = false;
|
desc.RenderTarget[0].BlendEnable = false;
|
||||||
_nonblendingState = new BlendState(desc);
|
_nonblendingState = new BlendState(desc);
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
Path.Combine(pathNextToParent, includer._parentFileDirectory, StringView(fileName));
|
Path.Combine(pathNextToParent, includer._parentFileDirectory, StringView(fileName));
|
||||||
|
|
||||||
Stream fileStream = Application.Get().ContentManager.GetStream(pathNextToParent);
|
Stream fileStream = Application.Instance.ContentManager.GetStream(pathNextToParent);
|
||||||
|
|
||||||
if (fileStream == null)
|
if (fileStream == null)
|
||||||
{
|
{
|
||||||
fileStream = Application.Get().ContentManager.GetStream(StringView(fileName));
|
fileStream = Application.Instance.ContentManager.GetStream(StringView(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileStream == null)
|
if (fileStream == null)
|
||||||
|
|||||||
@@ -176,8 +176,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
static void InitDeferredRenderer()
|
static void InitDeferredRenderer()
|
||||||
{
|
{
|
||||||
TestFullscreenEffect = Content.LoadAsset("Shaders\\simpleLight.hlsl");
|
TestFullscreenEffect = Content.LoadAsset("Resources/Shaders/simpleLight.hlsl");
|
||||||
s_tonemappingEffect = Content.LoadAsset("Shaders\\SimpleTonemapping.hlsl");
|
s_tonemappingEffect = Content.LoadAsset("Resources/Shaders/SimpleTonemapping.hlsl");
|
||||||
|
|
||||||
_gBuffer = new GBuffer();
|
_gBuffer = new GBuffer();
|
||||||
BlendStateDescription gBufferBlendDesc = .Default;
|
BlendStateDescription gBufferBlendDesc = .Default;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using GlitchyEngine.Renderer.Text;
|
using GlitchyEngine.Renderer.Text;
|
||||||
using GlitchyEngine.World;
|
using GlitchyEngine.World;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
@@ -130,9 +131,9 @@ namespace GlitchyEngine.Renderer
|
|||||||
private static bool s_sceneRunning;
|
private static bool s_sceneRunning;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static Effect s_quadBatchEffect;
|
private static AssetHandle<Effect> s_quadBatchEffect;
|
||||||
private static Effect s_circleBatchEffect;
|
private static AssetHandle<Effect> s_circleBatchEffect;
|
||||||
private static Effect s_lineBatchEffect;
|
private static AssetHandle<Effect> s_lineBatchEffect;
|
||||||
|
|
||||||
private static GeometryBinding s_quadGeometry;
|
private static GeometryBinding s_quadGeometry;
|
||||||
|
|
||||||
@@ -161,9 +162,9 @@ namespace GlitchyEngine.Renderer
|
|||||||
private static DrawOrder s_drawOrder;
|
private static DrawOrder s_drawOrder;
|
||||||
|
|
||||||
/// The effect that is currently used to draw the sprites.
|
/// The effect that is currently used to draw the sprites.
|
||||||
private static Effect s_currentQuadEffect;
|
private static AssetHandle<Effect> s_currentQuadEffect;
|
||||||
private static Effect s_currentCircleEffect;
|
private static AssetHandle<Effect> s_currentCircleEffect;
|
||||||
private static Effect s_currentLineEffect;
|
private static AssetHandle<Effect> s_currentLineEffect;
|
||||||
|
|
||||||
public static uint32 MaxInstancesPerBatch
|
public static uint32 MaxInstancesPerBatch
|
||||||
{
|
{
|
||||||
@@ -183,9 +184,9 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileFunction!();
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
s_quadBatchEffect = new Effect("content\\Shaders\\spritebatch.hlsl");
|
s_quadBatchEffect = Content.LoadAsset("Resources/Shaders/spritebatch.hlsl", null, true);
|
||||||
s_circleBatchEffect = new Effect("content\\Shaders\\circlebatch.hlsl");
|
s_circleBatchEffect = Content.LoadAsset("Resources/Shaders/circlebatch.hlsl", null, true);
|
||||||
s_lineBatchEffect = new Effect("content\\Shaders\\linebatch.hlsl");
|
s_lineBatchEffect = Content.LoadAsset("Resources/Shaders/linebatch.hlsl", null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitGeometry()
|
private static void InitGeometry()
|
||||||
@@ -427,10 +428,6 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
FontRenderer.Deinit();
|
FontRenderer.Deinit();
|
||||||
|
|
||||||
s_quadBatchEffect.ReleaseRef();
|
|
||||||
s_circleBatchEffect.ReleaseRef();
|
|
||||||
s_lineBatchEffect.ReleaseRef();
|
|
||||||
|
|
||||||
s_quadGeometry.ReleaseRef();
|
s_quadGeometry.ReleaseRef();
|
||||||
|
|
||||||
s_whiteTexture.ReleaseRef();
|
s_whiteTexture.ReleaseRef();
|
||||||
@@ -449,10 +446,6 @@ namespace GlitchyEngine.Renderer
|
|||||||
delete s_circleInstanceQueue;
|
delete s_circleInstanceQueue;
|
||||||
delete s_lineInstanceQueue;
|
delete s_lineInstanceQueue;
|
||||||
|
|
||||||
s_currentQuadEffect?.ReleaseRef();
|
|
||||||
s_currentCircleEffect?.ReleaseRef();
|
|
||||||
s_currentLineEffect?.ReleaseRef();
|
|
||||||
|
|
||||||
s_opaqueBlendState.ReleaseRef();
|
s_opaqueBlendState.ReleaseRef();
|
||||||
s_transparentBlendState.ReleaseRef();
|
s_transparentBlendState.ReleaseRef();
|
||||||
|
|
||||||
@@ -462,7 +455,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove?
|
// 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!();
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
#if DEBUG
|
#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.");
|
Log.EngineLogger.AssertDebug(!s_sceneRunning, "You have to call EndScene before you can make another call to BeginScene.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//s_textureColorEffect.Bind(Renderer._context);
|
if(effect != .Invalid)
|
||||||
|
|
||||||
s_currentQuadEffect?.ReleaseRef();
|
|
||||||
if(effect != null)
|
|
||||||
{
|
{
|
||||||
s_currentQuadEffect = effect..AddRef();
|
s_currentQuadEffect = effect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_currentQuadEffect = s_quadBatchEffect..AddRef();
|
s_currentQuadEffect = s_quadBatchEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_currentCircleEffect?.ReleaseRef();
|
if(circleEffect != .Invalid)
|
||||||
if(circleEffect != null)
|
|
||||||
{
|
{
|
||||||
s_currentCircleEffect = effect..AddRef();
|
s_currentCircleEffect = circleEffect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_currentCircleEffect = s_circleBatchEffect..AddRef();
|
s_currentCircleEffect = s_circleBatchEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_currentLineEffect = s_lineBatchEffect;
|
||||||
|
|
||||||
s_currentQuadEffect.Variables["ViewProjection"].SetData(camera.ViewProjection);
|
s_currentQuadEffect.Variables["ViewProjection"].SetData(camera.ViewProjection);
|
||||||
s_currentCircleEffect.Variables["ViewProjection"].SetData(camera.ViewProjection);
|
s_currentCircleEffect.Variables["ViewProjection"].SetData(camera.ViewProjection);
|
||||||
|
|
||||||
@@ -502,7 +493,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
#endif
|
#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!();
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -510,37 +501,25 @@ namespace GlitchyEngine.Renderer
|
|||||||
Log.EngineLogger.AssertDebug(!s_sceneRunning, "You have to call EndScene before you can make another call to BeginScene.");
|
Log.EngineLogger.AssertDebug(!s_sceneRunning, "You have to call EndScene before you can make another call to BeginScene.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//s_textureColorEffect.Bind(Renderer._context);
|
if(effect != .Invalid)
|
||||||
|
|
||||||
s_currentQuadEffect?.ReleaseRef();
|
|
||||||
if(effect != null)
|
|
||||||
{
|
{
|
||||||
s_currentQuadEffect = effect..AddRef();
|
s_currentQuadEffect = effect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_currentQuadEffect = s_quadBatchEffect..AddRef();
|
s_currentQuadEffect = s_quadBatchEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_currentCircleEffect?.ReleaseRef();
|
if(circleEffect != .Invalid)
|
||||||
if(circleEffect != null)
|
|
||||||
{
|
{
|
||||||
s_currentCircleEffect = effect..AddRef();
|
s_currentCircleEffect = circleEffect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_currentCircleEffect = s_circleBatchEffect..AddRef();
|
s_currentCircleEffect = s_circleBatchEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_currentLineEffect?.ReleaseRef();
|
s_currentLineEffect = s_lineBatchEffect;
|
||||||
/*if(circleEffect != null)
|
|
||||||
{
|
|
||||||
s_currentLineEffect = effect..AddRef();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{*/
|
|
||||||
s_currentLineEffect = s_lineBatchEffect..AddRef();
|
|
||||||
//}
|
|
||||||
|
|
||||||
Matrix viewProjection = camera.Projection * Matrix.Invert(transform);
|
Matrix viewProjection = camera.Projection * Matrix.Invert(transform);
|
||||||
|
|
||||||
@@ -555,7 +534,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
#endif
|
#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!();
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
#if DEBUG
|
#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.");
|
Log.EngineLogger.AssertDebug(!s_sceneRunning, "You have to call EndScene before you can make another call to BeginScene.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//s_textureColorEffect.Bind(Renderer._context);
|
if(effect != .Invalid)
|
||||||
|
|
||||||
s_currentQuadEffect?.ReleaseRef();
|
|
||||||
if(effect != null)
|
|
||||||
{
|
{
|
||||||
s_currentQuadEffect = effect..AddRef();
|
s_currentQuadEffect = effect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_currentQuadEffect = s_quadBatchEffect..AddRef();
|
s_currentQuadEffect = s_quadBatchEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_currentCircleEffect?.ReleaseRef();
|
if(circleEffect != .Invalid)
|
||||||
if(circleEffect != null)
|
|
||||||
{
|
{
|
||||||
s_currentCircleEffect = effect..AddRef();
|
s_currentCircleEffect = circleEffect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_currentCircleEffect = s_circleBatchEffect..AddRef();
|
s_currentCircleEffect = s_circleBatchEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_currentLineEffect?.ReleaseRef();
|
s_currentLineEffect = s_lineBatchEffect;
|
||||||
/*if(circleEffect != null)
|
|
||||||
{
|
|
||||||
s_currentLineEffect = effect..AddRef();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{*/
|
|
||||||
s_currentLineEffect = s_lineBatchEffect..AddRef();
|
|
||||||
//}
|
|
||||||
|
|
||||||
Matrix viewProjection = camera.Projection * camera.View;
|
Matrix viewProjection = camera.Projection * camera.View;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using GlitchyEngine.Core;
|
using GlitchyEngine.Core;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
using static FreeType.HarfBuzz;
|
using static FreeType.HarfBuzz;
|
||||||
|
|
||||||
using internal GlitchyEngine.Renderer.Text;
|
using internal GlitchyEngine.Renderer.Text;
|
||||||
@@ -15,7 +16,7 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
{
|
{
|
||||||
internal static FT_Library s_Library;
|
internal static FT_Library s_Library;
|
||||||
|
|
||||||
public static Effect _msdfEffect;
|
public static AssetHandle<Effect> _msdfEffect;
|
||||||
|
|
||||||
internal static bool s_isInitialized;
|
internal static bool s_isInitialized;
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
InitFreetype();
|
InitFreetype();
|
||||||
|
|
||||||
_msdfEffect = new Effect("content\\Shaders\\msdfShader.hlsl");
|
_msdfEffect = Content.LoadAsset("Resources/Shaders/msdfShader.hlsl");
|
||||||
|
|
||||||
s_isInitialized = true;
|
s_isInitialized = true;
|
||||||
}
|
}
|
||||||
@@ -37,8 +38,6 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileFunction!();
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_msdfEffect.ReleaseRef();
|
|
||||||
|
|
||||||
DeinitFreetype();
|
DeinitFreetype();
|
||||||
|
|
||||||
s_isInitialized = false;
|
s_isInitialized = false;
|
||||||
@@ -334,7 +333,7 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
// TODO: this is very not good!
|
// TODO: this is very not good!
|
||||||
var lastEffect = Renderer2D.[Friend]s_currentQuadEffect;
|
var lastEffect = Renderer2D.[Friend]s_currentQuadEffect;
|
||||||
Renderer2D.[Friend]s_currentQuadEffect = _msdfEffect..AddRef();
|
Renderer2D.[Friend]s_currentQuadEffect = _msdfEffect;
|
||||||
// TODO: oh no....
|
// TODO: oh no....
|
||||||
// Copy viewProjection from current effect
|
// Copy viewProjection from current effect
|
||||||
Matrix viewProjection = lastEffect.Variables["ViewProjection"].[Friend]GetData<Matrix>();
|
Matrix viewProjection = lastEffect.Variables["ViewProjection"].[Friend]GetData<Matrix>();
|
||||||
@@ -409,7 +408,6 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
// TODO: not good!
|
// TODO: not good!
|
||||||
// Change back effect
|
// Change back effect
|
||||||
_msdfEffect.ReleaseRef();
|
|
||||||
Renderer2D.[Friend]s_currentQuadEffect = lastEffect;
|
Renderer2D.[Friend]s_currentQuadEffect = lastEffect;
|
||||||
|
|
||||||
// release all atlas textures
|
// release all atlas textures
|
||||||
@@ -440,7 +438,7 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
// TODO: this is very not good!
|
// TODO: this is very not good!
|
||||||
var lastEffect = Renderer2D.[Friend]s_currentQuadEffect;
|
var lastEffect = Renderer2D.[Friend]s_currentQuadEffect;
|
||||||
Renderer2D.[Friend]s_currentQuadEffect = _msdfEffect..AddRef();
|
Renderer2D.[Friend]s_currentQuadEffect = _msdfEffect;
|
||||||
// TODO: oh no....
|
// TODO: oh no....
|
||||||
// Copy viewProjection from current effect
|
// Copy viewProjection from current effect
|
||||||
Matrix viewProjection = lastEffect.Variables["ViewProjection"].[Friend]GetData<Matrix>();
|
Matrix viewProjection = lastEffect.Variables["ViewProjection"].[Friend]GetData<Matrix>();
|
||||||
@@ -663,7 +661,6 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
// TODO: not good!
|
// TODO: not good!
|
||||||
// Change back effect
|
// Change back effect
|
||||||
_msdfEffect.ReleaseRef();
|
|
||||||
Renderer2D.[Friend]s_currentQuadEffect = lastEffect;
|
Renderer2D.[Friend]s_currentQuadEffect = lastEffect;
|
||||||
|
|
||||||
// release all atlas textures
|
// release all atlas textures
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class SceneRenderer
|
|||||||
private uint32 _viewportWidth;
|
private uint32 _viewportWidth;
|
||||||
private uint32 _viewportHeight;
|
private uint32 _viewportHeight;
|
||||||
|
|
||||||
private AssetHandle _gammaCorrectEffect;
|
private AssetHandle<Effect> _gammaCorrectEffect;
|
||||||
|
|
||||||
public RenderTargetGroup CompositeTarget => _compositeTarget;
|
public RenderTargetGroup CompositeTarget => _compositeTarget;
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ class SceneRenderer
|
|||||||
DepthTargetDescription = .(.D24_UNorm_S8_UInt)
|
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.
|
/// Sets the size of the viewport into which the scene will be rendered.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using GlitchyEngine;
|
|||||||
using ImGui;
|
using ImGui;
|
||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
namespace Sandbox
|
namespace Sandbox
|
||||||
{
|
{
|
||||||
class TextureViewer
|
class TextureViewer
|
||||||
@@ -22,7 +23,7 @@ namespace Sandbox
|
|||||||
|
|
||||||
GraphicsContext _context ~ _.ReleaseRef();
|
GraphicsContext _context ~ _.ReleaseRef();
|
||||||
|
|
||||||
Effect _effect ~ _.ReleaseRef();
|
AssetHandle<Effect> _effect;
|
||||||
|
|
||||||
float _zoom = 1.0f;
|
float _zoom = 1.0f;
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ namespace Sandbox
|
|||||||
|
|
||||||
private void InitEffect()
|
private void InitEffect()
|
||||||
{
|
{
|
||||||
_effect = new Effect("content\\Shaders\\textureViewerShader.hlsl");
|
_effect = Content.LoadAsset("Shaders\\textureViewerShader.hlsl");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitState()
|
private void InitState()
|
||||||
|
|||||||