Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
Graph -> CompiledGraph
Most of graphs members moved to new GraphBuilder
  • Loading branch information
tadgem committed May 7, 2023
1 parent ec6ad4b commit 50a7f54
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ I started this project in March / April 2022. After having spent years working o
+ ECS Design
+ Modular Design for Engine Components + Game Systems.
+ Serialization infrastructure using JSON.
+ Pipeline Graph renderer architecture, which allows reuse of shared data and abstraction of resource generation.
+ Pipeline CompiledGraph renderer architecture, which allows reuse of shared data and abstraction of resource generation.
+ ShaderDataSource architecture which allows data binding code for shaders to be reused.
+ Lua scripting support (LuaJIT + Lua available through use of a CMake option)
+ Jolt Physics Integration
Expand Down
4 changes: 2 additions & 2 deletions harmony-core/include/ImGui/GraphScript/GraphScriptImGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ namespace harmony {
class GraphScriptImGuiEditor {
public:

explicit GraphScriptImGuiEditor(GraphScriptNodeRegistry* vm);
explicit GraphScriptImGuiEditor(GraphScript::NodeRegistry* vm);
Vector<ImGuiGraphState> m_GraphStates;

void Render();

protected:
ImVec2 p_MousePosition;
GraphScriptNodeRegistry* m_GraphScriptBuilder;
GraphScript::NodeRegistry* m_GraphScriptBuilder;
int p_SelectedGraphIndex;
bool p_ShowNodeSelector = false;
};
Expand Down
42 changes: 23 additions & 19 deletions harmony-core/include/Script/GraphScript/GraphScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,38 +134,42 @@ namespace harmony {
};


class Graph {
class CompiledGraph {
public:
void CallEntryPoint(EntryPointName &name);

bool Build();
protected:
Map<EntryPointName, Ops> p_Entries;
};

nlohmann::json Serialize();
class NodeRegistry {
public:
NodeRegistry();

void CallEntryPoint(EntryPointName &name);
~NodeRegistry();

void AddNode(GraphScript::IGraphNode *node);

void RemoveNode(GraphScript::IGraphNode *node);

Vector<GraphScript::IGraphNode *> m_AvailableNodes;
};

class GraphBuilder
{
public:
String m_Name;
Vector<Unique<IGraphNode>> m_GraphNodes;
Vector<Unique<IVariable>> m_Variables;
Vector<Unique<IConnection>> m_Connections;
Vector<Unique<EntryPointNode>> m_EntryPoints;
protected:
Map<EntryPointName, Ops> p_Entries;
};

}

class GraphScriptNodeRegistry {
public:
GraphScriptNodeRegistry();

~GraphScriptNodeRegistry();

void AddNode(GraphScript::IGraphNode *node);

void RemoveNode(GraphScript::IGraphNode *node);
Unique<CompiledGraph> Build();
nlohmann::json Serialize();
};
}

Vector<GraphScript::IGraphNode *> m_AvailableNodes;
};
}

#endif //HARMONY_DOJO_GRAPHSCRIPT_H
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

namespace harmony
{
class GraphScriptNodeRegistry;

namespace GraphScript
{
class NodeRegistry;
}

class GraphScriptProgramComponent : public ProgramComponent
{
Expand All @@ -26,14 +30,14 @@ namespace harmony

void Cleanup() override;

GraphScriptNodeRegistry* GetBuilder();
GraphScript::NodeRegistry* GetNodeRegistry();

nlohmann::json ToJson() override;

void FromJson(const nlohmann::json &json) override;

protected:
Unique<GraphScriptNodeRegistry> p_Builder;
Unique<GraphScript::NodeRegistry> p_NodeRegistry;

};
}
Expand Down
2 changes: 1 addition & 1 deletion harmony-core/src/ImGui/GraphScript/GraphScriptImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ void harmony::GraphScriptImGuiEditor::Render() {

}

harmony::GraphScriptImGuiEditor::GraphScriptImGuiEditor(harmony::GraphScriptNodeRegistry *vm) : m_GraphScriptBuilder(vm)
harmony::GraphScriptImGuiEditor::GraphScriptImGuiEditor(harmony::GraphScript::NodeRegistry *vm) : m_GraphScriptBuilder(vm)
{
}
2 changes: 1 addition & 1 deletion harmony-core/src/ImGui/imgui_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ static void ShowDemoWindowWidgets() {
ImGui::TreePop();
}

