Skip to content

Commit

Permalink
🧼 [Particles] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Dec 29, 2023
1 parent c03491c commit 6b35c19
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 29 deletions.
17 changes: 15 additions & 2 deletions src/ModulesGraph/ModulesGraph.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "ModulesGraph.h"
#include <Module_Particles/Module_Particles.h>
#include <Nodes/FunctionSignature.h>
#include <Nodes/module_texture_name.h>
#include <imgui.h>
#include <algorithm>
#include <cstddef>
Expand All @@ -10,6 +9,7 @@
#include "Cool/Gpu/RenderTarget.h"
#include "Module_Compositing/generate_compositing_shader_code.h"
#include "Module_Particles/generate_simulation_shader_code.h"
#include "Nodes/valid_glsl.h"
#include "UI/imgui_show.h"

namespace Lab {
Expand Down Expand Up @@ -133,6 +133,19 @@ void ModulesGraph::on_time_reset()
node->module.on_time_reset();
}

static auto texture_name_for_module(NodeDefinition const& definition, Cool::NodeId const& id) -> std::string
{
using fmt::literals::operator""_a;
return valid_glsl(fmt::format(
FMT_COMPILE(
R"STR(texture_{name}{id})STR"
),
"name"_a = definition.name(),
"id"_a = to_string(id.underlying_uuid())
)
);
}

void ModulesGraph::create_and_compile_all_modules(Cool::NodesGraph const& graph, Cool::NodeId const& root_node_id, UpdateContext_Ref ctx, Cool::DirtyFlagFactory_Ref dirty_flag_factory)
{
_particles_module_nodes.clear();
Expand All @@ -155,7 +168,7 @@ void ModulesGraph::create_and_compile_all_modules(Cool::NodesGraph const& graph,

auto initializer_node_id = Cool::NodeId();

auto const texture_name_in_shader = module_texture_name(node_definition, particles_root_node_id);
auto const texture_name_in_shader = texture_name_for_module(node_definition, particles_root_node_id);

if (std::none_of(
_particles_module_nodes.begin(),
Expand Down
15 changes: 1 addition & 14 deletions src/Nodes/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "FunctionSignature.h"
#include "Node.h"
#include "NodeDefinition.h"
#include "helpers.h"
#include "input_to_primitive_type.h"
#include "valid_glsl.h"

namespace Lab {

Expand Down Expand Up @@ -121,19 +121,6 @@ static auto desired_function_name(
);
}

auto module_texture_name(NodeDefinition const& definition, Cool::NodeId const& id) -> std::string
{
using fmt::literals::operator""_a;
return valid_glsl(fmt::format(
FMT_COMPILE(
R"STR(texture_{name}{id})STR"
),
"name"_a = definition.name(),
"id"_a = to_string(id.underlying_uuid())
)
);
}

auto valid_property_name(std::string const& name, reg::AnyId const& property_default_variable_id) // We use a unique id per property to make sure they don't clash with anything. For example if the node was called Zoom and its property was also called Zoom, both the function and the uniform variable would get the same name.
-> std::string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Nodes/CodeGen_desired_function_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "CodeGen_implicit_conversion.h"
#include "FunctionSignature.h"
#include "PrimitiveType.h"
#include "helpers.h"
#include "tl/expected.hpp"
#include "valid_glsl.h"

namespace Lab {

Expand Down
2 changes: 1 addition & 1 deletion src/Nodes/fixup_node_definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "FunctionSignature.h"
#include "NodeDefinition.h"
#include "PrimitiveType.h"
#include "helpers.h"
#include "valid_glsl.h"

namespace Lab {

Expand Down
10 changes: 0 additions & 10 deletions src/Nodes/module_texture_name.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/Nodes/helpers.cpp → src/Nodes/valid_glsl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "helpers.h"
#include "valid_glsl.h"

namespace Lab {

Expand Down
File renamed without changes.

0 comments on commit 6b35c19

Please sign in to comment.