Blender V4.5
BKE_compute_context_cache.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
9
11#include "BLI_map.hh"
12#include "BLI_vector.hh"
13
14namespace blender::bke {
15
27 LinearAllocator<> allocator_;
30
32 modifier_contexts_cache_;
35 group_node_contexts_cache_;
37 simulation_zone_contexts_cache_;
39 repeat_zone_contexts_cache_;
42 foreach_geometry_element_zone_contexts_cache_;
44 evaluate_closure_contexts_cache_;
45
46 public:
48 const NodesModifierData &nmd);
49 const ModifierComputeContext &for_modifier(const ComputeContext *parent, int modifier_uid);
50
53
55 int32_t node_id,
56 const bNodeTree *tree = nullptr);
57
59 int output_node_id);
61 const bNode &output_node);
62
64 int32_t output_node_id,
65 int iteration);
67 const bNode &output_node,
68 int iteration);
69
71 const ComputeContext *parent, int32_t output_node_id, int index);
73 const ComputeContext *parent, const bNode &output_node, int index);
74
76 const ComputeContext *parent,
77 int32_t node_id,
78 const bNodeTree *tree = nullptr,
79 const std::optional<nodes::ClosureSourceLocation> &closure_source_location = std::nullopt);
80
85 template<typename T, typename... Args> const T &for_any_uncached(Args &&...args)
86 {
87 destruct_ptr<T> compute_context = allocator_.construct<T>(std::forward<Args>(args)...);
88 const T &result = *compute_context;
89 cache_.append(std::move(compute_context));
90 return result;
91 }
92};
93
94} // namespace blender::bke
const EvaluateClosureComputeContext & for_evaluate_closure(const ComputeContext *parent, int32_t node_id, const bNodeTree *tree=nullptr, const std::optional< nodes::ClosureSourceLocation > &closure_source_location=std::nullopt)
const ModifierComputeContext & for_modifier(const ComputeContext *parent, const NodesModifierData &nmd)
const GroupNodeComputeContext & for_group_node(const ComputeContext *parent, int32_t node_id, const bNodeTree *tree=nullptr)
const ForeachGeometryElementZoneComputeContext & for_foreach_geometry_element_zone(const ComputeContext *parent, int32_t output_node_id, int index)
const RepeatZoneComputeContext & for_repeat_zone(const ComputeContext *parent, int32_t output_node_id, int iteration)
const OperatorComputeContext & for_operator(const ComputeContext *parent)
const SimulationZoneComputeContext & for_simulation_zone(const ComputeContext *parent, int output_node_id)
KDTree_3d * tree
#define T
std::unique_ptr< T, DestructValueAtAddress< T > > destruct_ptr