Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daethalus committed May 22, 2024
1 parent 7c3baa9 commit 54ffcfd
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 45 deletions.
18 changes: 9 additions & 9 deletions Editor/Source/Fyrion/Editor/Editor/GraphEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ namespace Fyrion

ResourceObject object = Repository::Read(m_graph);

Array<RID> nodes = object.GetSubObjectSetAsArray(ResourceGraphAsset::Nodes);
Array<RID> nodes = object.GetSubObjectSetAsArray(GraphAsset::Nodes);
for (RID node : nodes)
{
AddNodeCache(node);
}

Array<RID> links = object.GetSubObjectSetAsArray(ResourceGraphAsset::Links);
Array<RID> links = object.GetSubObjectSetAsArray(GraphAsset::Links);
for (RID link : links)
{
AddLinkCache(link);
Expand All @@ -278,7 +278,7 @@ namespace Fyrion
nodeObject.Commit();

ResourceObject graphAsset = Repository::Write(m_graph);
graphAsset.AddToSubObjectSet(ResourceGraphAsset::Nodes, nodeAsset);
graphAsset.AddToSubObjectSet(GraphAsset::Nodes, nodeAsset);
graphAsset.Commit();

Repository::SetUUID(nodeAsset, UUID::RandomUUID());
Expand All @@ -296,7 +296,7 @@ namespace Fyrion
nodeObject.Commit();

ResourceObject graphAsset = Repository::Write(m_graph);
graphAsset.AddToSubObjectSet(ResourceGraphAsset::Nodes, nodeAsset);
graphAsset.AddToSubObjectSet(GraphAsset::Nodes, nodeAsset);
graphAsset.Commit();

Repository::SetUUID(nodeAsset, UUID::RandomUUID());
Expand All @@ -316,7 +316,7 @@ namespace Fyrion
nodeObject.Commit();

ResourceObject graphAsset = Repository::Write(m_graph);
graphAsset.AddToSubObjectSet(ResourceGraphAsset::Nodes, nodeAsset);
graphAsset.AddToSubObjectSet(GraphAsset::Nodes, nodeAsset);
graphAsset.Commit();

Repository::SetUUID(nodeAsset, UUID::RandomUUID());
Expand Down Expand Up @@ -396,7 +396,7 @@ namespace Fyrion
linkObject.Commit();

ResourceObject graphAsset = Repository::Write(m_graph);
graphAsset.AddToSubObjectSet(ResourceGraphAsset::Links, linkAsset);
graphAsset.AddToSubObjectSet(GraphAsset::Links, linkAsset);
graphAsset.Commit();

Repository::SetUUID(linkAsset, UUID::RandomUUID());
Expand All @@ -421,7 +421,7 @@ namespace Fyrion
linkObject.Commit();

ResourceObject graphAsset = Repository::Write(m_graph);
graphAsset.AddToSubObjectSet(ResourceGraphAsset::Links, linkAsset);
graphAsset.AddToSubObjectSet(GraphAsset::Links, linkAsset);
graphAsset.Commit();

Repository::SetUUID(linkAsset, UUID::RandomUUID());
Expand Down Expand Up @@ -490,12 +490,12 @@ namespace Fyrion
Repository::DestroyResource(it.first);
}

if (const auto it = std::ranges::find(pin->node->inputs, pin); it != pin->node->inputs.end())
if (const auto it = std::find(pin->node->inputs.begin(), pin->node->inputs.end(), pin); it != pin->node->inputs.end())
{
pin->node->inputs.Erase(it);
}

