Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NOD_geometry_nodes_to_lazy_function_graph.hh « nodes « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8b05d56e596e752c4b45bc864c0d271fe4a37ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* SPDX-License-Identifier: GPL-2.0-or-later */

#pragma once

#include "FN_lazy_function_graph.hh"
#include "FN_lazy_function_graph_executor.hh"

#include "NOD_geometry_nodes_log.hh"
#include "NOD_multi_function.hh"

#include "BLI_compute_context.hh"

struct Object;
struct Depsgraph;

namespace blender::nodes {

namespace lf = fn::lazy_function;
using lf::LazyFunction;

struct GeoNodesModifierData {
  const Object *self_object = nullptr;
  Depsgraph *depsgraph = nullptr;
  geo_eval_log::GeoModifierLog *eval_log = nullptr;
  const MultiValueMap<ComputeContextHash, const lf::FunctionNode *> *side_effect_nodes;
};

struct GeoNodesLFUserData : public lf::UserData {
  GeoNodesModifierData *modifier_data = nullptr;
  const ComputeContext *compute_context = nullptr;
};

struct GeometryNodeLazyFunctionMapping {
  Map<const bNodeSocket *, lf::Socket *> dummy_socket_map;
  Vector<lf::OutputSocket *> group_input_sockets;
  MultiValueMap<const lf::Socket *, const bNodeSocket *> bsockets_by_lf_socket_map;
  Map<const bNode *, const lf::FunctionNode *> group_node_map;
  Map<const bNode *, const lf::FunctionNode *> viewer_node_map;
};

struct GeometryNodesLazyFunctionGraphInfo {
  LinearAllocator<> allocator;
  std::unique_ptr<NodeMultiFunctions> node_multi_functions;
  Vector<std::unique_ptr<LazyFunction>> functions;
  Vector<GMutablePointer> values_to_destruct;
  GeometryNodeLazyFunctionMapping mapping;
  lf::Graph graph;

  ~GeometryNodesLazyFunctionGraphInfo()
  {
    for (GMutablePointer &p : this->values_to_destruct) {
      p.destruct();
    }
  }
};

class GeometryNodesLazyFunctionLogger : public fn::lazy_function::GraphExecutor::Logger {
 private:
  const GeometryNodesLazyFunctionGraphInfo &lf_graph_info_;

 public:
  GeometryNodesLazyFunctionLogger(const GeometryNodesLazyFunctionGraphInfo &lf_graph_info)
      : lf_graph_info_(lf_graph_info)
  {
  }

  void log_socket_value(const fn::lazy_function::Context &context,
                        const fn::lazy_function::Socket &lf_socket,
                        GPointer value) const override;
};

class GeometryNodesLazyFunctionSideEffectProvider
    : public fn::lazy_function::GraphExecutor::SideEffectProvider {
 private:
  const GeometryNodesLazyFunctionGraphInfo &lf_graph_info_;

 public:
  GeometryNodesLazyFunctionSideEffectProvider(
      const GeometryNodesLazyFunctionGraphInfo &lf_graph_info)
      : lf_graph_info_(lf_graph_info)
  {
  }

  Vector<const lf::FunctionNode *> get_nodes_with_side_effects(
      const lf::Context &context) const override;
};

const GeometryNodesLazyFunctionGraphInfo &ensure_geometry_nodes_lazy_function_graph(
    const bNodeTree &btree);

}  // namespace blender::nodes