// Plot/Graph widgets are not very good.
// Plot/CompiledGraph widgets are not very good.
// Consider using a third-party library such as ImPlot: https://github.com/epezent/implot
// (see others https://github.com/ocornut/imgui/wiki/Useful-Extensions)
IMGUI_DEMO_MARKER("Widgets/Plotting");
Expand Down
2 changes: 1 addition & 1 deletion harmony-core/src/ImGui/imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6712,7 +6712,7 @@ bool ImGui::ListBox(const char *label, int *current_item, bool (*items_getter)(v
// - PlotLines()
// - PlotHistogram()
//-------------------------------------------------------------------------
// Plot/Graph widgets are not very good.
// Plot/CompiledGraph widgets are not very good.
// Consider writing your own, or using a third-party one, see:
// - ImPlot https://github.com/epezent/implot
// - others https://github.com/ocornut/imgui/wiki/Useful-Extensions
Expand Down
20 changes: 6 additions & 14 deletions harmony-core/src/Script/GraphScript/GraphScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ harmony::GraphScript::IGraphNode *harmony::GraphScript::EntryPointNode::Clone()
return nullptr;
}

void harmony::GraphScriptNodeRegistry::AddNode(harmony::GraphScript::IGraphNode *node) {
void harmony::GraphScript::NodeRegistry::AddNode(harmony::GraphScript::IGraphNode *node) {
if (node == nullptr) {
harmony::log::warn("GraphScriptVM : Provided Node is nullptr");
return;
Expand All @@ -61,12 +61,12 @@ void harmony::GraphScriptNodeRegistry::AddNode(harmony::GraphScript::IGraphNode

}

harmony::GraphScriptNodeRegistry::GraphScriptNodeRegistry() {
harmony::GraphScript::NodeRegistry::NodeRegistry() {
m_AvailableNodes = Vector<GraphScript::IGraphNode *>();
}


harmony::GraphScriptNodeRegistry::~GraphScriptNodeRegistry() {
harmony::GraphScript::NodeRegistry::~NodeRegistry() {
for (auto node: m_AvailableNodes) {
if(node)
{
Expand All @@ -76,7 +76,7 @@ harmony::GraphScriptNodeRegistry::~GraphScriptNodeRegistry() {
m_AvailableNodes.clear();
}

void harmony::GraphScriptNodeRegistry::RemoveNode(harmony::GraphScript::IGraphNode *node) {
void harmony::GraphScript::NodeRegistry::RemoveNode(harmony::GraphScript::IGraphNode *node) {
auto it = std::find(m_AvailableNodes.begin(), m_AvailableNodes.end(), node);
if (it == m_AvailableNodes.end()) {
harmony::log::warn("GraphScriptVM : Node not found in VM available nodes");
Expand All @@ -85,9 +85,9 @@ void harmony::GraphScriptNodeRegistry::RemoveNode(harmony::GraphScript::IGraphNo
m_AvailableNodes.erase(it);
}

void harmony::GraphScript::Graph::CallEntryPoint(EntryPointName &name) {
void harmony::GraphScript::CompiledGraph::CallEntryPoint(EntryPointName &name) {
if (p_Entries.find(name) == p_Entries.end()) {
harmony::log::warn("GraphScript : Graph : No entry point : {}", name.m_id);
harmony::log::warn("GraphScript : CompiledGraph : No entry point : {}", name.m_id);
return;
}

Expand All @@ -99,14 +99,6 @@ void harmony::GraphScript::Graph::CallEntryPoint(EntryPointName &name) {

}

bool harmony::GraphScript::Graph::Build() {
return false;
}

nlohmann::json harmony::GraphScript::Graph::Serialize() {
return nlohmann::json();
}

harmony::GraphScript::EntryPointName::EntryPointName(const std::string & name) {
for (auto c: name) {
m_id += c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
harmony::GraphScriptProgramComponent::GraphScriptProgramComponent()
{
m_TypeHash = typeid(GraphScriptProgramComponent).hash_code();
p_Builder = CreateUnique<GraphScriptNodeRegistry>();
p_Builder->AddNode(new GraphScript::PrintNode());
p_Builder->AddNode(new GraphScript::EntryPointNode());
p_NodeRegistry = CreateUnique<GraphScript::NodeRegistry>();
p_NodeRegistry->AddNode(new GraphScript::PrintNode());
p_NodeRegistry->AddNode(new GraphScript::EntryPointNode());
}

void harmony::GraphScriptProgramComponent::Init() {
Expand Down Expand Up @@ -38,9 +38,9 @@ void harmony::GraphScriptProgramComponent::FromJson(const nlohmann::json &json)

harmony::GraphScriptProgramComponent::~GraphScriptProgramComponent()
{
p_Builder.reset();
p_NodeRegistry.reset();
}

harmony::GraphScriptNodeRegistry *harmony::GraphScriptProgramComponent::GetBuilder() {
return p_Builder.get();
harmony::GraphScript::NodeRegistry *harmony::GraphScriptProgramComponent::GetNodeRegistry() {
return p_NodeRegistry.get();
}
4 changes: 2 additions & 2 deletions templates/harmony-dojo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ void operator delete(void *memory, size_t size) {
int main() {
harmony::Editor app;

auto *graph = new harmony::GraphScript::Graph();
auto *graph = new harmony::GraphScript::CompiledGraph();
auto graphScriptComponent = app.GetProgramComponent<harmony::GraphScriptProgramComponent>().lock();

harmony::GraphScriptNodeRegistry* vm = graphScriptComponent->GetBuilder();
harmony::GraphScript::NodeRegistry* vm = graphScriptComponent->GetNodeRegistry();

auto proc = []() {

Expand Down
2 changes: 1 addition & 1 deletion templates/harmony-editor-runtime/src/EditorApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "ECS/SimpleCollisionSystem.h"
#include "Script/GraphScript/GraphScriptProgramComponent.h"

harmony::Editor::Editor() : harmony::RuntimeProgram("Editor"), p_MainMenuBar(*this), m_GraphScriptEditor(p_GraphScriptComponent->GetBuilder()) {
harmony::Editor::Editor() : harmony::RuntimeProgram("Editor"), p_MainMenuBar(*this), m_GraphScriptEditor(p_GraphScriptComponent->GetNodeRegistry()) {
OPTICK_EVENT();
m_Logger.Init();
AddAssetTypeNames();
Expand Down

0 comments on commit 50a7f54

Please sign in to comment.