if (const auto it = std::ranges::find(pin->node->outputs, pin); it != pin->node->outputs.end())
if (const auto it = std::find(pin->node->outputs.begin(), pin->node->outputs.end(), pin); it != pin->node->outputs.end())
{
pin->node->outputs.Erase(it);
}
Expand Down
5 changes: 3 additions & 2 deletions Editor/Source/Fyrion/Editor/Window/ProjectBrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Fyrion/Resource/ResourceAssets.hpp"
#include "Fyrion/Resource/Repository.hpp"
#include "Fyrion/Engine.hpp"
#include "Fyrion/Assets/AssetTypes.hpp"
#include "Fyrion/Graphics/RenderGraph.hpp"
#include "Fyrion/Resource/ResourceGraph.hpp"
#include "Fyrion/Scene/SceneAssets.hpp"
Expand Down Expand Up @@ -376,7 +377,7 @@ namespace Fyrion
{
Editor::GetSceneEditor().LoadScene(node->rid);
}
else if (node->objectType == GetTypeID<ResourceGraphAsset>() || node->objectType == GetTypeID<RenderGraphAsset>())
else if (node->objectType == GetTypeID<GraphAsset>() || node->objectType == GetTypeID<RenderGraphAsset>())
{
GraphEditorWindow::OpenGraphWindow(node->rid);
}
Expand Down Expand Up @@ -504,7 +505,7 @@ namespace Fyrion
void ProjectBrowserWindow::AssetNewResourceGraph(const MenuItemEventData& eventData)
{
ProjectBrowserWindow* projectBrowserWindow = static_cast<ProjectBrowserWindow*>(eventData.drawData);
RID newAsset = projectBrowserWindow->m_assetTree.NewAsset(projectBrowserWindow->m_openFolder, Repository::CreateResource<ResourceGraphAsset>(), "New Resource Graph");
RID newAsset = projectBrowserWindow->m_assetTree.NewAsset(projectBrowserWindow->m_openFolder, Repository::CreateResource<GraphAsset>(), "New Resource Graph");

ImGui::SelectContentItem(Hash<RID>::Value(newAsset), CONTENT_TABLE_ID + projectBrowserWindow->m_windowId);
ImGui::RenameContentSelected(CONTENT_TABLE_ID + projectBrowserWindow->m_windowId);
Expand Down
12 changes: 12 additions & 0 deletions Engine/Source/Fyrion/Assets/AssetTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ namespace Fyrion
constexpr static u32 OutputPin = 3;
};

struct GraphInstanceAsset
{
constexpr static u32 Graph = 0;
constexpr static u32 Inputs = 0;
};

struct GraphAsset
{
constexpr static u32 Nodes = 0;
constexpr static u32 Links = 1;
};

struct DCCMesh
{

Expand Down
5 changes: 5 additions & 0 deletions Engine/Source/Fyrion/Assets/Assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ namespace Fyrion
.Value<GraphNodeAsset::Label, String>("Label")
.Build();

ResourceTypeBuilder<GraphAsset>::Builder("Fyrion::ResourceGraph")
.SubObjectSet<GraphAsset::Links>("Links")
.SubObjectSet<GraphAsset::Nodes>("Nodes")
.Build();

ResourceTypeBuilder<DCCMesh>::Builder()
.Build();
}
Expand Down
11 changes: 5 additions & 6 deletions Engine/Source/Fyrion/ImGui/FieldRenderers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "Fyrion/Assets/AssetTypes.hpp"
#include "Fyrion/Core/Registry.hpp"
#include "Fyrion/Resource/Repository.hpp"
#include "Fyrion/Resource/ResourceGraph.hpp"
#include "Lib/imgui_internal.h"

namespace Fyrion
Expand Down Expand Up @@ -37,12 +36,11 @@ namespace Fyrion
context->showResourceSelection = true;
context->resourceTypeSelection = resourceReference->resourceType;
context->fieldShowSelection = fieldHandler;
//context->graphOutputSelection = resourceReference->graphOutput;
}
}
ImGui::PopID();

if (rid && resourceReference && resourceReference->resourceType == GetTypeID<ResourceGraphAsset>())
if (rid && resourceReference && resourceReference->resourceType == GetTypeID<GraphAsset>())
{
ImGui::EndTable();

Expand Down Expand Up @@ -75,7 +73,7 @@ namespace Fyrion

ResourceObject graphObject = Repository::Read(rid);

Array<RID> nodes = graphObject.GetSubObjectSetAsArray(ResourceGraphAsset::Nodes);
Array<RID> nodes = graphObject.GetSubObjectSetAsArray(GraphAsset::Nodes);

for (RID node : nodes)
{
Expand All @@ -100,9 +98,11 @@ namespace Fyrion
.userData = nullptr,
.callback = [](ImGui::DrawTypeDesc& desc, ConstPtr newValue)
{

//TODO - need to create a instance.
}
});

ImGui::TableNextColumn();
}
}
}
Expand All @@ -118,7 +118,6 @@ namespace Fyrion
ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_WidthStretch, 0.4f);
ImGui::TableSetupColumn("Item", ImGuiTableColumnFlags_WidthStretch);
}

}


Expand Down
7 changes: 1 addition & 6 deletions Engine/Source/Fyrion/Resource/Repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "concurrentqueue.h"
#include "ResourceGraph.hpp"
#include "Fyrion/Assets/AssetTypes.hpp"
#include "Fyrion/IO/FileSystem.hpp"
#include "Fyrion/IO/Path.hpp"

Expand Down Expand Up @@ -1274,11 +1275,5 @@ namespace Fyrion
Registry::Type<Array<RID>>("Fyrion::RIDArray");
Registry::Type<SubObjectSetData>();
Registry::Type<StreamObject>();

ResourceTypeBuilder<ResourceGraphAsset>::Builder("Fyrion::ResourceGraph")
.SubObjectSet<ResourceGraphAsset::Links>("Links")
.SubObjectSet<ResourceGraphAsset::Nodes>("Nodes")
.Build();

}
}
4 changes: 2 additions & 2 deletions Engine/Source/Fyrion/Resource/ResourceGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ namespace Fyrion

ResourceObject graphAsset = Repository::Read(assetGraph);

Array<RID> nodes = graphAsset.GetSubObjectSetAsArray(ResourceGraphAsset::Nodes);
Array<RID> links = graphAsset.GetSubObjectSetAsArray(ResourceGraphAsset::Links);
Array<RID> nodes = graphAsset.GetSubObjectSetAsArray(GraphAsset::Nodes);
Array<RID> links = graphAsset.GetSubObjectSetAsArray(GraphAsset::Links);

Array<ResourceGraphNodeInfo> nodesInfo;
Array<ResourceGraphLinkInfo> nodeLinks;
Expand Down
12 changes: 0 additions & 12 deletions Engine/Source/Fyrion/Resource/ResourceGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ namespace Fyrion

class ResourceGraph;

struct GraphInstanceAsset
{
constexpr static u32 Graph = 0;
constexpr static u32 Inputs = 0;
};

struct ResourceGraphAsset
{
constexpr static u32 Nodes = 0;
constexpr static u32 Links = 1;
};

struct ResourceGraphNodeValue
{
String name{};
Expand Down
4 changes: 2 additions & 2 deletions Engine/Source/Fyrion/Resource/ResourceTypes.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "Fyrion/Common.hpp"
#include "Fyrion/Core/Array.hpp"
#include "Fyrion/Core/StringView.hpp"
#include "Fyrion/Core/Span.hpp"

Expand Down Expand Up @@ -91,10 +92,9 @@ namespace Fyrion
struct ResourceReference
{
TypeID resourceType{};
TypeID graphOutput{};
Array<TypeID> graphOutput{};
};


struct AssetRoot
{
constexpr static u32 Name = 0;
Expand Down
5 changes: 3 additions & 2 deletions Engine/Source/Fyrion/Scene/Components/RenderComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "RenderComponent.hpp"

#include "Fyrion/Assets/AssetTypes.hpp"
#include "Fyrion/Graphics/DefaultRenderPipeline/GraphNodes.hpp"
#include "Fyrion/Resource/ResourceGraph.hpp"
#include "Fyrion/Scene/SceneObject.hpp"
Expand All @@ -14,8 +15,8 @@ namespace Fyrion
void RenderComponent::RegisterType(NativeTypeHandler<RenderComponent>& type)
{
type.Field<&RenderComponent::m_resourceGraph>("resourceGraph").Attribute<ResourceReference>(ResourceReference{
.resourceType = GetTypeID<ResourceGraphAsset>(),
.graphOutput = GetTypeID<GeometryRender>()
.resourceType = GetTypeID<GraphAsset>(),
.graphOutput = {GetTypeID<GeometryRender>()}
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions Engine/Test/Fyrion/Resource/ResourceGraphTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace
Engine::Init();
{
RegisterTypes();
RID rid = Repository::CreateResource<ResourceGraphAsset>();
RID rid = Repository::CreateResource<GraphAsset>();

//asset
{
Expand Down Expand Up @@ -132,9 +132,9 @@ namespace

{
ResourceObject object = Repository::Write(rid);
object.AddToSubObjectSet(ResourceGraphAsset::Nodes, contentString1);
object.AddToSubObjectSet(ResourceGraphAsset::Nodes, output);
object.AddToSubObjectSet(ResourceGraphAsset::Links, link1);
object.AddToSubObjectSet(GraphAsset::Nodes, contentString1);
object.AddToSubObjectSet(GraphAsset::Nodes, output);
object.AddToSubObjectSet(GraphAsset::Links, link1);
object.Commit();
}
}
Expand Down

0 comments on commit 54ffcfd

Please sign in to comment.